How to build an Oracle Forms application on BPEL/WF

Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

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<br /><br />  --<br />  -- DO NOT EDIT THIS FILE - it is machine generated!<br />  --<br /><br />  args   JNI.ARGLIST;<br /><br />  -- Constructor for signature ()V<br />  FUNCTION new RETURN ORA_JAVA.JOBJECT IS<br />  BEGIN<br />    args := NULL;<br />    RETURN (JNI.NEW_OBJECT('com/applied/bpel/worklist/TaskService', '()V', args));<br />  END;<br /><br />  -- Method: getTasksForUser (Ljava/lang/String;)[Ljava/lang/String;<br />  FUNCTION getTasksForUser(<br />    a0    VARCHAR2) RETURN ORA_JAVA.JARRAY IS<br />  BEGIN<br />    args := JNI.CREATE_ARG_LIST(1);<br />    JNI.ADD_STRING_ARG(args, a0);<br />    RETURN JNI.CALL_OBJECT_METHOD(TRUE, NULL, 'com/applied/bpel/worklist/TaskService', 'getTasksForUser', '(Ljava/lang/String;)[Ljava/lang/String;', args);<br />  END;<br /><br /><br />BEGIN<br />  NULL;<br />END; <br />

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:

procedure populate_worklist<br />is<br />  l_workstlist 		ORA_JAVA.JARRAY;<br />  l_listLength   	NUMBER;<br />  l_object_data  	VARCHAR2(255);<br />  <br />  l_sep_pos       number;<br />BEGIN<br />	go_block('WRKLIST');<br />	clear_block(NO_COMMIT);<br />  -- Call out to Java to get the list of tasks<br />  l_workstlist := TaskService.getTasksForUser('toDo');<br /><br />  -- How many strings did the Java return?<br />  l_listLength := ORA_JAVA.GET_ARRAY_LENGTH(l_workstlist);<br /><br />  -- For each string, extract the details of the loan.<br />  for i in 1..l_listLength loop<br /><br />    -- Get element i from the array of strings.<br />    l_object_data := ORA_JAVA.GET_STRING_ARRAY_ELEMENT(l_workstlist, i-1);<br />    l_sep_pos := instr(l_object_data, '|');<br />           <br />    :wrklist.object_id := to_number(substr(l_object_data, 1, l_sep_pos - 1));<br />    :wrklist.form_name := substr(l_object_data, l_sep_pos + 1);<br />    :wrklist.object_name := get_object_name(substr(to_char(:wrklist.object_id),1,1), :wrklist.object_id);<br />    if i != l_listLength<br />    then<br />      next_record;<br />    end if;<br />  end loop;<br />  first_record;<br />END;<br /><br />

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.




Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

About Author

Comments are closed.