Middleware
Application Server
Date: 12/16/2005
Author: Tony D'Silva
For full documentation and javadoc on the Scheduler see the Oracle Containers for Java Scheduler Developer's Guide on OTN.
The application accompanying this how-to demonstrates how to deploy and use the scheduler in the JMS jobstore configuration, from a J2EE application in the OC4J container.
Provide links to where the software is available. The least should include a JDK, Ant, and OC4J
List the notation used throughout the document. Keep to the convention of %NAME% for environment like variables.
oracle.ias.scheduler.Executable
public interface Executable {
public void execute (JobContext context);
}
execute()The Scheduler is an application component. In order to access the Scheduler a JNDI lookup is necessary. The following example demonstrates how to perform this lookup:
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("java:comp/env/ejb/scheduler");
SchedulerHome home = (SchedulerHome)
PortableRemoteObject.narrow(objRef, SchedulerHome.class);
Scheduler scheduler = home.create();
add()
public JobHandle add(String description,
String className,
Schedule schedule,
Properties properties)
description- The description for this job.
className- The name of the Java class that will be run when the specified schedule expires. This class must implement the
Executableinterface.
schedule- Specifies when and how often the job is run by the Scheduler. The Scheduler supports several different options for specifying including including iCalendar recurrence expressions.
properties- This parameter is used to specifying runtime parameters for the job.
JobHandle
The following instructions are for running this demonstration on a standalone instance of Oracle Containers for J2EE 10g (10.1.3.0.0).
Stand Alone Installation: %ORACLE_HOME%/bin/oc4j start
Note that the oc4j command expects the JAVA_HOME environment variable to point to a full JDK installation.
OracleAS Managed Installation: %ORACLE_HOME%/opmn/bin/opmnctl startall
To build and deploy the application, type the following command from the %HOWTO_HOME% directory:
You should now have the newly created SchedulerJDBCDemo .ear in your %HOWTO_HOME%/dist directory.
Before deploying it will first test whether OC4J is running.
Note that you can also deploy the application separately . Ensure the %ORACLE_HOME% environment variable is defined, and from the %HOWTO_HOME% directory, type the command:
ant deploy
http://localhost:8888/scheduler/simple-jmsdemo
This will bring up the main page for submitting a job that periodically puts a timestamped message on a jms queue :
- Job Starts in :
- The number of seconds from current time for job executions to commence
- Job Ends in :
- The number of seconds from current time for job to end
- Interval :
- The interval between executions
After filling in the form and clicking on the submit button, watch the oc4j console for timestamped messages output from the scheduler's job