de.danet.an.workflow.api
Class MethodInvocationBatch

java.lang.Object
  extended byde.danet.an.workflow.api.MethodInvocationBatch
All Implemented Interfaces:
Batch, java.io.Serializable

public class MethodInvocationBatch
extends java.lang.Object
implements Batch, java.io.Serializable

This class provides a Batch implementation that executes several invocations of remote objects on the server in a single transaction and returns the results. This class can be thought of as a "generic DTO".

Version:
$Revision: 1.5 $
Author:
See Also:
Serialized Form

Nested Class Summary
 class MethodInvocationBatch.Result
          The result of an execution of this kind of batch.
 
Nested classes inherited from class de.danet.an.workflow.api.Batch
Batch.Context
 
Constructor Summary
MethodInvocationBatch()
          Create a new empty method invocation batch.
MethodInvocationBatch(boolean stopOnException)
          Create a new empty method invocation batch.
 
Method Summary
 void addInvocation(int result, java.lang.String method, java.lang.String[] argTypes, java.lang.Object[] args, boolean discard)
          Adds a method invocation on a previous result to the batch.
 void addInvocation(java.lang.Object obj, java.lang.String method, java.lang.String[] argTypes, java.lang.Object[] args)
          Adds a method invocation to the batch.
 java.lang.Object execute(Batch.Context ctx)
          Executes the registered method invocations one by one in a single transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodInvocationBatch

public MethodInvocationBatch()
Create a new empty method invocation batch. Equivalent to MethodInvocationBatch(false).


MethodInvocationBatch

public MethodInvocationBatch(boolean stopOnException)
Create a new empty method invocation batch. The flag passed as parameter controls if an exception stops the batch execution.

Parameters:
stopOnException - if true execution is interrupted on the first encountered exception
Method Detail

addInvocation

public void addInvocation(java.lang.Object obj,
                          java.lang.String method,
                          java.lang.String[] argTypes,
                          java.lang.Object[] args)
Adds a method invocation to the batch.

Parameters:
obj - the objects whose method is to be invoked.
method - the method name.
argTypes - the argument types as strings suitable for ClassLoader.loadClass. May be null which is interpreted as "no parameters".
args - the actual arguments. May be null which is interpreted as "no parameters".

addInvocation

public void addInvocation(int result,
                          java.lang.String method,
                          java.lang.String[] argTypes,
                          java.lang.Object[] args,
                          boolean discard)
Adds a method invocation on a previous result to the batch.

Parameters:
result - relative index of the result to be used for method invovation, i.e. -1 is the previous result.
method - the method name.
argTypes - the argument types as strings suitable for ClassLoader.loadClass. May be null which is interpreted as "no parameters".
args - the actual arguments. May be null which is interpreted as "no parameters".
discard - if true the referenced result will be removed from the result list.

execute

public java.lang.Object execute(Batch.Context ctx)
Executes the registered method invocations one by one in a single transaction. Note that execution is terminated if an invoked method sets rollback only.

Specified by:
execute in interface Batch
Parameters:
ctx - the execution context.
Returns:
the execution result, which is of type Result.