List of usage examples for org.springframework.beans.factory.support ManagedList ManagedList
public ManagedList(int initialCapacity)
From source file:com.dangdang.ddframe.job.spring.namespace.parser.common.AbstractJobBeanDefinitionParser.java
private List<BeanDefinition> createJobListeners(final Element element) { List<Element> listenerElements = DomUtils.getChildElementsByTagName(element, LISTENER_TAG); List<BeanDefinition> result = new ManagedList<>(listenerElements.size()); for (Element each : listenerElements) { String className = each.getAttribute(CLASS_ATTRIBUTE); BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(className); factory.setScope(BeanDefinition.SCOPE_PROTOTYPE); try {/*from w ww . j a va 2 s. c o m*/ Class listenerClass = Class.forName(className); if (AbstractDistributeOnceElasticJobListener.class.isAssignableFrom(listenerClass)) { factory.addConstructorArgValue(each.getAttribute(STARTED_TIMEOUT_MILLISECONDS_ATTRIBUTE)); factory.addConstructorArgValue(each.getAttribute(COMPLETED_TIMEOUT_MILLISECONDS_ATTRIBUTE)); } } catch (final ClassNotFoundException ex) { throw new RuntimeException(ex); } result.add(factory.getBeanDefinition()); } return result; }
From source file:org.springframework.cloud.aws.messaging.listener.QueueMessageHandlerTest.java
private AbstractBeanDefinition getQueueMessageHandlerBeanDefinition() { BeanDefinitionBuilder queueMessageHandlerBeanDefinitionBuilder = BeanDefinitionBuilder .rootBeanDefinition(QueueMessageHandler.class); ManagedList<HandlerMethodReturnValueHandler> returnValueHandlers = new ManagedList<>(1); returnValueHandlers.add(new SendToHandlerMethodReturnValueHandler(this.messageTemplate)); queueMessageHandlerBeanDefinitionBuilder.addPropertyValue("returnValueHandlers", returnValueHandlers); return queueMessageHandlerBeanDefinitionBuilder.getBeanDefinition(); }
From source file:com.dangdang.ddframe.rdb.sharding.spring.namespace.parser.ShardingJdbcDataSourceBeanDefinitionParser.java
private List<BeanDefinition> parseBindingTablesConfig(final Element element) { Element bindingTableRulesElement = DomUtils.getChildElementByTagName(element, ShardingJdbcDataSourceBeanDefinitionParserTag.BINDING_TABLE_RULES_TAG); if (null == bindingTableRulesElement) { return Collections.emptyList(); }//from w w w. j a v a 2 s . co m List<Element> bindingTableRuleElements = DomUtils.getChildElementsByTagName(bindingTableRulesElement, ShardingJdbcDataSourceBeanDefinitionParserTag.BINDING_TABLE_RULE_TAG); BeanDefinitionBuilder bindingTableRuleFactory = BeanDefinitionBuilder .rootBeanDefinition(BindingTableRuleConfig.class); List<BeanDefinition> result = new ManagedList<>(bindingTableRuleElements.size()); for (Element bindingTableRuleElement : bindingTableRuleElements) { bindingTableRuleFactory.addPropertyValue("tableNames", bindingTableRuleElement .getAttribute(ShardingJdbcDataSourceBeanDefinitionParserTag.LOGIC_TABLES_ATTRIBUTE)); result.add(bindingTableRuleFactory.getBeanDefinition()); } return result; }
From source file:ch.simuonline.idh.attribute.resolver.spring.dc.aq.impl.AttributeQueryDataConnectorParser.java
/** {@inheritDoc} */ @Override/*from w ww . j a v a 2 s .c om*/ protected void doV2Parse(@Nonnull final Element config, @Nonnull final ParserContext parserContext, @Nonnull final BeanDefinitionBuilder builder) { log.debug("{} Parsing v2 configuration {}", getLogPrefix(), config); final String targetResolvingStrategy = AttributeSupport.getAttributeValue(config, new QName("targetDeterminationStrategy")); Constraint.isNotNull(StringSupport.trimOrNull(targetResolvingStrategy), "The targetDeterminationStrategy can not be null or empty, please adjust entityID from the AQ DataConnector"); if (targetResolvingStrategy.equals("mysql")) { // Constructor is MySQLTargetResolvingStrategy(String url, String username, String password), adding arguments in this order: final BeanDefinitionBuilder mysqlTargetResolvingStrategy = BeanDefinitionBuilder .genericBeanDefinition(MySQLTargetDeterminationStrategy.class); final String dbURL = AttributeSupport.getAttributeValue(config, new QName("dbURL")); Constraint.isNotNull(StringSupport.trimOrNull(dbURL), "The dbURL attribute is required if the targetResolvingStrategy is mysql, please adjust entityID from the AQ DataConnector"); mysqlTargetResolvingStrategy.addConstructorArgValue(dbURL); final String dbUsername = AttributeSupport.getAttributeValue(config, new QName("dbUsername")); Constraint.isNotNull(StringSupport.trimOrNull(dbUsername), "The dbUsername attribute is required if the targetResolvingStrategy is mysql, please adjust entityID from the AQ DataConnector"); mysqlTargetResolvingStrategy.addConstructorArgValue(dbUsername); final String dbPassword = AttributeSupport.getAttributeValue(config, new QName("dbPassword")); Constraint.isNotNull(StringSupport.trimOrNull(dbPassword), "The dbPassword attribute is required if the targetResolvingStrategy is mysql, please adjust entityID from the AQ DataConnector"); mysqlTargetResolvingStrategy.addConstructorArgValue(dbPassword); builder.addPropertyValue("targetResolvingStrategy", mysqlTargetResolvingStrategy.getBeanDefinition()); } else if (targetResolvingStrategy.equals("ldap")) { final BeanDefinitionBuilder ldapTargetResolvingStrategy = BeanDefinitionBuilder .genericBeanDefinition(LDAPTargetDeterminationStrategy.class); final String sourceAttributeID = AttributeSupport.getAttributeValue(config, new QName("sourceAttributeID")); Constraint.isNotNull(StringSupport.trimOrNull(sourceAttributeID), "The sourceAttributeID attribute is required if the targetResolvingStrategy is ldap, please adjust entityID from the AQ DataConnector"); ldapTargetResolvingStrategy.addConstructorArgValue(sourceAttributeID); final List<Element> dependencyElements = ElementSupport.getChildElements(config, ResolverPluginDependencyParser.ELEMENT_NAME); ldapTargetResolvingStrategy.addPropertyValue("dependencies", SpringSupport.parseCustomElements(dependencyElements, parserContext)); final String connectorID = AttributeSupport.getAttributeValue(config, new QName("id")); Constraint.isNotNull(StringSupport.trimOrNull(sourceAttributeID), "The connectorID can not be empty, please adjust it for the AQ DataConnector"); ldapTargetResolvingStrategy.addConstructorArgValue(connectorID); builder.addPropertyValue("targetResolvingStrategy", ldapTargetResolvingStrategy.getBeanDefinition()); } else { log.error("{} Unsupported targetResolvingStrategy: {}. Change it to mysql or ldap! ", getLogPrefix(), targetResolvingStrategy); } final BeanDefinitionBuilder attributeQueryBuilder = BeanDefinitionBuilder .genericBeanDefinition(AttributeQueryBuilder.class); // Parse value of the entityID attribute final String issuer = AttributeSupport.getAttributeValue(config, new QName("entityID")); Constraint.isNotNull(StringSupport.trimOrNull(issuer), "The entityID of the Issuer can not be empty, please adjust entityID from the AQ DataConnector"); attributeQueryBuilder.addConstructorArgValue(issuer); // parsing of the defined AQAttributes for the attribute query final List<Element> children = ElementSupport.getChildElements(config, ATTRIBUTE_ELEMENT_NAME); final List<BeanDefinition> attributes = new ManagedList<>(children.size()); for (final Element child : children) { final String name = AttributeSupport.getAttributeValue(child, new QName("name")); final String friendlyName = AttributeSupport.getAttributeValue(child, new QName("friendlyName")); final BeanDefinitionBuilder attribute = BeanDefinitionBuilder.genericBeanDefinition(AQAttribute.class); attribute.addConstructorArgValue(name); attribute.addConstructorArgValue(friendlyName); log.debug("{} Added one AQAttribute to the resolving List. Friendly Name {}, Name {}", getLogPrefix(), friendlyName, name); attributes.add(attribute.getBeanDefinition()); } attributeQueryBuilder.addConstructorArgValue(attributes); builder.addPropertyValue("attributeQueryBuilder", attributeQueryBuilder.getBeanDefinition()); final BeanDefinitionBuilder keyManager = BeanDefinitionBuilder .genericBeanDefinition(AttributeQueryKeyManager.class); // parse the keyLocaton attribute from the AQ DataCOnnector final String keyLocation = AttributeSupport.getAttributeValue(config, new QName("keyLocation")); Constraint.isNotNull(StringSupport.trimOrNull(keyLocation), "Key location can not be empty, please adjust keyLocation from the AQ DataConnector"); // parse the certLocaton attribute from the AQ DataCOnnector final String certLocation = AttributeSupport.getAttributeValue(config, new QName("certLocation")); Constraint.isNotNull(StringSupport.trimOrNull(certLocation), "Certificate location can not be empty, please adjust certLocation from the AQ DataConnector"); keyManager.addConstructorArgValue(getPrivateKey(keyLocation)); keyManager.addConstructorArgValue(getCertificate(certLocation)); builder.addPropertyValue("attributeQueryKeyManager", keyManager.getBeanDefinition()); // if the asertionSigned attribute is true, set the value to true final String signatureRequired = AttributeSupport.getAttributeValue(config, new QName("assertionSigned")); if (signatureRequired != null && signatureRequired.equals("true")) { builder.addPropertyValue("signatureRequired", Boolean.TRUE); } // if the requestedAttributesRequired attribute is true, set the value to true final String requireMetadataAttributes = AttributeSupport.getAttributeValue(config, new QName("requestedAttributesRequired")); if (requireMetadataAttributes != null && requireMetadataAttributes.equals("true")) { builder.addPropertyValue("requireMetadataAttributes", Boolean.TRUE); } builder.setInitMethodName("initialize"); builder.setDestroyMethodName("destroy"); }
From source file:com.dangdang.ddframe.job.lite.spring.namespace.parser.common.AbstractJobBeanDefinitionParser.java
private List<BeanDefinition> createJobListeners(final Element element) { Element listenerElement = DomUtils.getChildElementByTagName(element, LISTENER_TAG); Element distributedListenerElement = DomUtils.getChildElementByTagName(element, DISTRIBUTED_LISTENER_TAG); List<BeanDefinition> result = new ManagedList<>(2); if (null != listenerElement) { BeanDefinitionBuilder factory = BeanDefinitionBuilder .rootBeanDefinition(listenerElement.getAttribute(CLASS_ATTRIBUTE)); factory.setScope(BeanDefinition.SCOPE_PROTOTYPE); result.add(factory.getBeanDefinition()); }//from www. ja v a2s .co m if (null != distributedListenerElement) { BeanDefinitionBuilder factory = BeanDefinitionBuilder .rootBeanDefinition(distributedListenerElement.getAttribute(CLASS_ATTRIBUTE)); factory.setScope(BeanDefinition.SCOPE_PROTOTYPE); factory.addConstructorArgValue(distributedListenerElement .getAttribute(DISTRIBUTED_LISTENER_STARTED_TIMEOUT_MILLISECONDS_ATTRIBUTE)); factory.addConstructorArgValue(distributedListenerElement .getAttribute(DISTRIBUTED_LISTENER_COMPLETED_TIMEOUT_MILLISECONDS_ATTRIBUTE)); result.add(factory.getBeanDefinition()); } return result; }
From source file:edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils.java
/** * Parse list of elements into bean definitions. * /*from w w w . j a va 2 s .c om*/ * @param elements list of elements to parse * @param idAttribute attribute that carries the unique ID for the bean * @param parserContext current parsing context * * @return list of bean references */ public static ManagedList parseCustomElements(List<Element> elements, String idAttribute, ParserContext parserContext) { if (elements == null) { return null; } ManagedList definitions = new ManagedList(elements.size()); for (Element e : elements) { definitions.add(parseCustomElement(e, idAttribute, parserContext)); } return definitions; }
From source file:it.pronetics.madstore.common.configuration.spring.MadStoreConfigurationBeanDefinitionParser.java
@SuppressWarnings("unchecked") private void parseCrawlerConfigurations(Element element, BeanDefinitionBuilder factory) { List<Element> targetSites = DomUtils.getChildElementsByTagName(element, TARGET_SITE); List<CrawlerConfiguration> crawlerConfigurations = new ManagedList(targetSites.size()); for (Element targetSiteEle : targetSites) { String hostName = DomUtils.getChildElementByTagName(targetSiteEle, HOST_NAME).getTextContent(); String startLink = DomUtils.getChildElementByTagName(targetSiteEle, START_LINK).getTextContent(); String maxConcurrentDownloads = DomUtils .getChildElementByTagName(targetSiteEle, MAX_CONCURRENT_DOWNLOADS).getTextContent(); String maxVisitedLinks = DomUtils.getChildElementByTagName(targetSiteEle, MAX_VISITED_LINKS) .getTextContent();// w ww . j a v a 2s. c o m CrawlerConfiguration crawlerConfiguration = new CrawlerConfiguration(); crawlerConfiguration.setHostName(hostName); crawlerConfiguration.setStartLink(startLink); crawlerConfiguration.setMaxConcurrentDownloads(new Integer(maxConcurrentDownloads).intValue()); crawlerConfiguration.setMaxVisitedLinks(new Integer(maxVisitedLinks).intValue()); crawlerConfigurations.add(crawlerConfiguration); } factory.addPropertyValue(CRAWLER_CONFIGURATIONS_BEAN_PROPERTY, crawlerConfigurations); }
From source file:org.jdal.beans.DefaultsBeanDefinitionParser.java
/** * Register default TablePanel Actions/*from w w w.ja v a 2 s . com*/ * @param element current element * @param parserContext parserContext * @return a new ComponentDefinition with default table action list. */ private ComponentDefinition registerDefaultTableActions(Element element, ParserContext parserContext) { ManagedList<Object> actions = new ManagedList<Object>(7); actions.add(createBeanDefinition(AddAction.class, parserContext)); actions.add(createBeanDefinition(SelectAllAction.class, parserContext)); actions.add(createBeanDefinition(DeselectAllAction.class, parserContext)); actions.add(createBeanDefinition(RemoveAllAction.class, parserContext)); actions.add(createBeanDefinition(HideShowFilterAction.class, parserContext)); actions.add(createBeanDefinition(ApplyFilterAction.class, parserContext)); actions.add(createBeanDefinition(ClearFilterAction.class, parserContext)); BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(ListFactoryBean.class); bdb.getRawBeanDefinition().setSource(parserContext.extractSource(element)); bdb.addPropertyValue("sourceList", actions); bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE); BeanComponentDefinition bcd = new BeanComponentDefinition(bdb.getBeanDefinition(), DEFAULT_TABLE_ACTIONS); registerBeanComponentDefinition(element, parserContext, bcd); return bcd; }
From source file:org.brekka.stillingar.spring.config.ConfigurationServiceBeanDefinitionParser.java
/** * @param element/* www. jav a 2s. c om*/ * @param builder */ protected void prepareJAXB(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { Element jaxbElement = selectSingleChildElement(element, "jaxb", false); // Path String contextPath = jaxbElement.getAttribute("context-path"); builder.addConstructorArgValue(contextPath); // Schemas List<Element> schemaElementList = selectChildElements(jaxbElement, "schema"); ManagedList<URL> schemaUrlList = new ManagedList<URL>(schemaElementList.size()); for (Element schemaElement : schemaElementList) { String schemaPath = schemaElement.getTextContent(); try { Resource resource = parserContext.getReaderContext().getResourceLoader().getResource(schemaPath); schemaUrlList.add(resource.getURL()); } catch (IOException e) { throw new ConfigurationException(String.format("Failed to parse schema location '%s'", schemaPath), e); } } builder.addConstructorArgValue(schemaUrlList); // Namespaces builder.addConstructorArgReference(this.namespacesId); // ConversionManager builder.addConstructorArgValue(prepareJAXBConversionManager()); }
From source file:it.pronetics.madstore.common.configuration.spring.MadStoreConfigurationBeanDefinitionParser.java
@SuppressWarnings("unchecked") private void parseIndexConfiguration(Element repositoryElement, BeanDefinitionBuilder beanDefinitionBuilder) { IndexConfiguration indexConfiguration = new IndexConfiguration(); Element indexConfigurationElement = DomUtils.getChildElementByTagName(repositoryElement, INDEX_CONFIGURATION_TAG);//from w w w . ja va 2s .com String madStoreDir = MadStoreConfigurationManager.getInstance().getMadStoreHome(); String indexDir = new StringBuilder(madStoreDir).append(SEPARATOR).append(DEFAULT_INDEX_FOLDER).toString(); indexConfiguration.setIndexDir(indexDir); List<Element> indexedPropertiesNamespacesElementList = DomUtils.getChildElementsByTagName( DomUtils.getChildElementByTagName(indexConfigurationElement, INDEXED_PROPERTIES_NAMESPACES), NAMESPACE); Map<String, String> indexedPropertiesNamespaces = new HashMap<String, String>(); for (Element namespaceElement : indexedPropertiesNamespacesElementList) { String name = namespaceElement.getAttribute(NAMESPACE_PREFIX); String xPath = namespaceElement.getAttribute(NAMESPACE_URL); indexedPropertiesNamespaces.put(name, xPath); } indexConfiguration.setIndexedPropertiesNamespaces(indexedPropertiesNamespaces); List<Element> indexedPropertiesElementList = DomUtils.getChildElementsByTagName( DomUtils.getChildElementByTagName(indexConfigurationElement, INDEXED_PROPERTIES), PROPERTY); List<Property> indexedProperties = new ManagedList(indexedPropertiesElementList.size()); for (Element propertyElement : indexedPropertiesElementList) { String name = propertyElement.getAttribute(PROPERTY_NAME); String xPath = DomUtils.getChildElementByTagName(propertyElement, XPATH).getTextContent(); int boost = Integer .valueOf((DomUtils.getChildElementByTagName(propertyElement, BOOST).getTextContent())); Property indexedProperty = indexConfiguration.new Property(name, xPath, boost); indexedProperties.add(indexedProperty); } indexConfiguration.setIndexedProperties(indexedProperties); beanDefinitionBuilder.addPropertyValue(INDEX_CONFIGURATION_BEAN_PROPERTY, indexConfiguration); }