KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > impl > StdJobRunShellFactory


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 /*
19  * Previously Copyright (c) 2001-2004 James House
20  */

21 package org.quartz.impl;
22
23 import org.quartz.Scheduler;
24 import org.quartz.SchedulerException;
25 import org.quartz.core.JobRunShell;
26 import org.quartz.core.JobRunShellFactory;
27 import org.quartz.core.SchedulingContext;
28
29 /**
30  * <p>
31  * Responsible for creating the instances of <code>{@link org.quartz.core.JobRunShell}</code>
32  * to be used within the <class>{@link org.quartz.core.QuartzScheduler}
33  * </code> instance.
34  * </p>
35  *
36  * <p>
37  * This implementation does not re-use any objects, it simply makes a new
38  * JobRunShell each time <code>borrowJobRunShell()</code> is called.
39  * </p>
40  *
41  * @author James House
42  */

43 public class StdJobRunShellFactory implements JobRunShellFactory {
44     /*
45      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46      *
47      * Data members.
48      *
49      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50      */

51
52     private Scheduler scheduler;
53
54     private SchedulingContext schedCtxt;
55
56     /*
57      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58      *
59      * Interface.
60      *
61      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62      */

63
64     /**
65      * <p>
66      * Initialize the factory, providing a handle to the <code>Scheduler</code>
67      * that should be made available within the <code>JobRunShell</code> and
68      * the <code>JobExecutionCOntext</code> s within it, and a handle to the
69      * <code>SchedulingContext</code> that the shell will use in its own
70      * operations with the <code>JobStore</code>.
71      * </p>
72      */

73     public void initialize(Scheduler scheduler, SchedulingContext schedCtxt) {
74         this.scheduler = scheduler;
75         this.schedCtxt = schedCtxt;
76     }
77
78     /**
79      * <p>
80      * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread}
81      * </code> to obtain instances of <code>
82      * {@link org.quartz.core.JobRunShell}</code>.
83      * </p>
84      */

85     public JobRunShell borrowJobRunShell() throws SchedulerException {
86         return new JobRunShell(this, scheduler, schedCtxt);
87     }
88
89     /**
90      * <p>
91      * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread}
92      * </code> to return instances of <code>
93      * {@link org.quartz.core.JobRunShell}</code>.
94      * </p>
95      */

96     public void returnJobRunShell(JobRunShell jobRunShell) {
97         jobRunShell.passivate();
98     }
99
100 }
101
Popular Tags