Example usage for org.springframework.beans.factory.support BeanDefinitionBuilder addPropertyValue

List of usage examples for org.springframework.beans.factory.support BeanDefinitionBuilder addPropertyValue

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support BeanDefinitionBuilder addPropertyValue.

Prototype

public BeanDefinitionBuilder addPropertyValue(String name, @Nullable Object value) 

Source Link

Document

Add the supplied property value under the given property name.

Usage

From source file:edu.internet2.middleware.shibboleth.common.config.security.StaticExplicitKeySignatureTrustEngineBeanDefinitionParser.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, "Credential");
    builder.addPropertyValue("credentials",
            SpringConfigurationUtils.parseCustomElements(childElems, parserContext));
}

From source file:com.dinstone.jrpc.spring.EndpointBeanDefinitionParser.java

private BeanDefinition getConfigBeanDefinition(Element element, ParserContext parserContext,
        String configName) {/*  w w  w  . j av  a2 s.  c  om*/
    BeanDefinitionBuilder sbd = BeanDefinitionBuilder.genericBeanDefinition(ConfigBean.class);

    Element configElement = getChildElement(element, configName);
    if (configElement != null) {
        String schema = configElement.getAttribute("schema");
        sbd.addPropertyValue("schema", schema);
        String address = configElement.getAttribute("address");
        sbd.addPropertyValue("address", address);

        NodeList childNodeList = configElement.getChildNodes();
        Properties properties = new Properties();
        for (int i = 0; i < childNodeList.getLength(); i++) {
            Node childNode = childNodeList.item(i);
            if (childNode instanceof Element && nodeMatch(childNode, "property")) {
                Element pe = (Element) childNode;
                properties.put(pe.getAttribute("key"), pe.getAttribute("value"));
            }
        }
        sbd.addPropertyValue("properties", properties);
    }

    return sbd.getBeanDefinition();
}

From source file:org.mule.transport.zmq.config.OutboundEndpointDefinitionParser.java

public BeanDefinition parse(Element element, ParserContext parserContent) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder
            .rootBeanDefinition(OutboundEndpointMessageProcessor.class.getName());
    String configRef = element.getAttribute("config-ref");
    if ((configRef != null) && (!StringUtils.isBlank(configRef))) {
        builder.addPropertyValue("moduleObject", configRef);
    }//from   w w w.  ja v  a 2  s .  c om
    if ((element.getAttribute("payload-ref") != null)
            && (!StringUtils.isBlank(element.getAttribute("payload-ref")))) {
        if (element.getAttribute("payload-ref").startsWith("#")) {
            builder.addPropertyValue("payload", element.getAttribute("payload-ref"));
        } else {
            builder.addPropertyValue("payload", (("#[registry:" + element.getAttribute("payload-ref")) + "]"));
        }
    }
    if ((element.getAttribute("retryMax") != null)
            && (!StringUtils.isBlank(element.getAttribute("retryMax")))) {
        builder.addPropertyValue("retryMax", element.getAttribute("retryMax"));
    }
    if (element.hasAttribute("exchange-pattern")) {
        builder.addPropertyValue("exchangePattern", element.getAttribute("exchange-pattern"));
    }
    if (element.hasAttribute("socket-operation")) {
        builder.addPropertyValue("socketOperation", element.getAttribute("socket-operation"));
    }
    if ((element.getAttribute("address") != null) && (!StringUtils.isBlank(element.getAttribute("address")))) {
        builder.addPropertyValue("address", element.getAttribute("address"));
    }
    if ((element.getAttribute("filter") != null) && (!StringUtils.isBlank(element.getAttribute("filter")))) {
        builder.addPropertyValue("filter", element.getAttribute("filter"));
    }
    if ((element.getAttribute("identity") != null)
            && (!StringUtils.isBlank(element.getAttribute("identity")))) {
        builder.addPropertyValue("identity", element.getAttribute("identity"));
    }
    if ((element.getAttribute("multipart") != null)
            && (!StringUtils.isBlank(element.getAttribute("multipart")))) {
        builder.addPropertyValue("multipart", element.getAttribute("multipart"));
    }
    BeanDefinition definition = builder.getBeanDefinition();
    definition.setAttribute(MuleHierarchicalBeanDefinitionParserDelegate.MULE_NO_RECURSE, Boolean.TRUE);
    MutablePropertyValues propertyValues = parserContent.getContainingBeanDefinition().getPropertyValues();
    if (parserContent.getContainingBeanDefinition().getBeanClassName()
            .equals("org.mule.config.spring.factories.PollingMessageSourceFactoryBean")) {
        propertyValues.addPropertyValue("messageProcessor", definition);
    } else {
        if (parserContent.getContainingBeanDefinition().getBeanClassName()
                .equals("org.mule.enricher.MessageEnricher")) {
            propertyValues.addPropertyValue("enrichmentMessageProcessor", definition);
        } else {
            PropertyValue messageProcessors = propertyValues.getPropertyValue("messageProcessors");
            if ((messageProcessors == null) || (messageProcessors.getValue() == null)) {
                propertyValues.addPropertyValue("messageProcessors", new ManagedList());
            }
            List listMessageProcessors = ((List) propertyValues.getPropertyValue("messageProcessors")
                    .getValue());
            listMessageProcessors.add(definition);
        }
    }
    return definition;
}

From source file:edu.internet2.middleware.psp.spring.LdapDnFromGrouperNamePSOIdentifierAttributeDefinitionBeanDefinitionParser.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);

    String baseDn = pluginConfig.getAttributeNS(null, "baseDn");
    LOG.debug("Setting baseDn of element '{}' to: '{}'", pluginConfig.getLocalName(), baseDn);
    pluginBuilder.addPropertyValue("baseDn", baseDn);

    String baseStem = pluginConfig.getAttributeNS(null, "baseStem");
    LOG.debug("Setting baseStem of element '{}' to: '{}'", pluginConfig.getLocalName(), baseStem);
    pluginBuilder.addPropertyValue("baseStem", baseStem);

    String structure = pluginConfig.getAttributeNS(null, "structure");
    LOG.debug("Setting structure of element '{}' to: '{}'", pluginConfig.getLocalName(), structure);
    pluginBuilder.addPropertyValue("structure", structure);

    String rdnAttributeName = pluginConfig.getAttributeNS(null, "rdnAttributeName");
    LOG.debug("Setting rdnAttributeName of element '{}' to: '{}'", pluginConfig.getLocalName(),
            rdnAttributeName);//  ww  w  . ja va 2  s. com
    pluginBuilder.addPropertyValue("rdnAttributeName", rdnAttributeName);

    String stemRdnAttributeName = pluginConfig.getAttributeNS(null, "stemRdnAttributeName");
    LOG.debug("Setting stemRdnAttributeName of element '{}' to: '{}'", pluginConfig.getLocalName(),
            stemRdnAttributeName);
    pluginBuilder.addPropertyValue("stemRdnAttributeName", stemRdnAttributeName);
}

From source file:org.jasypt.spring31.xml.encryption.AbstractEncryptionBeanDefinitionParser.java

protected final void processIntegerAttribute(final Element element, final BeanDefinitionBuilder builder,
        final String attributeName, final String propertyName) {
    final String attributeValue = element.getAttribute(attributeName);
    if (StringUtils.hasText(attributeValue)) {
        try {//from  w  w w. j ava  2 s. c om
            final Integer attributeIntegerValue = Integer.valueOf(attributeValue);
            builder.addPropertyValue(propertyName, attributeIntegerValue);
        } catch (final NumberFormatException e) {
            throw new NumberFormatException(
                    "Config attribute \"" + attributeName + "\" is not a valid integer");
        }
    }
}

From source file:com.predic8.membrane.core.config.spring.AbstractParser.java

protected void setProperty(BeanDefinitionBuilder builder, String propertyName, Object value) {
    if (value instanceof RuntimeBeanNameReference)
        builder.addPropertyReference(propertyName, ((RuntimeBeanNameReference) value).getBeanName());
    else//from ww w . j a  v  a  2  s  . c  o  m
        builder.addPropertyValue(propertyName, value);
}

From source file:com.sinosoft.one.data.jpa.repository.config.OneJpaRepositoryConfigDefinitionParser.java

protected void postProcessBeanDefinition(JpaRepositoryConfiguration ctx, BeanDefinitionBuilder builder,
        BeanDefinitionRegistry registry, Object beanSource) {

    String transactionManagerRef = StringUtils.hasText(ctx.getTransactionManagerRef())
            ? ctx.getTransactionManagerRef()
            : DEFAULT_TRANSACTION_MANAGER_BEAN_NAME;
    builder.addPropertyValue("transactionManager", transactionManagerRef);

    String entityManagerRef = ctx.getEntityManagerFactoryRef();

    if (StringUtils.hasText(entityManagerRef)) {
        builder.addPropertyValue("entityManager",
                getEntityManagerBeanDefinitionFor(entityManagerRef, beanSource));
    }//from w  ww .  j a va  2s.co m
}

From source file:nz.co.senanque.madura.bundle.spring.BeanBeanDefinitionParser.java

protected void doParse(Element element, BeanDefinitionBuilder bean) {
    String bundleManager = element.getAttribute("bundleManager");
    if (!StringUtils.hasText(bundleManager))
        bundleManager = "bundleManager";
    bean.addPropertyReference("bundleManager", bundleManager);

    String interfaceName = element.getAttribute("interface");
    if (StringUtils.hasText(interfaceName)) {
        bean.addPropertyValue("interface", interfaceName);
    }/*from  w  ww . j  a va  2s  .  com*/
}

From source file:org.jdal.vaadin.beans.DefaultsBeanDefinitionParser.java

/**
 * Register default CustomEditorConfigurer
 * @return default CustomEditorComfigurer ComponentDefinition
 *//*from   w  w w . j av  a 2  s .  co m*/
private ComponentDefinition registerPropertyEditors(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
    Map<String, String> map = new HashMap<String, String>();
    map.put("com.vaadin.server.Resource", "org.jdal.vaadin.beans.VaadinResourcePropertyEditor");
    bdb.addPropertyValue("customEditors", map);
    BeanComponentDefinition bcd = new BeanComponentDefinition(bdb.getBeanDefinition(),
            CUSTOM_EDITOR_CONFIGURER_BEAN_NAME);
    registerBeanComponentDefinition(element, parserContext, bcd);
    return bcd;
}