In this Document

  Goal
  Solution
  Overview
  Steps in writing Java Concurrent Program
  Template Program:
  Program Logic
  Program Parameters
  Database Operations
  Setting request Completion Status
  Register executable
  Register Concurrent Program
  Test Program from OS Prompt
  Sample Program
  Note:

APPLIES TO:

Oracle Concurrent Processing - Version 11.0.0 to 12.1.3 [Release 11 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?

SOLUTION

Overview

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(). The main() method, implemented by AOL, will 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 log and output files. CpContext will have the request specific log and output file input methods. The class name with the main method will be registered as the java executable file name in the register executable form
or by using pl/sql API.



Developer has to 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 goes to apps.zip file with package location ‘oracle/apps/wip/shopfloor/server/BackgroundProgram.class’.
Developer will register ‘BackgroundProgram’ as the executable file name and ‘oracle.apps.wip.shopfloor.server’ as the package path in the register executable form. Developer has to follow the java notation to register the package path location, ‘.’ to denote
the directory instead of ‘/’ in UNIX.



Java Concurrent Program parameters must register with token names in the parameter screen of the register concurrent programs form. Developer can get the value of the parameter for a given token name in the java concurrent program. These token names will be
used in passing the parameter values as parameter string to the concurrent program from the command line for testing the java concurrent program.



Developer should set the status and completion text for the java program by using the setCompletion() method provided by AOL. The runProgram() method should call setCompletion() method to report the program completion status to the Concurrent Manager. The program
may set its completion status to Normal, Warning or Error. Completion text is optional.

Steps in writing Java Concurrent Program

Template 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 requirement. 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 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 will 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 240 characters. If it is more

* than 240 then full string will appear in log file and truncated 240

* characters will 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 request 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.

Please refer AOL/J Parameter list to get the Parameter List name, value pairs. You will 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 screen.

Database Operations

Use getJDBCConnection method to get the connection object for any JDBC operations within program and release the connection to the AppsContext connection pool. Use CpContext's commit(), rollback() methods to commit
or rollback the transactions in the database. These methods will set the program proffered rollback segments after commit or rollback segments for the rest of the database transaction in the Java Concurrent Program.

Setting request Completion Status

Call setCompletion() method of the ReqCompletion object which is a member of CpContext before returning from your Java Concurrent 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 register concurrent executables form.

Register Concurrent Program

Register you Java Concurrent Program as concurrent program in the register concurrent program form. Register all the parameters that you want to pass to the program in the parameter screen 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 then the all the log file information will be printed to the standard output. Specify the 'request.requestid' to rerun already completed request. You can specify the all the application user specific
context values with -D to get the specific user context to the program when run from the OS prompt. Pass all the parameters if any by using the AOL/J Parameter list syntax.

Sample Program

package 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 is an example.  Oracle does not support this Sample in any way.

Customizations are not supported neither.

If you need additional assistance, please contact Oracle Consulting.

How to Create a Java Concurrent Program的更多相关文章

  1. Kafka中错误:Unrecognized VM option ‘UseCompressedOops’ Error: Clould not create the Java Vritual Machine. Error: A fatal exception has occurres . Program will exit.

    错误的描述: 在kafka安装目录下,执行 $ bin/zookeeper-server-start.sh config/zookeeper.properties & Unrecognized ...

  2. java virtual machine launcher Error:Could not create the Java Virtual Machine. Error:A Fatal exception has occurred,Program will exit.

    Error:Could not create the Java Virtual Machine. Error:A Fatal exception has occurred,Program will e ...

  3. Failed to create the java virtual machine完全解决办法

    一直用EcliPSe开发java,突然有这么一天,无法启动了,splash窗口显示“Failed to create the Java Virtual Machine”,结果发现eclipse和mye ...

  4. 关于打开Eclipse时出现eclipse failed to create the java virtual machine与locking is not possible in the direc

    原文转自:http://www.cnblogs.com/steararre/p/4037453.html 今天在机子上使用Eclipse时候打开发现这两个问题,通过查阅资料膜拜大神博客得知解决方法,特 ...

  5. 关于打开Eclipse时出现eclipse failed to create the java virtual machine与locking is not possible in the directory问题的解决

    今天在机子上使用Eclipse时候打开发现这两个问题,通过查阅资料膜拜大神博客得知解决方法,特此整理下来,方便后来遇到此问题的小伙伴们. 一开始打开Eclipse时候出现问题现象1,问题1解决以后就出 ...

  6. weblogic10.3 启动报错 Unrecognized option: -jrockit Error: Could not create the Java Virtual Machine

    今天在使用weblogic10.3+jdk7创建domain的时候,建好domain后启动报如下错误信息: Unrecognized option: -jrockitError: Could not ...

  7. weblogic安装使用: Could not Create the Java Virtual Machine

    第一次使用weblogic,完全不明白是怎么一回事!找安装包花了大把时间!找到了不知道怎么安装 -- _ --||| 找了一篇安装文档<weblogic 安装部署手册.doc>, 位于:[ ...

  8. Email the output of a concurrent program as Attachment

    This article illustrates the steps to be followed to Email a concurrent program's output. Write a pr ...

  9. Dependent Parameters in Concurrent Program using Special Value Set

    Dependent Parameters in Oracle Applications Requirement: Say there is a concurrent program that lets ...

随机推荐

  1. [C#参考]byte数组和Image的相互转换

    功能需求 1.把一张图片(png bmp jpeg bmp gif)转换为byte数组在内存中操作. 2.把内存中的byte数组转换成Image对象,赋值给相应的控件显示. 3.从图片byte数组得到 ...

  2. CSS技巧!像table一样布局div

    摘自:http://www.cnblogs.com/hnyei/archive/2011/09/19/2181442.html 许多网页设计师都喜欢,将两个或者多个容器等高的并排放置,并在里面展示每个 ...

  3. C语言之三大查找算法

    查找算法 1.二分查找 二分查找就是折半查找,其基本思想是:首先选取表中间位置的记录,将其关键字与给定关键字key进行比较,若相等,则查找成功.若key值比该关键字值大,则要找的元素一定在右子表中,则 ...

  4. SSL证书与Https应用部署小结

    为了提高网站的安全性,一般会在比较敏感的部分页面采用https传输,比如注册.登录.控制台等.像Gmail.网银等全部采用https传输. https/ssl 主要起到两个作用:网站认证.内容加密传输 ...

  5. dubbo 服务化

    当网站变大后,不可避免的需要拆分应用进行服务化,以提高开发效率,调优性能,节省关键竞争资源等. 当服务越来越多时,服务的URL地址信息就会爆炸式增长,配置管理变得非常困难,F5硬件负载均衡器的单点压力 ...

  6. CoreAnimation —— CALayer

    概述 如上篇博文讲述,UIView中封装了很多系统方法,可以满足我们的大部分需求.但是,其也有很多限制.那些方法产生的动画基本单元为UIView,是非常重量级的对象,而且也不支持三维布局,大部分是对视 ...

  7. 企业级IM应该帮助员工提高绩效,避免无关的信息干扰

    很多上班族一定熟悉如下的场景: 您早上上班一打开QQ,就弹出一个新闻集成窗口,随便点开看看吧,这一点不要紧,您就被一个又一个的链接带着逛下去了.等回过神来要工作的时候,发现已经在这些八卦新闻上浪费了一 ...

  8. Jquery 实现动态加入table tr 和删除tr 以及checkbox的全选 和 获取加入TR删除TR后的数据

    关于jquery实现动态加入table tr的问题我也不多说了 上面代码非常多地方都有凝视的 关于返回的 编辑后的table 数据 我这里想说的是我直接把他保存成一个连接起来的字符串了 格式 str= ...

  9. UIAlertView、UIActionSheet兼容iOS8

    链接地址:http://blog.csdn.net/nextstudio/article/details/39959895?utm_source=tuicool 1.前言 iOS8新增了UIAlert ...

  10. ViewPager,使用Fragment实现

    效果如图: 使用Fragment实现tab的缺点就是不能够滑动.不过应该也算优点,具体场景可以自由选择. 完整代码:imooc-tab022fragment,在我的百度云网盘上. MainAcgtiv ...