本文整理汇总了Java中org.springframework.beans.factory.support.ManagedList.setMergeEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ManagedList.setMergeEnabled方法的具体用法?Java ManagedList.setMergeEnabled怎么用?Java ManagedList.setMergeEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.ManagedList
的用法示例。
在下文中一共展示了ManagedList.setMergeEnabled方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseList
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
/**
* Parses a list of elements into a list of beans/standard content.
*
* @param grandChildren - The list 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 managedList of the nested content.
*/
protected ManagedList parseList(ArrayList<Element> grandChildren, Element child, BeanDefinitionBuilder parent,
ParserContext parserContext) {
ArrayList<Object> listItems = new ArrayList<Object>();
for (int i = 0; i < grandChildren.size(); i++) {
Element grandChild = grandChildren.get(i);
if (grandChild.getTagName().compareTo("value") == 0) {
listItems.add(grandChild.getTextContent());
} else {
listItems.add(parseBean(grandChild, parent, parserContext));
}
}
String merge = child.getAttribute("merge");
ManagedList beans = new ManagedList(listItems.size());
beans.addAll(listItems);
if (merge != null) {
beans.setMergeEnabled(Boolean.valueOf(merge));
}
return beans;
}
示例2: visitList
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
/**
* Iterates through the list values and calls helpers to process the value
*
* @param listVal the list to process
* @param propertyName name of the property which has the list value
* @param nestedBeanStack stack of bean containers which contains the list property
*/
protected void visitList(List<?> listVal, String propertyName, Stack<BeanDefinitionHolder> nestedBeanStack) {
boolean isMergeEnabled = false;
if (listVal instanceof ManagedList) {
isMergeEnabled = ((ManagedList) listVal).isMergeEnabled();
}
ManagedList newList = new ManagedList();
newList.setMergeEnabled(isMergeEnabled);
for (int i = 0; i < listVal.size(); i++) {
Object elem = listVal.get(i);
if (isStringValue(elem)) {
elem = processListStringPropertyValue(propertyName, listVal, getString(elem), i, nestedBeanStack,
beanProcessors);
} else {
elem = visitPropertyValue(propertyName, elem, nestedBeanStack);
}
newList.add(i, elem);
}
listVal.clear();
listVal.addAll(newList);
}
示例3: postProcessBeanFactory
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
Map<String, ResourceBundleNameProvider> beans = beanFactory.getBeansOfType(ResourceBundleNameProvider.class);
if (beans != null) {
BeanDefinition messageSourceDef = beanFactory.getBeanDefinition("messageSource");
ManagedList<TypedStringValue> bundleNames = new ManagedList<>();
bundleNames.setMergeEnabled(true);
Collection<ResourceBundleNameProvider> nameProviders = beans.values();
for (ResourceBundleNameProvider resourceBundleNameProvider : nameProviders) {
for (String bundleName : resourceBundleNameProvider.getBundleNames()) {
bundleNames.add(new TypedStringValue(bundleName));
}
}
messageSourceDef.getPropertyValues().add("basenames", bundleNames);
}
}
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:20,代码来源:MessageSourceBeanFactoryPostProcessor.java
示例4: parseList
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
/**
* Parses a list of elements into a list of beans/standard content.
*
* @param grandChildren - The list 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 managedList of the nested content.
*/
private ManagedList parseList(ArrayList<Element> grandChildren, Element child, BeanDefinitionBuilder parent,
ParserContext parserContext) {
ArrayList<Object> listItems = new ArrayList<Object>();
for (int i = 0; i < grandChildren.size(); i++) {
Element grandChild = grandChildren.get(i);
if (grandChild.getTagName().compareTo("spring:value") == 0) {
listItems.add(grandChild.getTextContent());
} else {
listItems.add(parseBean(grandChild, parent, parserContext));
}
}
String merge = child.getAttribute("merge");
ManagedList beans = new ManagedList(listItems.size());
if (merge != null) {
beans.setMergeEnabled(Boolean.valueOf(merge));
}
beans.addAll(listItems);
return beans;
}
示例5: createPropertiesList
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
/**
* Creates the list of the properties to be used within the configuration
* from the outer world.
*
* @param element
* the parent element which contains all the properties
* @param parserContext
* the <code>ParserContext</code>
*
* @return the <code>List</code> containing the beans with properties
*/
protected List<?> createPropertiesList(final Element element,
final ParserContext parserContext) {
final List<Element> propEls = DomUtils.getChildElementsByTagName(
element, XML_ELEMENT_PROPERTIES);
// create the list
final ManagedList<Object> list = new ManagedList<Object>(propEls.size());
list.setSource(parserContext.extractSource(element));
list.setElementTypeName(PropertiesLoaderSupport.class.getName());
list.setMergeEnabled(false);
for (final Element propEl : propEls) {
final String loadId = propEl.getAttribute(XML_ATTRIBUTE_LOADID);
final RuntimeBeanReference ref = new RuntimeBeanReference(loadId);
ref.setSource(parserContext.extractSource(propEl));
list.add(ref);
}
return list;
}
示例6: parseListElement
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
/**
* Parse a list element.
*/
public List<?> parseListElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(BeanDefinitionParserDelegate.VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedList<Object> target = new ManagedList<Object>(nl.getLength());
target.setSource(extractSource(collectionEle));
target.setElementTypeName(defaultElementType);
target.setMergeEnabled(parseMergeAttribute(collectionEle));
parseCollectionElements(nl, target, bd, defaultElementType);
return target;
}
示例7: parseListElement
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
/**
* Parse a list element.
*/
public List<Object> parseListElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedList<Object> target = new ManagedList<Object>(nl.getLength());
target.setSource(extractSource(collectionEle));
target.setElementTypeName(defaultElementType);
target.setMergeEnabled(parseMergeAttribute(collectionEle));
parseCollectionElements(nl, target, bd, defaultElementType);
return target;
}
示例8: parseListElement
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
/**
* Parse a list element.
*/
public List parseListElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedList<Object> target = new ManagedList<Object>(nl.getLength());
target.setSource(extractSource(collectionEle));
target.setElementTypeName(defaultElementType);
target.setMergeEnabled(parseMergeAttribute(collectionEle));
parseCollectionElements(nl, target, bd, defaultElementType);
return target;
}
示例9: handleListValues
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
protected Object handleListValues(final PropertyValue configuredValue)
{
final Object value;
LOGGER.debug("[{}] List of values / bean reference names has been configured - treating property {} of {} as <list>", this.beanName,
this.propertyName, this.targetBeanName);
final ManagedList<Object> list = new ManagedList<>();
if (this.merge && configuredValue != null)
{
final Object configuredValueDefinition = configuredValue.getValue();
if (configuredValueDefinition instanceof ManagedList<?>)
{
final ManagedList<?> oldList = (ManagedList<?>) configuredValueDefinition;
list.setElementTypeName(oldList.getElementTypeName());
list.setMergeEnabled(oldList.isMergeEnabled());
list.setSource(oldList.getSource());
list.addAll(oldList);
LOGGER.debug("[{}] Merged existing value list values: {}", this.beanName, oldList);
}
}
List<Object> valuesToAdd;
if (this.valueList != null)
{
LOGGER.debug("[{}] List of configured values for {} of {}: ", this.beanName, this.propertyName, this.targetBeanName,
this.valueList);
valuesToAdd = this.valueList;
}
else
{
LOGGER.debug("[{}] List of configured bean reference names for {} of {}: ", this.beanName, this.propertyName,
this.targetBeanName, this.beanReferenceNameList);
valuesToAdd = new ArrayList<>();
for (final String beanReferenceName : this.beanReferenceNameList)
{
valuesToAdd.add(new RuntimeBeanReference(beanReferenceName));
}
}
if (this.addAsFirst)
{
LOGGER.debug("[{}] Adding new entries at start of list for {} of {}", this.beanName, this.propertyName, this.targetBeanName);
list.addAll(0, valuesToAdd);
}
else if (this.addAtIndex >= 0 && this.addAtIndex < list.size())
{
LOGGER.debug("[{}] Adding new entries at position {} of list for {} of {}", this.beanName, String.valueOf(this.addAtIndex),
this.propertyName, this.targetBeanName);
list.addAll(this.addAtIndex, valuesToAdd);
}
else
{
LOGGER.debug("[{}] Adding new entries at end of list for {} of {}", this.beanName, this.propertyName, this.targetBeanName);
list.addAll(valuesToAdd);
}
if (!list.isMergeEnabled() && this.mergeParent)
{
LOGGER.debug("[{}] Enabling \"merge\" for <list> on {} of {}", this.beanName, this.propertyName, this.targetBeanName);
}
list.setMergeEnabled(list.isMergeEnabled() || this.mergeParent);
value = list;
return value;
}
示例10: visitList
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected void visitList(String nestedPropertyName, String propertyName, BeanDefinition beanDefinition,
Map<String, String> parentExpressionGraph, Map<String, String> expressionGraph, List listVal,
ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) {
boolean isMergeEnabled = false;
if (listVal instanceof ManagedList) {
isMergeEnabled = ((ManagedList) listVal).isMergeEnabled();
}
ManagedList newList = new ManagedList();
newList.setMergeEnabled(isMergeEnabled);
// if merging, need to find size of parent list so we can know which element to set
// when evaluating expressions
int parentListSize = 0;
if (isMergeEnabled && StringUtils.isNotBlank(beanDefinition.getParentName())) {
BeanDefinition parentBeanDefinition = beanFactory.getMergedBeanDefinition(beanDefinition.getParentName());
PropertyValue parentListPropertyValue = parentBeanDefinition.getPropertyValues().getPropertyValue(
propertyName);
if (parentListPropertyValue != null) {
List parentList = (List) parentListPropertyValue.getValue();
parentListSize = parentList.size();
}
}
for (int i = 0; i < listVal.size(); i++) {
Object elem = listVal.get(i);
int elementPosition = i + parentListSize;
String elemPropertyName = nestedPropertyName + "[" + elementPosition + "]";
if (hasExpression(elem)) {
String strValue = getStringValue(elem);
expressionGraph.put(elemPropertyName, strValue);
newList.add(i, null);
} else {
// process list value bean definition as a top level bean
if ((elem instanceof BeanDefinition) || (elem instanceof BeanDefinitionHolder)) {
String beanName = null;
BeanDefinition beanDefinitionValue;
if (elem instanceof BeanDefinition) {
beanDefinitionValue = (BeanDefinition) elem;
} else {
beanDefinitionValue = ((BeanDefinitionHolder) elem).getBeanDefinition();
beanName = ((BeanDefinitionHolder) elem).getBeanName();
}
processBeanDefinition(beanName, beanDefinitionValue, beanFactory, processedBeanNames);
}
newList.add(i, 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> adjustedParentExpressionGraph = new HashMap<String, String>();
for (Map.Entry<String, String> parentExpression : parentExpressionGraph.entrySet()) {
if (!parentExpression.getKey().startsWith(nestedPropertyName + "[")) {
adjustedParentExpressionGraph.put(parentExpression.getKey(), parentExpression.getValue());
}
}
parentExpressionGraph.clear();
parentExpressionGraph.putAll(adjustedParentExpressionGraph);
}
listVal.clear();
listVal.addAll(newList);
}
示例11: parseStaticOptions
import org.springframework.beans.factory.support.ManagedList; //导入方法依赖的package包/类
protected AbstractBeanDefinition parseStaticOptions(ParserContext parserContext, BeanDefinitionRegistry beanDefRegistry, Element elem, String elemNsPrefix,
String elemNsUri, String elemLocalName, AbstractBeanDefinition beanDef) throws Exception {
super.parseDefinition(parserContext, beanDefRegistry, elem, elemNsPrefix, elemNsUri, elemLocalName, beanDef);
MutablePropertyValues staticOptsPropValues = beanDef.getPropertyValues();
List<Element> staticFuncElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_FUNC_ELEM_LOCAL_NAME);
if (!staticFuncElems.isEmpty()) {
ManagedList<Object> staticFuncs = new ManagedList<>(staticFuncElems.size());
staticFuncs.setMergeEnabled(true);
staticFuncs.setElementTypeName(ExtensionFunctionDefinition.class.getName());
staticFuncElems
.forEach(staticFuncElem -> staticFuncs.add(new RuntimeBeanReference(staticFuncElem.getAttribute(BeanDefinitionParserDelegate.REF_ATTRIBUTE))));
staticOptsPropValues.addPropertyValue(FUNCS_PROP_NAME, staticFuncs);
}
List<Element> staticNsElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_NS_ELEM_LOCAL_NAME);
if (!staticNsElems.isEmpty()) {
ManagedMap<String, String> staticNamespaces = new ManagedMap<>(staticNsElems.size());
staticNamespaces.setMergeEnabled(true);
for (Element staticNsElem : staticNsElems) {
staticNamespaces.put(staticNsElem.getAttribute(PREFIX_ATTR_NAME), DomUtils.getTextValue(staticNsElem).trim());
}
staticOptsPropValues.addPropertyValue(NAMESPACES_PROP_NAME, staticNamespaces);
}
List<Element> staticVarElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_VAR_ELEM_LOCAL_NAME);
if (!staticVarElems.isEmpty()) {
ManagedMap<QName, Object> staticVars = new ManagedMap<>(staticVarElems.size());
staticVars.setMergeEnabled(true);
staticVars.setValueTypeName(XdmValue.class.getName());
for (Element staticVarElem : staticVarElems) {
staticVars.put(new QName(staticVarElem.getAttribute(NAME_ATTRIBUTE)), DomUtils.getTextValue(staticVarElem).trim());
}
staticOptsPropValues.addPropertyValue(VARS_PROP_NAME, staticVars);
}
List<Element> staticPooledDocElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_POOLED_DOC_ELEM_LOCAL_NAME);
if (!staticPooledDocElems.isEmpty()) {
XdmDocumentBeanDefinitionParser docBeanDefParser =
((XdmDocumentBeanDefinitionParser) this.nsHandler.getBeanDefinitionParsers().get(XdmDocumentBeanDefinitionParser.DOC_ELEM_LOCAL_NAME));
ManagedList<Object> staticPooledDocs = new ManagedList<>(staticPooledDocElems.size());
staticPooledDocs.setMergeEnabled(true);
staticPooledDocs.setElementTypeName(XdmDocument.class.getName());
for (Element staticPooledDocElem : staticPooledDocElems) {
staticPooledDocs.add(
docBeanDefParser.parse(staticPooledDocElem, new ParserContext(parserContext.getReaderContext(), parserContext.getDelegate(), beanDef)));
}
staticOptsPropValues.addPropertyValue(POOLED_DOCS_PROP_NAME, staticPooledDocs);
}
return beanDef;
}