List of usage examples for org.springframework.beans.factory.support BeanDefinitionBuilder addPropertyValue
public BeanDefinitionBuilder addPropertyValue(String name, @Nullable Object value)
From source file:org.apache.smscserver.config.spring.ListenerBeanDefinitionParser.java
/** * {@inheritDoc}/*from w w w . j a v a 2s . c o m*/ */ @Override protected void doParse(final Element element, final ParserContext parserContext, final BeanDefinitionBuilder builder) { BeanDefinitionBuilder factoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(ListenerFactory.class); if (StringUtils.hasText(element.getAttribute("port"))) { factoryBuilder.addPropertyValue("port", Integer.valueOf(element.getAttribute("port"))); } SslConfiguration ssl = this.parseSsl(element); if (ssl != null) { factoryBuilder.addPropertyValue("sslConfiguration", ssl); } if (StringUtils.hasText(element.getAttribute("idle-timeout"))) { factoryBuilder.addPropertyValue("idleTimeout", SpringUtil.parseInt(element, "idle-timeout", 300)); } String localAddress = SpringUtil.parseStringFromInetAddress(element, "local-address"); if (localAddress != null) { factoryBuilder.addPropertyValue("serverAddress", localAddress); } factoryBuilder.addPropertyValue("implicitSsl", SpringUtil.parseBoolean(element, "implicit-ssl", false)); Element blacklistElm = SpringUtil.getChildElement(element, SmscServerNamespaceHandler.SMSCSERVER_NS, "blacklist"); if (blacklistElm != null) { this.LOG.warn( "Element 'blacklist' is deprecated, and may be removed in a future release. Please use 'remote-ip-filter' instead. "); try { RemoteIpFilter remoteIpFilter = new RemoteIpFilter(IpFilterType.DENY, blacklistElm.getTextContent()); factoryBuilder.addPropertyValue("sessionFilter", remoteIpFilter); } catch (UnknownHostException e) { throw new IllegalArgumentException("Invalid IP address or subnet in the 'blacklist' element", e); } } Element remoteIpFilterElement = SpringUtil.getChildElement(element, SmscServerNamespaceHandler.SMSCSERVER_NS, "remote-ip-filter"); if (remoteIpFilterElement != null) { if (blacklistElm != null) { throw new SmscServerConfigurationException( "Element 'remote-ip-filter' may not be used when 'blacklist' element is specified. "); } String filterType = remoteIpFilterElement.getAttribute("type"); try { RemoteIpFilter remoteIpFilter = new RemoteIpFilter(IpFilterType.parse(filterType), remoteIpFilterElement.getTextContent()); factoryBuilder.addPropertyValue("sessionFilter", remoteIpFilter); } catch (UnknownHostException e) { throw new IllegalArgumentException( "Invalid IP address or subnet in the 'remote-ip-filter' element"); } } BeanDefinition factoryDefinition = factoryBuilder.getBeanDefinition(); String listenerFactoryName = parserContext.getReaderContext().generateBeanName(factoryDefinition); BeanDefinitionHolder factoryHolder = new BeanDefinitionHolder(factoryDefinition, listenerFactoryName); this.registerBeanDefinition(factoryHolder, parserContext.getRegistry()); // set the factory on the listener bean builder.getRawBeanDefinition().setFactoryBeanName(listenerFactoryName); builder.getRawBeanDefinition().setFactoryMethodName("createListener"); }
From source file:com.dangdang.ddframe.rdb.sharding.spring.namespace.parser.ShardingJdbcDataSourceBeanDefinitionParser.java
private void parseDefaultDataSource(final BeanDefinitionBuilder factory, final Element element) { String defaultDataSource = element .getAttribute(ShardingJdbcDataSourceBeanDefinitionParserTag.DEFAULT_DATA_SOURCE_TAG); if (!Strings.isNullOrEmpty(defaultDataSource)) { factory.addPropertyValue("defaultDataSourceName", defaultDataSource); }/*from w ww . j a va 2 s.c o m*/ }
From source file:biz.c24.io.spring.integration.config.MarshallingTransformerParser.java
@Override protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String sinkFactory = element.getAttribute("sink-factory"); Assert.hasText(sinkFactory, "the 'sink-factory' attribute is required"); builder.addPropertyReference("sinkFactory", sinkFactory); String outputType = element.getAttribute("output-type"); Assert.hasText(outputType, "the 'output-type' attribute is required"); builder.addPropertyValue("outputType", outputType); }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.attributeDefinition.MappedAttributeDefinitionBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { super.doParse(pluginId, pluginConfig, pluginConfigChildren, pluginBuilder, parserContext); List<ValueMap> valueMaps = processValueMaps(pluginId, pluginConfigChildren, pluginBuilder); pluginBuilder.addPropertyValue("valueMaps", valueMaps); if (pluginConfigChildren.containsKey(DEFAULT_VALUE_ELEMENT_NAME)) { Element defaultValueElem = pluginConfigChildren.get(DEFAULT_VALUE_ELEMENT_NAME).get(0); String defaultValue = DatatypeHelper.safeTrimOrNullString(defaultValueElem.getTextContent()); pluginBuilder.addPropertyValue("defaultValue", defaultValue); if (log.isDebugEnabled()) { log.debug("Attribute definition {} default value: {}", pluginId, defaultValue); }//from ww w .j a v a 2 s.c o m boolean passThru = false; if (defaultValueElem.hasAttributeNS(null, "passThru")) { passThru = XMLHelper .getAttributeValueAsBoolean(defaultValueElem.getAttributeNodeNS(null, "passThru")); } pluginBuilder.addPropertyValue("passThru", passThru); if (log.isDebugEnabled()) { log.debug("Attribute definition {} uses default value pass thru: {}", pluginId, passThru); } } }
From source file:org.smf4j.spring.ResolveBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext context, BeanDefinitionBuilder builder) { // The path path.to.node.accumulator to the accumulator we're looking // up.//from ww w. j a va 2 s. c o m String path = element.getAttribute(PATH_ATTR); if (!StringUtils.hasLength(path)) { context.getReaderContext().error("'resolve' elements must have a 'path' attribute.", element); } // Set the path builder.addPropertyValue(PATH_ATTR, path); // Make sure that spring knows we depend on the given beans, which are // probably <registrar> nodes. String dependsOn = element.getAttribute(DEPENDSON_ATTR); if (StringUtils.hasLength(dependsOn)) { for (String id : StringUtils.commaDelimitedListToSet(dependsOn)) { // Depend on the indicated registrar name builder.addDependsOn(id); } } else { // Depend on the default registrar name builder.addDependsOn(RegistrarBeanDefinitionParser.MASTER_REGISTRAR_ID); } }
From source file:com.joyveb.dbpimpl.cass.prepare.config.xml.CassandraClusterParser.java
@Override protected void postProcess(BeanDefinitionBuilder builder, Element element) { List<Element> subElements = DomUtils.getChildElements(element); // parse nested elements for (Element subElement : subElements) { String name = subElement.getLocalName(); if ("local-pooling-options".equals(name)) { builder.addPropertyValue("localPoolingOptions", parsePoolingOptions(subElement)); } else if ("remote-pooling-options".equals(name)) { builder.addPropertyValue("remotePoolingOptions", parsePoolingOptions(subElement)); } else if ("socket-options".equals(name)) { builder.addPropertyValue("socketOptions", parseSocketOptions(subElement)); }/*w ww. jav a2s .co m*/ } }
From source file:com.joyveb.dbpimpl.cass.prepare.config.xml.CassandraSessionParser.java
@Override protected void postProcess(BeanDefinitionBuilder builder, Element element) { List<Element> subElements = DomUtils.getChildElements(element); // parse nested elements for (Element subElement : subElements) { String name = subElement.getLocalName(); if ("keyspace-attributes".equals(name)) { builder.addPropertyValue("keyspaceAttributes", parseKeyspaceAttributes(subElement)); builder.addPropertyValue("tables", parseTablesAttributes(subElement)); }//from w w w . ja v a 2 s . c o m } }
From source file:fr.xebia.management.config.ManagedCachingConnectionFactoryDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder .rootBeanDefinition(ManagedCachingConnectionFactory.class); builder.setRole(BeanDefinition.ROLE_APPLICATION); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); builder.addPropertyReference("targetConnectionFactory", element.getAttribute(CONNECTION_FACTORY_ATTRIBUTE)); builder.addPropertyValue("cacheConsumers", element.getAttribute(CACHE_CONSUMERS_ATTRIBUTE)); builder.addPropertyValue("cacheProducers", element.getAttribute(CACHE_PRODUCERS_ATTRIBUTE)); builder.addPropertyValue("sessionCacheSize", element.getAttribute(SESSION_CACHE_SIZE_ATTRIBUTE)); builder.addPropertyValue("reconnectOnException", element.getAttribute(RECONNECT_ON_EXCEPTION)); return builder.getBeanDefinition(); }
From source file:org.opencredo.esper.integration.config.xml.EsperChannelThroughputMonitorParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String channelRef = element.getAttribute("channel-ref"); builder.addConstructorArgReference(channelRef); String sourceId = element.getAttribute("sourceId"); Assert.hasText(sourceId, "sourceId attribute is required"); builder.addConstructorArgValue(sourceId); String timeSample = element.getAttribute("time-sample"); builder.addPropertyValue("timeSample", timeSample); }
From source file:edu.internet2.middleware.shibboleth.common.config.security.StaticPKIXSignatureTrustEngineBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { log.info("Parsing configuration for {} trust engine with id: {}", XMLHelper.getXSIType(element).getLocalPart(), element.getAttributeNS(null, "id")); List<Element> childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "ValidationInfo"); builder.addPropertyValue("PKIXInfo", SpringConfigurationUtils.parseInnerCustomElements(childElems, parserContext)); childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "TrustedName"); HashSet<String> trustedNames = new HashSet<String>(childElems.size()); for (Element nameElem : childElems) { trustedNames.add(DatatypeHelper.safeTrimOrNullString(nameElem.getTextContent())); }//from ww w .j a va2 s . co m builder.addPropertyValue("trustedNames", trustedNames); childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "ValidationOptions"); if (childElems.size() > 0) { builder.addPropertyValue("PKIXValidationOptions", SpringConfigurationUtils.parseInnerCustomElement((Element) childElems.get(0), parserContext)); } }