Search in sources :

Example 1 with MessageProcessor

use of org.springframework.integration.handler.MessageProcessor in project spring-integration by spring-projects.

the class AbstractStandardMessageHandlerFactoryBean method createHandler.

@Override
protected MessageHandler createHandler() {
    MessageHandler handler;
    if (this.targetObject == null) {
        Assert.isTrue(!StringUtils.hasText(this.targetMethodName), "The target method is only allowed when a target object (ref or inner bean) is also provided.");
    }
    if (this.targetObject != null) {
        Assert.state(this.expression == null, "The 'targetObject' and 'expression' properties are mutually exclusive.");
        AbstractMessageProducingHandler actualHandler = this.extractTypeIfPossible(this.targetObject, AbstractMessageProducingHandler.class);
        boolean targetIsDirectReplyProducingHandler = actualHandler != null && // give subclasses a say
        canBeUsedDirect(actualHandler) && methodIsHandleMessageOrEmpty(this.targetMethodName);
        if (this.targetObject instanceof MessageProcessor<?>) {
            handler = this.createMessageProcessingHandler((MessageProcessor<?>) this.targetObject);
        } else if (targetIsDirectReplyProducingHandler) {
            if (logger.isDebugEnabled()) {
                logger.debug("Wiring handler (" + this.targetObject + ") directly into endpoint");
            }
            checkReuse(actualHandler);
            postProcessReplyProducer(actualHandler);
            handler = (MessageHandler) this.targetObject;
        } else {
            handler = this.createMethodInvokingHandler(this.targetObject, this.targetMethodName);
        }
    } else if (this.expression != null) {
        handler = this.createExpressionEvaluatingHandler(this.expression);
    } else {
        handler = this.createDefaultHandler();
    }
    return handler;
}
Also used : AbstractReplyProducingMessageHandler(org.springframework.integration.handler.AbstractReplyProducingMessageHandler) MessageHandler(org.springframework.messaging.MessageHandler) MessageProcessor(org.springframework.integration.handler.MessageProcessor) AbstractMessageProducingHandler(org.springframework.integration.handler.AbstractMessageProducingHandler)

Example 2 with MessageProcessor

use of org.springframework.integration.handler.MessageProcessor in project spring-integration by spring-projects.

the class GroovyTransformerTests method testInt2433VerifyRiddingOfMessageProcessorsWrapping.

@Test
public void testInt2433VerifyRiddingOfMessageProcessorsWrapping() {
    assertTrue(this.groovyTransformerMessageHandler instanceof MessageTransformingHandler);
    Transformer transformer = TestUtils.getPropertyValue(this.groovyTransformerMessageHandler, "transformer", Transformer.class);
    assertTrue(transformer instanceof AbstractMessageProcessingTransformer);
    @SuppressWarnings("rawtypes") MessageProcessor messageProcessor = TestUtils.getPropertyValue(transformer, "messageProcessor", MessageProcessor.class);
    // before it was MethodInvokingMessageProcessor
    assertTrue(messageProcessor instanceof GroovyScriptExecutingMessageProcessor);
}
Also used : AbstractMessageProcessingTransformer(org.springframework.integration.transformer.AbstractMessageProcessingTransformer) MessageTransformingHandler(org.springframework.integration.transformer.MessageTransformingHandler) Transformer(org.springframework.integration.transformer.Transformer) AbstractMessageProcessingTransformer(org.springframework.integration.transformer.AbstractMessageProcessingTransformer) MessageProcessor(org.springframework.integration.handler.MessageProcessor) GroovyScriptExecutingMessageProcessor(org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor) GroovyScriptExecutingMessageProcessor(org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor) Test(org.junit.Test)

Example 3 with MessageProcessor

use of org.springframework.integration.handler.MessageProcessor in project spring-integration by spring-projects.

the class GroovyFilterTests method testInt2433VerifyRiddingOfMessageProcessorsWrapping.

@Test
public void testInt2433VerifyRiddingOfMessageProcessorsWrapping() {
    assertTrue(this.groovyFilterMessageHandler instanceof MessageFilter);
    MessageSelector selector = TestUtils.getPropertyValue(this.groovyFilterMessageHandler, "selector", MethodInvokingSelector.class);
    @SuppressWarnings("rawtypes") MessageProcessor messageProcessor = TestUtils.getPropertyValue(selector, "messageProcessor", MessageProcessor.class);
    // before it was MethodInvokingMessageProcessor
    assertTrue(messageProcessor instanceof GroovyScriptExecutingMessageProcessor);
}
Also used : MessageProcessor(org.springframework.integration.handler.MessageProcessor) GroovyScriptExecutingMessageProcessor(org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor) GroovyScriptExecutingMessageProcessor(org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor) MessageSelector(org.springframework.integration.core.MessageSelector) MessageFilter(org.springframework.integration.filter.MessageFilter) Test(org.junit.Test)

Example 4 with MessageProcessor

use of org.springframework.integration.handler.MessageProcessor in project spring-integration by spring-projects.

the class GroovySplitterTests method testInt2433VerifyRiddingOfMessageProcessorsWrapping.

@Test
public void testInt2433VerifyRiddingOfMessageProcessorsWrapping() {
    assertTrue(this.groovySplitterMessageHandler instanceof MethodInvokingSplitter);
    @SuppressWarnings("rawtypes") MessageProcessor messageProcessor = TestUtils.getPropertyValue(this.groovySplitterMessageHandler, "messageProcessor", MessageProcessor.class);
    // before it was MethodInvokingMessageProcessor
    assertTrue(messageProcessor instanceof GroovyScriptExecutingMessageProcessor);
}
Also used : MethodInvokingSplitter(org.springframework.integration.splitter.MethodInvokingSplitter) MessageProcessor(org.springframework.integration.handler.MessageProcessor) GroovyScriptExecutingMessageProcessor(org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor) GroovyScriptExecutingMessageProcessor(org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor) Test(org.junit.Test)

Example 5 with MessageProcessor

use of org.springframework.integration.handler.MessageProcessor in project spring-integration by spring-projects.

the class GroovyRouterTests method testInt2433VerifyRiddingOfMessageProcessorsWrapping.

@Test
public void testInt2433VerifyRiddingOfMessageProcessorsWrapping() {
    assertTrue(this.groovyRouterMessageHandler instanceof MethodInvokingRouter);
    @SuppressWarnings("rawtypes") MessageProcessor messageProcessor = TestUtils.getPropertyValue(this.groovyRouterMessageHandler, "messageProcessor", MessageProcessor.class);
    // before it was MethodInvokingMessageProcessor
    assertTrue(messageProcessor instanceof GroovyScriptExecutingMessageProcessor);
}
Also used : MessageProcessor(org.springframework.integration.handler.MessageProcessor) GroovyScriptExecutingMessageProcessor(org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor) MethodInvokingRouter(org.springframework.integration.router.MethodInvokingRouter) GroovyScriptExecutingMessageProcessor(org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor) Test(org.junit.Test)

Aggregations

MessageProcessor (org.springframework.integration.handler.MessageProcessor)5 Test (org.junit.Test)4 GroovyScriptExecutingMessageProcessor (org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor)4 MessageSelector (org.springframework.integration.core.MessageSelector)1 MessageFilter (org.springframework.integration.filter.MessageFilter)1 AbstractMessageProducingHandler (org.springframework.integration.handler.AbstractMessageProducingHandler)1 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)1 MethodInvokingRouter (org.springframework.integration.router.MethodInvokingRouter)1 MethodInvokingSplitter (org.springframework.integration.splitter.MethodInvokingSplitter)1 AbstractMessageProcessingTransformer (org.springframework.integration.transformer.AbstractMessageProcessingTransformer)1 MessageTransformingHandler (org.springframework.integration.transformer.MessageTransformingHandler)1 Transformer (org.springframework.integration.transformer.Transformer)1 MessageHandler (org.springframework.messaging.MessageHandler)1