KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > ee > jta > JTAJobRunShellFactory


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

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

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

44 public class JTAJobRunShellFactory implements JobRunShellFactory {
45
46     /*
47      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48      *
49      * Data members.
50      *
51      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52      */

53
54     private Scheduler scheduler;
55
56     private SchedulingContext schedCtxt;
57
58     /*
59      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60      *
61      * Constructors.
62      *
63      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64      */

65
66     public JTAJobRunShellFactory() {
67     }
68
69     /*
70      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71      *
72      * Interface.
73      *
74      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75      */

76
77     /**
78      * <p>
79      * Initialize the factory, providing a handle to the <code>Scheduler</code>
80      * that should be made available within the <code>JobRunShell</code> and
81      * the <code>JobExecutionContext</code> s within it, and a handle to the
82      * <code>SchedulingContext</code> that the shell will use in its own
83      * operations with the <code>JobStore</code>.
84      * </p>
85      */

86     public void initialize(Scheduler scheduler, SchedulingContext schedCtxt)
87         throws SchedulerConfigException {
88         this.scheduler = scheduler;
89         this.schedCtxt = schedCtxt;
90     }
91
92     /**
93      * <p>
94      * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread}
95      * </code> to obtain instances of <code>
96      * {@link org.quartz.core.JobRunShell}</code>.
97      * </p>
98      */

99     public JobRunShell borrowJobRunShell() {
100         return new JTAJobRunShell(this, scheduler, schedCtxt);
101     }
102
103     /**
104      * <p>
105      * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread}
106      * </code> to return instances of <code>
107      * {@link org.quartz.core.JobRunShell}</code>.
108      * </p>
109      */

110     public void returnJobRunShell(JobRunShell jobRunShell) {
111         jobRunShell.passivate();
112     }
113
114 }
Popular Tags