KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > impl > jdbcjobstore > JobStoreTX


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.jdbcjobstore;
22
23 import java.sql.Connection JavaDoc;
24
25 import org.quartz.JobPersistenceException;
26 import org.quartz.SchedulerConfigException;
27 import org.quartz.spi.ClassLoadHelper;
28 import org.quartz.spi.SchedulerSignaler;
29
30 /**
31  * <p>
32  * <code>JobStoreTX</code> is meant to be used in a standalone environment.
33  * Both commit and rollback will be handled by this class.
34  * </p>
35  *
36  * <p>
37  * If you need a <code>{@link org.quartz.spi.JobStore}</code> class to use
38  * within an application-server environment, use <code>{@link
39  * org.quartz.impl.jdbcjobstore.JobStoreCMT}</code>
40  * instead.
41  * </p>
42  *
43  * @author <a HREF="mailto:jeff@binaryfeed.org">Jeffrey Wescott</a>
44  * @author James House
45  */

46 public class JobStoreTX extends JobStoreSupport {
47
48     /*
49      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50      *
51      * Interface.
52      *
53      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54      */

55
56     public void initialize(ClassLoadHelper loadHelper,
57             SchedulerSignaler signaler) throws SchedulerConfigException {
58
59         super.initialize(loadHelper, signaler);
60
61         getLog().info("JobStoreTX initialized.");
62     }
63
64     /**
65      * For <code>JobStoreTX</code>, the non-managed TX connection is just
66      * the normal connection because it is not CMT.
67      *
68      * @see JobStoreSupport#getConnection()
69      */

70     protected Connection JavaDoc getNonManagedTXConnection()
71         throws JobPersistenceException {
72         return getConnection();
73     }
74     
75     /**
76      * Execute the given callback having optionally aquired the given lock.
77      * For <code>JobStoreTX</code>, because it manages its own transactions
78      * and only has the one datasource, this is the same behavior as
79      * executeInNonManagedTXLock().
80      *
81      * @param lockName The name of the lock to aquire, for example
82      * "TRIGGER_ACCESS". If null, then no lock is aquired, but the
83      * lockCallback is still executed in a transaction.
84      *
85      * @see JobStoreSupport#executeInNonManagedTXLock(String, TransactionCallback)
86      * @see JobStoreCMT#executeInLock(String, TransactionCallback)
87      * @see JobStoreSupport#getNonManagedTXConnection()
88      * @see JobStoreSupport#getConnection()
89      */

90     protected Object JavaDoc executeInLock(
91             String JavaDoc lockName,
92             TransactionCallback txCallback) throws JobPersistenceException {
93         return executeInNonManagedTXLock(lockName, txCallback);
94     }
95 }
96 // EOF
97
Popular Tags