當前位置: 首頁>>代碼示例>>Java>>正文


Java TypedStringValue.setSource方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.config.TypedStringValue.setSource方法的典型用法代碼示例。如果您正苦於以下問題:Java TypedStringValue.setSource方法的具體用法?Java TypedStringValue.setSource怎麽用?Java TypedStringValue.setSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.config.TypedStringValue的用法示例。


在下文中一共展示了TypedStringValue.setSource方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseValueElement

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Return a typed String value Object for the given value element.
 * 
 * @param ele element
 * @param defaultTypeName type class name
 * @return typed String value Object
 */
private Object parseValueElement(Element ele, String defaultTypeName) {
	// It's a literal value.
	String value = DomUtils.getTextValue(ele);
	String specifiedTypeName = ele.getAttribute(BeanDefinitionParserDelegate.TYPE_ATTRIBUTE);
	String typeName = specifiedTypeName;
	if (!StringUtils.hasText(typeName)) {
		typeName = defaultTypeName;
	}
	try {
		TypedStringValue typedValue = buildTypedStringValue(value, typeName);
		typedValue.setSource(extractSource(ele));
		typedValue.setSpecifiedTypeName(specifiedTypeName);
		return typedValue;
	} catch (ClassNotFoundException ex) {
		error("Type class [" + typeName + "] not found for <value> element", ele, ex);
		return value;
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:26,代碼來源:BlueprintParser.java

示例2: parsePropsElement

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
	ManagedProperties props = new OrderedManagedProperties();
	props.setSource(extractSource(propsEle));
	props.setMergeEnabled(parseMergeAttribute(propsEle));

	List propEles = DomUtils.getChildElementsByTagName(propsEle, BeanDefinitionParserDelegate.PROP_ELEMENT);
	for (Iterator it = propEles.iterator(); it.hasNext();) {
		Element propEle = (Element) it.next();
		String key = propEle.getAttribute(BeanDefinitionParserDelegate.KEY_ATTRIBUTE);
		// Trim the text value to avoid unwanted whitespace
		// caused by typical XML formatting.
		String value = DomUtils.getTextValue(propEle).trim();

		TypedStringValue keyHolder = new TypedStringValue(key);
		keyHolder.setSource(extractSource(propEle));
		TypedStringValue valueHolder = new TypedStringValue(value);
		valueHolder.setSource(extractSource(propEle));
		props.put(keyHolder, valueHolder);
	}

	return props;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:26,代碼來源:BlueprintParser.java

示例3: parseValueElement

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Return a typed String value Object for the given value element.
 */
public Object parseValueElement(Element ele, String defaultTypeName) {
	// It's a literal value.
	String value = DomUtils.getTextValue(ele);
	String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE);
	String typeName = specifiedTypeName;
	if (!StringUtils.hasText(typeName)) {
		typeName = defaultTypeName;
	}
	try {
		TypedStringValue typedValue = buildTypedStringValue(value, typeName);
		typedValue.setSource(extractSource(ele));
		typedValue.setSpecifiedTypeName(specifiedTypeName);
		return typedValue;
	}
	catch (ClassNotFoundException ex) {
		error("Type class [" + typeName + "] not found for <value> element", ele, ex);
		return value;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:BeanDefinitionParserDelegate.java

示例4: parsePropsElement

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
	ManagedProperties props = new ManagedProperties();
	props.setSource(extractSource(propsEle));
	props.setMergeEnabled(parseMergeAttribute(propsEle));

	List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT);
	for (Element propEle : propEles) {
		String key = propEle.getAttribute(KEY_ATTRIBUTE);
		// Trim the text value to avoid unwanted whitespace
		// caused by typical XML formatting.
		String value = DomUtils.getTextValue(propEle).trim();
		TypedStringValue keyHolder = new TypedStringValue(key);
		keyHolder.setSource(extractSource(propEle));
		TypedStringValue valueHolder = new TypedStringValue(value);
		valueHolder.setSource(extractSource(propEle));
		props.put(keyHolder, valueHolder);
	}

	return props;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:BeanDefinitionParserDelegate.java

示例5: addIncludePatterns

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) {
	ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>();
	NodeList childNodes = element.getChildNodes();
	for (int i = 0; i < childNodes.getLength(); i++) {
		Node node = childNodes.item(i);
		if (node instanceof Element) {
			Element includeElement = (Element) node;
			TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name"));
			valueHolder.setSource(parserContext.extractSource(includeElement));
			includePatterns.add(valueHolder);
		}
	}
	if (!includePatterns.isEmpty()) {
		includePatterns.setSource(parserContext.extractSource(element));
		beanDef.getPropertyValues().add("includePatterns", includePatterns);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:AspectJAutoProxyBeanDefinitionParser.java

示例6: buildTypedStringValueForMap

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Build a typed String value Object for the given raw value.
 * 
 * @see org.springframework.beans.factory.config.TypedStringValue
 */
private Object buildTypedStringValueForMap(String value, String defaultTypeName, Element entryEle) {
	try {
		TypedStringValue typedValue = buildTypedStringValue(value, defaultTypeName);
		typedValue.setSource(extractSource(entryEle));
		return typedValue;
	} catch (ClassNotFoundException ex) {
		error("Type class [" + defaultTypeName + "] not found for Map key/value type", entryEle, ex);
		return value;
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:16,代碼來源:BlueprintParser.java

示例7: buildTypedStringValueForMap

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Build a typed String value Object for the given raw value.
 * @see org.springframework.beans.factory.config.TypedStringValue
 */
protected final Object buildTypedStringValueForMap(String value, String defaultTypeName, Element entryEle) {
	try {
		TypedStringValue typedValue = buildTypedStringValue(value, defaultTypeName);
		typedValue.setSource(extractSource(entryEle));
		return typedValue;
	}
	catch (ClassNotFoundException ex) {
		error("Type class [" + defaultTypeName + "] not found for Map key/value type", entryEle, ex);
		return value;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:BeanDefinitionParserDelegate.java

示例8: parsePropertySubElement

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Parse a value, ref or collection sub-element of a property or constructor-arg element. This method is called from
 * several places to handle reusable elements such as idref, ref, null, value and so on.
 * 
 * In fact, this method is the main reason why the BeanDefinitionParserDelegate is not used in full since the
 * element namespace becomes important as mixed rfc124/bean content can coexist.
 * 
 * @param ele subelement of property element; we don't know which yet
 * @param defaultValueType the default type (class name) for any <code>&lt;value&gt;</code> tag that might be
 * created
 */
private Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) {
	// skip other namespace
	String namespaceUri = ele.getNamespaceURI();

	// check Spring own namespace
	if (parserContext.getDelegate().isDefaultNamespace(namespaceUri)) {
		return parserContext.getDelegate().parsePropertySubElement(ele, bd);
	}
	// let the delegate handle other ns
	else if (!NAMESPACE_URI.equals(namespaceUri)) {
		return parserContext.getDelegate().parseCustomElement(ele);
	}

	// 
	else {
		if (DomUtils.nodeNameEquals(ele, BEAN)) {
			BeanDefinitionHolder bdHolder = parseComponentDefinitionElement(ele, bd);
			if (bdHolder != null) {
				bdHolder = ParsingUtils.decorateBeanDefinitionIfRequired(ele, bdHolder, parserContext);
			}
			return bdHolder;
		}

		if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.REF_ELEMENT)) {
			return parseRefElement(ele);
		} else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.IDREF_ELEMENT)) {
			return parseIdRefElement(ele);
		} else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.VALUE_ELEMENT)) {
			return parseValueElement(ele, defaultValueType);
		} else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.NULL_ELEMENT)) {
			// It's a distinguished null value. Let's wrap it in a TypedStringValue
			// object in order to preserve the source location.
			TypedStringValue nullHolder = new TypedStringValue(null);
			nullHolder.setSource(parserContext.extractSource(ele));
			return nullHolder;
		} else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.ARRAY_ELEMENT)) {
			return parseArrayElement(ele, bd);
		} else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.LIST_ELEMENT)) {
			return parseListElement(ele, bd);
		} else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.SET_ELEMENT)) {
			return parseSetElement(ele, bd);
		} else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.MAP_ELEMENT)) {
			return parseMapElement(ele, bd);
		} else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.PROPS_ELEMENT)) {
			return parsePropsElement(ele);
		}

		// maybe it's a nested service/reference/ref-list/ref-set
		return parserContext.getDelegate().parseCustomElement(ele, bd);
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:63,代碼來源:BlueprintParser.java

示例9: parseAttributeSource

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
private RootBeanDefinition parseAttributeSource(Element attrEle, ParserContext parserContext) {
	List<Element> methods = DomUtils.getChildElementsByTagName(attrEle, METHOD_ELEMENT);
	ManagedMap<TypedStringValue, RuleBasedTransactionAttribute> transactionAttributeMap =
		new ManagedMap<TypedStringValue, RuleBasedTransactionAttribute>(methods.size());
	transactionAttributeMap.setSource(parserContext.extractSource(attrEle));

	for (Element methodEle : methods) {
		String name = methodEle.getAttribute(METHOD_NAME_ATTRIBUTE);
		TypedStringValue nameHolder = new TypedStringValue(name);
		nameHolder.setSource(parserContext.extractSource(methodEle));

		RuleBasedTransactionAttribute attribute = new RuleBasedTransactionAttribute();
		String propagation = methodEle.getAttribute(PROPAGATION_ATTRIBUTE);
		String isolation = methodEle.getAttribute(ISOLATION_ATTRIBUTE);
		String timeout = methodEle.getAttribute(TIMEOUT_ATTRIBUTE);
		String readOnly = methodEle.getAttribute(READ_ONLY_ATTRIBUTE);
		if (StringUtils.hasText(propagation)) {
			attribute.setPropagationBehaviorName(RuleBasedTransactionAttribute.PREFIX_PROPAGATION + propagation);
		}
		if (StringUtils.hasText(isolation)) {
			attribute.setIsolationLevelName(RuleBasedTransactionAttribute.PREFIX_ISOLATION + isolation);
		}
		if (StringUtils.hasText(timeout)) {
			try {
				attribute.setTimeout(Integer.parseInt(timeout));
			}
			catch (NumberFormatException ex) {
				parserContext.getReaderContext().error("Timeout must be an integer value: [" + timeout + "]", methodEle);
			}
		}
		if (StringUtils.hasText(readOnly)) {
			attribute.setReadOnly(Boolean.valueOf(methodEle.getAttribute(READ_ONLY_ATTRIBUTE)));
		}

		List<RollbackRuleAttribute> rollbackRules = new LinkedList<RollbackRuleAttribute>();
		if (methodEle.hasAttribute(ROLLBACK_FOR_ATTRIBUTE)) {
			String rollbackForValue = methodEle.getAttribute(ROLLBACK_FOR_ATTRIBUTE);
			addRollbackRuleAttributesTo(rollbackRules,rollbackForValue);
		}
		if (methodEle.hasAttribute(NO_ROLLBACK_FOR_ATTRIBUTE)) {
			String noRollbackForValue = methodEle.getAttribute(NO_ROLLBACK_FOR_ATTRIBUTE);
			addNoRollbackRuleAttributesTo(rollbackRules,noRollbackForValue);
		}
		attribute.setRollbackRules(rollbackRules);

		transactionAttributeMap.put(nameHolder, attribute);
	}

	RootBeanDefinition attributeSourceDefinition = new RootBeanDefinition(NameMatchTransactionAttributeSource.class);
	attributeSourceDefinition.setSource(parserContext.extractSource(attrEle));
	attributeSourceDefinition.getPropertyValues().add("nameMap", transactionAttributeMap);
	return attributeSourceDefinition;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:54,代碼來源:TxAdviceBeanDefinitionParser.java

示例10: parsePropertySubElement

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Parse a value, ref or collection sub-element of a property or
 * constructor-arg element.
 * @param ele subelement of property element; we don't know which yet
 * @param defaultValueType the default type (class name) for any
 * {@code &lt;value&gt;} tag that might be created
 */
public Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) {
	if (!isDefaultNamespace(ele)) {
		return parseNestedCustomElement(ele, bd);
	}
	else if (nodeNameEquals(ele, BEAN_ELEMENT)) {
		BeanDefinitionHolder nestedBd = parseBeanDefinitionElement(ele, bd);
		if (nestedBd != null) {
			nestedBd = decorateBeanDefinitionIfRequired(ele, nestedBd, bd);
		}
		return nestedBd;
	}
	else if (nodeNameEquals(ele, REF_ELEMENT)) {
		// A generic reference to any name of any bean.
		String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE);
		boolean toParent = false;
		if (!StringUtils.hasLength(refName)) {
			// A reference to the id of another bean in the same XML file.
			refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE);
			if (!StringUtils.hasLength(refName)) {
				// A reference to the id of another bean in a parent context.
				refName = ele.getAttribute(PARENT_REF_ATTRIBUTE);
				toParent = true;
				if (!StringUtils.hasLength(refName)) {
					error("'bean', 'local' or 'parent' is required for <ref> element", ele);
					return null;
				}
			}
		}
		if (!StringUtils.hasText(refName)) {
			error("<ref> element contains empty target attribute", ele);
			return null;
		}
		RuntimeBeanReference ref = new RuntimeBeanReference(refName, toParent);
		ref.setSource(extractSource(ele));
		return ref;
	}
	else if (nodeNameEquals(ele, IDREF_ELEMENT)) {
		return parseIdRefElement(ele);
	}
	else if (nodeNameEquals(ele, VALUE_ELEMENT)) {
		return parseValueElement(ele, defaultValueType);
	}
	else if (nodeNameEquals(ele, NULL_ELEMENT)) {
		// It's a distinguished null value. Let's wrap it in a TypedStringValue
		// object in order to preserve the source location.
		TypedStringValue nullHolder = new TypedStringValue(null);
		nullHolder.setSource(extractSource(ele));
		return nullHolder;
	}
	else if (nodeNameEquals(ele, ARRAY_ELEMENT)) {
		return parseArrayElement(ele, bd);
	}
	else if (nodeNameEquals(ele, LIST_ELEMENT)) {
		return parseListElement(ele, bd);
	}
	else if (nodeNameEquals(ele, SET_ELEMENT)) {
		return parseSetElement(ele, bd);
	}
	else if (nodeNameEquals(ele, MAP_ELEMENT)) {
		return parseMapElement(ele, bd);
	}
	else if (nodeNameEquals(ele, PROPS_ELEMENT)) {
		return parsePropsElement(ele);
	}
	else {
		error("Unknown property sub-element: [" + ele.getNodeName() + "]", ele);
		return null;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:77,代碼來源:BeanDefinitionParserDelegate.java

示例11: parsePropertyValue

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Get the value of a property element. May be a list etc.
 * Also used for constructor arguments, "propertyName" being null in this case.
 */
public Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) {
	String elementName = (propertyName != null) ?
					"<property> element for property '" + propertyName + "'" :
					"<constructor-arg> element";

	// Should only have one child element: ref, value, list, etc.
	NodeList nl = ele.getChildNodes();
	Element subElement = null;
	for (int i = 0; i < nl.getLength(); i++) {
		Node node = nl.item(i);
		if (node instanceof Element && !nodeNameEquals(node, DESCRIPTION_ELEMENT) &&
				!nodeNameEquals(node, META_ELEMENT)) {
			// Child element is what we're looking for.
			if (subElement != null) {
				error(elementName + " must not contain more than one sub-element", ele);
			}
			else {
				subElement = (Element) node;
			}
		}
	}

	boolean hasRefAttribute = ele.hasAttribute(REF_ATTRIBUTE);
	boolean hasValueAttribute = ele.hasAttribute(VALUE_ATTRIBUTE);
	if ((hasRefAttribute && hasValueAttribute) ||
			((hasRefAttribute || hasValueAttribute) && subElement != null)) {
		error(elementName +
				" is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element", ele);
	}

	if (hasRefAttribute) {
		String refName = ele.getAttribute(REF_ATTRIBUTE);
		if (!StringUtils.hasText(refName)) {
			error(elementName + " contains empty 'ref' attribute", ele);
		}
		RuntimeBeanReference ref = new RuntimeBeanReference(refName);
		ref.setSource(extractSource(ele));
		return ref;
	}
	else if (hasValueAttribute) {
		TypedStringValue valueHolder = new TypedStringValue(ele.getAttribute(VALUE_ATTRIBUTE));
		valueHolder.setSource(extractSource(ele));
		return valueHolder;
	}
	else if (subElement != null) {
		return parsePropertySubElement(subElement, bd);
	}
	else {
		// Neither child element nor "ref" or "value" attribute found.
		error(elementName + " must specify a ref or value", ele);
		return null;
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:58,代碼來源:BeanDefinitionParserDelegate.java

示例12: parsePropertySubElement

import org.springframework.beans.factory.config.TypedStringValue; //導入方法依賴的package包/類
/**
 * Parse a value, ref or collection sub-element of a property or
 * constructor-arg element.
 * @param ele subelement of property element; we don't know which yet
 * @param defaultValueType the default type (class name) for any
 * {@code <value>} tag that might be created
 */
public Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) {
	if (!isDefaultNamespace(ele)) {
		return parseNestedCustomElement(ele, bd);
	}
	else if (nodeNameEquals(ele, BEAN_ELEMENT)) {
		BeanDefinitionHolder nestedBd = parseBeanDefinitionElement(ele, bd);
		if (nestedBd != null) {
			nestedBd = decorateBeanDefinitionIfRequired(ele, nestedBd, bd);
		}
		return nestedBd;
	}
	else if (nodeNameEquals(ele, REF_ELEMENT)) {
		// A generic reference to any name of any bean.
		String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE);
		boolean toParent = false;
		if (!StringUtils.hasLength(refName)) {
			// A reference to the id of another bean in the same XML file.
			refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE);
			if (!StringUtils.hasLength(refName)) {
				// A reference to the id of another bean in a parent context.
				refName = ele.getAttribute(PARENT_REF_ATTRIBUTE);
				toParent = true;
				if (!StringUtils.hasLength(refName)) {
					error("'bean', 'local' or 'parent' is required for <ref> element", ele);
					return null;
				}
			}
		}
		if (!StringUtils.hasText(refName)) {
			error("<ref> element contains empty target attribute", ele);
			return null;
		}
		RuntimeBeanReference ref = new RuntimeBeanReference(refName, toParent);
		ref.setSource(extractSource(ele));
		return ref;
	}
	else if (nodeNameEquals(ele, IDREF_ELEMENT)) {
		return parseIdRefElement(ele);
	}
	else if (nodeNameEquals(ele, VALUE_ELEMENT)) {
		return parseValueElement(ele, defaultValueType);
	}
	else if (nodeNameEquals(ele, NULL_ELEMENT)) {
		// It's a distinguished null value. Let's wrap it in a TypedStringValue
		// object in order to preserve the source location.
		TypedStringValue nullHolder = new TypedStringValue(null);
		nullHolder.setSource(extractSource(ele));
		return nullHolder;
	}
	else if (nodeNameEquals(ele, ARRAY_ELEMENT)) {
		return parseArrayElement(ele, bd);
	}
	else if (nodeNameEquals(ele, LIST_ELEMENT)) {
		return parseListElement(ele, bd);
	}
	else if (nodeNameEquals(ele, SET_ELEMENT)) {
		return parseSetElement(ele, bd);
	}
	else if (nodeNameEquals(ele, MAP_ELEMENT)) {
		return parseMapElement(ele, bd);
	}
	else if (nodeNameEquals(ele, PROPS_ELEMENT)) {
		return parsePropsElement(ele);
	}
	else {
		error("Unknown property sub-element: [" + ele.getNodeName() + "]", ele);
		return null;
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:77,代碼來源:BeanDefinitionParserDelegate.java


注:本文中的org.springframework.beans.factory.config.TypedStringValue.setSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。