org.springframework.beans.factory.support.ManagedSet Java Examples

The following examples show how to use org.springframework.beans.factory.support.ManagedSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomSchemaParser.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: DictionaryBeanFactoryPostProcessor.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: BeanDefinitionWriterServiceImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
private XStream createStream() {
	XStream stream = new XStream();
	stream.registerConverter(new BeanDefinitionConverter(stream.getMapper()));
	stream.registerConverter(new BeanDefinitionHolderConverter(stream.getMapper()));
	stream.registerConverter(new TypedStringValueConverter());
	stream.registerConverter(new ManagedCollectionConverter(stream.getMapper()));
	stream.registerConverter(new ManagedMapConverter(stream.getMapper()));
	stream.registerConverter(new RuntimeBeanReferenceConverter());
	stream.alias("map", ManagedMap.class);
	stream.alias("list", ManagedList.class);
	stream.alias("set", ManagedSet.class);
	stream.alias("array", ManagedArray.class);
	stream.aliasType("bean", BeanDefinition.class);
	stream.alias("bean", BeanDefinitionHolder.class);
	stream.alias("ref", RuntimeBeanReference.class);
	return stream;
}
 
Example #4
Source File: BeanDefinitionParserDelegate.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Parse a set element.
 */
public Set<Object> parseSetElement(Element collectionEle, @Nullable BeanDefinition bd) {
	String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
	NodeList nl = collectionEle.getChildNodes();
	ManagedSet<Object> target = new ManagedSet<>(nl.getLength());
	target.setSource(extractSource(collectionEle));
	target.setElementTypeName(defaultElementType);
	target.setMergeEnabled(parseMergeAttribute(collectionEle));
	parseCollectionElements(nl, target, bd, defaultElementType);
	return target;
}
 
Example #5
Source File: BeanDefinitionParserDelegate.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Parse a set element.
 */
public Set<Object> parseSetElement(Element collectionEle, @Nullable BeanDefinition bd) {
	String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
	NodeList nl = collectionEle.getChildNodes();
	ManagedSet<Object> target = new ManagedSet<>(nl.getLength());
	target.setSource(extractSource(collectionEle));
	target.setElementTypeName(defaultElementType);
	target.setMergeEnabled(parseMergeAttribute(collectionEle));
	parseCollectionElements(nl, target, bd, defaultElementType);
	return target;
}
 
Example #6
Source File: CacheXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
/** 获取瞬时策略集合 */
private static ManagedSet<Object> getTransienceStrategies(Element configurationElement, ParserContext context) {
    // 设置每个执行策略配置
    ManagedSet<Object> strategies = new ManagedSet<>();
    List<Element> elements = XmlUtility.getChildElementsByTagName(configurationElement, ElementDefinition.TRANSIENCE_STRATEGY.getName());
    for (Element element : elements) {
        String reference = element.getAttribute(AttributeDefinition.REFERENCE.getName());
        strategies.add(new RuntimeBeanReference(reference));
    }
    return strategies;
}
 
Example #7
Source File: CacheXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
/** 获取持久策略集合 */
private static ManagedSet<Object> getPersistenceStrategies(Element configurationElement, ParserContext context) {
    // 设置每个执行策略配置
    ManagedSet<Object> strategies = new ManagedSet<>();
    List<Element> elements = XmlUtility.getChildElementsByTagName(configurationElement, ElementDefinition.PERSISTENCE_STRATEGY.getName());
    for (Element element : elements) {
        String reference = element.getAttribute(AttributeDefinition.REFERENCE.getName());
        strategies.add(new RuntimeBeanReference(reference));
    }
    return strategies;
}
 
Example #8
Source File: BeanDefinitionParserDelegate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: BeanDefinitionParserDelegate.java    From blog_demos with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: BeanDefinitionParserDelegate.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source File: BeanDefinitionWriterServiceImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
public boolean canConvert(Class type) {
	return type.equals(ManagedList.class) || type.equals(ManagedArray.class) || type.equals(ManagedSet.class);
}