Thursday, March 14, 2013


Oracle BI Scheduler Custom Java Program Package:


Oracle BI Scheduler Custom Java Program Package

The public interfaces and class for Oracle BI Scheduler Custom Java Program are packaged as com.siebel.analytics.scheduler.javahostrpccalls. There are two interfaces and one class, which are described in following topics:

 SchedulerJavaExtension Interface

Your custom code must implement the following interface:
package com.siebel.analytics.scheduler.javahostrpccalls;
public interface SchedulerJavaExtension {
public void run(SchedulerJobInfo jobInfo) throws SchedulerJobException;
public void cancel();
}

Example: Creating a Java Program for Agents.

This example creates a Java program that copies the results of an agent to another directory. The example creates a Java class that contains filecopy logic.
To create a Java program to be used with agents:
  1. Create a Java program using a Java editor.
    1. Create a new Java class called 'sched'.
    2. Paste the following code into the Java editor:
      package sched;
          import java.io.*;
          import java.lang.Thread;
       
          import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJavaExtension;
          import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobException;
          import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobInfo;
       
          public class sched implements SchedulerJavaExtension{
          public void run(SchedulerJobInfo jobInfo) throws SchedulerJobException
          {
            System.out.println("JobID is:" + jobInfo.jobID());
            System.out.println("Instance ID is:" + jobInfo.instanceID());
            System.out.println("JobInfo to string is:" + jobInfo.toString());
            try
            {
              // File outputFile = new File("D:\\JavaJob.txt");
              File attachFile = jobInfo.getResultSetFile();
              
              InputStream in = new FileInputStream(attachFile.getAbsolutePath());
              OutputStream out = new FileOutputStream(jobInfo.parameter(0));          
              byte[] buf = new byte[1024];
              int len;
              while ((len = in.read(buf)) > 0) 
              {
                out.write(buf, 0, len);
              }
              in.close();
              out.close();        
              
            }
          catch(Exception ex)
          {
            throw new SchedulerJobException(1, 1, ex.getMessage());
          }
          }
          public void cancel()
          {
          }
          }
      
    3. Add the schedulerrpccalls.jar file from the \MW_HOME\ORACLE_HOME\bifoundation\javahost\lib\scheduler directory into your classpath.
    4. Compile the Java Class without errors.
    5. Jar the compiled output to a file. For example, filecopy.jar.
    6. Note the location of the file and ensure that there are no errors.
To configure a Java program to be used with
agents:
  1. Copy the filecopy.jar file that you created in to the following directory: ORACLE_HOME\bifoundation\javahost\lib
  2. Make the following changes to the JavaHost configuration file, which is called config.xml:
    <Scheduler>
      <Enabled>True</Enabled>        <DefaultUserJarFilePath>D:\<ORACLE_HOME>\bifoundation\javahost\lib</DefaultUserJarFilePath>
    </Scheduler>
    If the JavaHost file is not configured correctly, then the agent log file can stop getting written to, although the agent and the Scheduler are still running. In this situation, you stop the Scheduler using the Windows Task Manager.
  3. Restart the JavaHost service.

Adding Java Jobs for Oracle BI Scheduler

Use the following procedure to add a Java job for the Oracle BI Scheduler.
Note:The compiled Java class file has to exist on the
JavaHost computer before you can configure the properties.
To add a Java Job for Oracle BI Scheduler:
  1. Access the Job Manager and from the Jobs menu, select Add New Job. The Add New job window appears.
  2. In the Script Type field, select Java.
  3. Specify the custom properties. For information about setting these values. Example values and settings for a Java job with the class name "sample.Test", file path "Sample", and no additional paths and parameters are included below.
    Field Value or Setting
    Script Type Java
    Class Name sample.Test
    Class File (Jar File) Sample
  4. Click OK.

Oracle BI Scheduler Java Extension Example

The following example illustrates how to use the previously described interfaces and class to create a custom Java action. For more information,This example does not contain any long running code, so it is acceptable to do nothing in the cancel method.When the compiled class runs, it collects the ID of the user who ran the agent, the job ID of the agent, the instance ID of the agent, and all possible parameters into an output file.
package sample;
import java.io.*;
import java.lang.Thread;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJavaExtension;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobException;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobInfo;
/**
 *
 * @author
 */public class SimpleTest implements SchedulerJavaExtension
{
public void run(SchedulerJobInfo jobInfo) throws SchedulerJobException
{
System.out.println("JobID is:" + jobInfo.jobID());
System.out.println("Instance ID is:" + jobInfo.instanceID());
System.out.println("JobInfo to string is:" + jobInfo.toString());
try
{
File outputFile = new File("D:\\temp\\JavaJob.txt");
FileWriter out = new FileWriter(outputFile);
out.write("User ID:\t\t" + jobInfo.userID() + "\r\n");
out.write("Job ID:\t\t" + jobInfo.jobID() + "\r\n");
out.write("Instance ID:\t\t" + jobInfo.instanceID() + "\r\n");
out.write("Parameter Count:\t\t" + jobInfo.parameterCount() + "\r\n");
for(int i = 0; i < jobInfo.parameterCount(); ++i)
{
out.write("\tParameter ");
out.write(new Integer(i).toString());
out.write(":\t" + jobInfo.parameter(i) + "\r\n");
}
out.close();
}
catch(Exception ex)
{
throw new SchedulerJobException(1, 1, ex.getMessage());
}
}
public void cancel()
{
}
}

Just for information.


Thanks,
Satya Ranki Reddy

No comments:

Post a Comment