List of usage examples for org.springframework.beans.factory.support ManagedList ManagedList
public ManagedList()
From source file:com.clican.pluto.dataprocess.spring.parser.TimerProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { String cronExpression = element.getAttribute("cronExpression"); String startTime = element.getAttribute("startTime"); String endTime = element.getAttribute("endTime"); String taskScheduler = element.getAttribute("taskScheduler"); String concurrent = element.getAttribute("concurrent"); if (StringUtils.isEmpty(taskScheduler)) { taskScheduler = "taskScheduler"; }// www. ja v a 2 s . co m String stepCommit = element.getAttribute("stepCommit"); if (StringUtils.isNotEmpty(stepCommit)) { beanDef.getPropertyValues().addPropertyValue("stepCommit", Boolean.parseBoolean(stepCommit)); } beanDef.getPropertyValues().addPropertyValue("cronExpression", cronExpression); beanDef.getPropertyValues().addPropertyValue("startTime", startTime); beanDef.getPropertyValues().addPropertyValue("endTime", endTime); beanDef.getPropertyValues().addPropertyValue("taskScheduler", new RuntimeBeanReference(taskScheduler)); if (StringUtils.isNotEmpty(concurrent)) { beanDef.getPropertyValues().addPropertyValue("concurrent", Boolean.parseBoolean(concurrent)); } String[] timerProcessors = element.getAttribute("timerProcessors").split(","); List partitionProcessorList = new ManagedList(); for (String timerProcessor : timerProcessors) { partitionProcessorList.add(new RuntimeBeanReference(timerProcessor.trim())); } beanDef.getPropertyValues().addPropertyValue("timerProcessors", partitionProcessorList); }
From source file:fr.acxio.tools.agia.alfresco.configuration.FolderDefinitionParser.java
protected AbstractBeanDefinition parseFolderElement(Element sElement, ParserContext sParserContext, BeanDefinitionBuilder sBuilder) { ManagedList<BeanDefinition> aChildren = new ManagedList<BeanDefinition>(); ManagedList<BeanDefinition> aDocuments = new ManagedList<BeanDefinition>(); sBuilder.addPropertyValue("parent", parseFolder(sElement)); NodeList children = sElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node instanceof Element) { String nodeName = node.getLocalName(); Element child = (Element) node; if (nodeName.equals(NODEDEF_PROPERTIES)) { sBuilder.addPropertyValue("propertiesDefinitions", parseProperties(child, sParserContext)); } else if (nodeName.equals(NODEDEF_ASPECTS)) { sBuilder.addPropertyValue("aspectsDefinitions", parseAspects(child)); } else if (nodeName.equals(NODEDEF_ASSOCIATIONS)) { sBuilder.addPropertyValue("associationsDefinitions", parseAssociations(child)); } else if (nodeName.equals(NODEDEF_FOLDER)) { aChildren.add(parseFolderElement(child, sParserContext, BeanDefinitionBuilder.rootBeanDefinition(FolderDefinitionFactoryBean.class))); } else if (nodeName.equals(NODEDEF_DOCUMENT)) { DocumentDefinitionParser aDocumentDefinitionParser = new DocumentDefinitionParser(); aDocuments.add(aDocumentDefinitionParser.parse(child, sParserContext)); }/*from w ww.j a v a2 s .c om*/ } } sBuilder.addPropertyValue("children", aChildren); sBuilder.addPropertyValue("documents", aDocuments); return sBuilder.getBeanDefinition(); }
From source file:eap.config.AspectJAutoProxyBeanDefinitionParser.java
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) { ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node instanceof Element) { Element includeElement = (Element) node; TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name")); valueHolder.setSource(parserContext.extractSource(includeElement)); includePatterns.add(valueHolder); }//w w w . ja v a2 s . c o m } if (!includePatterns.isEmpty()) { includePatterns.setSource(parserContext.extractSource(element)); beanDef.getPropertyValues().add("includePatterns", includePatterns); } }
From source file:com.clican.pluto.dataprocess.spring.parser.JGroupPartitionProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { ((RootBeanDefinition) beanDef).setInitMethodName("init"); String partition = element.getAttribute("partition"); if (StringUtils.isEmpty(partition)) { partition = "partition"; }/*from w w w .j a va2 s. com*/ String partitionListName = element.getAttribute("partitionListName"); if (StringUtils.isNotEmpty(element.getAttribute("inputVarName"))) { String[] inputVarName = element.getAttribute("inputVarName").split(","); beanDef.getPropertyValues().addPropertyValue("inputVarName", inputVarName); } if (StringUtils.isNotEmpty(element.getAttribute("outputVarName"))) { String[] outputVarName = element.getAttribute("outputVarName").split(","); beanDef.getPropertyValues().addPropertyValue("outputVarName", outputVarName); } String serviceName = element.getAttribute("serviceName"); beanDef.getPropertyValues().addPropertyValue("partitionListName", partitionListName); beanDef.getPropertyValues().addPropertyValue("serviceName", serviceName); try { beanDef.getPropertyValues().addPropertyValue("partition", new RuntimeBeanReference(partition)); } catch (Throwable e) { } String[] partitionProcessors = element.getAttribute("partitionProcessors").split(","); List partitionProcessorList = new ManagedList(); for (String partitionProcessor : partitionProcessors) { partitionProcessorList.add(new RuntimeBeanReference(partitionProcessor.trim())); } beanDef.getPropertyValues().addPropertyValue("partitionProcessors", partitionProcessorList); }
From source file:org.carewebframework.shell.plugins.PluginXmlParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { builder.setInitMethodName("init"); builder.setDestroyMethodName("destroy"); builder.addDependsOn("pluginRegistry"); builder.addDependsOn("manifestIterator"); builder.addPropertyReference("pluginRegistry", "pluginRegistry"); builder.addPropertyValue("path", getResourcePath(parserContext)); addProperties(element, builder);// ww w. j a va2 s. c o m Element resourceTag = findTag("resource", element); if (resourceTag != null) { ManagedList<AbstractBeanDefinition> resourceList = new ManagedList<AbstractBeanDefinition>(); NodeList resources = getTagChildren("resource", element); for (int i = 0; i < resources.getLength(); i++) { parseResources((Element) resources.item(i), builder, resourceList); } builder.addPropertyValue("resources", resourceList); } Element securityTag = findTag("security", element); if (securityTag != null) { addProperties(securityTag, builder); ManagedList<AbstractBeanDefinition> authorityList = new ManagedList<AbstractBeanDefinition>(); NodeList authorities = getTagChildren("security", element); for (int i = 0; i < authorities.getLength(); i++) { parseAuthorities((Element) authorities.item(i), builder, authorityList); } builder.addPropertyValue("authorities", authorityList); } Element serializationTag = findTag("serialization", element); if (serializationTag != null) { addProperties(serializationTag, builder); ManagedList<AbstractBeanDefinition> propertyList = new ManagedList<AbstractBeanDefinition>(); NodeList properties = getTagChildren("serialization", element); for (int i = 0; i < properties.getLength(); i++) { parseProperties((Element) properties.item(i), builder, propertyList); } builder.addPropertyValue("properties", propertyList); } }
From source file:org.smf4j.spring.RegistrarBeanDefinitionParser.java
protected ManagedList<RuntimeBeanReference> parseChildren(ParserContext context, Element element) { ManagedList<RuntimeBeanReference> nodes = new ManagedList<RuntimeBeanReference>(); RegistryNodeTemplateDefinitionParser p = new RegistryNodeTemplateDefinitionParser(false); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); if (childNode.getNodeType() != Node.ELEMENT_NODE) { continue; }// ww w . j av a2s . c o m Element child = (Element) childNode; String childTagName = child.getLocalName(); String childBeanId = null; if (NODE_TAG.equals(childTagName)) { BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(RegistryNodeProxy.class); childBeanId = p.parseNode(context, child, bdb); } else if (NODE_TEMPLATE_TAG.equals(NODE_TEMPLATE_TAG)) { childBeanId = p.createNodeTemplateRef(context, child); } else { context.getReaderContext().error("Unknown tag", child); } if (childBeanId != null) { nodes.add(new RuntimeBeanReference(childBeanId)); } } return nodes; }
From source file:nats.client.spring.config.NatsBeanDefinitionParser.java
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(NatsFactoryBean.class); // Parse list of hosts final List<String> uris = new ManagedList<>(); final List<Element> hosts = DomUtils.getChildElementsByTagName(element, ELEMENT_URL); for (Element host : hosts) { uris.add(host.getTextContent()); }/*from w ww . j a va 2 s. co m*/ builder.addPropertyValue("hostUris", uris); // Parse list of subscriptions final List<BeanDefinition> subscriptions = new ManagedList<>(); final List<Element> subscriptionElements = DomUtils.getChildElementsByTagName(element, ELEMENT_SUBSCRIPTION); for (Element subscriptionElement : subscriptionElements) { final BeanDefinitionBuilder subscriptionBuilder = BeanDefinitionBuilder .genericBeanDefinition(SubscriptionConfig.class); subscriptionBuilder.addConstructorArgValue(subscriptionElement.getAttribute(ATTRIBUTE_SUBJECT)); subscriptionBuilder.addConstructorArgReference(subscriptionElement.getAttribute(ATTRIBUTE_REF)); subscriptionBuilder.addConstructorArgValue(subscriptionElement.getAttribute(ATTRIBUTE_METHOD)); subscriptionBuilder.addConstructorArgValue(subscriptionElement.getAttribute(ATTRIBUTE_QUEUE_GROUP)); subscriptions.add(subscriptionBuilder.getBeanDefinition()); } builder.addPropertyValue("subscriptions", subscriptions); // Parse attributes builder.addPropertyValue("autoReconnect", element.getAttribute(ATTRIBUTE_AUTO_RECONNECT)); builder.addPropertyValue("reconnectWaitTime", element.getAttribute(ATTRIBUTE_RECONNECT_WAIT_TIME)); final String eventLoopGroupRef = element.getAttribute(ATTRIBUTE_EVENT_LOOP_GROUP_REF); if (StringUtils.hasText(eventLoopGroupRef)) { builder.addPropertyReference("eventLoopGroup", eventLoopGroupRef); } final String callbackExecutorRef = element.getAttribute(ATTRIBUTE_CALLBACK_EXECUTOR_REF); if (StringUtils.hasText(callbackExecutorRef)) { builder.addPropertyReference("callbackExecutor", callbackExecutorRef); } final String connectionStateListenerRef = element.getAttribute(ATTRIBUTE_CONNECTION_STATE_LISTENER_REF); if (StringUtils.hasText(connectionStateListenerRef)) { builder.addPropertyReference("connectionStateListener", connectionStateListenerRef); } // Register bean final String id = element.getAttribute(ATTRIBUTE_ID); final AbstractBeanDefinition beanDefinition = builder.getBeanDefinition(); parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); return beanDefinition; }
From source file:com.clican.pluto.fsm.spring.parser.AbstractStateParser.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionRegistry bdr = parserContext.getRegistry(); RootBeanDefinition beanDef = new RootBeanDefinition(); beanDef.setDestroyMethodName("destroy"); beanDef.setAbstract(false);//w w w.j av a 2 s. c om beanDef.setBeanClass(getStateClass(element)); beanDef.setLazyInit(false); beanDef.setAutowireMode(Autowire.BY_NAME.value()); String name = element.getAttribute("name"); if (bdr.containsBeanDefinition(name)) { throw new RuntimeException("name[" + name + "]is defined duplicated"); } bdr.registerBeanDefinition(name, beanDef); beanDef.getPropertyValues().addPropertyValue("name", name); String value = element.getAttribute("value"); beanDef.getPropertyValues().addPropertyValue("value", value); String propagation = element.getAttribute("propagation"); beanDef.getPropertyValues().addPropertyValue("propagation", propagation); String nextStates = element.getAttribute("nextStates"); if (StringUtils.isNotEmpty(nextStates)) { List nextStateList = new ManagedList(); for (String nextState : nextStates.split(",")) { nextStateList.add(new RuntimeBeanReference(nextState.trim())); } beanDef.getPropertyValues().addPropertyValue("nextStates", nextStateList); } String previousStates = element.getAttribute("previousStates"); if (StringUtils.isNotEmpty(previousStates)) { List previousStateList = new ManagedList(); for (String previousState : previousStates.split(",")) { previousStateList.add(new RuntimeBeanReference(previousState.trim())); } beanDef.getPropertyValues().addPropertyValue("previousStates", previousStateList); } NodeList nodeList = element.getChildNodes(); Map nextCondStates = new ManagedMap(); Map params = new ManagedMap(); List stateListeners = new ManagedList(); List taskListeners = new ManagedList(); Map timeoutListeners = new ManagedMap(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String localName = node.getLocalName(); Element e = (Element) node; if ("nextCondStates".equals(localName)) { String expr = e.getAttribute("expr"); nextStates = e.getAttribute("nextStates"); List nextStateList = new ManagedList(); if (StringUtils.isNotEmpty(nextStates)) { for (String nextState : nextStates.split(",")) { nextStateList.add(new RuntimeBeanReference(nextState.trim())); } } nextCondStates.put(expr, nextStateList); } else if ("param".equals(localName)) { String paramName = e.getAttribute("name"); String paramValue = e.getAttribute("value"); params.put(paramName, paramValue); } else if ("stateListener".equals(localName) || "timeoutListener".equals(localName) || "taskListener".equals(localName)) { String clazz = e.getAttribute("clazz"); String listener = e.getAttribute("listener"); Object obj; if (StringUtils.isNotEmpty(clazz)) { try { RootBeanDefinition bean = new RootBeanDefinition(); bean.setAbstract(false); bean.setBeanClass(Class.forName(clazz)); bean.setLazyInit(false); bean.setAutowireMode(Autowire.BY_NAME.value()); if ("timeoutListener".equals(localName)) { String timeoutName = e.getAttribute("name"); String startTime = e.getAttribute("startTime"); String dueTime = e.getAttribute("dueTime"); String repeatTime = e.getAttribute("repeatTime"); String repeatDuration = e.getAttribute("repeatDuration"); String businessCalendarName = e.getAttribute("businessCalendarName"); bean.getPropertyValues().addPropertyValue("name", timeoutName); bean.getPropertyValues().addPropertyValue("startTime", startTime); bean.getPropertyValues().addPropertyValue("dueTime", dueTime); bean.getPropertyValues().addPropertyValue("repeatTime", repeatTime); bean.getPropertyValues().addPropertyValue("repeatDuration", repeatDuration); bean.getPropertyValues().addPropertyValue("businessCalendarName", businessCalendarName); } NodeList nodeList2 = element.getChildNodes(); Map params2 = new ManagedMap(); for (int j = 0; j < nodeList2.getLength(); j++) { Node node2 = nodeList2.item(j); if (node2.getNodeType() == Node.ELEMENT_NODE) { String localName2 = node2.getLocalName(); if ("param".equals(localName2)) { String paramName = ((Element) node2).getAttribute("name"); String paramValue = ((Element) node2).getAttribute("value"); params2.put(paramName, paramValue); } } } obj = bean; } catch (Exception ex) { throw new RuntimeException(ex); } } else if (StringUtils.isNotEmpty(listener)) { obj = new RuntimeBeanReference(listener.trim()); } else { throw new RuntimeException("There must be clazz or listener parameter setting"); } if ("stateListener".equals(localName)) { stateListeners.add(obj); } else if ("taskListeners".equals(localName)) { taskListeners.add(obj); } else { String timeoutName = e.getAttribute("name"); timeoutListeners.put(timeoutName, obj); } } } } beanDef.getPropertyValues().addPropertyValue("nextCondStates", nextCondStates); beanDef.getPropertyValues().addPropertyValue("params", params); beanDef.getPropertyValues().addPropertyValue("stateListeners", stateListeners); if (element.getNodeName().equals("task")) { beanDef.getPropertyValues().addPropertyValue("taskListeners", taskListeners); } beanDef.getPropertyValues().addPropertyValue("timeoutListeners", timeoutListeners); customiseBeanDefinition(beanDef, element, parserContext); return beanDef; }
From source file:de.itsvs.cwtrpc.controller.config.CacheControlConfigBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { final ManagedList<AbstractBeanDefinition> uriConfigs; update(element, builder, XmlNames.LOWER_CASE_MATCH_ATTR, "lowerCaseMatch"); update(element, builder, XmlNames.DEFAULTS_ENABLED_ATTR, "defaultsEnabled"); update(element, builder, XmlNames.CACHE_MAX_AGE_ATTR, "cacheMaxAge"); uriConfigs = new ManagedList<AbstractBeanDefinition>(); for (Element child : DomUtils.getChildElementsByTagName(element, XmlNames.URI_ELEMENT)) { uriConfigs.add(createUriConfigBeanDefinition(child, parserContext)); }/*from w w w .ja v a 2 s . com*/ if (!uriConfigs.isEmpty()) { builder.addPropertyValue("uriConfigs", uriConfigs); } }
From source file:jeeves.server.overrides.AddPropertyUpdater.java
@SuppressWarnings("unchecked") @Override//from w w w . j av a 2s .c o m protected void doUpdate(ConfigurableListableBeanFactory beanFactory, BeanDefinition bean, Object value) { Log.debug(Log.JEEVES, "Adding new value " + value + " to property: " + propertyName + " on " + beanName); PropertyValue propertyValue = bean.getPropertyValues().getPropertyValue(propertyName); if (propertyValue == null) { final String beanClassName = bean.getBeanClassName(); try { final Class<?> aClass = Class.forName(beanClassName); final PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(aClass); for (PropertyDescriptor descriptor : propertyDescriptors) { if (propertyName.equals(descriptor.getName())) { final Class<?> collectionType = descriptor.getWriteMethod().getParameterTypes()[0]; if (List.class.isAssignableFrom(collectionType)) { propertyValue = new PropertyValue(propertyName, new ManagedList<Object>()); } else if (Set.class.isAssignableFrom(collectionType)) { propertyValue = new PropertyValue(propertyName, new ManagedSet<Object>()); } else if (Map.class.isAssignableFrom(collectionType)) { propertyValue = new PropertyValue(propertyName, new ManagedMap<Object, Object>()); } else if (Properties.class.isAssignableFrom(collectionType)) { propertyValue = new PropertyValue(propertyName, new ManagedProperties()); } else if (Array.class.isAssignableFrom(collectionType)) { throw new IllegalArgumentException("Array collections not currently supported"); } else if (Collection.class.isAssignableFrom(collectionType)) { propertyValue = new PropertyValue(propertyName, new ManagedList<Object>()); } else { throw new IllegalArgumentException( collectionType + " is not a supported type for adding new values"); } break; } } if (propertyValue == null) { throw new IllegalArgumentException("Unable to find the collection type for property: " + propertyName + " on bean " + beanName); } bean.getPropertyValues().addPropertyValue(propertyValue); } catch (ClassNotFoundException e) { throw new AssertionError(e); } } Object originalValue = propertyValue.getValue(); if (originalValue instanceof Collection) { Collection<Object> coll = (Collection<Object>) originalValue; coll.add(value); } else { throw new IllegalArgumentException(originalValue + " is not a collection as expected"); } }