org.apache.camel.model
Class ProcessorType

java.lang.Object
  extended by org.apache.camel.model.ProcessorType
Direct Known Subclasses:
CatchType, ChoiceType, ExceptionType, ExpressionNode, OutputType, ProceedType, ResequencerType, RouteType, ThrottlerType, ToType

public abstract class ProcessorType
extends Object

Version:
$Revision: 1.1 $

Field Summary
static String DEFAULT_TRACE_CATEGORY
           
 
Constructor Summary
ProcessorType()
           
 
Method Summary
protected  void addOutput(ProcessorType processorType)
           
 void addRoutes(RouteContext routeContext, Collection<Route> routes)
           
 AggregatorType aggregator(Expression correlationExpression)
          A builder for the Aggregator pattern where a batch of messages are processed (up to a maximum amount or until some timeout is reached) and messages for the same correlation key are combined together using some kind of {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges into a smaller number of exchanges.
 AggregatorType aggregator(Expression correlationExpression, AggregationStrategy aggregationStrategy)
          A builder for the Aggregator pattern where a batch of messages are processed (up to a maximum amount or until some timeout is reached) and messages for the same correlation key are combined together using some kind of {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges into a smaller number of exchanges.
 ProcessorType beanRef(String ref)
          Adds a bean which is invoked which could be a final destination, or could be a transformation in a pipeline
 ProcessorType beanRef(String ref, String method)
          Adds a bean and method which is invoked which could be a final destination, or could be a transformation in a pipeline
 ChoiceType choice()
          Creates a choice of one or more predicates with an otherwise clause
protected  void configureChild(ProcessorType output)
           
 ProcessorType convertBodyTo(Class type)
          Converts the IN message body to the specified type
 ProcessorType convertOutBodyTo(Class type)
          Converts the OUT message body to the specified type
protected  Processor createCompositeProcessor(List<Processor> list)
          Creates a new instance of some kind of composite processor which defaults to using a Pipeline but derived classes could change the behaviour
protected  ErrorHandlerBuilder createErrorHandlerBuilder()
           
 Processor createOutputsProcessor(RouteContext routeContext)
           
protected  Processor createOutputsProcessor(RouteContext routeContext, Collection<ProcessorType> outputs)
           
 Processor createProcessor(RouteContext routeContext)
           
 DelayerType delayer(Expression<Exchange> processAtExpression)
          A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on
 DelayerType delayer(Expression<Exchange> processAtExpression, long delay)
          A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on
 DelayerType delayer(long delay)
          A builder for the Delayer pattern where a fixed amount of milliseconds are used to delay processing of a message exchange
 ProcessorType errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
          Installs the given error handler builder
 ExceptionType exception(Class exceptionType)
           
 FilterType filter(ExpressionType expression)
           
 FilterType filter(Predicate predicate)
          Creates a predicate which is applied and only if it is true then the exchange is forwarded to the destination
 FilterType filter(String language, String expression)
           
 ErrorHandlerBuilder getErrorHandlerBuilder()
           
 Boolean getInheritErrorHandlerFlag()
           
abstract  List<InterceptorType> getInterceptors()
           
abstract  List<ProcessorType> getOutputs()
           
 IdempotentConsumerType idempotentConsumer(Expression messageIdExpression, MessageIdRepository messageIdRepository)
          Creates an IdempotentConsumer to avoid duplicate messages
 ProcessorType inheritErrorHandler(boolean condition)
          Configures whether or not the error handler is inherited by every processing node (or just the top most one)
 InterceptType intercept()
           
 ProcessorType intercept(DelegateProcessor interceptor)
           
 OtherwiseType intercept(Predicate predicate)
          Apply an interceptor route if the predicate is true
 ProcessorType interceptor(String ref)
           
 ProcessorType interceptors(String... refs)
           
 boolean isInheritErrorHandler()
           
protected  Processor makeProcessor(RouteContext routeContext)
          Creates the processor and wraps it in any necessary interceptors and error handlers
 MulticastType multicast()
          Multicasts messages to all its child outputs; so that each processor and destination gets a copy of the original message to avoid the processors interfering with each other.
 ProcessorType pipeline(Collection<Endpoint> endpoints)
          Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint
 ProcessorType pipeline(Endpoint... endpoints)
          Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint
 ProcessorType pipeline(String... uris)
          Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint
 PolicyRef policies()
           
 PolicyRef policy(Policy policy)
           
 ProcessorType proceed()
           
 ProcessorType process(Processor processor)
          Adds the custom processor to this destination which could be a final destination, or could be a transformation in a pipeline
 ProcessorType recipientList(Expression receipients)
          Creates a dynamic Recipient List pattern.
 ResequencerType resequencer(Expression... expressions)
          A builder for the Resequencer pattern where a list of expressions are evaluated to be able to compare the message exchanges to reorder them.
 ResequencerType resequencer(Expression<Exchange> expression)
          A builder for the Resequencer pattern where an expression is evaluated to be able to compare the message exchanges to reorder them.
 ResequencerType resequencer(List<Expression> expressions)
          A builder for the Resequencer pattern where a list of expressions are evaluated to be able to compare the message exchanges to reorder them.
 ProcessorType setBody(Expression expression)
          Adds a processor which sets the body on the IN message
 void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
          Sets the error handler to use with processors created by this builder
 ProcessorType setHeader(String name, Expression expression)
          Adds a processor which sets the header on the IN message
 void setInheritErrorHandlerFlag(Boolean inheritErrorHandlerFlag)
           
 ProcessorType setOutBody(Expression expression)
          Adds a processor which sets the body on the OUT message
 ProcessorType setOutHeader(String name, Expression expression)
          Adds a processor which sets the header on the OUT message
 ProcessorType setProperty(String name, Expression expression)
          Adds a processor which sets the exchange property
 SplitterType splitter(Expression receipients)
          A builder for the Splitter pattern where an expression is evaluated to iterate through each of the parts of a message and then each part is then send to some endpoint.
 ThrottlerType throttler(long maximumRequestCount)
          A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on
 ProcessorType to(Collection<Endpoint> endpoints)
          Sends the exchange to a list of endpoint using the MulticastProcessor pattern
 ProcessorType to(Endpoint... endpoints)
          Sends the exchange to a list of endpoints using the MulticastProcessor pattern
 ProcessorType to(Endpoint endpoint)
          Sends the exchange to the given endpoint
 ProcessorType to(String... uris)
          Sends the exchange to a list of endpoints using the MulticastProcessor pattern
 ProcessorType to(String uri)
          Sends the exchange to the given endpoint URI
 ProcessorType trace()
          Trace logs the exchange before it goes to the next processing step using the DEFAULT_TRACE_CATEGORY logging category.
 ProcessorType trace(String category)
          Trace logs the exchange before it goes to the next processing step using the specified logging category.
 TryType tryBlock()
          Creates a try/catch block
protected  Processor wrapInErrorHandler(Processor processor)
          A strategy method to allow newly created processors to be wrapped in an error handler.
 Processor wrapProcessor(RouteContext routeContext, Processor processor)
          Wraps the child processor in whatever necessary interceptors and error handlers
protected  Processor wrapProcessorInInterceptors(RouteContext routeContext, Processor target)
          A strategy method which allows derived classes to wrap the child processor in some kind of interceptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TRACE_CATEGORY

public static final String DEFAULT_TRACE_CATEGORY
See Also:
Constant Field Values
Constructor Detail

ProcessorType

public ProcessorType()
Method Detail

getOutputs

public abstract List<ProcessorType> getOutputs()

getInterceptors

public abstract List<InterceptorType> getInterceptors()

createProcessor

public Processor createProcessor(RouteContext routeContext)
                          throws Exception
Throws:
Exception

createOutputsProcessor

public Processor createOutputsProcessor(RouteContext routeContext)
                                 throws Exception
Throws:
Exception

addRoutes

public void addRoutes(RouteContext routeContext,
                      Collection<Route> routes)
               throws Exception
Throws:
Exception

wrapProcessor

public Processor wrapProcessor(RouteContext routeContext,
                               Processor processor)
                        throws Exception
Wraps the child processor in whatever necessary interceptors and error handlers

Throws:
Exception

to

public ProcessorType to(String uri)
Sends the exchange to the given endpoint URI


to

public ProcessorType to(Endpoint endpoint)
Sends the exchange to the given endpoint


to

public ProcessorType to(String... uris)
Sends the exchange to a list of endpoints using the MulticastProcessor pattern


to

public ProcessorType to(Endpoint... endpoints)
Sends the exchange to a list of endpoints using the MulticastProcessor pattern


to

public ProcessorType to(Collection<Endpoint> endpoints)
Sends the exchange to a list of endpoint using the MulticastProcessor pattern


multicast

public MulticastType multicast()
Multicasts messages to all its child outputs; so that each processor and destination gets a copy of the original message to avoid the processors interfering with each other.


pipeline

public ProcessorType pipeline(String... uris)
Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint


pipeline

public ProcessorType pipeline(Endpoint... endpoints)
Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint


pipeline

public ProcessorType pipeline(Collection<Endpoint> endpoints)
Creates a Pipeline of the list of endpoints so that the message will get processed by each endpoint in turn and for request/response the output of one endpoint will be the input of the next endpoint


idempotentConsumer

public IdempotentConsumerType idempotentConsumer(Expression messageIdExpression,
                                                 MessageIdRepository messageIdRepository)
Creates an IdempotentConsumer to avoid duplicate messages


filter

public FilterType filter(Predicate predicate)
Creates a predicate which is applied and only if it is true then the exchange is forwarded to the destination

Returns:
the builder for a predicate

choice

public ChoiceType choice()
Creates a choice of one or more predicates with an otherwise clause

Returns:
the builder for a choice expression

tryBlock

public TryType tryBlock()
Creates a try/catch block

Returns:
the builder for a tryBlock expression

recipientList

public ProcessorType recipientList(Expression receipients)
Creates a dynamic Recipient List pattern.

Parameters:
receipients - is the builder of the expression used in the RecipientList to decide the destinations

splitter

public SplitterType splitter(Expression receipients)
A builder for the Splitter pattern where an expression is evaluated to iterate through each of the parts of a message and then each part is then send to some endpoint.

Parameters:
receipients - the expression on which to split
Returns:
the builder

resequencer

public ResequencerType resequencer(Expression<Exchange> expression)
A builder for the Resequencer pattern where an expression is evaluated to be able to compare the message exchanges to reorder them. e.g. you may wish to sort by some header

Parameters:
expression - the expression on which to compare messages in order
Returns:
the builder

resequencer

public ResequencerType resequencer(List<Expression> expressions)
A builder for the Resequencer pattern where a list of expressions are evaluated to be able to compare the message exchanges to reorder them. e.g. you may wish to sort by some headers

Parameters:
expressions - the expressions on which to compare messages in order
Returns:
the builder

resequencer

public ResequencerType resequencer(Expression... expressions)
A builder for the Resequencer pattern where a list of expressions are evaluated to be able to compare the message exchanges to reorder them. e.g. you may wish to sort by some headers

Parameters:
expressions - the expressions on which to compare messages in order
Returns:
the builder

aggregator

public AggregatorType aggregator(Expression correlationExpression)
A builder for the Aggregator pattern where a batch of messages are processed (up to a maximum amount or until some timeout is reached) and messages for the same correlation key are combined together using some kind of {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges into a smaller number of exchanges.

A good example of this is stock market data; you may be receiving 30,000 messages/second and you may want to throttle it right down so that multiple messages for the same stock are combined (or just the latest message is used and older prices are discarded). Another idea is to combine line item messages together into a single invoice message.

Parameters:
correlationExpression - the expression used to calculate the correlation key. For a JMS message this could be the expression header("JMSDestination") or header("JMSCorrelationID")

aggregator

public AggregatorType aggregator(Expression correlationExpression,
                                 AggregationStrategy aggregationStrategy)
A builder for the Aggregator pattern where a batch of messages are processed (up to a maximum amount or until some timeout is reached) and messages for the same correlation key are combined together using some kind of {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges into a smaller number of exchanges.

A good example of this is stock market data; you may be receiving 30,000 messages/second and you may want to throttle it right down so that multiple messages for the same stock are combined (or just the latest message is used and older prices are discarded). Another idea is to combine line item messages together into a single invoice message.

Parameters:
correlationExpression - the expression used to calculate the correlation key. For a JMS message this could be the expression header("JMSDestination") or header("JMSCorrelationID")

delayer

public DelayerType delayer(Expression<Exchange> processAtExpression)
A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on

Parameters:
processAtExpression - an expression to calculate the time at which the messages should be processed
Returns:
the builder

delayer

public DelayerType delayer(Expression<Exchange> processAtExpression,
                           long delay)
A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on

Parameters:
processAtExpression - an expression to calculate the time at which the messages should be processed
delay - the delay in milliseconds which is added to the processAtExpression to determine the time the message should be processed
Returns:
the builder

delayer

public DelayerType delayer(long delay)
A builder for the Delayer pattern where a fixed amount of milliseconds are used to delay processing of a message exchange

Parameters:
delay - the default delay in milliseconds
Returns:
the builder

throttler

public ThrottlerType throttler(long maximumRequestCount)
A builder for the Delayer pattern where an expression is used to calculate the time which the message will be dispatched on

Returns:
the builder

interceptor

public ProcessorType interceptor(String ref)

intercept

public InterceptType intercept()

proceed

public ProcessorType proceed()

exception

public ExceptionType exception(Class exceptionType)

intercept

public OtherwiseType intercept(Predicate predicate)
Apply an interceptor route if the predicate is true


interceptors

public ProcessorType interceptors(String... refs)

filter

public FilterType filter(ExpressionType expression)

filter

public FilterType filter(String language,
                         String expression)

trace

public ProcessorType trace()
Trace logs the exchange before it goes to the next processing step using the DEFAULT_TRACE_CATEGORY logging category.

Returns:

trace

public ProcessorType trace(String category)
Trace logs the exchange before it goes to the next processing step using the specified logging category.

Parameters:
category - the logging category trace messages will sent to.
Returns:

policies

public PolicyRef policies()

policy

public PolicyRef policy(Policy policy)

intercept

public ProcessorType intercept(DelegateProcessor interceptor)

errorHandler

public ProcessorType errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
Installs the given error handler builder

Parameters:
errorHandlerBuilder - the error handler to be used by default for all child routes
Returns:
the current builder with the error handler configured

inheritErrorHandler

public ProcessorType inheritErrorHandler(boolean condition)
Configures whether or not the error handler is inherited by every processing node (or just the top most one)

Parameters:
condition - the falg as to whether error handlers should be inherited or not
Returns:
the current builder

process

public ProcessorType process(Processor processor)
Adds the custom processor to this destination which could be a final destination, or could be a transformation in a pipeline


beanRef

public ProcessorType beanRef(String ref)
Adds a bean which is invoked which could be a final destination, or could be a transformation in a pipeline


beanRef

public ProcessorType beanRef(String ref,
                             String method)
Adds a bean and method which is invoked which could be a final destination, or could be a transformation in a pipeline


setBody

public ProcessorType setBody(Expression expression)
Adds a processor which sets the body on the IN message


setOutBody

public ProcessorType setOutBody(Expression expression)
Adds a processor which sets the body on the OUT message


setHeader

public ProcessorType setHeader(String name,
                               Expression expression)
Adds a processor which sets the header on the IN message


setOutHeader

public ProcessorType setOutHeader(String name,
                                  Expression expression)
Adds a processor which sets the header on the OUT message


setProperty

public ProcessorType setProperty(String name,
                                 Expression expression)
Adds a processor which sets the exchange property


convertBodyTo

public ProcessorType convertBodyTo(Class type)
Converts the IN message body to the specified type


convertOutBodyTo

public ProcessorType convertOutBodyTo(Class type)
Converts the OUT message body to the specified type


getErrorHandlerBuilder

public ErrorHandlerBuilder getErrorHandlerBuilder()

setErrorHandlerBuilder

public void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
Sets the error handler to use with processors created by this builder


isInheritErrorHandler

public boolean isInheritErrorHandler()

getInheritErrorHandlerFlag

public Boolean getInheritErrorHandlerFlag()

setInheritErrorHandlerFlag

public void setInheritErrorHandlerFlag(Boolean inheritErrorHandlerFlag)

makeProcessor

protected Processor makeProcessor(RouteContext routeContext)
                           throws Exception
Creates the processor and wraps it in any necessary interceptors and error handlers

Throws:
Exception

wrapProcessorInInterceptors

protected Processor wrapProcessorInInterceptors(RouteContext routeContext,
                                                Processor target)
                                         throws Exception
A strategy method which allows derived classes to wrap the child processor in some kind of interceptor

Parameters:
routeContext -
target - the processor which can be wrapped
Returns:
the original processor or a new wrapped interceptor
Throws:
Exception

wrapInErrorHandler

protected Processor wrapInErrorHandler(Processor processor)
                                throws Exception
A strategy method to allow newly created processors to be wrapped in an error handler.

Throws:
Exception

createErrorHandlerBuilder

protected ErrorHandlerBuilder createErrorHandlerBuilder()

configureChild

protected void configureChild(ProcessorType output)

addOutput

protected void addOutput(ProcessorType processorType)

createCompositeProcessor

protected Processor createCompositeProcessor(List<Processor> list)
Creates a new instance of some kind of composite processor which defaults to using a Pipeline but derived classes could change the behaviour


createOutputsProcessor

protected Processor createOutputsProcessor(RouteContext routeContext,
                                           Collection<ProcessorType> outputs)
                                    throws Exception
Throws:
Exception


Copyright © 2007 Apache Software Foundation. All Rights Reserved.