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:com.dangdang.ddframe.rdb.sharding.spring.namespace.parser.ShardingJdbcStrategyBeanDefinition.java

static AbstractBeanDefinition getBeanDefinitionByElement(final Element element) {
    BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(StrategyConfig.class);
    factory.addPropertyValue("shardingColumns",
            element.getAttribute(ShardingJdbcStrategyBeanDefinitionParserTag.SHARDING_COLUMNS_ATTRIBUTE));
    factory.addPropertyValue("algorithmClassName",
            element.getAttribute(ShardingJdbcStrategyBeanDefinitionParserTag.ALGORITHM_CLASS_ATTRIBUTE));
    factory.addPropertyValue("algorithmExpression",
            element.getAttribute(ShardingJdbcStrategyBeanDefinitionParserTag.ALGORITHM_EXPRESSION_ATTRIBUTE));
    return factory.getBeanDefinition();
}

From source file:org.jdal.beans.BeanDefinitionUtils.java

/**
 * Add property value to {@link BeanDefinitionBuilder} if needed, following the naming {@link Conventions}
 * @param bdb BeanDefintionBuilder to operate on.
 * @param element Element holding the attribute
 * @param attributeName the attribute name
 *//*from w  w  w  .j  a v a2 s.  c om*/
public static void addPropertyValueIfNeeded(BeanDefinitionBuilder bdb, Element element, String attributeName) {
    if (element.hasAttribute(attributeName))
        bdb.addPropertyValue(Conventions.attributeNameToPropertyName(attributeName),
                element.getAttribute(attributeName));
}

From source file:org.xacml4j.spring.pdp.PolicyDecisionPointDefinitionParser.java

private static void parseChildComponents(List<Element> childElements, BeanDefinitionBuilder factory) {
    Preconditions.checkArgument(childElements.size() == 1);
    factory.addPropertyValue("domainPolicy", parseComponent(childElements.get(0)).getBeanDefinition());
}

From source file:com.mtgi.analytics.aop.config.v11.SchedulerActivationPostProcessor.java

/**
 * Convenience method to register a {@link SchedulerActivationPostProcessor} in the given BeanFactory
 * parse context with the given properties.
 * @param parseContext the target bean factory in this context will have a {@link SchedulerActivationPostProcessor} registered
 * @param sourceFactory the source for both the named scheduler and trigger instances
 * @param schedulerName the name of the Quartz {@link Scheduler} in <code>sourceFactory</code> to use
 * @param triggerName the name of the Quarty {@link Trigger} in <code>sourceFactory</code> that must be scheduled
 *//*from   w w w  . ja v a 2  s .c  o m*/
public static void registerPostProcessor(ParserContext parseContext, BeanFactory sourceFactory,
        String schedulerName, String triggerName) {
    BeanDefinitionBuilder scheduleBootstrap = BeanDefinitionBuilder
            .rootBeanDefinition(SchedulerActivationPostProcessor.class);
    scheduleBootstrap.addPropertyValue("sourceFactory", sourceFactory);
    scheduleBootstrap.addPropertyValue("schedulerName", schedulerName);
    scheduleBootstrap.addPropertyValue("triggerName", triggerName);
    scheduleBootstrap.setLazyInit(false);
    parseContext.getReaderContext().registerWithGeneratedName(scheduleBootstrap.getBeanDefinition());
}

From source file:org.xacml4j.spring.FunctionProvidersDefinitionParser.java

private static BeanDefinitionBuilder parseComponent(Element element) {
    BeanDefinitionBuilder component = BeanDefinitionBuilder.rootBeanDefinition(FunctionProvider.class);
    String clazz = element.getAttribute("class");
    if (StringUtils.hasText(clazz)) {
        component.addPropertyValue("providerClass", clazz);
    }/*w  ww  .j a va 2s  .c o m*/
    String ref = element.getAttribute("ref");
    if (StringUtils.hasText(ref)) {
        component.addPropertyReference("providerInstance", ref);
    }
    return component;
}

From source file:fr.pilato.spring.elasticsearch.xml.ClientBeanDefinitionParser.java

public static BeanDefinition buildTransportClientDef(BeanDefinitionBuilder nodeFactory, String esNodes) {
    if (esNodes != null && esNodes.length() > 0) {
        nodeFactory.addPropertyValue("esNodes", esNodes);
    }//from   www  .  ja  va 2s  . co m
    return nodeFactory.getBeanDefinition();
}

From source file:org.xacml4j.spring.DecisionCombiningAlgorithmProvidersDefinitionParser.java

private static BeanDefinitionBuilder parseComponent(Element element) {
    BeanDefinitionBuilder component = BeanDefinitionBuilder
            .rootBeanDefinition(DecisionCombiningAlgorithmProviderBean.class);
    String clazz = element.getAttribute("class");
    if (StringUtils.hasText(clazz)) {
        component.addPropertyValue("class", clazz);
    }/*from ww w.j a v  a2s .  c  o  m*/
    String ref = element.getAttribute("ref");
    if (StringUtils.hasText(ref)) {
        component.addPropertyReference("ref", ref);
    }
    return component;
}

From source file:org.xacml4j.spring.pip.ResolverRegistryDefinitionParser.java

private static BeanDefinitionBuilder parseResolvers(Element element) {
    BeanDefinitionBuilder component = BeanDefinitionBuilder
            .rootBeanDefinition(ResolverRegistrationFactoryBean.class);
    String policyId = element.getAttribute("policyId");
    if (StringUtils.hasText(policyId)) {
        component.addPropertyValue("policyId", policyId);
    }/*w w  w.jav  a2  s  .com*/
    String ref = element.getAttribute("ref");
    if (StringUtils.hasText(ref)) {
        component.addPropertyReference("resolver", ref);
    }
    return component;
}

From source file:com.textocat.textokit.eval.EvaluationLauncher.java

public static void runUsingProperties(Properties configProperties) throws Exception {
    GenericApplicationContext appCtx = new GenericApplicationContext();

    appCtx.getEnvironment().getPropertySources()
            .addLast(new PropertiesPropertySource("configFile", configProperties));

    XmlBeanDefinitionReader xmlBDReader = new XmlBeanDefinitionReader(appCtx);
    xmlBDReader.loadBeanDefinitions(APP_CONTEXT_LOCATION);

    // register listeners
    Map<String, String> listenerImpls = getPrefixedKeyPairs(configProperties, PREFIX_LISTENER_ID);
    for (String listenerId : listenerImpls.keySet()) {
        String listenerClass = listenerImpls.get(listenerId);
        BeanDefinitionBuilder bb = genericBeanDefinition(listenerClass);
        Map<String, String> listenerProperties = getPrefixedKeyPairs(configProperties,
                PREFIX_LISTENER_PROPERTY + listenerId + ".");
        for (String propName : listenerProperties.keySet()) {
            bb.addPropertyValue(propName, listenerProperties.get(propName));
        }// w w  w.ja va 2s.  c  o m
        appCtx.registerBeanDefinition(listenerId, bb.getBeanDefinition());
    }

    appCtx.refresh();

    appCtx.registerShutdownHook();

    GoldStandardBasedEvaluation eval = appCtx.getBean(GoldStandardBasedEvaluation.class);
    eval.run();
}

From source file:org.xacml4j.spring.pip.ResolverRegistryDefinitionParser.java

private static void parseResolvers(List<Element> childElements, BeanDefinitionBuilder factory) {
    ManagedList<BeanDefinition> children = new ManagedList<BeanDefinition>(childElements.size());
    for (Element childElement : childElements) {
        BeanDefinitionBuilder child = parseResolvers(childElement);
        children.add(child.getBeanDefinition());
    }//from   w ww  . j  a  va2s  . co m
    factory.addPropertyValue("resolvers", children);
}