EBS JAVA CONCURRENT

Oracle Java Concurrent Program

Goal

How to create a Java Concurrent Program?

Applied To

Oracle eBusiness Suite (EBS) R11/R12

Solution

Most of us write Concurrent Programs using the following Technologies:
  1. Oracle Reports
  2. PL/SQL Stored Procedure
  3. SQL*PLUS
But there are times when we require Java instead of Oracle native PL/SQL programming language. We require Java Programming especially (but not limited to) in the following cases:

  1. File handling (More efficient using Java instead of PL/SQL )
  2. Secure FTP of files between servers
  3. Networking
  4. 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
You can find full list of Java classes related to Java Concurrent Programming under Oracle EBS Application server atJAVA_TOP/oracle/apps/fnd/cp/request</strong>.</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Most of the newbies raise the following common questions related to Java Concurrent Program:</span></span><br><br><ol><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">What is the starting point</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Where should I keep the Java file</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">How to compile the Java class</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">I know how to&nbsp;resister&nbsp;a concurrent program in EBS, but in case of Java Concurrent Program what should be the Execution File Path</span></span></li></ol><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">The starting point is to create your own package where you will keep you custom Java Classes. In order to create your package, you should follow the Oracle Standards. As per the Oracle Standard, you should create the package using the following structure:</span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">&nbsp; oracle.apps.yourcustomappname.packagename.subpackage.....</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Let us presume the name of your custom application is&nbsp;</span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">xxcust</span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">&nbsp;and the directory where we will keep your new custom Java class is&nbsp;</span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">request</span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">&nbsp;</span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">directory</span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">. And the&nbsp;<strong>request&nbsp;</strong></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">directory&nbsp;</span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">is under&nbsp;</span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">cp&nbsp;</span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">directory</span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">. This means the fully&nbsp;qualified path for our custom Java Class is&nbsp;<strong>oracle.apps.xxcust.cp.request.</strong></span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">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 underJAVA_TOP. Since our directory structure starts withoracle followed by apps, both of these directories already exist. So to create our directory structure, follow the below steps:
cd JAVA_TOP/oracle/apps
mkdirpxxcust/cp/request</span></span><br><spanstyle="color:rgb(59,59,59);fontfamily:OpenSans,sansserif;"><spanstyle="lineheight:19.5px;"> cd xxcust/cp/request
pwd</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><strong>....../oracle/apps/xxcust/cp/request</strong></span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">And this is directory where you write your Java Class.</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"><br></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"><strong><em>Structure of your Java Class</em></strong></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Oracle EBS provides an interface Class "<strong>JavaConcurrentProgram</strong>"&nbsp;with abstract method&nbsp;<em>runProgram()&nbsp;</em>which passes the concurrent processing context "CpContext". And you will write you business logic in the runProgram() method. The&nbsp;CpContext 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.</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">The basic structure of the Java Class (to be used as a concurrent program) is given below:</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">//**************Template.java****************************//</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">package oracle.apps.xxcust.cp.request;</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">import oracle.apps.fnd.cp.request.*;</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">public class Template implements JavaConcurrentProgram{</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">&nbsp; &nbsp; public void runProgram(CpContext ctx){</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"><br></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">&nbsp; &nbsp; &nbsp; &nbsp; // Write your Business Logic here</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">&nbsp; &nbsp; &nbsp; &nbsp;</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//This line will signal successful end of the program to the concurrent manager.</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL, "Completed");</span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">&nbsp; &nbsp; }</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">}</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">//**************End of Template.java********************//</span><br><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><strong>Example</strong></span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">Let us start writing a Java Concurrent program "<strong>Test.java</strong>" to do the following tasks:</span><br><br><ol><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Write text to Output File</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Write Test to Log File</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Get userName of the concurrent Program run requester and write to Output File</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Send success message to the Concurrent Manager</span></span></li></ol><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Make sure you are inside "&nbsp;<em><strong>JAVA_TOP/oracle/apps/xxcust/cp/request ” location, and create the following Test.java file.
//********************Test.java***********************/
package oracle.apps.xxadfd.cp.request;
import oracle.apps.fnd.cp.request.;
public class Test implements 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 “ JAVATOP/oracle/apps/xxcust/cp/request</strong></span><spanstyle="color:rgb(59,59,59);fontfamily:OpenSans,sansserif;lineheight:19.5px;">"location,andrunthefollowingcommand:</span><br><spanstyle="color:rgb(59,59,59);fontfamily:OpenSans,sansserif;lineheight:19.5px;"> java Test [without extension]
It will generate Test.class file in the current directory i.e. ” $JAVA_TOP/oracle/apps/xxcust/cp/request “.

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]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值