001: /*
002: * Copyright 2004-2005 OpenSymphony
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy
006: * of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations
014: * under the License.
015: *
016: */
017:
018: /*
019: * Previously Copyright (c) 2001-2004 James House
020: */
021: package org.quartz.ee.jta;
022:
023: import org.quartz.Scheduler;
024: import org.quartz.SchedulerConfigException;
025: import org.quartz.core.JobRunShell;
026: import org.quartz.core.JobRunShellFactory;
027: import org.quartz.core.SchedulingContext;
028:
029: /**
030: * <p>
031: * Responsible for creating the instances of <code>{@link org.quartz.ee.jta.JTAJobRunShell}</code>
032: * to be used within the <class>{@link org.quartz.core.QuartzScheduler}
033: * </code> instance.
034: * </p>
035: *
036: * <p>
037: * This implementation does not re-use any objects, it simply makes a new
038: * JTAJobRunShell each time <code>borrowJobRunShell()</code> is called.
039: * </p>
040: *
041: * @author James House
042: */
043: public class JTAJobRunShellFactory implements JobRunShellFactory {
044:
045: /*
046: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
047: *
048: * Data members.
049: *
050: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
051: */
052:
053: private Scheduler scheduler;
054:
055: private SchedulingContext schedCtxt;
056:
057: /*
058: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
059: *
060: * Constructors.
061: *
062: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
063: */
064:
065: public JTAJobRunShellFactory() {
066: }
067:
068: /*
069: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
070: *
071: * Interface.
072: *
073: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
074: */
075:
076: /**
077: * <p>
078: * Initialize the factory, providing a handle to the <code>Scheduler</code>
079: * that should be made available within the <code>JobRunShell</code> and
080: * the <code>JobExecutionContext</code> s within it, and a handle to the
081: * <code>SchedulingContext</code> that the shell will use in its own
082: * operations with the <code>JobStore</code>.
083: * </p>
084: */
085: public void initialize(Scheduler scheduler,
086: SchedulingContext schedCtxt)
087: throws SchedulerConfigException {
088: this .scheduler = scheduler;
089: this .schedCtxt = schedCtxt;
090: }
091:
092: /**
093: * <p>
094: * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread}
095: * </code> to obtain instances of <code>
096: * {@link org.quartz.core.JobRunShell}</code>.
097: * </p>
098: */
099: 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: }
|