Example usage for org.springframework.integration.support.utils IntegrationUtils INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME

List of usage examples for org.springframework.integration.support.utils IntegrationUtils INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME

Introduction

In this page you can find the example usage for org.springframework.integration.support.utils IntegrationUtils INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME.

Prototype

String INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME

To view the source code for org.springframework.integration.support.utils IntegrationUtils INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME.

Click Source Link

Usage

From source file:xolpoc.plugins.StreamPlugin.java

private void track(final Module module, MessageChannel channel, final Map<String, Object> historyProps) {
    final MessageBuilderFactory messageBuilderFactory = module.getComponent(
            IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME, MessageBuilderFactory.class) == null
                    ? new DefaultMessageBuilderFactory()
                    : module.getComponent(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME,
                            MessageBuilderFactory.class);
    if (channel instanceof ChannelInterceptorAware) {
        ((ChannelInterceptorAware) channel).addInterceptor(new ChannelInterceptorAdapter() {

            @Override/* w  w w  . j  av  a 2 s . c  o  m*/
            public Message<?> preSend(Message<?> message, MessageChannel channel) {
                @SuppressWarnings("unchecked")
                Collection<Map<String, Object>> history = (Collection<Map<String, Object>>) message.getHeaders()
                        .get(XdHeaders.XD_HISTORY);
                if (history == null) {
                    history = new ArrayList<Map<String, Object>>(1);
                } else {
                    history = new ArrayList<Map<String, Object>>(history);
                }
                Map<String, Object> map = new LinkedHashMap<String, Object>();
                map.putAll(historyProps);
                map.put("thread", Thread.currentThread().getName());
                history.add(map);
                Message<?> out = messageBuilderFactory.fromMessage(message)
                        .setHeader(XdHeaders.XD_HISTORY, history).build();
                return out;
            }
        });
    }
}

From source file:org.springframework.integration.config.IntegrationRegistrar.java

private void registerMessageBuilderFactory(BeanDefinitionRegistry registry) {
    boolean alreadyRegistered = false;
    if (registry instanceof ListableBeanFactory) {
        alreadyRegistered = ((ListableBeanFactory) registry)
                .containsBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME);
    } else {//from  ww w. j a v  a  2  s  . c o m
        alreadyRegistered = registry
                .isBeanNameInUse(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME);
    }
    if (!alreadyRegistered) {
        BeanDefinitionBuilder mbfBuilder = BeanDefinitionBuilder
                .genericBeanDefinition(DefaultMessageBuilderFactory.class).addPropertyValue("readOnlyHeaders",
                        IntegrationProperties.getExpressionFor(IntegrationProperties.READ_ONLY_HEADERS));
        registry.registerBeanDefinition(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME,
                mbfBuilder.getBeanDefinition());
    }

}