Anonymous avatar Anonymous committed 8321dab

Issue number: QUARTZ-497
If a Semaphore implements TablePrefixAware interface, then propogate the JobStoreSupport's table prefix to the Semaphore.

git-svn-id: http://svn.opensymphony.com/svn/quartz/trunk@610 69f7d36a-ea1c-0410-88ea-9fd03e4c9665

Comments (0)

Files changed (2)

src/java/org/quartz/impl/StdSchedulerFactory.java

 import org.quartz.ee.jta.UserTransactionHelper;
 import org.quartz.impl.jdbcjobstore.JobStoreSupport;
 import org.quartz.impl.jdbcjobstore.Semaphore;
+import org.quartz.impl.jdbcjobstore.TablePrefixAware;
 import org.quartz.simpl.RAMJobStore;
 import org.quartz.simpl.SimpleThreadPool;
 import org.quartz.spi.ClassLoadHelper;
     
     public static final String PROP_JOB_STORE_LOCK_HANDLER_CLASS = PROP_JOB_STORE_LOCK_HANDLER_PREFIX + ".class";
 
+    public static final String PROP_TABLE_PREFIX = "tablePrefix";
+
     public static final String PROP_JOB_STORE_CLASS = "org.quartz.jobStore.class";
 
     public static final String PROP_JOB_STORE_USE_PROP = "org.quartz.jobStore.useProperties";
             throw initException;
         }
 
-        if (js instanceof org.quartz.impl.jdbcjobstore.JobStoreSupport) {
-            ((org.quartz.impl.jdbcjobstore.JobStoreSupport) js)
-                .setInstanceId(schedInstId);
-            ((org.quartz.impl.jdbcjobstore.JobStoreSupport) js)
-                .setInstanceName(schedName);
+        if (js instanceof JobStoreSupport) {
+            ((JobStoreSupport)js).setInstanceId(schedInstId);
+            ((JobStoreSupport)js).setInstanceName(schedName);
             
             // Install custom lock handler (Semaphore)
             String lockHandlerClass = cfg.getStringProperty(PROP_JOB_STORE_LOCK_HANDLER_CLASS);
                     Semaphore lockHandler = (Semaphore)loadHelper.loadClass(lockHandlerClass).newInstance();
                     
                     tProps = cfg.getPropertyGroup(PROP_JOB_STORE_LOCK_HANDLER_PREFIX, true);
+
+                    // If this lock handler requires the table prefix, add it to its properties.
+                    if (lockHandler instanceof TablePrefixAware) {
+                        tProps.setProperty(
+                            PROP_TABLE_PREFIX, ((JobStoreSupport)js).getTablePrefix());
+                    }
+                    
                     try {
                         setBeanProps(lockHandler, tProps);
                     } catch (Exception e) {
                         throw initException;
                     }
                     
-                    ((org.quartz.impl.jdbcjobstore.JobStoreSupport) js).setLockHandler(lockHandler);
+                    ((JobStoreSupport)js).setLockHandler(lockHandler);
                     getLog().info("Using custom data access locking (synchronization): " + lockHandlerClass);
                 } catch (Exception e) {
                     initException = new SchedulerException("JobStore LockHandler class '" + lockHandlerClass
         if (autoId) {
             try {
                 schedInstId = DEFAULT_INSTANCE_ID;
-                if (js instanceof org.quartz.impl.jdbcjobstore.JobStoreSupport) {
-                    if(((org.quartz.impl.jdbcjobstore.JobStoreSupport) js) 
-                        .isClustered()) {
+                if (js instanceof JobStoreSupport) {
+                    if(((JobStoreSupport)js).isClustered()) {
                         schedInstId = instanceIdGenerator.generateInstanceId();                    
                     }
                 }
         }
 
         if (js instanceof JobStoreSupport) {
-            JobStoreSupport jjs = (JobStoreSupport) js;
+            JobStoreSupport jjs = (JobStoreSupport)js;
             jjs.setInstanceId(schedInstId);
             jjs.setDbRetryInterval(dbFailureRetry);
         }

src/java/org/quartz/impl/jdbcjobstore/TablePrefixAware.java

+/* 
+ * Copyright 2004-2006 OpenSymphony 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
+ * use this file except in compliance with the License. You may obtain a copy 
+ * of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0 
+ *   
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
+ * License for the specific language governing permissions and limitations 
+ * under the License.
+ */
+package org.quartz.impl.jdbcjobstore;
+
+/**
+ * Interface for Quartz objects that need to know what the table prefix of
+ * the tables used by a JDBC JobStore is.
+ */
+public interface TablePrefixAware {
+    void setTablePrefix(String tablePrefix);
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.