|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface defines a custom activity that gets data field values,
performs a task, and finishes up by setting data field values in a
process instance. Apart from accessing data field values as input,
and setting values when it finishes, the ISimpleWorkPerformer class does
not have any other access to information on the work item or the process
instance. The perform
method is where you define the main
body of work that the activity accomplishes.
Method Summary | |
void |
destroy()
This method does any cleaning up that is needed when the application that uses the custom activity is unloaded. |
void |
init(java.util.Hashtable env)
This method performs initialization tasks required by the custom activity when the application starts. |
void |
perform(java.util.Hashtable in,
java.util.Hashtable out)
This method performs whatever tasks the activity needs to do. |
Method Detail |
public void init(java.util.Hashtable env) throws java.lang.Exception
init
method is
not executed each time a custom activity is created in
a process instance -- it is invoked only once when the application
starts. You would use the init
method to do things like
set up database connections that are shared by all instances of the
activity, or to define variables that are constant across all instances
of the activity.
It takes a hashtable of environment variables as its input argument. This hashtable is automatically passed to it when it is invoked. The parameters in the hashtable are defined in an XML description file.
The values of the parameters in the hashtable are determined by the process designer when creating the process map. For example, if the environment hash table includes a parameter Language, then when the process designer opens the properties editor for the custom activity in the Builder, they see a property called Language. Note that Language is not a data field -- it is a property of the custom activity.
Define the init
method to perform whatever initialization
tasks are desired. To get the value of a parameter in the environment
hashtable, call the get
method on the environment
hashtable. The get
method returns the value of the
parameter, or null if there is no such parameter. For example:
public void init( Hashtable environment )
throws Exception
{
String lang = (String) environment.get( "Language" );
Note: because of the lack of types in XML, all the values of the hashtable are strings.
env
- a hashtable that contains an element for each
ENVIRONMENT entry of the XML filejava.lang.Exception
- any exception will prevent the
application from loading itself.public void perform(java.util.Hashtable in, java.util.Hashtable out) throws java.lang.Exception
The input hashtable contains values taken from data fields, and the output hashtable contains values to put into data fields.
To get the value of a parameter in the input hashtable, call the
get
method on the input hashtable. This method returns
the value of the parameter, or null if there is no such parameter.
To set data field values, call put
on the output
hashtable. When the perform
method has finished
executing, the values in the output hashtable are automatically
inserted into the appropriate data fields according to the mapping
information in the XML description file.
This example gets the name of the user from a data field in the
process instance (exactly which data field is determined by the XML
description file) and puts a value in the WelcomeMsg parameter of
the output hashtable. This greeting is inserted automatically into a
data field, whose exact identity is again determined by the XML
description file.
public void perform( Hashtable input, Hashtable output )
throws Exception
{
// Get the value of the UserName parameter of the input hashtable.
//
String userName = (String) input.get( "UserName" );
// Throw an exception if no user name is available.
//
if( userName == null )
{
throw new Exception( "UserName has not been initialized!" );
}
// Generate a greeting.
//
String msg = "Hello " + userName;
// Put the greeting into the WelcomeMsg parameter of
// the output hashtable.
//
output.put( "WelcomeMsg", msg );
}
The XML description file specifies the parameters in the input hashtable, and indicates which data field provides the value for each parameter. The same file also specifies the parameters in the output hashtable, and indicates how the values of the output parameters are mapped back into data fields in the process instance.
in
- a hashtable of input parameters that usually
contain values of data fields in the process
instanceout
- a hashtable of output parameters that the work
performer generatesjava.lang.Exception
- all exceptions will be mapped to
the exception nodes based on the
exception mapping defined in the
XML file.public void destroy()
init
method.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |