Monday, March 24, 2008

Oracle Apps - Java Concurrent Program

Writing a Java Concurrent Program

Concurrent Processing provides an interface JavaConcurrentProgram with abstract method runProgram() which passes the concurrent processing context CpContext. The concurrent program developer will implement all of their business logic for a concurrent program in runProgram().
CpContext will have the request specific log and output file input methods. The class name with the runProgram() method will be registered as the java executable file name in the register executable form.

Follow the following generic format to write a Java Concurrent Program…

package oracle.apps.yourpackage.subpackage;

import oracle.apps.fnd.common.Context;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.cp.request.*;
import oracle.apps.fnd.util.*;

public class HelloWorldApp
implements JavaConcurrentProgram{
public void runProgram(CpContext ctx){

//Obtain the reference to the Output file for Concurrent Prog
OutFile out = ctx.getOutFile();

//Obtain the reference to the Log file for Concurrent Prog
LogFile log = ctx.getLogFile();


//To read parameters passed via Concurrent Program
String myName = null;
ParameterList lPara = ctx.getParameterList();
while (lPara.hasMoreElements())
NameValueType aNVT = lPara.nextParameter();
if ( aNVT.getName().equalsIgnoreCase("My Name") )
myName = aNVT.getValue(););

//Write your logic here

out.writeln("This will be printed to the Output File");

log.writeln("This will be printed to the Log File", 0);

//Request the completion of this Concurrent Prog
//This step will signal the end of execution of your Concurrent Prog
ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL,  "Completed.");
//Handle any exceptional conditions
catch(Exception e){
StackTraceElement ste[] = e.getStackTrace();
for(int i=0; i<ste.length; i++){
log.writeln(ste[i].toString(), 0);

Best Practice

As a best practice, use Oracle JDeveloper patched with the following patch number: 6012619. You can download it from Metalink. This patched release of JDeveloper includes all the FND packages and other requisite packages commonly used while writing Java Concurrent Programs. You may use Eclipse, but you will have to manually copy all the packages from Oracle Apps Server to your local machine and give its reference to the project.

Porting Third-Party Libraries

Ask the DBA to place all the requisite third-party libraries under $JAVA_TOP. To make the third-party libraries available to your JCP, follow the steps outlined below to create your Concurrent Program Executable and to create the actual Concurrent Program.

Create Concurrent Program Executable

Path: Concurrent -> Program -> Executable
Create the concurrent program executable, details of which are as follows:
Executable   : HelloWorld
Short Name   : HelloWorld
Application   : Custom Applications
Execution Method  : Java Concurrent Program
Execution File Name         : HelloWorldApp This is your main class file
Execution File Path  : oracle.apps.yourpackage.subpackage

Create the Concurrent Program

Path: Concurrent -> Program -> Define
We are having one concurrent program.
Program  : HelloWorld Java Concurrent Program
Application : Custom Applications
Description : Hello World Program
Executable Name : HelloWorld
Executable Method : Java Concurrent Program
Options  : -classpath  /dv00/oracle/product/DEV1110/java:/dv00/oracle/apps/DEV1110/11.5/au/11.5.0/java/
Note:- If your JCP does not make use of any Third-Party libraries, then please DO NOT put any entry in the Options.
The Options to be specified must be fully qualified. Use of environment variables will fail the execution of the Java Concurrent Program.
/dv00/oracle/product/DEV1110/java - This is the path to my $JAVA_TOP
/dv00/oracle/apps/DEV1110/11.5/au/11.5.0/java/ - This is the path to my $AU_TOP/java/
/dv00/oracle/product/DEV1110/java/thirdParty1.jar - This is the JAR reference to my first Third Party Library dependency.
/dv00/oracle/product/DEV1110/java/thirdParty2.jar - This is the JAR reference to my second Third Party Library dependency.
The paths must be set for appropriate environment as specified above and must be separated using a colon “:” without any new-line characters.

Keywords: apps software,concurrent application,concurrent applications,concurrent tutorial,java application,java concurrent program,java concurrent programming,java example,java examples,
java programming,java sample,java sample code,java source code,java tutorial,java tutorial program,oracle resume


Anonymous said...

Is it possible to run this code in Jdeveloper.

Sank "Da Devil" Daru said...

Yes. As mentioned in the post, use the patched JDeveloper.

Anonymous said...

I tried the patch 6739235 as our DBA's suggested that for our config. I am not seeing the Fnd.cp & fnd.util files. I tried to run your sample its throwing me ," cannot access directory error fnd\cp\request.., Verify directory is reachable from class path." . How do i get the files to fix? Thanks for your help. -SK

Sank "Da Devil" Daru said...

Can you please provide your environment (apps/java/jdk/os) details?

This post was targeted against Apps 1110.

Zhan said...

Great job!!! After many hours of digging I finally found how to setup properly the classpath for my concurrent program! Thank you so much!