org.apache.commons.pipeline.stage
Class DynamicLookupStaticMethodStage

java.lang.Object
  extended by org.apache.commons.pipeline.stage.BaseStage
      extended by org.apache.commons.pipeline.stage.DynamicLookupStaticMethodStage
All Implemented Interfaces:
Stage

public class DynamicLookupStaticMethodStage
extends BaseStage

Provide this Stage with a class and a static method name and it will dynamically look up the appropriate method to call based on the object type. If the object type is an array, it will assume that the method that needs to be called contains the method signature as described by the objects in the array. The object returned from the method call will be exqueued.

The resulting object will be exqueued on the main pipeline if it is not null. If it is null, we will try to place the original object on the branch specified by the nullResultBranchKey property. The default for this value is "nullResult".


Field Summary
 
Fields inherited from class org.apache.commons.pipeline.stage.BaseStage
context
 
Constructor Summary
DynamicLookupStaticMethodStage(Class clazz, String methodName)
          Creates a new instance of DynamicLookupStaticMethodStage
DynamicLookupStaticMethodStage(String className, String methodName)
          Creates a new DynamicLookupStaticMethodStage for the specified class and static method.
 
Method Summary
 Class getMethodClass()
          Returns the class containing the method to be executed
 String getMethodName()
          Returns the name of the method to be executed.
 String getNullResultBranchKey()
          Getter for property nullResultBranchKey.
 void process(Object obj)
           Finds the appropriate method overloading for the method specified by methodName, calls it to process the object, and exqueues any returned object.
 void setNullResultBranchKey(String nullResultBranchKey)
          Setter for property nullResultBranchKey.
 
Methods inherited from class org.apache.commons.pipeline.stage.BaseStage
emit, emit, init, postprocess, preprocess, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicLookupStaticMethodStage

public DynamicLookupStaticMethodStage(Class clazz,
                                      String methodName)
Creates a new instance of DynamicLookupStaticMethodStage

Parameters:
clazz - The class that defines the static method that will be used to process objects.
methodName - The name of the method. This method may be overloaded.

DynamicLookupStaticMethodStage

public DynamicLookupStaticMethodStage(String className,
                                      String methodName)
                               throws ClassNotFoundException
Creates a new DynamicLookupStaticMethodStage for the specified class and static method.

Parameters:
className - The fully qualified class name of the class in which the static method that will be used to process objects is defined.
methodName - The name of the method. This method may be overloaded.
Throws:
ClassNotFoundException - if the specified class cannot be loaded.
Method Detail

process

public void process(Object obj)
             throws StageException

Finds the appropriate method overloading for the method specified by methodName, calls it to process the object, and exqueues any returned object. If the returned object is null, the original object is enqueued on the branch specified by the nullResultBranchKey property.

Specified by:
process in interface Stage
Overrides:
process in class BaseStage
Parameters:
obj - The object to process.
Throws:
StageException - an Exception thrown by an overriding implementation should be wrapped in a StageException

getMethodName

public String getMethodName()
Returns the name of the method to be executed.


getMethodClass

public Class getMethodClass()
Returns the class containing the method to be executed


getNullResultBranchKey

public String getNullResultBranchKey()
Getter for property nullResultBranchKey.

Returns:
Value of property nullResultBranchKey.

setNullResultBranchKey

public void setNullResultBranchKey(String nullResultBranchKey)
Setter for property nullResultBranchKey.

Parameters:
nullResultBranchKey - New value of property nullResultBranchKey.


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.