Oracle Java Concurrent Program
Goal
How to create a Java Concurrent Program?
Applied To
Oracle eBusiness Suite (EBS) R11/R12
Solution
First of all let me assure you that writing a Java Concurrent Program is an easy task,just need some basic skills of Java Programming.
Oracle EBS provides many java classes to support Java Concurrent Programming.The most important and common classes are as follows:
Most of the newbies raise the following common questions related to Java Concurrent Program:
Let us presume the name of your custom application is xxcust and the directory where we will keep your new custom Java class is request directory . And therequest is under cp . This means the fullyqualified path for our custom Java Class isoracle.apps.xxcust.cp.request.
Now you will be wondering where to create this above mentioned directory/package structure. You have to create this structure in the EBS Application Server under $JAVA_TOP. Since our directory structure starts withoraclefollowed byapps,both of these directories already exist. So to create our directory structure,follow the below steps:
$cd $JAVA_TOP/oracle/apps
$mkdir -p xxcust/cp/request
$cd xxcust/cp/request
$pwd
....../oracle/apps/xxcust/cp/request
And this is directory where you write your Java Class.
Structure of your Java Class
Oracle EBS provides an interface Class "JavaConcurrentProgram"with abstract methodrunProgram()which passes the concurrent processing context "CpContext". And you will write you business logic in the runProgram() method. TheCpContext will feed log and output file specific information to the runProgram method.The name of the custom class which will implement the JavaConcurrentProgram interface will be used in EBS to register it as a Java concurrent program Executable.
The basic structure of the Java Class (to be used as a concurrent program) is given below:
//**************Template.java****************************//
package oracle.apps.xxcust.cp.request;
import oracle.apps.fnd.cp.request.*;
public class Template implements JavaConcurrentProgram{
public void runProgram(CpContext ctx){
// Write your Business Logic here
//This line will signal successful end of the program to the concurrent manager.
ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL,"Completed");
}
}
//**************End of Template.java********************//
Example
Let us start writing a Java Concurrent program "Test.java" to do the following tasks:
//*************************Test.java****************************/
package oracle.apps.xxadfd.cp.request;
public classTestimplements JavaConcurrentProgram{
public void runProgram(CpContext ctx){
// get reference to Out and Log files
OutFile out = ctx.getOutFile();
LogFile log = ctx.getLogFile();
out.writeln("This is my Output file ! ");
log.writeln("This is my Log file",LogFile.STATEMENT);
//get concurrent program Request Details
ReqDetails rDet = ctx.getReqDetails();
String userName = rDet.getUserInfo().getUserName();
// write username to the Out File
out.writeln("User Name = "+userName);
// Success message to the Concurrent Manager
ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL,"Completed");
}
//***********************End of Test.java****************************/
Compile the Java Program Test.java
Make sure you are inside " $JAVA_TOP/oracle/apps/xxcust/cp/request " location,and run the following command:
$java Test[without extension]
It will generateTest.classfile in the current directory i.e. " ".
Program Registration in EBS
Registration of Executable
Executable: TestJavaProg[Any Meaningful Name]
Short Name: T estJavaProg [Any Meaningful short Name]
Application: Application Name[Select (Custom or any other) Application Name]
Execution Method: Java Concurrent Program
Execution File Name: Test [Name of our Java Class Compiled above]
Execution File Patch: oracle.apps.xxadfd.cp.request [Our Java Class Package Name]
Registration of Program
Program: Test Java Prog
Short Name: TESTJAVAPROG
Application: Application Name [Select any Application name]
Executable: TestJavaProg [Name of the Executable registered above]
Most of us write Concurrent Programs using the following Technologies:
- Oracle Reports
- PL/SQL Stored Procedure
- SQL*PLUS
- File handling (More efficient using Java instead of PL/SQL )
- Secure FTP of files between servers
- Networking
- Connecting to other non Oracle Databases
First of all let me assure you that writing a Java Concurrent Program is an easy task,just need some basic skills of Java Programming.
Oracle EBS provides many java classes to support Java Concurrent Programming.The most important and common classes are as follows:
- JavaConcurrentProgram.class
- CpContext.class
- LogFile.class
- OutFile.class
Most of the newbies raise the following common questions related to Java Concurrent Program:
- What is the starting point
- Where should I keep the Java file
- How to compile the Java class
- I know how toresistera concurrent program in EBS,but in case of Java Concurrent Program what should be the Execution File Path
Let us presume the name of your custom application is xxcust and the directory where we will keep your new custom Java class is request directory . And therequest is under cp . This means the fullyqualified path for our custom Java Class isoracle.apps.xxcust.cp.request.
Now you will be wondering where to create this above mentioned directory/package structure. You have to create this structure in the EBS Application Server under $JAVA_TOP. Since our directory structure starts withoraclefollowed byapps,both of these directories already exist. So to create our directory structure,follow the below steps:
$cd $JAVA_TOP/oracle/apps
$mkdir -p xxcust/cp/request
$cd xxcust/cp/request
$pwd
....../oracle/apps/xxcust/cp/request
And this is directory where you write your Java Class.
Structure of your Java Class
Oracle EBS provides an interface Class "JavaConcurrentProgram"with abstract methodrunProgram()which passes the concurrent processing context "CpContext". And you will write you business logic in the runProgram() method. TheCpContext will feed log and output file specific information to the runProgram method.The name of the custom class which will implement the JavaConcurrentProgram interface will be used in EBS to register it as a Java concurrent program Executable.
The basic structure of the Java Class (to be used as a concurrent program) is given below:
//**************Template.java****************************//
package oracle.apps.xxcust.cp.request;
import oracle.apps.fnd.cp.request.*;
public class Template implements JavaConcurrentProgram{
public void runProgram(CpContext ctx){
// Write your Business Logic here
//This line will signal successful end of the program to the concurrent manager.
ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL,"Completed");
}
}
//**************End of Template.java********************//
Example
Let us start writing a Java Concurrent program "Test.java" to do the following tasks:
- Write text to Output File
- Write Test to Log File
- Get userName of the concurrent Program run requester and write to Output File
- Send success message to the Concurrent Manager
//*************************Test.java****************************/
package oracle.apps.xxadfd.cp.request;
public classTestimplements JavaConcurrentProgram{
public void runProgram(CpContext ctx){
// get reference to Out and Log files
OutFile out = ctx.getOutFile();
LogFile log = ctx.getLogFile();
out.writeln("This is my Output file ! ");
log.writeln("This is my Log file",LogFile.STATEMENT);
//get concurrent program Request Details
ReqDetails rDet = ctx.getReqDetails();
String userName = rDet.getUserInfo().getUserName();
// write username to the Out File
out.writeln("User Name = "+userName);
// Success message to the Concurrent Manager
ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL,"Completed");
}
//***********************End of Test.java****************************/
Compile the Java Program Test.java
Make sure you are inside " $JAVA_TOP/oracle/apps/xxcust/cp/request " location,and run the following command:
$java Test[without extension]
It will generateTest.classfile in the current directory i.e. " ".
Program Registration in EBS
Registration of Executable
Executable: TestJavaProg[Any Meaningful Name]
Short Name: T estJavaProg [Any Meaningful short Name]
Application: Application Name[Select (Custom or any other) Application Name]
Execution Method: Java Concurrent Program
Execution File Name: Test [Name of our Java Class Compiled above]
Execution File Patch: oracle.apps.xxadfd.cp.request [Our Java Class Package Name]
Registration of Program
Program: Test Java Prog
Short Name: TESTJAVAPROG
Application: Application Name [Select any Application name]
Executable: TestJavaProg [Name of the Executable registered above]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。