Package org.mule.processor.chain

Examples of org.mule.processor.chain.DefaultMessageProcessorChainBuilder


        testOutboundEvent = createTestOutboundEvent();
    }

    public void testProcessors() throws Exception
    {
        DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
        builder.chain(new TestMessageProcessor("1"), new TestMessageProcessor("2"), new TestMessageProcessor("3"));
        MessageProcessor mpChain = builder.build();
       
        result = mpChain.process(testOutboundEvent);
        assertEquals(TEST_MESSAGE + ":1:2:3", result.getMessage().getPayload());
    }
View Full Code Here


        assertEquals(TEST_MESSAGE + ":1:2:3", result.getMessage().getPayload());
    }

    public void testNoProcessors() throws Exception
    {
        DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
        MessageProcessor mpChain = builder.build();
       
        result = mpChain.process(testOutboundEvent);
        assertEquals(TEST_MESSAGE, result.getMessage().getPayload());
    }
View Full Code Here

    // The optimal solution is to have response message processors contained inside the <response> element injected into their grandparent element directly.
    private static class EndpointResponseMessageProcessorChainFactoryBean extends MessageProcessorChainFactoryBean
    {
        public Object getObject() throws Exception
        {
            DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
            builder.setName("processor chain '" + name + "'");
            for (Object processor : processors)
            {
                if (processor instanceof MessageProcessor)
                {
                    builder.chain((MessageProcessor) processor);
                }
                else if (processor instanceof MessageProcessorBuilder)
                {
                    builder.chain((MessageProcessorBuilder) processor);
                }
                else
                {
                    throw new IllegalArgumentException(
                        "MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
                }
            }
            return builder.build();
        }
View Full Code Here

    {
        // ensure properties, hence HTTP headers, are propagated both ways
        final TransformerTemplate copyInboundToOutboundPropertiesTransformer = new TransformerTemplate(
            new CopyInboundToOutboundPropertiesTransformerCallback());

        final DefaultMessageProcessorChainBuilder proxyBuilder = new DefaultMessageProcessorChainBuilder();
        proxyBuilder.chain(copyInboundToOutboundPropertiesTransformer);
        proxyBuilder.chain(new ResponseMessageProcessorAdapter(copyInboundToOutboundPropertiesTransformer));

        if (outboundEndpoint instanceof DynamicURIOutboundEndpoint)
        {
            // do not mess with endpoints that are already dynamic
            proxyBuilder.chain(outboundEndpoint);
        }
        else
        {
            // create a templated outbound endpoint to propagate extra path elements (including query parameters)
            proxyBuilder.chain(new TransformerTemplate(new TransformerCallback()
            {
                public Object doTransform(final MuleMessage message) throws Exception
                {
                    final String pathExtension = StringUtils.substringAfter(
                            (String) message.getInboundProperty("http.request"),
                            (String) message.getInboundProperty("http.context.path"));

                    message.setInvocationProperty("http.path.extension",
                                                  StringUtils.defaultString(pathExtension));
                    return message;
                }
            }));

            final OutboundEndpoint dynamicOutboundEndpoint;

            if (outboundEndpoint.isDynamic())
            {
                dynamicOutboundEndpoint = outboundEndpoint;
            }
            else
            {
                final String uriTemplate = outboundEndpoint.getEndpointURI().getUri().toString()
                                           + "#[variable:http.path.extension]";

                URIBuilder uriBuilder = new URIBuilder(uriTemplate, muleContext);
                DynamicURIBuilder dynamicURIBuilder = new DynamicURIBuilder(uriBuilder);

                dynamicOutboundEndpoint = new DynamicOutboundEndpoint(
                        new EndpointURIEndpointBuilder(outboundEndpoint), dynamicURIBuilder);
            }

            proxyBuilder.chain(dynamicOutboundEndpoint);
        }

        MessageProcessor proxyMessageProcessor;
        if (cachingStrategy != null)
        {
            final MessageProcessorChain cachedMessageProcessors = proxyBuilder.build();

            proxyMessageProcessor = new MessageProcessor()
            {

                @Override
                public MuleEvent process(MuleEvent event) throws MuleException
                {
                    return cachingStrategy.process(event, cachedMessageProcessors);
                }
            };
        }
        else
        {
            proxyMessageProcessor = proxyBuilder.build();
        }

        builder.chain(proxyMessageProcessor);
    }
View Full Code Here

        this.messageProcessors = messageProcessors;
    }

    public Object getObject() throws Exception
    {
        DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
        builder.setName("'transaction' child processor chain");
        TransactionalInterceptingMessageProcessor txProcessor =
            new TransactionalInterceptingMessageProcessor();
        txProcessor.setExceptionListener(this.exceptionListener);
        MuleTransactionConfig transactionConfig = createTransactionConfig(this.action);
        txProcessor.setTransactionConfig(transactionConfig);
        transactionConfig.setFactory(getTransactionFactory());
        builder.chain(txProcessor);
        for (Object processor : messageProcessors)
        {
            if (processor instanceof MessageProcessor)
            {
                builder.chain((MessageProcessor) processor);
            }
            else if (processor instanceof MessageProcessorBuilder)
            {
                builder.chain((MessageProcessorBuilder) processor);
            }
            else
            {
                throw new IllegalArgumentException(
                    "MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
            }
            if (processor instanceof MessagingExceptionHandlerAware)
            {
                ((MessagingExceptionHandlerAware) processor).setMessagingExceptionHandler(exceptionListener);
            }
        }
        return builder.build();
    }
View Full Code Here

        return builder.build();
    }

    protected MessageProcessorChainBuilder getBuilderInstance()
    {
        DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
        builder.setName("processor chain '"+name+"'");
        return builder;
    }
View Full Code Here

    }

    @Override
    public MessageProcessorFilterPair getObject() throws Exception
    {
        MessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
        for (Object processor : messageProcessors)
        {
            if (processor instanceof MessageProcessor)
            {
                builder.chain((MessageProcessor) processor);
            }
            else if (processor instanceof MessageProcessorBuilder)
            {
                builder.chain((MessageProcessorBuilder) processor);
            }
            else
            {
                throw new IllegalArgumentException(
                    "MessageProcessorBuilder should only have MessageProcessors or MessageProcessorBuilders configured");
View Full Code Here

        this.messageProcessors = messageProcessors;
    }

    public Object getObject() throws Exception
    {
        DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
        builder.setName("'response' child processor chain");
        for (Object processor : messageProcessors)
        {
            if (processor instanceof MessageProcessor)
            {
                builder.chain((MessageProcessor) processor);
            }
            else if (processor instanceof MessageProcessorBuilder)
            {
                builder.chain((MessageProcessorBuilder) processor);
            }
            else
            {
                throw new IllegalArgumentException(
                    "MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
            }
        }
        ResponseMessageProcessorAdapter responseAdapter = new ResponseMessageProcessorAdapter();
        responseAdapter.setProcessor(builder.build());
        return responseAdapter;
    }
View Full Code Here

        this.messageProcessors = messageProcessors;
    }

    public Object getObject() throws Exception
    {
        DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
        builder.setName("'async' child chain");

        for (Object processor : messageProcessors)
        {
            if (processor instanceof MessageProcessor)
            {
                builder.chain((MessageProcessor) processor);
            }
            else if (processor instanceof MessageProcessorBuilder)
            {
                builder.chain((MessageProcessorBuilder) processor);
            }
            else
            {
                throw new IllegalArgumentException(
                    "MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
            }
        }
        AsyncDelegateMessageProcessor delegate = new AsyncDelegateMessageProcessor(builder.build(),
            processingStrategy, name);
        delegate.setAnnotations(getAnnotations());
        return delegate;
    }
View Full Code Here

    //-                    END LIFECYCLE METHODS
    //----------------------------------------------------------------------------------------//

    protected void buildServiceMessageProcessorChain() throws MuleException
    {
        DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder(this);
        builder.setName("Service '" + name + "' Processor Chain");
        builder.chain(getServiceStartedAssertingMessageProcessor());
        addMessageProcessors(builder);
        messageProcessorChain = builder.build();
    }
View Full Code Here

TOP

Related Classes of org.mule.processor.chain.DefaultMessageProcessorChainBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.