本文整理汇总了Java中org.springframework.beans.factory.support.ManagedSet.setMergeEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ManagedSet.setMergeEnabled方法的具体用法?Java ManagedSet.setMergeEnabled怎么用?Java ManagedSet.setMergeEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.ManagedSet
的用法示例。
在下文中一共展示了ManagedSet.setMergeEnabled方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSet
import org.springframework.beans.factory.support.ManagedSet; //导入方法依赖的package包/类
/**
* Parses a list of elements into a set of beans/standard content.
*
* @param grandChildren - The set of beans/content in a bean property
* @param child - The property tag for the parent.
* @param parent - The parent bean that the tag is nested in.
* @param parserContext - Provided information and functionality regarding current bean set.
* @return A managedSet of the nested content.
*/
protected ManagedSet parseSet(ArrayList<Element> grandChildren, Element child, BeanDefinitionBuilder parent,
ParserContext parserContext) {
ManagedSet setItems = new ManagedSet();
for (int i = 0; i < grandChildren.size(); i++) {
Element grandChild = grandChildren.get(i);
if (child.getTagName().compareTo("value") == 0) {
setItems.add(grandChild.getTextContent());
} else {
setItems.add(parseBean(grandChild, parent, parserContext));
}
}
String merge = child.getAttribute("merge");
if (merge != null) {
setItems.setMergeEnabled(Boolean.valueOf(merge));
}
return setItems;
}
示例2: visitSet
import org.springframework.beans.factory.support.ManagedSet; //导入方法依赖的package包/类
/**
* Iterates through the set values and calls helpers to process the value
*
* @param setVal the set to process
* @param propertyName name of the property which has the set value
* @param nestedBeanStack stack of bean containers which contains the set property
*/
protected void visitSet(Set setVal, String propertyName, Stack<BeanDefinitionHolder> nestedBeanStack) {
boolean isMergeEnabled = false;
if (setVal instanceof ManagedSet) {
isMergeEnabled = ((ManagedSet) setVal).isMergeEnabled();
}
ManagedSet newSet = new ManagedSet();
newSet.setMergeEnabled(isMergeEnabled);
for (Object elem : setVal) {
if (isStringValue(elem)) {
elem = processSetStringPropertyValue(propertyName, setVal, getString(elem), nestedBeanStack,
beanProcessors);
} else {
elem = visitPropertyValue(propertyName, elem, nestedBeanStack);
}
newSet.add(elem);
}
setVal.clear();
setVal.addAll(newSet);
}
示例3: parseSet
import org.springframework.beans.factory.support.ManagedSet; //导入方法依赖的package包/类
/**
* Parses a list of elements into a set of beans/standard content.
*
* @param grandChildren - The set of beans/content in a bean property
* @param child - The property tag for the parent.
* @param parent - The parent bean that the tag is nested in.
* @param parserContext - Provided information and functionality regarding current bean set.
* @return A managedSet of the nested content.
*/
private ManagedSet parseSet(ArrayList<Element> grandChildren, Element child, BeanDefinitionBuilder parent,
ParserContext parserContext) {
ManagedSet setItems = new ManagedSet();
for (int i = 0; i < grandChildren.size(); i++) {
Element grandChild = grandChildren.get(i);
if (child.getTagName().compareTo("spring:value") == 0) {
setItems.add(grandChild.getTextContent());
} else {
setItems.add(parseBean(grandChild, parent, parserContext));
}
}
String merge = child.getAttribute("merge");
if (merge != null) {
setItems.setMergeEnabled(Boolean.valueOf(merge));
}
return setItems;
}
示例4: parseSetElement
import org.springframework.beans.factory.support.ManagedSet; //导入方法依赖的package包/类
/**
* Parse a set element.
*/
public Set<?> parseSetElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(BeanDefinitionParserDelegate.VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedSet<Object> target = new ManagedSet<Object>(nl.getLength());
target.setSource(extractSource(collectionEle));
target.setElementTypeName(defaultElementType);
target.setMergeEnabled(parseMergeAttribute(collectionEle));
parseCollectionElements(nl, target, bd, defaultElementType);
return target;
}
示例5: parseSetElement
import org.springframework.beans.factory.support.ManagedSet; //导入方法依赖的package包/类
/**
* Parse a set element.
*/
public Set<Object> parseSetElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedSet<Object> target = new ManagedSet<Object>(nl.getLength());
target.setSource(extractSource(collectionEle));
target.setElementTypeName(defaultElementType);
target.setMergeEnabled(parseMergeAttribute(collectionEle));
parseCollectionElements(nl, target, bd, defaultElementType);
return target;
}
示例6: parseSetElement
import org.springframework.beans.factory.support.ManagedSet; //导入方法依赖的package包/类
/**
* Parse a set element.
*/
public Set parseSetElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedSet<Object> target = new ManagedSet<Object>(nl.getLength());
target.setSource(extractSource(collectionEle));
target.setElementTypeName(defaultElementType);
target.setMergeEnabled(parseMergeAttribute(collectionEle));
parseCollectionElements(nl, target, bd, defaultElementType);
return target;
}
示例7: handleSetValues
import org.springframework.beans.factory.support.ManagedSet; //导入方法依赖的package包/类
protected Object handleSetValues(final PropertyValue configuredValue)
{
final Object value;
LOGGER.debug("[{}] Set of values / bean reference names has been configured - treating property {} of {} as <set>", this.beanName,
this.propertyName, this.targetBeanName);
final ManagedSet<Object> set = new ManagedSet<>();
if (this.merge && configuredValue != null)
{
final Object configuredValueDefinition = configuredValue.getValue();
if (configuredValueDefinition instanceof ManagedSet<?>)
{
final ManagedSet<?> oldSet = (ManagedSet<?>) configuredValueDefinition;
set.setElementTypeName(oldSet.getElementTypeName());
set.setMergeEnabled(oldSet.isMergeEnabled());
set.setSource(oldSet.getSource());
set.addAll(oldSet);
LOGGER.debug("[{}] Merged existing value set values: {}", this.beanName, oldSet);
}
}
Set<Object> valuesToAdd;
if (this.valueSet != null)
{
LOGGER.debug("[{}] Set of configured values for {} of {}: ", this.beanName, this.propertyName, this.targetBeanName,
this.valueSet);
valuesToAdd = this.valueSet;
}
else
{
LOGGER.debug("[{}] Set of configured bean reference names for {} of {}: ", this.beanName, this.propertyName,
this.targetBeanName, this.beanReferenceNameSet);
valuesToAdd = new HashSet<>();
for (final String beanReferenceName : this.beanReferenceNameSet)
{
valuesToAdd.add(new RuntimeBeanReference(beanReferenceName));
}
}
LOGGER.debug("[{}] Adding new entries to set for {} of {}", this.beanName, this.propertyName, this.targetBeanName);
set.addAll(valuesToAdd);
if (!set.isMergeEnabled() && this.mergeParent)
{
LOGGER.debug("[{}] Enabling \"merge\" for <set> on {} of {}", this.beanName, this.propertyName, this.targetBeanName);
}
set.setMergeEnabled(set.isMergeEnabled() || this.mergeParent);
value = set;
return value;
}
示例8: visitSet
import org.springframework.beans.factory.support.ManagedSet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected void visitSet(String propertyName, Map<String, String> parentPropertyExpressions,
Map<String, String> propertyExpressions, Set setVal, ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames) {
boolean isMergeEnabled = false;
if (setVal instanceof ManagedSet) {
isMergeEnabled = ((ManagedSet) setVal).isMergeEnabled();
}
ManagedSet newSet = new ManagedSet();
newSet.setMergeEnabled(isMergeEnabled);
for (Object elem : setVal) {
if (hasExpression(elem)) {
String strValue = getStringValue(elem);
propertyExpressions.put(propertyName + ExpressionEvaluator.EMBEDDED_PROPERTY_NAME_ADD_INDICATOR,
strValue);
} else {
// process set value bean definition as a top level bean
if ((elem instanceof BeanDefinition) || (elem instanceof BeanDefinitionHolder)) {
String beanName = null;
BeanDefinition beanDefinition;
if (elem instanceof BeanDefinition) {
beanDefinition = (BeanDefinition) elem;
} else {
beanDefinition = ((BeanDefinitionHolder) elem).getBeanDefinition();
beanName = ((BeanDefinitionHolder) elem).getBeanName();
}
processBeanDefinition(beanName, beanDefinition, beanFactory, processedBeanNames);
}
newSet.add(elem);
}
}
// determine if we need to clear any parent expressions for this list
if (!isMergeEnabled) {
// clear any expressions that match the property name minus index
Map<String, String> adjustedParentExpressions = new HashMap<String, String>();
for (Map.Entry<String, String> parentExpression : parentPropertyExpressions.entrySet()) {
if (!parentExpression.getKey().startsWith(
propertyName + ExpressionEvaluator.EMBEDDED_PROPERTY_NAME_ADD_INDICATOR)) {
adjustedParentExpressions.put(parentExpression.getKey(), parentExpression.getValue());
}
}
parentPropertyExpressions.clear();
parentPropertyExpressions.putAll(adjustedParentExpressions);
}
setVal.clear();
setVal.addAll(newSet);
}