Why Oracle Forms and BPEL?
Old style Forms applications normally don’t hold much workflow functionality. Sure there is an order in which the forms should be used. The workflow of the application is in the mind and knowledge of the user. For my current project I am investigating, together with my colleague Peter Ebell, ways how we can use Oracle’s BPEL Workflow engine to enable workflow functionality in existing forms applications.
The idea is to implement a Java class that interacts between Oracle Forms and the BPEL Workflow enginge. This class we be embedded in a new workflow Form. This form will be used to startup the existing forms of the application. Goal is to make the existing application a workflow enabled application without modifying it. The workflow functionality should be an add-on and not a modification of existing applications.
I will describe the BPEL process and Java/Forms class in a future post. This post will describe how we embedded the Java class in the workflow form.
The Workflow Java class
The workflow Java class should return a list of object ID’s and form names. The form name will be used to startup the correct existing application form. The object ID should hold the primary key of the entity that should be queried by the form when it’s started up. Oracle BPEL’s workflow enginge holds worklists that determine these lists.
The embedded class should be available for both Forms developer and the forms server. That way the class be used at design and run time. For Forms developer the correct setting in the registry key FORMS_BUILDER_CLASSPATH should be set:
On the application server the Forms server configuration file default.env should be modified. Be sure to add the jar holding the Java class to the CLASSPATH variable.
Importing the Java class in Oracle Forms
Importing the Java class in Oracle Forms is very easy. Use the Import Java Classes funtion for that:
In the Import Java Class tool you can select the class that should be imported into Oracle Forms. You will only see classes that can be found in the FORMS_BUILDER_CLASSPATH registry entry.
The import of the Java class results in a machine generated PL/SQL wrapper package that can be used within Forms:
PACKAGE BODY TaskService IS
-- DO NOT EDIT THIS FILE - it is machine generated!
-- Constructor for signature ()V
FUNCTION new RETURN ORA_JAVA.JOBJECT IS
args := NULL;
RETURN (JNI.NEW_OBJECT('com/applied/bpel/worklist/TaskService', '()V', args));
-- Method: getTasksForUser (Ljava/lang/String;)[Ljava/lang/String;
a0 VARCHAR2) RETURN ORA_JAVA.JARRAY IS
args := JNI.CREATE_ARG_LIST(1);
RETURN JNI.CALL_OBJECT_METHOD(TRUE, NULL, 'com/applied/bpel/worklist/TaskService', 'getTasksForUser', '(Ljava/lang/String;)[Ljava/lang/String;', args);
That is basically it. The Java class that acts as a brigde between Oracle BPEL and Oracle forms can now be used to query the Oracle BPEL WF worklists:
-- Call out to Java to get the list of tasks
l_workstlist := TaskService.getTasksForUser('toDo');
-- How many strings did the Java return?
l_listLength := ORA_JAVA.GET_ARRAY_LENGTH(l_workstlist);
-- For each string, extract the details of the loan.
for i in 1..l_listLength loop
-- Get element i from the array of strings.
l_object_data := ORA_JAVA.GET_STRING_ARRAY_ELEMENT(l_workstlist, i-1);
l_sep_pos := instr(l_object_data, '|');
:wrklist.object_id := to_number(substr(l_object_data, 1, l_sep_pos - 1));
:wrklist.form_name := substr(l_object_data, l_sep_pos + 1);
:wrklist.object_name := get_object_name(substr(to_char(:wrklist.object_id),1,1), :wrklist.object_id);
if i != l_listLength
The code above performs a static call to the Java class and it populates a Forms block with the workflow data. This data can now be used to start the correct Forms as defined in the BPEL Workflow. The final form looks like this:
In a future post we will give more detail on the implementation of the Java class that interacts with Oracle Workflow. We will also post how we have used the ESB from Oracle as a legacy wrapper. That way we could expose existing functionality as a service that then could be used in a BPEL workflow.