Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.ManagedList


    Element listenersElement = (Element) listenersElements.get(0);
    List listenerElements = DomUtils.getChildElementsByTagName(
        listenersElement, "cachingListener");

    ManagedList listeners = new ManagedList();
    boolean registerCachingListener = true;
    int listenerCount = listenerElements.size();

    for (int i = 0; i < listenerCount; i++) {
      Element listenerElement = (Element) listenerElements.get(i);

      Object cachingListener = beanReferenceParser.parse(listenerElement,
          parserContext, registerCachingListener);
      cachingListenerValidator.validate(cachingListener, i, parserContext);
      listeners.add(cachingListener);
    }

    return listeners;
  }
View Full Code Here


                                         BeanDefinitionBuilder bean) {
      
        List<Element> elemList = DOMUtils.findAllElementsByTagNameNS(parent,
                                                                     name.getNamespaceURI(),
                                                                     name.getLocalPart());
        ManagedList list = new ManagedList(elemList.size());
        list.setSource(ctx.extractSource(parent));
       
        for (Element elem : elemList) {
            list.add(ctx.getDelegate().parsePropertySubElement(elem, bean.getBeanDefinition()));
        }
        return list;
    }
View Full Code Here

        for (Element listener : eventListeners) {
            String beanName = listener.getAttribute("ref");
            // if this a bean ref
            if (StringUtils.hasText(beanName)) {
                if (TYPE_AGENDA_EVENT_LISTENER.equalsIgnoreCase(listenerType) || TYPE_PROCESS_EVENT_LISTENER.equalsIgnoreCase(listenerType) || TYPE_WORKING_MEMORY_EVENT_LISTENER.equalsIgnoreCase(listenerType)) {
                    ManagedList subList = (ManagedList) listeners.get(listenerType);
                    if (subList == null) {
                        subList = new ManagedList();
                        listeners.put(listenerType, subList);
                    }
                    subList.add(new RuntimeBeanReference(beanName));
                } else {
                    throw new IllegalArgumentException("eventListener must be of type 'agenda-event-listener or 'process-event-listener' or 'working-memory-event-listener'.");
                }
            } else {
                //not a ref check if it is a nested bean
                Element nestedBean = DomUtils.getChildElementByTagName(listener, "bean");
                if (nestedBean == null) {
                    //no 'ref' and no nested beans, add the default debug listeners part of the core libs.
                    Object obj = null;
                    if (TYPE_AGENDA_EVENT_LISTENER.equalsIgnoreCase(listenerType)) {
                        obj = new DebugAgendaEventListener();
                    } else if (TYPE_PROCESS_EVENT_LISTENER.equalsIgnoreCase(listenerType)) {
                        obj = new DebugProcessEventListener();
                    } else if (TYPE_WORKING_MEMORY_EVENT_LISTENER.equalsIgnoreCase(listenerType)) {
                        obj = new DebugWorkingMemoryEventListener();
                    }
                    ManagedList subList = (ManagedList) listeners.get(listenerType);
                    if (subList == null) {
                        subList = new ManagedList();
                        listeners.put(listenerType, subList);
                    }
                    subList.add(obj);
                } else {
                    //String type = StringUtils.hasText(listenerType) ? listenerType: "infer";
                    Object obj = parserContext.getDelegate().parsePropertySubElement(nestedBean, null, null);
                    ManagedList subList = (ManagedList) listeners.get(listenerType);
                    if (subList == null) {
                        subList = new ManagedList();
                        listeners.put(listenerType, subList);
                    }
                    subList.add(obj);
                }
            }
        }
        return listeners;
    }
View Full Code Here

            batch = DomUtils.getChildElementByTagName(element,
                    "script");
        }
        if (batch != null) {
            // we know there can only ever be one
            ManagedList children = new ManagedList();

            for (int i = 0, length = batch.getChildNodes().getLength(); i < length; i++) {
                Node n = batch.getChildNodes().item(i);
                if (n instanceof Element) {
                    Element e = (Element) n;

                    BeanDefinitionBuilder beanBuilder = null;
                    if ("insert-object".equals(e.getLocalName())) {
                        String ref = e.getAttribute("ref");
                        Element nestedElm = getFirstElement(e.getChildNodes());
                        beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(InsertObjectCommand.class);
                        if (StringUtils.hasText(ref)) {
                            beanBuilder.addConstructorArgReference(ref);
                        } else if (nestedElm != null) {
                            beanBuilder.addConstructorArgValue(parserContext.getDelegate().parsePropertySubElement(nestedElm,
                                    null,
                                    null));
                        } else {
                            throw new IllegalArgumentException("insert-object must either specify a 'ref' attribute or have a nested bean");
                        }
                    } else if ("set-global".equals(e.getLocalName())) {
                        String ref = e.getAttribute("ref");
                        Element nestedElm = getFirstElement(e.getChildNodes());
                        beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(SetGlobalCommand.class);
                        beanBuilder.addConstructorArgValue(e.getAttribute("identifier"));
                        if (StringUtils.hasText(ref)) {
                            beanBuilder.addConstructorArgReference(ref);
                        } else if (nestedElm != null) {
                            beanBuilder.addConstructorArgValue(parserContext.getDelegate().parsePropertySubElement(nestedElm,
                                    null,
                                    null));
                        } else {
                            throw new IllegalArgumentException("set-global must either specify a 'ref' attribute or have a nested bean");
                        }
                    } else if ("fire-until-halt".equals(e.getLocalName())) {
                        beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(FireUntilHaltCommand.class);
                    } else if ("fire-all-rules".equals(e.getLocalName())) {
                        beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(FireAllRulesCommand.class);
                        String max = e.getAttribute("max");
                        if (StringUtils.hasText(max)) {
                            beanBuilder.addPropertyValue("max",
                                    max);
                        }
                    } else if ("start-process".equals(e.getLocalName())) {

                        beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(StartProcessCommand.class);
                        String processId = e.getAttribute("process-id");
                        if (!StringUtils.hasText(processId)) {
                            throw new IllegalArgumentException("start-process must specify a process-id");
                        }
                        beanBuilder.addConstructorArgValue(processId);

                        List<Element> params = DomUtils.getChildElementsByTagName(e,
                                "parameter");
                        if (!params.isEmpty()) {
                            ManagedMap map = new ManagedMap();
                            for (Element param : params) {
                                String identifier = param.getAttribute("identifier");
                                if (!StringUtils.hasText(identifier)) {
                                    throw new IllegalArgumentException("start-process paramaters must specify an identifier");
                                }

                                String ref = param.getAttribute("ref");
                                Element nestedElm = getFirstElement(param.getChildNodes());
                                if (StringUtils.hasText(ref)) {
                                    map.put(identifier,
                                            new RuntimeBeanReference(ref));
                                } else if (nestedElm != null) {
                                    map.put(identifier,
                                            parserContext.getDelegate().parsePropertySubElement(nestedElm,
                                                    null,
                                                    null));
                                } else {
                                    throw new IllegalArgumentException("start-process paramaters must either specify a 'ref' attribute or have a nested bean");
                                }
                            }
                            beanBuilder.addPropertyValue("parameters",
                                    map);
                        }
                    } else if ("signal-event".equals(e.getLocalName())) {
                        beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(SignalEventCommand.class);
                        String processInstanceId = e.getAttribute("process-instance-id");
                        if (StringUtils.hasText(processInstanceId)) {
                            beanBuilder.addConstructorArgValue(processInstanceId);
                        }

                        beanBuilder.addConstructorArgValue(e.getAttribute("event-type"));

                        String ref = e.getAttribute("ref");
                        Element nestedElm = getFirstElement(e.getChildNodes());
                        if (StringUtils.hasText(ref)) {
                            beanBuilder.addConstructorArgReference(ref);
                        } else if (nestedElm != null) {
                            beanBuilder.addConstructorArgValue(parserContext.getDelegate().parsePropertySubElement(nestedElm,
                                    null,
                                    null));
                        } else {
                            throw new IllegalArgumentException("signal-event must either specify a 'ref' attribute or have a nested bean");
                        }
                    }
                    if (beanBuilder == null) {
                        throw new IllegalStateException("Unknow element: " + e.getLocalName());
                    }
                    children.add(beanBuilder.getBeanDefinition());
                }
            }
            factory.addPropertyValue("batch",
                    children);
        }
View Full Code Here

                }
            }
        }

        protected ManagedList parseListeners(Node node, Class listenerConfigClass) {
            ManagedList listeners = new ManagedList();
            final String implementationAttr = "implementation";
            for (Node listenerNode : new IterableNodeList(node.getChildNodes(), Node.ELEMENT_NODE)) {
                final BeanDefinitionBuilder listenerConfBuilder = createBeanBuilder(listenerConfigClass);
                fillAttributeValues(listenerNode, listenerConfBuilder, implementationAttr);
                Node implementationNode = null;
                if ((implementationNode = listenerNode.getAttributes().getNamedItem(implementationAttr)) != null) {
                    listenerConfBuilder.addPropertyReference(implementationAttr, getTextContent(implementationNode));
                }
                listeners.add(listenerConfBuilder.getBeanDefinition());
            }
            return listeners;
        }
View Full Code Here

            }
            return listeners;
        }

        protected ManagedList parseProxyFactories(Node node, Class proxyFactoryConfigClass) {
            ManagedList list = new ManagedList();
            for (Node _node : new IterableNodeList(node.getChildNodes(), Node.ELEMENT_NODE)) {
                final BeanDefinitionBuilder confBuilder = createBeanBuilder(proxyFactoryConfigClass);
                fillAttributeValues(_node, confBuilder);
                list.add(confBuilder.getBeanDefinition());
            }
            return list;
        }
View Full Code Here

            BeanDefinitionBuilder globalSerializerConfigBuilder = null;
            String implementation = "implementation";
            String className = "class-name";
            String typeClassName = "type-class";

            ManagedList serializers = new ManagedList();
            for (Node child : new IterableNodeList(node, Node.ELEMENT_NODE)) {
                final String name = cleanNodeName(child);
                if ("global-serializer".equals(name)) {
                    globalSerializerConfigBuilder = createBeanBuilder(GlobalSerializerConfig.class);
                    final NamedNodeMap attrs = child.getAttributes();
                    final Node implRef = attrs.getNamedItem(implementation);
                    final Node classNode = attrs.getNamedItem(className);
                    if(implRef != null) {
                        globalSerializerConfigBuilder.addPropertyReference(xmlToJavaName(implementation), getTextContent(implRef));
                    }
                    if(classNode != null) {
                        globalSerializerConfigBuilder.addPropertyValue(xmlToJavaName(className), getTextContent(classNode));
                    }
                }
                if ("serializer".equals(name)) {
                    BeanDefinitionBuilder serializerConfigBuilder = createBeanBuilder(SerializerConfig.class);
                    fillAttributeValues(child, serializerConfigBuilder);
                    final NamedNodeMap attrs = child.getAttributes();
                    final Node implRef = attrs.getNamedItem(implementation);
                    final Node classNode = attrs.getNamedItem(className);

                    final Node typeClass = attrs.getNamedItem(typeClassName);

                    if(typeClass != null){
                        serializerConfigBuilder.addPropertyValue( "typeClassName",getTextContent(typeClass));
                    }

                    if(implRef != null) {
                        serializerConfigBuilder.addPropertyReference(xmlToJavaName(implementation), getTextContent(implRef));
                    }
                    if(classNode != null) {
                        serializerConfigBuilder.addPropertyValue(xmlToJavaName(className), getTextContent(classNode));
                    }
                    serializers.add(serializerConfigBuilder.getBeanDefinition());
                }
            }
            if(globalSerializerConfigBuilder != null) {
                serializationConfigBuilder.addPropertyValue("globalSerializerConfig", globalSerializerConfigBuilder.getBeanDefinition());
            }
View Full Code Here

                    final String name = xmlToJavaName(att.getNodeName());
                    final String value = att.getNodeValue();
                    builder.addPropertyValue(name, value);
                }
            }
            ManagedList interfacesSet = new ManagedList();
            for (org.w3c.dom.Node n : new IterableNodeList(node, Node.ELEMENT_NODE)) {
                String name = xmlToJavaName(cleanNodeName(n));
                String value = getTextContent(n);
                if ("interface".equals(name)) {
                    interfacesSet.add(value);
                }
            }
            builder.addPropertyValue("interfaces", interfacesSet);
            networkConfigBuilder.addPropertyValue("interfaces", beanDefinition);
        }
View Full Code Here

            networkConfigBuilder.addPropertyValue("join", beanDefinition);
        }


        private void handleOutboundPorts(final Node node, final BeanDefinitionBuilder networkConfigBuilder) {
            ManagedList outboundPorts = new ManagedList();
            for (org.w3c.dom.Node child : new IterableNodeList(node, Node.ELEMENT_NODE)) {
                final String name = cleanNodeName(child);
                if ("ports".equals(name)) {
                    String value = getTextContent(child);
                    outboundPorts.add(value);
                }
            }
            networkConfigBuilder.addPropertyValue("outboundPortDefinitions", outboundPorts);
        }
View Full Code Here

            final BeanDefinitionBuilder builder =
                    createAndFillBeanBuilder(node, TcpIpConfig.class,
                            "tcpIpConfig",
                            joinConfigBuilder,
                            "interface", "member", "members");
            final ManagedList members = new ManagedList();
            for (org.w3c.dom.Node n : new IterableNodeList(node.getChildNodes(), Node.ELEMENT_NODE)) {
                String name = xmlToJavaName(cleanNodeName(n.getNodeName()));
                if ("member".equals(name) || "members".equals(name) || "interface".equals(name)) {
                    String value = getTextContent(n);
                    members.add(value);
                }
            }
            builder.addPropertyValue("members", members);
        }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.support.ManagedList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.