Search in sources :

Example 31 with ManagedList

use of org.springframework.beans.factory.support.ManagedList in project cxf by apache.

the class UndertowHTTPServerEngineFactoryBeanDefinitionParser method getRequiredElementsList.

private List<Object> getRequiredElementsList(Element parent, ParserContext ctx, QName name, BeanDefinitionBuilder bean) {
    List<Element> elemList = DOMUtils.findAllElementsByTagNameNS(parent, name.getNamespaceURI(), name.getLocalPart());
    ManagedList<Object> list = new ManagedList<Object>(elemList.size());
    list.setSource(ctx.extractSource(parent));
    for (Element elem : elemList) {
        list.add(ctx.getDelegate().parsePropertySubElement(elem, bean.getBeanDefinition()));
    }
    return list;
}
Also used : Element(org.w3c.dom.Element) ManagedList(org.springframework.beans.factory.support.ManagedList)

Example 32 with ManagedList

use of org.springframework.beans.factory.support.ManagedList in project dubbo by alibaba.

the class ServiceAnnotationBeanPostProcessor method toRuntimeBeanReferences.

private ManagedList<RuntimeBeanReference> toRuntimeBeanReferences(String... beanNames) {
    ManagedList<RuntimeBeanReference> runtimeBeanReferences = new ManagedList<RuntimeBeanReference>();
    if (!ObjectUtils.isEmpty(beanNames)) {
        for (String beanName : beanNames) {
            String resolvedBeanName = environment.resolvePlaceholders(beanName);
            runtimeBeanReferences.add(new RuntimeBeanReference(resolvedBeanName));
        }
    }
    return runtimeBeanReferences;
}
Also used : ManagedList(org.springframework.beans.factory.support.ManagedList) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 33 with ManagedList

use of org.springframework.beans.factory.support.ManagedList in project hudson-2.x by hudson.

the class BeanBuilder method manageListIfNecessary.

/**
	 * Checks whether there are any runtime refs inside the list and
	 * converts it to a ManagedList if necessary
	 *
	 * @param value The object that represents the list
	 * @return Either a new list or a managed one
	 */
private Object manageListIfNecessary(Object value) {
    List list = (List) value;
    boolean containsRuntimeRefs = false;
    for (ListIterator i = list.listIterator(); i.hasNext(); ) {
        Object e = i.next();
        if (e instanceof RuntimeBeanReference) {
            containsRuntimeRefs = true;
        }
        if (e instanceof BeanConfiguration) {
            BeanConfiguration c = (BeanConfiguration) e;
            i.set(c.getBeanDefinition());
            containsRuntimeRefs = true;
        }
    }
    if (containsRuntimeRefs) {
        List tmp = new ManagedList();
        tmp.addAll((List) value);
        value = tmp;
    }
    return value;
}
Also used : ManagedList(org.springframework.beans.factory.support.ManagedList) List(java.util.List) GroovyObject(groovy.lang.GroovyObject) ManagedList(org.springframework.beans.factory.support.ManagedList) ListIterator(java.util.ListIterator) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 34 with ManagedList

use of org.springframework.beans.factory.support.ManagedList in project grails-core by grails.

the class ChainedTransactionManagerPostProcessor method createTransactionManagerBeanReferences.

protected ManagedList<RuntimeBeanReference> createTransactionManagerBeanReferences(BeanDefinition chainedTransactionManagerBeanDefinition) {
    ManagedList<RuntimeBeanReference> transactionManagerRefs = new ManagedList<RuntimeBeanReference>();
    ConstructorArgumentValues constructorValues = chainedTransactionManagerBeanDefinition.getConstructorArgumentValues();
    constructorValues.addIndexedArgumentValue(0, transactionManagerRefs);
    transactionManagerRefs.add(new RuntimeBeanReference(PRIMARY_TRANSACTION_MANAGER));
    return transactionManagerRefs;
}
Also used : ManagedList(org.springframework.beans.factory.support.ManagedList) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference) ConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues)

Example 35 with ManagedList

use of org.springframework.beans.factory.support.ManagedList in project redisson by redisson.

the class RedissonRPCServerDefinitionParser method parseNested.

@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
    Class<?> apiClass;
    try {
        apiClass = Class.forName(helper.getAttribute(element, RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE));
    } catch (ClassNotFoundException ex) {
        throw new IllegalArgumentException("The class [" + helper.getAttribute(element, RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE) + "] specified in \"" + RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE + "\" attribute has not " + "found. Please check the class path.", ex);
    }
    builder.addPropertyValue("targetObject", new RuntimeBeanReference(helper.getAttribute(element, RedissonNamespaceParserSupport.REMOTE_SERVICE_REF_ATTRIBUTE)));
    builder.addPropertyValue("targetMethod", "register");
    ManagedList args = new ManagedList();
    args.add(apiClass);
    args.add(new RuntimeBeanReference(helper.getAttribute(element, BeanDefinitionParserDelegate.BEAN_REF_ATTRIBUTE)));
    String workers = null;
    if (helper.hasAttribute(element, RedissonNamespaceParserSupport.CONCURRENT_WORKERS_ATTRIBUTE)) {
        workers = helper.getAttribute(element, RedissonNamespaceParserSupport.CONCURRENT_WORKERS_ATTRIBUTE);
    }
    if (StringUtils.hasText(workers)) {
        args.add(Integer.parseInt(workers));
    }
    if (helper.hasAttribute(element, RedissonNamespaceParserSupport.EXECUTOR_REF_ATTRIBUTE)) {
        Assert.state(helper.hasAttribute(element, RedissonNamespaceParserSupport.CONCURRENT_WORKERS_ATTRIBUTE), "The \"" + RedissonNamespaceParserSupport.CONCURRENT_WORKERS_ATTRIBUTE + "\" attribute in \"" + RedissonNamespaceParserSupport.RPC_SERVER_ELEMENT + "\" element is required when \"" + RedissonNamespaceParserSupport.EXECUTOR_REF_ATTRIBUTE + "\" attribute is specified.");
        args.add(new RuntimeBeanReference(helper.getAttribute(element, RedissonNamespaceParserSupport.EXECUTOR_REF_ATTRIBUTE)));
    }
    builder.addPropertyValue("arguments", args);
}
Also used : ManagedList(org.springframework.beans.factory.support.ManagedList) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Aggregations

ManagedList (org.springframework.beans.factory.support.ManagedList)60 Element (org.w3c.dom.Element)37 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)27 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)26 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)20 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)18 BeanMetadataElement (org.springframework.beans.BeanMetadataElement)10 BeanComponentDefinition (org.springframework.beans.factory.parsing.BeanComponentDefinition)10 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)6 Node (org.w3c.dom.Node)6 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)5 ConstructorArgumentValues (org.springframework.beans.factory.config.ConstructorArgumentValues)4 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)4 GroovyObject (groovy.lang.GroovyObject)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BeanReference (org.springframework.beans.factory.config.BeanReference)3 CompositeComponentDefinition (org.springframework.beans.factory.parsing.CompositeComponentDefinition)3 GenericBeanDefinition (org.springframework.beans.factory.support.GenericBeanDefinition)3 ManagedMap (org.springframework.beans.factory.support.ManagedMap)3