01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/jobscheduler/tags/sakai_2-4-1/scheduler-component-shared/src/java/org/sakaiproject/component/app/scheduler/jobs/SpringJobBeanWrapper.java $
03: * $Id: SpringJobBeanWrapper.java 8696 2006-05-02 15:51:45Z john.ellis@rsmart.com $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004 The Regents of the University of Michigan, Trustees of Indiana University,
07: * Board of Trustees of the Leland Stanford, Jr., University, and The MIT Corporation
08: *
09: * Licensed under the Educational Community License Version 1.0 (the "License");
10: * By obtaining, using and/or copying this Original Work, you agree that you have read,
11: * understand, and will comply with the terms and conditions of the Educational Community License.
12: * You may obtain a copy of the License at:
13: *
14: * http://cvs.sakaiproject.org/licenses/license_1_0.html
15: *
16: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17: * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
18: * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19: * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21: *
22: **********************************************************************************/package org.sakaiproject.component.app.scheduler.jobs;
23:
24: import org.sakaiproject.api.app.scheduler.JobBeanWrapper;
25: import org.sakaiproject.api.app.scheduler.SchedulerManager;
26: import org.sakaiproject.component.cover.ComponentManager;
27: import org.quartz.Job;
28: import org.quartz.JobExecutionContext;
29: import org.quartz.JobExecutionException;
30:
31: /**
32: * This class is final to ensure that it will be constructable
33: * by the scheduler infrastructure
34: */
35: public final class SpringJobBeanWrapper implements JobBeanWrapper, Job {
36:
37: private String beanId;
38: private String jobName;
39: private SchedulerManager schedulerManager;
40:
41: public SpringJobBeanWrapper() {
42: }
43:
44: public Class getJobClass() {
45: return this .getClass();
46: }
47:
48: public String getBeanId() {
49: return beanId;
50: }
51:
52: public void setBeanId(String beanId) {
53: this .beanId = beanId;
54: }
55:
56: public String getJobType() {
57: return jobName;
58: }
59:
60: public void setJobName(String jobName) {
61: this .jobName = jobName;
62: }
63:
64: public void init() {
65: getSchedulerManager().registerBeanJob(getJobType(), this );
66: }
67:
68: public void execute(JobExecutionContext jobExecutionContext)
69: throws JobExecutionException {
70: String beanId = jobExecutionContext.getJobDetail()
71: .getJobDataMap().getString(SPRING_BEAN_NAME);
72: Job job = (Job) ComponentManager.get(beanId);
73: job.execute(jobExecutionContext);
74: }
75:
76: public SchedulerManager getSchedulerManager() {
77: return schedulerManager;
78: }
79:
80: public void setSchedulerManager(SchedulerManager schedulerManager) {
81: this.schedulerManager = schedulerManager;
82: }
83: }
|