Package org.mule.api.processor

Examples of org.mule.api.processor.MessageProcessorChainBuilder


        ((ExpressionFilter) filter).setCustomEvaluator(customEvaluator);
    }

    public Object 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 MessageProcessor's or MessageProcessorBuilder's configured");
            }
        }
        return filter == null
                             ? new MessageProcessorFilterPair(builder.build(), AcceptAllFilter.INSTANCE)
                             : new MessageProcessorFilterPair(builder.build(), filter);
    }
View Full Code Here


        this.processors = processors;
    }

    public Object getObject() throws Exception
    {
        MessageProcessorChainBuilder builder = getBuilderInstance();
        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

    }

    @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

     * Creates the message processor chain in which we will delegate the process of mule events.
     * The chain composes a string transformer, a CXF client proxy and and outbound endpoint.
     */
    private MessageProcessor createMessageProcessor() throws MuleException
    {
        MessageProcessorChainBuilder chainBuilder = new DefaultMessageProcessorChainBuilder();

        chainBuilder.chain(new AbstractInterceptingMessageProcessor()
        {

            @Override
            public MuleEvent process(MuleEvent event) throws MuleException
            {
                try
                {
                    /* If the requestBody variable is set, it will be used as the payload to send instead
                     * of the payload of the message. This will happen when an operation required no input parameters. */

                    if (requestBody != null)
                    {
                        event.getMessage().setPayload(requestBody);
                    }

                    copyAttachmentsRequest(event);

                    MuleEvent result =  processNext(event);

                    copyAttachmentsResponse(result);
                    return result;
                }
                catch (DispatchException e)
                {
                    /* When a Soap Fault is returned in the response, CXF raises a SoapFault exception.
                     * We need to wrap the information of this exception into a new exception of the WS consumer module */

                    if (e.getCause() instanceof SoapFault)
                    {
                        SoapFault soapFault = (SoapFault) e.getCause();

                        event.getMessage().setPayload(soapFault.getDetail());

                        throw new SoapFaultException(event, soapFault.getFaultCode(), soapFault.getSubCode(),
                                                     soapFault.getMessage(), soapFault.getDetail());
                    }
                    else
                    {
                        throw e;
                    }
                }
            }
        });

        // Add a message processor that removes the invocation property CxfConstants.OPERATION if present
        // (as it may change the behavior of CXF proxy client). It is added again after executing the proxy client.
        chainBuilder.chain(new AbstractInterceptingMessageProcessor()
        {
            @Override
            public MuleEvent process(MuleEvent event) throws MuleException
            {
                Object operation = event.getMessage().removeProperty(CxfConstants.OPERATION, PropertyScope.INVOCATION);

                MuleEvent result = processNext(event);

                if (operation != null)
                {
                    result.getMessage().setInvocationProperty(CxfConstants.OPERATION, operation);
                }
                return result;
            }
        });

        chainBuilder.chain(createCxfOutboundMessageProcessor(config.getSecurity()));

        chainBuilder.chain(new AbstractInterceptingMessageProcessor()
        {
            @Override
            public MuleEvent process(MuleEvent event) throws MuleException
            {
                // Remove outbound properties that are mapped to SOAP headers, so that the
                // underlying transport does not include them as headers.

                List<String> outboundProperties = new ArrayList<String>(event.getMessage().getOutboundPropertyNames());

                for (String outboundProperty : outboundProperties)
                {
                    if (outboundProperty.startsWith(SOAP_HEADERS_PROPERTY_PREFIX))
                    {
                        event.getMessage().removeProperty(outboundProperty, PropertyScope.OUTBOUND);
                    }
                }

                // Send the request through the transport/connector
                MuleEvent result = processNext(event);

                // Ensure that the http.status code inbound property (if present) is a String.
                Object statusCode = result.getMessage().getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, null);
                if (statusCode != null && !(statusCode instanceof String))
                {
                    result.getMessage().setProperty(HttpConnector.HTTP_STATUS_PROPERTY, statusCode.toString(), PropertyScope.INBOUND);
                }

                return result;
            }
        });

        chainBuilder.chain(config.createOutboundMessageProcessor());

        return chainBuilder.build();
    }
View Full Code Here

        else
        {
            nameSource = ((StageNameSourceProvider) flowConstruct).getAsyncStageNameSource();
        }

        MessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder(flowConstruct);
        processingStrategy.configureProcessors(Collections.singletonList(delegate), nameSource, builder,
                                               muleContext);
        try
        {
            target = builder.build();
        }
        catch (MuleException e)
        {
            throw new InitialisationException(e, this);
        }
View Full Code Here

TOP

Related Classes of org.mule.api.processor.MessageProcessorChainBuilder

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.