Package org.springframework.beans.factory.support

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


    }

    private void parseBatch(ParserContext parserContext, BeanDefinitionBuilder factory, Element batch) {
        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 (org.springframework.util.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 (org.springframework.util.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 (org.springframework.util.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 (!org.springframework.util.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 (!org.springframework.util.StringUtils.hasText(identifier)) {
                                    throw new IllegalArgumentException("start-process paramaters must specify an identifier");
                                }

                                String ref = param.getAttribute("ref");
                                Element nestedElm = getFirstElement(param.getChildNodes());
                                if (org.springframework.util.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 parameters 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 (org.springframework.util.StringUtils.hasText(processInstanceId)) {
                            beanBuilder.addConstructorArgValue(processInstanceId);
                        }

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

                        String ref = e.getAttribute("ref");
                        Element nestedElm = getFirstElement(e.getChildNodes());
                        if (org.springframework.util.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


public class LoggerUtil {
    static int i = 0;

    public static void parseRuntimeLoggers(ParserContext parserContext, BeanDefinitionBuilder factory, Element element) {
        ManagedList loggerAdaptors = new ManagedList();
        List<Element> fileLoggerElements = DomUtils.getChildElementsByTagName(element, "fileLogger");
        if (fileLoggerElements != null) {
            for (Element fileLoggerElement : fileLoggerElements) {
                String id = checkAndSetID(element, fileLoggerElement);
                parserContext.getDelegate().parsePropertySubElement(fileLoggerElement, null, null);
                loggerAdaptors.add(new RuntimeBeanReference(id));
            }
        }
        Element consoleLoggerElement = DomUtils.getChildElementByTagName(element, "consoleLogger");
        if (consoleLoggerElement != null) {
            String id = checkAndSetID(element, consoleLoggerElement);
            parserContext.getDelegate().parsePropertySubElement(consoleLoggerElement, null, null);
            loggerAdaptors.add(new RuntimeBeanReference(id));
        }
        if (loggerAdaptors.size() > 0) {
            factory.addPropertyValue("knowledgeRuntimeLoggers", loggerAdaptors);
        }
    }
View Full Code Here

        Element objectMarshallingStrategiesElement = DomUtils.getChildElementByTagName(element, ELEMENT_OBJECT_MARSHALLING_STRATEGIES);
        if (objectMarshallingStrategiesElement != null) {
            List<String> marshallerOrderList = new ArrayList<String>();
            List<Element> children = DomUtils.getChildElements(objectMarshallingStrategiesElement);
            ManagedList managedCustomList = new ManagedList();

            for (Element child : children) {
                String localName = child.getLocalName();
                marshallerOrderList.add(localName);

                if (ELEMENT_SERIALIZABLE_PLACEHOLDER_RESOLVER_STRATEGY.equalsIgnoreCase(localName)) {
                    parsePlaceholderResolverStrategyElement(parserContext, factory, child, PROPERTY_SERIALIZABLE_PLACEHOLDER_RESOLVER_STRATEGY_ACCEPTOR);
                } else if (ELEMENT_IDENTITY_PLACEHOLDER_RESOLVER_STRATEGY.equalsIgnoreCase(localName)) {
                    parsePlaceholderResolverStrategyElement(parserContext, factory, child, PROPERTY_IDENTITY_PLACEHOLDER_RESOLVER_STRATEGY_ACCEPTOR);
                } else if (ELEMENT_PROCESS_INSTANCE_RESOLVER_STRATEGY.equalsIgnoreCase(localName)) {
                    //do nothing, the bean will be created in the EnvDefBeanFactory
                } else if (ELEMENT_JPA_PLACEHOLDER_RESOLVER_STRATEGY.equalsIgnoreCase(localName)) {
                    String envRef = child.getAttribute(ATTRIBUTE_ENV_REF);
                    if (StringUtils.hasText(envRef)) {
                        factory.addPropertyValue(PROPERTY_JPA_PLACE_HOLDER_RESOLVER_STRATEGY_ENV, new RuntimeBeanReference(envRef));
                    }
                } else if (ELEMENT_CUSTOM_MARSHALLING_STRATEGY.equalsIgnoreCase(localName)) {
                    String ref = child.getAttribute(ATTRIBUTE_REF);
                    if (StringUtils.hasText(ref)) {
                        managedCustomList.add(new RuntimeBeanReference(ref));
                    } else {
                        Element nestedBean = DomUtils.getChildElementByTagName(child, ELEMENT_BEAN);
                        if (nestedBean != null) {
                            Object obj = parserContext.getDelegate().parsePropertySubElement(nestedBean, null, null);
                            managedCustomList.add(obj);
                        } else {
                            throw new IllegalArgumentException(ELEMENT_CUSTOM_MARSHALLING_STRATEGY + " must have either a " + ATTRIBUTE_REF + " attribute or an embedded " + ELEMENT_BEAN + " child element!");
                        }
                    }
                }
View Full Code Here

        for (Element listener : eventListeners) {
            String ref = listener.getAttribute("ref");
            // if this a bean ref
            if (StringUtils.hasText(ref)) {
                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(ref));
                } 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 DebugRuleRuntimeEventListener();
                    } else {
                        throw new IllegalArgumentException("eventListener must be of type 'agenda-event-listener or 'process-event-listener' or 'working-memory-event-listener'.");
                    }
                    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

        if (rank != null && rank.length() > 0) {
            builder.addPropertyValue("rank", Integer.parseInt(rank));
        }
        List childElements = DomUtils.getChildElementsByTagName(element, "module");
        if (childElements != null && childElements.size() > 0) {
            ManagedList children = new ManagedList(childElements.size());
            for (int i = 0; i < childElements.size(); ++i) {
                Element childElement = (Element) childElements.get(i);
                BeanDefinitionBuilder bd = BeanDefinitionBuilder.genericBeanDefinition(Module.class);
                bd.addPropertyValue("className", childElement.getAttribute("className"));
                if (childElement.getAttribute("flags") != null) {
                    bd.addPropertyValue("flags", childElement.getAttribute("flags"));
                }
                String options = DomUtils.getTextValue(childElement);
                if (options != null && options.length() > 0) {
                    Properties props = new Properties();
                    try {
                        props.load(new ByteArrayInputStream(options.getBytes()));
                    } catch (IOException e) {
                        throw new IllegalStateException("Can not load options for JAAS module "
                                        + childElement.getAttribute("className") + " in config " + name);
                    }
                    bd.addPropertyValue("options", props);
                }
                children.add(bd.getBeanDefinition());
            }
            builder.addPropertyValue("modules", children);
        }
        // Publish to OSGi
        String publish = element.getAttribute("publish");
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  public void addPropertyValue(String propertyName, Object propertyValue) {

    ManagedList lstPrp = null;

    PropertyValue pv = super.getPropertyValue(propertyName);

    if (pv instanceof Mergeable) {
      lstPrp = (ManagedList) pv.getValue();
    } else if (pv != null) {
        lstPrp = new ManagedList();
         lstPrp.add(pv.getValue());
    }
   
    if (lstPrp != null) {
      lstPrp.add(propertyValue);
    }

    super.addPropertyValue(propertyName, (lstPrp != null ? lstPrp : propertyValue));
  }
View Full Code Here

                element.getAttribute("custom-evaluator"));
            objectFactoryBeanDefinition2.getPropertyValues().addPropertyValue("expression",
                element.getAttribute("expression"));
            objectFactoryBeanDefinition.getPropertyValues().addPropertyValue("expressionConfig",
                objectFactoryBeanDefinition2);
            ManagedList list = new ManagedList<ExpressionArgument>(1);
            list.add(objectFactoryBeanDefinition2);
            builder.getBeanDefinition().getPropertyValues().addPropertyValue("arguments",
                objectFactoryBeanDefinition);
        }
    }
View Full Code Here

                        // a collection of maps requires an extra intermediate object that does the
                        // lazy combination/caching of maps when first used
                        BeanDefinitionBuilder combiner = BeanDefinitionBuilder.rootBeanDefinition(MapCombiner.class);
                        targetProperties.addPropertyValue(newName, combiner.getBeanDefinition());
                        MutablePropertyValues combinerProperties = combiner.getBeanDefinition().getPropertyValues();
                        oldValue = new ManagedList();
                        pv = new PropertyValue(MapCombiner.LIST, oldValue);
                        combinerProperties.addPropertyValue(pv);
                    }
                    else
                    {
                        oldValue = new ManagedList();
                        pv = new PropertyValue(newName, oldValue);
                        targetProperties.addPropertyValue(pv);
                    }
                }
View Full Code Here

        {
            if (targetConfig.isCollection(propertyName))
            {
                if (null == oldValue)
                {
                    oldValue = new ManagedList();
                    pv = new PropertyValue(newName, oldValue);
                    targetProperties.addPropertyValue(pv);
                }

                List list = retrieveList(oldValue);
View Full Code Here

                oldValue = properties.getPropertyValue(name).getValue();
            }
            // merge collections
            if (config.isCollection() || oldValue instanceof Collection || value instanceof Collection)
            {
                Collection values = new ManagedList();
                if (null != oldValue)
                {
                    properties.removePropertyValue(name);
                    if (oldValue instanceof Collection)
                    {
                        values.addAll((Collection) oldValue);
                    }
                    else
                    {
                        values.add(oldValue);
                    }
                }
                if (value instanceof Collection)
                {
                    values.addAll((Collection) value);
                }
                else
                {
                    values.add(value);
                }
                properties.addPropertyValue(name, values);
            }
            else
            {
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.