Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

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

The interval job defined above runs on any one server (if it is deployed in a cluster) every 5 minutes.

Notes:

- The job definitions in job-manager-config.xml are not allowed to change at run time.
- The job definitions created by API with node value set to * require that applications and/or web applications to have job-manager-config.xml with start-job-manager element with true value.
- The web application scoped job implementation classes can be in any of web app or application or system classpath. The application scoped job implementation classes can be in any of application or system classpath.

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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.