biz.hammurapi.dataflow
Class JavaMethodDataPipe

java.lang.Object
  extended by biz.hammurapi.dataflow.JavaMethodDataPipe
All Implemented Interfaces:
DataPipe, DataSink, DataSource

public class JavaMethodDataPipe
extends java.lang.Object
implements DataPipe

Data pipe wrapper for Java method. Input data items are named after method parameters. Wrapped method shall be compiled with debug on for correct resolution of parameter names. If parameter names cannot be resolved, they are automatically named arg0, ...

Author:
Pavel

Field Summary
static java.lang.String ERROR
           
static java.lang.String RESULT
           
 
Constructor Summary
JavaMethodDataPipe(java.lang.reflect.Method method, java.lang.Object instance, java.lang.String returnName, boolean beanToData, boolean iterateOverReturn)
          Creates data pipe which invokes given method.
 
Method Summary
 boolean addData(Data data)
          Adds data to the sink.
 boolean controlsMultiplexing()
           
protected  java.lang.Object convert(java.lang.Object src, java.lang.Class targetType)
          Converts input data item to target type.
protected  Data createData(java.util.Map newValues, Data chain)
          Creates new data with return values or error.
 DataItemInfo[] getDataInfo()
           
 java.lang.String getName()
           
 void setExceptionHandler(java.lang.Class exceptionType, DataSink sink)
          Sets exception handler.
 void setSink(DataSink sink)
          Adds data sink to the source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final java.lang.String ERROR
See Also:
Constant Field Values

RESULT

public static final java.lang.String RESULT
See Also:
Constant Field Values
Constructor Detail

JavaMethodDataPipe

public JavaMethodDataPipe(java.lang.reflect.Method method,
                          java.lang.Object instance,
                          java.lang.String returnName,
                          boolean beanToData,
                          boolean iterateOverReturn)
Creates data pipe which invokes given method.

Parameters:
method - Method.
instance - Instances to invoke method against.
returnName - If beanToData is false, return value is stored in returnName data item. If beanToData is true, return name prefixes bean property names, unless it is null. If beanToData is false and returnName is null, then returnName defaults to "result". If method return type is Data then values from it are copied to output prefixed with return name or as-is if return name is null.
beanToData - If true return value Java Bean is converted to Data using BeanData class.
iterateOverReturn - If true and return value is collection or iterator, then the return value is iterated over.
Method Detail

addData

public boolean addData(Data data)
Description copied from interface: DataSink
Adds data to the sink.

Specified by:
addData in interface DataSink
Returns:
true if data was "consumed" and shall be removed from further processing. If this sink is attached to a multiplexor, then the multiplexor shall not continue adding given data to "sibling" sinks.

controlsMultiplexing

public boolean controlsMultiplexing()
Specified by:
controlsMultiplexing in interface DataSink
Returns:
true if this sink controls multiplexing to "sibling" sinks, i.e. if addData() can return true.

getDataInfo

public DataItemInfo[] getDataInfo()
Specified by:
getDataInfo in interface DataSink
Returns:
Information about data items expected/required by the sink.

getName

public java.lang.String getName()
Specified by:
getName in interface DataSource

setSink

public void setSink(DataSink sink)
Description copied from interface: DataSource
Adds data sink to the source. Data source multiplexes data it produces to all sinks unless one of sinks returns true from addData(), which terminates multiplexing.

Specified by:
setSink in interface DataSource

setExceptionHandler

public void setExceptionHandler(java.lang.Class exceptionType,
                                DataSink sink)
Sets exception handler. Handlers are evaluated in the order of generality, i.e. handlers are never shadowed.

Parameters:
exceptionType -
sink -

convert

protected java.lang.Object convert(java.lang.Object src,
                                   java.lang.Class targetType)
Converts input data item to target type. This implementation used ConvertingService, override as needed.

Parameters:
src - Source object
targetType -
Returns:

createData

protected Data createData(java.util.Map newValues,
                          Data chain)
Creates new data with return values or error. This implementation creates Map data.

Parameters:
newValues -
chain -
Returns:


Copyright © 2005 Hammurapi Group. All Rights Reserved.