How to Add our own java custom extension in ITIM workflow:
There are different approaches for calling our own java
methods or classes in ITIM Workflows.
One of those examples is the custom java extension in ITIM
workflow.
There are three main steps to be done for adding an custom
extension in ITIM workflows:
l
Creating the jar of the java code.
Step 1 : Write your code which you want to execute while
executing the workflow in the below format.
1.The
code format
package com.<Package name>;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.List;
import java.util.Vector;
import org.apache.axis.AxisFault;
import
com.ibm.itim.workflow.application.*;
import
com.ibm.itim.workflow.model.*;
public class <classname> implements WorkflowApplication
{
public <classname>()
{
}
WorkflowExecutionContext
ctx;
public void
setContext(WorkflowExecutionContext ctx)
{
this.ctx = ctx;
}
public ActivityResult success(String param)
{
System.out.println("Success"+param);
return new ActivityResult();
}
public ActivityResult failure()
{
// Return with success, no message
System.out.println("Failure");
return new ActivityResult(ActivityResult.STATUS_ABORT, "Error
message.");
}
public ActivityResult <Method name>(<Parameters required for
your method>) {
try {
<write you
code here>
If
it is successful then call then return the below success message.
return new ActivityResult(ActivityResult.SUCCESS);
If
it is not successfully executed then return the below message.
return new ActivityResult(ActivityResult.WARNING, "<Your own custom
message>", null);
} catch (MalformedURLException e1)
{
System.out.println("MalformedURLException : "+e1);
e1.printStackTrace();
return new
ActivityResult(ActivityResult.WARNING, "MalformedURLException
Error message.", null);
} catch (AxisFault e2) {
System.out.println("AxisFault : "+e2);
e2.printStackTrace();
return new
ActivityResult(ActivityResult.WARNING, "AxisFault Error
message.",null);
} catch (RemoteException e3) {
System.out.println("RemoteException : "+e3);
// TODO Auto-generated catch block
e3.printStackTrace();
return new
ActivityResult(ActivityResult.WARNING, "RemoteException
Error message.",null);
}
}
2.Now
make a jar file of the above method without including the supporting jars while
making the jar file.
3.Now
the supporting jars which are required for executing your code should be added
to the itim reference libraries
Step 2: Modifying the properties file in itim:
1.Add
the java package and class reference in the scriptframework.properties file in
the itim data folder in the below format.
ITIM.java.access.<extension name>=<Package name as
well as classname>
Eg:- ITIM.java.access.AppExt=com.company.AppExtExample
Step 3: Modifying the extensions file in itim to include
the methods:
1.Now
modify the workflowextensions.xml file (i.e) add the below lines to the xml
file.
<ACTIVITY
ACTIVITYID="<method name>" LIMIT="0">
<IMPLEMENTATION_TYPE>
<APPLICATION
CLASS_NAME="<Package name as well as
classname>"
METHOD_NAME="<method name>"
/>
</IMPLEMENTATION_TYPE>
<PARAMETERS>
<IN_PARAMETERS
PARAM_ID="<name of parameter>" TYPE="<type of
datatype>" />
</PARAMETERS>
</ACTIVITY>
2.You
need to do the above activity for each method you want to invoke in your java
extension.
Eg:- if you have three methods you need to write the above
lines three times with each method details in them the above lines are only for
one method.
3.Now
restart the Websphere including the ITIM application, appserver, nodes and
dmgr.
4.After
restarting go to the itim console and open any of the workflow and in the
extension click on the available methods you should find your method in that
options.
References:-
No comments:
Post a Comment