Skip Headers

Oracle Workflow API Reference
Release 2.6.3

Part Number B10286-02
Previous Next       Contents Index Glossary
         Previous  Next          Contents  Index  Glossary

Oracle Workflow Java Interface

The Oracle Workflow Java interface provides a means for any Java program to integrate with Oracle Workflow. The Oracle Workflow Engine and Notification APIs are accessible through public server PL/SQL packages and published views. The Oracle Workflow Java interface exposes those APIs as Java methods that can be called by any Java program to communicate with Oracle Workflow. The Java methods directly reference the WF_ENGINE and WF_NOTIFICATION PL/SQL package procedures and views and communicate with the Oracle Workflow database through JDBC.

The methods are defined within the WFEngineAPI class and the WFNotificationAPI class, in the Java package 'oracle.apps.fnd.wf.engine'. If a Workflow Engine or Notification API has a corresponding Java method, its Java method syntax is displayed immediately after its PL/SQL syntax in the documentation. See: Workflow Engine APIs and Notification APIs.

Additionally, Java functions can be incorporated within Workflow processes as external Java function activities. This functionality is currently only available for the standalone version of Oracle Workflow. The custom Java classes for these activities are implemented as classes that extend the WFFunctionAPI class. The custom classes must follow a standard API format so that they can be properly executed by the Oracle Workflow Java Function Activity Agent. See: Standard API for Java Procedures Called by Function Activities, Oracle Workflow Developer's Guide and Function Activity, Oracle Workflow Developer's Guide.

The WFFunctionAPI class and the WFAttribute class also contain methods that can be called to communicate with Oracle Workflow. These classes are defined in the Java package 'oracle.apps.fnd.wf'. See: Workflow Function APIs and Workflow Attribute APIs.

Java programs that integrate with Oracle Workflow should include the following import statements to provide access to classes required by Oracle Workflow:

import java.io.*;
import java.sql.*;
import java.math.BigDecimal;

import oracle.sql.*;
import oracle.jdbc.driver.*;

import oracle.apps.fnd.common.*;
import oracle.apps.fnd.wf.engine.*;
import oracle.apps.fnd.wf.*;

Oracle Workflow Context

Each Oracle Workflow Java method that accesses the database requires an input of a WFContext object. The WFContext object consists of database connectivity information which you instantiate and resource context information that the WFContext class instantiates. To call one of these Workflow Java APIs in your Java program, you must first instantiate a database variable of class WFDB with your database username, password and alias. You can also optionally supply a JDBC string. Then you must instantiate the WFContext object with the database variable. You can retrieve the system property CHARSET to specify the character set for the database session. The following code excerpt shows an example of how to instantiate these objects.

WFDB myDB;
WFContext ctx;
myDB = new WFDB(m_user, m_pwd, m_jdbcStr, m_conStr);
m_charSet = System.getProperty("CHARSET");
if (m_charSet == null) { // cannot be null
m_charSet = "UTF8";
}
try {
ctx = new WFContext(myDB, m_charSet);
// m_charSet is 'UTF8' by default

if (ctx.getDB().getConnection() == null) {
// connection failed
return;
}
// We now have a connection to the database.
}

catch (Exception e) {
// exit Message for this exception
}

If you have already established a JDBC connection, you can simply set that connection into the WFContext object, as shown in the following example:

WFContext ctx;
m_charSet = System.getProperty("CHARSET");
if (m_charSet == null) { // cannot be null
m_charSet = "UTF8";
}

ctx = new WFContext(m_charSet);
// m_charSet is 'UTF8' by default
ctx.setJDBCConnection(m_conn);
// m_conn is a pre-established JDBC connection

The Oracle Workflow Java APIs can be used safely in a thread, with certain restrictions:

There is no synchronized code inside the Oracle Workflow Java APIs, but there are no shared resources, either.

There is also no connection pooling in the Oracle Workflow Java APIs. For Oracle Applications, connection pooling is implemented at the AOL/J level; after you get the JDBC connection, you use the WFContext.setJDBCConnection() API to set the connection. This approach lets you manage your JDBC connection outside of the Oracle Workflow APIs.

Sample Java Program

Oracle Workflow provides an example Java program that illustrates how to call most of the Workflow Engine and Notification Java APIs. The Java program is named WFTest. It calls the various Java APIs to launch the WFDEMO process, set and get attributes and suspend, resume and abort the process, as well as the APIs to send a notification, set and get notification attributes, and delegate and transfer the notification. Before running the WFTest Java program, make sure you define CLASSPATH and LD_LIBRARY_PATH for the Oracle JDBC implementation and a supported version of Oracle. For example, on UNIX, use the following commands:

setenv CLASSPATH
<Workflow_JAR_file_directory>/wfapi.jar:${ORACLE_HOME}/jdbc/lib/classes111.zip
setenv LD_LIBRARY_PATH ${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
Note: If you are using the standalone version of Oracle Workflow, the Workflow JAR files are located in the <ORACLE_HOME>/jlib directory. If you are using the version of Oracle Workflow embedded in Oracle Applications, the Workflow JAR files are located in the <ORACLE_HOME>/wf/java/oracle/apps/fnd/wf/jar/ directory.

To initiate the WFTest program, run Java against oracle.apps.fnd.wf.WFTest. For example, on UNIX, enter the following statement on the command line:

$java oracle.apps.fnd.wf.WFTest

The source file for this program is also included in your Oracle Workflow installation so that you can view the sample code. The source file is named WFTest.java and is located in the <ORACLE_HOME>/wf/java/oracle/apps/fnd/wf/ directory.


         Previous  Next          Contents  Index  Glossary


Oracle Logo
Copyright © 2003 Oracle Corporation.

All rights reserved.