Oracle Apps Java Concurrent Program

Oracle Apps Java Concurrent Program

We can build Java concurrent programs to use java capabilities. 

Following are some steps 

1. Create and compile java Class in jDeveloper.

  1. my suggestion is to create Java class package oracle.apps.fnd.cp.request
  2. Java class must implements JavaConcurrentProgram

Sample Java Class

package oracle.apps.fnd.cp.request;

 

 

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.FileWriter;

import java.io.IOException;

import java.io.PrintWriter;

import java.io.StringWriter;

 

import java.security.NoSuchProviderException;

 

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

 

import java.text.SimpleDateFormat;

 

import java.util.Date;

 

import oracle.apps.fnd.util.ParameterList;

 

import oracle.jdbc.OracleCallableStatement;

 

public class JavaConcRestAPIClient implements JavaConcurrentProgram {

    String pDate;

 

    public JavaConcRestAPIClient() {

    }

 

    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();

 

        // get OutFile object from CpContext 

        OutFile lOF = pCpContext.getOutFile();

 

        // get LogFile object from CpContext 

        LogFile lLF = pCpContext.getLogFile();

 

        // value and use it as the application short name in the query 

        while (lPara.hasMoreElements()) {

            NameValueType aNVT = lPara.nextParameter();

            if (aNVT.getName().equals("pdate"))

                pDate = aNVT.getValue();

        }

      lOF.writeln("+--------------------------------------+");

      lOF.writeln("My Concurrent Program REST API Client");

      lOF.writeln("+---------------------------------------+");

      lOF.writeln("");

 

      try {

         

      lOF.writeln("+---------------------------------------+");

      lOF.writeln("Calling API ");

      lOF.writeln("+----------------------------------------+");

      lOF.writeln("");

 

        try {

 

            URL url;

                url = new URL("http://dummy.restapiexample.com/api/v1/employees");

         

            lOF.writeln("URL : " + url);

         

            HttpURLConnection con;

                con = (HttpURLConnection) url.openConnection();

    

            con.setRequestMethod("GET");

 

             int status = con.getResponseCode();

             BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

             String inputLine;

             StringBuffer content = new StringBuffer();

             while((inputLine = in.readLine()) != null) {

                     content.append(inputLine);

                    System.out.println(inputLine);

             }

             in.close();

             con.disconnect();

             System.out.println("Response status: " + status);

             System.out.println(content.toString());

             

            lOF.writeln("Content : " + content.toString());

 

 

            lOF.writeln("");

            lOF.writeln("+--------------------------------------+");

            lOF.writeln("My Concurrent Program REST API Complete");

            lOF.writeln("+--------------------------------------+");

 

            lRC.setCompletion(ReqCompletion.NORMAL, 

                    "Request Completed Normal");

       

        } catch (ProtocolException e) {

             lOF.writeln("Please check the log for error details)");

             lRC.setCompletion(ReqCompletion.ERROR, e.toString());

        

         } catch (IOException e) {

             lOF.writeln("Please check the log for error details)");

             lRC.setCompletion(ReqCompletion.ERROR, e.toString());

        

        } /*catch (MalformedURLException e) {

             lOF.writeln("Please check the log for error details)");

             lRC.setCompletion(ReqCompletion.ERROR, e.toString());

              

        }*/ 

        finally {

            pCpContext.releaseJDBCConnection();

        }

    }

}

 

2. Move the .class file to $JAVA_TOP$/oracle/apps/fnd/cp/request

3. Register as a Concurrent program
Executable

Concurrent Program

Must put the below reference jars into options without any space

-classpath /apps/apps_st/comn/java/classes:/apps/apps_st/appl/au/12.0.0/java/appsborg.zip:/apps/apps_st/appl/au/12.0.0/java/appsborg2.zip


Post a Comment

0 Comments