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.impl;
022:
023: import org.quartz.Scheduler;
024: import org.quartz.SchedulerException;
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.core.JobRunShell}</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: * JobRunShell each time <code>borrowJobRunShell()</code> is called.
039: * </p>
040: *
041: * @author James House
042: */
043: public class StdJobRunShellFactory implements JobRunShellFactory {
044: /*
045: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
046: *
047: * Data members.
048: *
049: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
050: */
051:
052: private Scheduler scheduler;
053:
054: private SchedulingContext schedCtxt;
055:
056: /*
057: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
058: *
059: * Interface.
060: *
061: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
062: */
063:
064: /**
065: * <p>
066: * Initialize the factory, providing a handle to the <code>Scheduler</code>
067: * that should be made available within the <code>JobRunShell</code> and
068: * the <code>JobExecutionCOntext</code> s within it, and a handle to the
069: * <code>SchedulingContext</code> that the shell will use in its own
070: * operations with the <code>JobStore</code>.
071: * </p>
072: */
073: public void initialize(Scheduler scheduler,
074: SchedulingContext schedCtxt) {
075: this .scheduler = scheduler;
076: this .schedCtxt = schedCtxt;
077: }
078:
079: /**
080: * <p>
081: * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread}
082: * </code> to obtain instances of <code>
083: * {@link org.quartz.core.JobRunShell}</code>.
084: * </p>
085: */
086: public JobRunShell borrowJobRunShell() throws SchedulerException {
087: return new JobRunShell(this , scheduler, schedCtxt);
088: }
089:
090: /**
091: * <p>
092: * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread}
093: * </code> to return instances of <code>
094: * {@link org.quartz.core.JobRunShell}</code>.
095: * </p>
096: */
097: public void returnJobRunShell(JobRunShell jobRunShell) {
098: jobRunShell.passivate();
099: }
100:
101: }
|