org.mule.processor
Class InvokerMessageProcessor

java.lang.Object
  extended by org.mule.processor.InvokerMessageProcessor
All Implemented Interfaces:
AnnotatedObject, MuleContextAware, Initialisable, MessageProcessor

public class InvokerMessageProcessor
extends Object
implements MessageProcessor, Initialisable, MuleContextAware, AnnotatedObject

InvokerMessageProcessor invokes a specified method of an object. An array of argument expressions can be provided to map the message to the method arguments. The method used is determined by the method name along with the number of argument expressions provided. The results of the expression evaluations will automatically be transformed where possible to the method argument type. Multiple methods with the same name and same number of arguments are not supported currently.


Field Summary
protected  List<?> arguments
           
protected  Class<?>[] argumentTypes
           
protected  ExpressionManager expressionManager
           
protected  Log logger
           
protected  Method method
           
protected  String methodName
           
protected  MuleContext muleContext
           
protected  String name
           
protected  Object object
           
protected  Class<?> objectType
           
protected  TemplateParser.PatternInfo patternInfo
           
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.AnnotatedObject
PROPERTY_NAME
 
Constructor Summary
InvokerMessageProcessor()
           
 
Method Summary
protected  MuleEvent createResultEvent(MuleEvent event, Object result)
           
protected  Object[] evaluateArguments(MuleEvent event, List<?> argumentTemplates)
           
protected  Object evaluateExpressionCandidate(Object expressionCandidate, MuleMessage message)
           
 Object getAnnotation(QName name)
          Gets the value of specified annotation.
 Map<QName,Object> getAnnotations()
          Gets all annotations.
 String getName()
           
 void initialise()
          Method used to perform any initialisation work.
protected  void lookupObjectInstance()
           
 MuleEvent process(MuleEvent event)
          Invokes the MessageProcessor.
protected  void resolveMethodToInvoke()
           
 void setAnnotations(Map<QName,Object> newAnnotations)
          Sets annotations to the object.
 void setArgumentExpressionsString(String arguments)
           
 void setArguments(List<?> arguments)
           
 void setArgumentTypes(Class<?>[] argumentTypes)
           
 void setMethodName(String methodName)
           
 void setMuleContext(MuleContext context)
           
 void setName(String name)
           
 void setObject(Object object)
           
 void setObjectType(Class<?> objectType)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected final transient Log logger

object

protected Object object

objectType

protected Class<?> objectType

methodName

protected String methodName

arguments

protected List<?> arguments

argumentTypes

protected Class<?>[] argumentTypes

name

protected String name

patternInfo

protected TemplateParser.PatternInfo patternInfo

method

protected Method method

expressionManager

protected ExpressionManager expressionManager

muleContext

protected MuleContext muleContext
Constructor Detail

InvokerMessageProcessor

public InvokerMessageProcessor()
Method Detail

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
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

resolveMethodToInvoke

protected void resolveMethodToInvoke()
                              throws InitialisationException
Throws:
InitialisationException

lookupObjectInstance

protected void lookupObjectInstance()
                             throws InitialisationException
Throws:
InitialisationException

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

evaluateArguments

protected Object[] evaluateArguments(MuleEvent event,
                                     List<?> argumentTemplates)
                              throws MessagingException
Throws:
MessagingException

evaluateExpressionCandidate

protected Object evaluateExpressionCandidate(Object expressionCandidate,
                                             MuleMessage message)
                                      throws TransformerException
Throws:
TransformerException

setObject

public void setObject(Object object)

setMethodName

public void setMethodName(String methodName)

setArgumentExpressionsString

public void setArgumentExpressionsString(String arguments)

setArguments

public void setArguments(List<?> arguments)

createResultEvent

protected MuleEvent createResultEvent(MuleEvent event,
                                      Object result)
                               throws MuleException
Throws:
MuleException

getName

public String getName()

setName

public void setName(String name)

setArgumentTypes

public void setArgumentTypes(Class<?>[] argumentTypes)

toString

public String toString()
Overrides:
toString in class Object

setMuleContext

public void setMuleContext(MuleContext context)
Specified by:
setMuleContext in interface MuleContextAware

setObjectType

public void setObjectType(Class<?> objectType)

getAnnotation

public final Object getAnnotation(QName name)
Description copied from interface: AnnotatedObject
Gets the value of specified annotation.

Specified by:
getAnnotation in interface AnnotatedObject
Returns:
the value of specified annotation

getAnnotations

public final Map<QName,Object> getAnnotations()
Description copied from interface: AnnotatedObject
Gets all annotations.

Specified by:
getAnnotations in interface AnnotatedObject
Returns:
all annotation

setAnnotations

public final void setAnnotations(Map<QName,Object> newAnnotations)
Description copied from interface: AnnotatedObject
Sets annotations to the object.

Specified by:
setAnnotations in interface AnnotatedObject


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