Package com.bea.p13n.jobmanager

This package provides interfaces and classes for creating and scheduling jobs using JobManager .

See
          Description

Interface Summary
JobContext Holds information about a job and an implementation of this is passed to the work manager to execute.
JobDefinition An abstract job definition interface.
JobManager The JobManager interface provides for managing (CRUD) job definitions, scheduling jobs and managing their run histories.
 

Enum Summary
JobDefinition.JOB_TYPE Supported job types.
JobManager.JOB_STATUS All the states a job can be in.
 

Package com.bea.p13n.jobmanager Description

This package provides interfaces and classes for creating and scheduling jobs using JobManager . The jobs are created by implementing one of the job interfaces TimerJob, IntervalJob ,EventJob, CalendarJob or StartupJob. The jobs can be scheduled to run by creating job definitions. The job definitions are created from a configuration file job-manager-config.xml or by using job manager API. The job-manager-config.xml should be placed under [Application Root]/META-INF for application scoped job definitions or [Web Application Root]/WEB-INF directory for web app scoped job definitions.

Each job definition can also register a job listener to get callbacks on job completion or on job failure by implementing JobListener interface and including it as part of job definition configuration.

Example of creating a job and configuring it in job-manager-config.xml

  1. Create a job by implementing one of the job interfaces TimerJob, IntervalJob ,EventJob, CalendarJob or StartupJob.
  2. The configuration (contents in job-manager-config.xml) for the TestJob is shown below
                        <?xml version="1.0"?>
                        <job-manager-config xmlns="http://www.bea.com/ns/p13n/10_1/job-manager-config">
                            <interval-job-definition>
                                <name>TestJob</name>
                                <group>TestJobGroup</group>
                                <job-class>com.test.job.TestJob</job-class>
                                <interval>5</interval>
                            </interval-job-definition>
                        </job-manager-config>
                    

    The job-manager-config.xml is placed under [Application Root]/META-INF if the job needs to run under application scope or [Web Application Root]/WEB-INF if the job needs to run under web application scope (or requires servlet context).

Example of creating a job using the job manager API

  1. Create a job by implementing one of the job interfaces TimerJob, IntervalJob ,EventJob, CalendarJob or StartupJob.
  2. Retrieve scoped Job Manager using JobManagerService.
                        // Retrieve JobManagerService
                        JobManagerService jobManagerService = com.bea.wlp.services.Services.getService(JobManagerService.class);
                        // Get web application scoped job manager instance
                        JobManager jobManager = jobManagerService.getJobManager(servletContext);
    
                        OR
    
                        // Get application scoped job manager instance
                        JobManager jobManager = jobManagerService.getJobManager();
                    
  3. Create interval job definition.
                        // Create interval job definition
                        IntervalJobDefinition interval  = new IntervalJobDefinition("TestJob");
                        interval.setGroup("TestJobGroup");
                        interval.setJobClass("com.test.job.TestJob");
                        interval.setInterval(5);
    
                        jobManager.createJobDefinition(interval);                    
                    
  4. The interval job defined above runs on any one server (if it is deployed in a cluster) every 5 minutes.

Notes:

See Also
JobManager, JobManagerService, TimerJob, IntervalJob, CalendarJob, EventJob, StartupJob, JobListener, TimerJobDefinition, IntervalJobDefinition, CalendarJobDefinition, EventJobDefinition, StartupJobDefinition


Copyright © 2011, Oracle. All rights reserved.