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:
- Create a Java program using a Java editor.
-
Create a new Java class called 'sched'.
-
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()
{
}
}
-
Add the schedulerrpccalls.jar file from the \MW_HOME\ORACLE_HOME\bifoundation\javahost\lib\scheduler directory
into your classpath.
-
Compile the Java Class without errors.
-
Jar the compiled output to a file. For example, filecopy.jar.
-
Note the location of the file and ensure that there are no
errors.
To configure a Java program to be used with
agents:
-
Copy the filecopy.jar file that you created in to the following
directory:
ORACLE_HOME\bifoundation\javahost\lib
-
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.
-
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:
-
Access the Job Manager and from the Jobs menu, select Add
New Job.
The Add New job window appears.
-
In the Script Type field, select Java.
-
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.
- 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