Search in sources :

Example 56 with ManagedList

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

the class MotanBeanDefinitionParser method parseMultiRef.

@SuppressWarnings({ "unchecked", "rawtypes" })
private static void parseMultiRef(String property, String value, RootBeanDefinition beanDefinition, ParserContext parserContext) {
    String[] values = value.split("\\s*[,]+\\s*");
    ManagedList list = null;
    for (int i = 0; i < values.length; i++) {
        String v = values[i];
        if (v != null && v.length() > 0) {
            if (list == null) {
                list = new ManagedList();
            }
            list.add(new RuntimeBeanReference(v));
        }
    }
    beanDefinition.getPropertyValues().addPropertyValue(property, list);
}
Also used : ManagedList(org.springframework.beans.factory.support.ManagedList) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 57 with ManagedList

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

the class MotanBeanDefinitionParser method parseMethods.

@SuppressWarnings({ "unchecked", "rawtypes" })
private static void parseMethods(String id, NodeList nodeList, RootBeanDefinition beanDefinition, ParserContext parserContext) throws ClassNotFoundException {
    if (nodeList != null && nodeList.getLength() > 0) {
        ManagedList methods = null;
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node instanceof Element) {
                Element element = (Element) node;
                if ("method".equals(node.getNodeName()) || "method".equals(node.getLocalName())) {
                    String methodName = element.getAttribute("name");
                    if (methodName == null || methodName.length() == 0) {
                        throw new IllegalStateException("<motan:method> name attribute == null");
                    }
                    if (methods == null) {
                        methods = new ManagedList();
                    }
                    BeanDefinition methodBeanDefinition = parse((Element) node, parserContext, MethodConfig.class, false);
                    String name = id + "." + methodName;
                    BeanDefinitionHolder methodBeanDefinitionHolder = new BeanDefinitionHolder(methodBeanDefinition, name);
                    methods.add(methodBeanDefinitionHolder);
                }
            }
        }
        if (methods != null) {
            beanDefinition.getPropertyValues().addPropertyValue("methods", methods);
        }
    }
}
Also used : Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) BeanDefinitionHolder(org.springframework.beans.factory.config.BeanDefinitionHolder) ManagedList(org.springframework.beans.factory.support.ManagedList) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Example 58 with ManagedList

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

the class ComponentScanBeanDefinitionParser method createTimerService.

protected BeanDefinition createTimerService() {
    String className = "io.leopard.web.timer.TimerServiceImpl";
    Class<?> clazz;
    try {
        clazz = Class.forName(className);
    } catch (ClassNotFoundException e) {
        return null;
    }
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(clazz);
    ManagedList<RuntimeBeanReference> timerBeanList = new ManagedList<RuntimeBeanReference>();
    for (String beanName : timerList) {
        timerBeanList.add(new RuntimeBeanReference(beanName));
    }
    builder.addPropertyValue("timers", timerBeanList);
    builder.setScope(BeanDefinition.SCOPE_SINGLETON);
    builder.setLazyInit(false);
    return RegisterComponentUtil.registerComponent(parserContext, builder, "timerService");
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) ManagedList(org.springframework.beans.factory.support.ManagedList) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 59 with ManagedList

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

the class NettyHttpServerEngineFactoryBeanDefinitionParser 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 60 with ManagedList

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

the class JettyHTTPServerEngineFactoryBeanDefinitionParser 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)

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