org.mule.routing
Class Foreach

java.lang.Object
  extended by org.mule.processor.AbstractMuleObjectOwner<MessageProcessor>
      extended by org.mule.processor.AbstractMessageProcessorOwner
          extended by org.mule.routing.Foreach
All Implemented Interfaces:
AnnotatedObject, FlowConstructAware, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, InterceptingMessageProcessor, MessageProcessor, MessageSource

public class Foreach
extends AbstractMessageProcessorOwner
implements Initialisable, InterceptingMessageProcessor

` * The Foreach MessageProcessor allows iterating over a collection payload, or any collection obtained by an expression, generating a message for each element.

The number of the message being processed is stored in #[variable:counter] and the root message is store in #[variable:rootMessage]. Both variables may be renamed by means of setCounterVariableName(String) and setRootMessageVariableName(String).

Defining a groupSize greater than one, allows iterating over collections of elements of the specified size.

The MuleEvent sent to the next message processor is the same that arrived to foreach.


Field Summary
static String COUNTER_PROPERTY
           
protected  Log logger
           
static String ROOT_MESSAGE_PROPERTY
           
 
Fields inherited from class org.mule.processor.AbstractMuleObjectOwner
flowConstruct, muleContext
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Fields inherited from interface org.mule.api.AnnotatedObject
PROPERTY_NAME
 
Constructor Summary
Foreach()
           
 
Method Summary
protected  List<MessageProcessor> getOwnedMessageProcessors()
           
 void initialise()
          Method used to perform any initialisation work.
 MuleEvent process(MuleEvent event)
          Invokes the MessageProcessor.
protected  MuleEvent processNext(MuleEvent event)
           
 void setBatchSize(int batchSize)
           
 void setCollectionExpression(String expression)
           
 void setCounterVariableName(String counterVariableName)
           
 void setListener(MessageProcessor listener)
          Set the MessageProcessor listener on a message source which will be invoked when a message is received or generated.
 void setMessageProcessors(List<MessageProcessor> messageProcessors)
           
 void setRootMessageVariableName(String rootMessageVariableName)
           
 
Methods inherited from class org.mule.processor.AbstractMessageProcessorOwner
getAnnotation, getAnnotations, getOwnedObjects, setAnnotations
 
Methods inherited from class org.mule.processor.AbstractMuleObjectOwner
dispose, getFlowConstruct, getMuleContext, setFlowConstruct, setMuleContext, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.api.lifecycle.Startable
start
 
Methods inherited from interface org.mule.api.lifecycle.Stoppable
stop
 
Methods inherited from interface org.mule.api.lifecycle.Disposable
dispose
 
Methods inherited from interface org.mule.api.context.MuleContextAware
setMuleContext
 
Methods inherited from interface org.mule.api.construct.FlowConstructAware
setFlowConstruct
 

Field Detail

ROOT_MESSAGE_PROPERTY

public static final String ROOT_MESSAGE_PROPERTY
See Also:
Constant Field Values

COUNTER_PROPERTY

public static final String COUNTER_PROPERTY
See Also:
Constant Field Values

logger

protected Log logger
Constructor Detail

Foreach

public Foreach()
Method Detail

process

public MuleEvent process(MuleEvent event)
                  throws MuleException
Description copied from interface: MessageProcessor
Invokes the MessageProcessor.

Specified by:
process in interface MessageProcessor
Parameters:
event - MuleEvent to be processed
Returns:
optional response MuleEvent
Throws:
MuleException

processNext

protected MuleEvent processNext(MuleEvent event)
                         throws MuleException
Throws:
MuleException

getOwnedMessageProcessors

protected List<MessageProcessor> getOwnedMessageProcessors()
Specified by:
getOwnedMessageProcessors in class AbstractMessageProcessorOwner

setListener

public void setListener(MessageProcessor listener)
Description copied from interface: MessageSource
Set the MessageProcessor listener on a message source which will be invoked when a message is received or generated.

Specified by:
setListener in interface MessageSource

setMessageProcessors

public void setMessageProcessors(List<MessageProcessor> messageProcessors)
                          throws MuleException
Throws:
MuleException

initialise

public void initialise()
                throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Overrides:
initialise in class AbstractMuleObjectOwner<MessageProcessor>
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

setCollectionExpression

public void setCollectionExpression(String expression)

setBatchSize

public void setBatchSize(int batchSize)

setRootMessageVariableName

public void setRootMessageVariableName(String rootMessageVariableName)

setCounterVariableName

public void setCounterVariableName(String counterVariableName)


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.