In this Document
|
Steps in writing Java Concurrent program |
|
Setting Request Completion Status |
|
Register Concurrent Program |
|
Test program from OS Prompt |
Applies To:Oracle Concurrent processing-version 11.0.0 to 12.1.3 [Release one to 12.1]
information in this document applies to any platform.
***checked for relevance on 01-oct-2014***
GOAL
How to create a Java Concurrent program?
Solutionoverview
Concurrent processing provides an interface ' Javaconcurrentprogram ' with abstract Method Runprogram () which passes the con Current processing context ' cpcontext '. The concurrent program developer would implement all of their business logic for a concurrent program in Runprogram (). The main () method, implemented by AOL, would call Runprogram () after performing all of the required initialization for the Concurrent program, including establishing a database connection, initializing the required contexts, and setting up the L OG and output files. Cpcontext would have the request specific log and output file input methods. The class name with the main method is registered as the Java executable file name in the Register executable form or By using the PL/SQL API.
Developer has-register the full package, path for the class in register executable form. For example, if WIP product creates a class in $WIP _top/java/shopfloor/server/backgroundprogram.class, then this class GoE s to apps.zip file with the package location ' Oracle/apps/wip/shopfloor/server/backgroundprogram.class '. Developer would register ' Backgroundprogram ' as the executable file name and ' Oracle.apps.wip.shopfloor.server ' as the pack Age path in the Register executable form. Developer have to follow the Java notation to register the package path location, '. ' to denote the directory instead of '/ ' In UNIX.
Java Concurrent Program parameters must registers with tokens names in the parameter screens of the register Concurrent progr AMS form. Developer can get the value of the parameter for a given token name in the Java concurrent program. These token names'll be used in passing the parameter values as parameter string to the concurrent program from the Comm Testing the Java concurrent program.
Developer should set the status and completion text for the Java program by using the Setcompletion () method provided by A Ol. The Runprogram () method should call Setcompletion () method for the program completion status to the Concurrent Manag Er. The program may set it completion status to Normal, Warning or Error. Completion text is optional.
Steps in writing Java Concurrent programtemplate Program:
You need to create the directory under $FND _top "manually First,
e.g. $FND _top/java/cp/request
Then copy the Template.java from the coding block below.
Copy the template Java Concurrent program to $FND _top/java/cp/request/template.java and start coding according to your REQ Uirement. Change file name and class name to your required name as Java Concurrent program name.
================= template.java===========================
Package oracle.apps.fnd.cp.request;
Change the package name to the required one.
Import all of the other required classes/packages.
Import oracle.apps.fnd.util.*;
Import oracle.apps.fnd.cp.request.*;
Change the name of the class from Template to your concurrent program
Class name
public class Template implements Javaconcurrentprogram
{
/** optionally provide class constructor without any arguments.
* If you provide any arguments to the class constructor then while
* Running the program would fail.
*/
public void Runprogram (Cpcontext pcpcontext)
{
Reqcompletion LRC = Pcpcontext.getreqcompletion ();
String completiontext = "";
/* Code your program logic here.
* Use Getjdbcconnection method to get the connection object for any
* JDBC operations.
* Use Cpcontext provided commit,rollback methods to Commit/rollback
* Data base transactions.
* Don ' t forget to release the connection before returning from this
* method.
*/
/* Call setcompletion method to set the request completion status and
* Completion text.
* Status values are reqcompletion.normal,reqcompletion.warning,
* Reqcompletion.error.
* Use completion text message of length characters. If it is more
* than full string would appear in log file and truncated 240
* Characters'll be used as request completion text.
*/
Lrc.setcompletion (Reqcompletion.normal, Completiontext);
}
}
==================end of template.java===========================
Program Logic
Implement the Runprogram with your Java Concurrent program business logic. Runprogram () gets the cpcontext. Cpcontext is a subclass of Aol/j Appscontext which provides the request specific member classes LogFile to write to Reques T log file, OutFile to write to request output file and reqcompletion to set the completion status of the request.
Program Parameters
Cpcontext uses the aol/j utility Parameter List to pass the parameters to the Java Concurrent program.
Refer aol/j Parameter list to get the Parameter list name, value pairs. You'll be referring parameter list name as the parameter name and corresponding value as the parameter value in the Java Concurrent program. You have to register the parameter names as token name in the Register concurrent program form parameter.
Database Operations
Use Getjdbcconnection method to get the connection object for any JDBC operations within program and release the Connectio N to the Appscontext connection pool. Use Cpcontext's commit (), rollback () methods to commit or rollback the transactions in the database. These methods would set the program proffered rollback segments after commit or rollback segments for the rest of the Datab ASE transaction in the Java Concurrent program.
Setting Request Completion Status
Call Setcompletion () method of the Reqcompletion object which are a member of Cpcontext before returning from your Java Con Current program to set the completion status for the program and optional completion text.
Register Executable
Register Your Java Concurrent program class name as Execution_file_name and package name in Execution_file_path in Registe R concurrent Executables form.
Register Concurrent Program
Register you Java Concurrent program as Concurrent program in the Register Concurrent program form. Register all the parameters, want to pass to the program in the parameter screens of this form. Register the Parameter List names referred in the program as the "token names in the" Parameter screen.
Test program from OS Prompt
You can test your Java Concurrent program from OS prompt by using the following syntax:
JAVA-DDBCFILE=<DBC filename with full path>
[-drequest.logfile=<logfile name>]
[-drequest.requestid=<request id>]
[-drequest.outfile=<output file name>]
[-drequest.userid=<user id>]
[-drequest.respapplid=<resp Appl id>]
[-drequest.respid=<resp id>]
[-drequest.secgrpid=<sec GRP id>]
[-drequest.enabletrace=<y/n>]
Oracle.apps.fnd.cp.request.Run <program/class name>
[<parameters>]
Example:
Java-ddbcfile=/d2/fnd/secure/appsnode_appdb.dbc
-dreqeust.requestid=23453-drequest.logfile=./myreq.log
Oracle.apps.fnd.cp.request.Run Oracle.apps.wip.program.MyProg
"Token1=value1:token2=value2"
If you don ' t specify the ' request.logfile ' with-d option and the all the log file information'll be printed to the STA Ndard output. Specify the ' Request.requestid ' to rerun already completed request. You can specify the ' all ' application user specific context values with-d to get the specific user context to the Progr Am when run from the OS prompt. Pass all the parameters if any by using the Aol/j Parameter list syntax.
Sample Programpackage oracle.apps.fnd.cp.request;
Import java.io.*;
Import java.sql.*;
Import oracle.apps.fnd.util.*;
public class Availableprog implements Javaconcurrentprogram
{
String Applname;
Public Availableprog ()
{
If no parameter value is specified for applname then use FND
As default value
Applname = "FND";
}
public void Runprogram (Cpcontext pcpcontext)
{
Get the JDBC Connection object
Connection mjconn = Pcpcontext.getjdbcconnection ();
Get parameter list Object from Cpcontext
Parameterlist Lpara = Pcpcontext.getparameterlist ();
Get Reqcompletion object from Cpcontext
Reqcompletion LRC = Pcpcontext.getreqcompletion ();
String Lquery =
"Select substr (user_concurrent_program_name,1,70)," +
"Decode (Enabled_flag, ' Y ', ' enabled ', ' N ', ' Disabled ')" +
"From FND_CONCURRENT_PROGRAMS_VL CP, FND_APPLICATION_VL a" +
"Where cp.application_id = a.application_id" +
"And A.application_short_name =?" +
"ORDER by 1";
Check for the Applname parameter token name and if it there get
Value and use it as the application short name in the query
while (Lpara.hasmoreelements ())
{
Namevaluetype ANVT = Lpara.nextparameter ();
if (Anvt.getname (). Equals ("Applname"))
Applname = Anvt.getvalue ();
}
Try
{
PreparedStatement lstmt = mjconn.preparestatement (lquery);
Lstmt.setstring (1, applname);
ResultSet lRs = Lstmt.executequery ();
Get OutFile object from Cpcontext
OutFile LOF = Pcpcontext.getoutfile ();
Get LogFile object from Cpcontext
LogFile LLF = Pcpcontext.getlogfile ();
Llf.writeln ("Generating Programs for application:" + Applname,
Logfile.statement);
Lof.writeln (
"Available Concurrent Programs for application" +
Applname);
Lof.writeln (
"Concurrent program Name Enabled");
Lof.writeln (
"-----------------------------------------------------------" );
while (Lrs.next ())
{
Lof.writeln (lrs.getstring (1) + "" + lrs.getstring (2));
}
Llf.writeln ("Generated Programs for Application:" + Applname,
Logfile.statement);
Lstmt.close ();
Lrc.setcompletion (Reqcompletion.normal, "Request completed NORMAL");
}
catch (SQLException e)
{
Lrc.setcompletion (Reqcompletion.error, e.tostring ());
}
Finally
{
Pcpcontext.releasejdbcconnection ();
}
}
}
Note:
This was an example. Oracle does not the support this Sample in any the.
Customizations is not supported neither.
If you need additional assistance and contact Oracle Consulting.
How to Create a Java Concurrent program