Example usage for org.springframework.integration.config.xml IntegrationNamespaceUtils setValueIfAttributeDefined

List of usage examples for org.springframework.integration.config.xml IntegrationNamespaceUtils setValueIfAttributeDefined

Introduction

In this page you can find the example usage for org.springframework.integration.config.xml IntegrationNamespaceUtils setValueIfAttributeDefined.

Prototype

public static void setValueIfAttributeDefined(BeanDefinitionBuilder builder, Element element,
        String attributeName, boolean emptyStringAllowed) 

Source Link

Document

Configures the provided bean definition builder with a property value corresponding to the attribute whose name is provided if that attribute is defined in the given element.

Usage

From source file:biz.c24.io.spring.integration.config.ValidatingHeaderEnricherParser.java

@Override
protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {

    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "fail-events", "addFailEvents");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "pass-events", "addPassEvents");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "statistics", "addStatistics");

}

From source file:biz.c24.io.spring.integration.config.ValidatingMessageSelectorParser.java

@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {

    BeanDefinitionBuilder builder = BeanDefinitionBuilder
            .genericBeanDefinition(C24ValidatingMessageSelector.class);
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "fail-fast", "failFast");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "throw-exception-on-rejection",
            "throwExceptionOnRejection");

    return builder.getBeanDefinition();
}

From source file:sipackage.config.xml.SIAdapterUpperPrefixOutboundGatewayParser.java

@Override
protected BeanDefinitionBuilder parseHandler(Element gatewayElement, ParserContext parserContext) {

    final BeanDefinitionBuilder siAdapterLowerPrefixOutboundGatewayBuilder = BeanDefinitionBuilder
            .genericBeanDefinition(SIAdapterUpperPrefixOutboundGateway.class);

    IntegrationNamespaceUtils.setValueIfAttributeDefined(siAdapterLowerPrefixOutboundGatewayBuilder,
            gatewayElement, "reply-timeout", "sendTimeout");

    final String replyChannel = gatewayElement.getAttribute("reply-channel");

    if (StringUtils.hasText(replyChannel)) {
        siAdapterLowerPrefixOutboundGatewayBuilder.addPropertyReference("outputChannel", replyChannel);
    }//from   w ww. j  a v  a2s.c  o m

    final BeanDefinitionBuilder siAdapterLowerPrefixExecutorBuilder = SIAdapterUpperPrefixParserUtils
            .getSIAdapterUpperPrefixExecutorBuilder(gatewayElement, parserContext);

    IntegrationNamespaceUtils.setValueIfAttributeDefined(siAdapterLowerPrefixExecutorBuilder, gatewayElement,
            "example-property");

    final BeanDefinition siAdapterLowerPrefixExecutorBuilderBeanDefinition = siAdapterLowerPrefixExecutorBuilder
            .getBeanDefinition();
    final String gatewayId = this.resolveId(gatewayElement,
            siAdapterLowerPrefixOutboundGatewayBuilder.getRawBeanDefinition(), parserContext);
    final String siAdapterLowerPrefixExecutorBeanName = gatewayId + ".siAdapterLowerPrefixExecutor";

    parserContext.registerBeanComponent(new BeanComponentDefinition(
            siAdapterLowerPrefixExecutorBuilderBeanDefinition, siAdapterLowerPrefixExecutorBeanName));

    siAdapterLowerPrefixOutboundGatewayBuilder.addConstructorArgReference(siAdapterLowerPrefixExecutorBeanName);

    return siAdapterLowerPrefixOutboundGatewayBuilder;

}

From source file:biz.c24.io.spring.integration.config.UnmarshallingTransformerParser.java

@Override
protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {

    String modelRef = element.getAttribute("model-ref");
    modelRef = StringUtils.hasText(modelRef) ? modelRef : C24ModelBeanDefinitionParser.DEFAULT_BEAN_NAME;
    builder.addConstructorArgReference(modelRef);

    IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "source-factory-ref",
            "sourceFactory");

    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "unwrap-document-root",
            "unwrapDocumentRoot");

}

From source file:org.springframework.batch.integration.config.xml.JobLaunchingGatewayParser.java

@Override
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {

    final BeanDefinitionBuilder jobLaunchingGatewayBuilder = BeanDefinitionBuilder
            .genericBeanDefinition(JobLaunchingGateway.class);

    final String jobLauncher = element.getAttribute("job-launcher");

    if (StringUtils.hasText(jobLauncher)) {
        jobLaunchingGatewayBuilder.addConstructorArgReference(jobLauncher);
    } else {/*from ww  w.  j av a 2s  . com*/
        if (logger.isDebugEnabled()) {
            logger.debug("No jobLauncher specified, using default 'jobLauncher' reference instead.");
        }
        jobLaunchingGatewayBuilder.addConstructorArgReference("jobLauncher");
    }

    IntegrationNamespaceUtils.setValueIfAttributeDefined(jobLaunchingGatewayBuilder, element, "reply-timeout",
            "sendTimeout");

    final String replyChannel = element.getAttribute("reply-channel");

    if (StringUtils.hasText(replyChannel)) {
        jobLaunchingGatewayBuilder.addPropertyReference("outputChannel", replyChannel);
    }

    return jobLaunchingGatewayBuilder;

}