Commits

Anonymous committed b5be6c4

Issue number: QUARTZ-493
Obtained from: Peter Durcansky
Submitted by: Peter Durcansky
Reviewed by: Jasper Rosenberg
Add ability to conditonally start the Scheduler instance created by the QuartzService MBean.

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

Comments (0)

Files changed (3)

src/jboss/org/quartz/ee/jmx/jboss/QuartzService.java

     private boolean usePropertiesFile;
 
     /*
+    * If true, the scheduler will be started. If false, the scheduler is initailized 
+    * (and available) but start() is not called - it will not execute jobs. 
+    */
+    private boolean startScheduler = true;
+    
+    /*
      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * 
      * Constructors.
         return propertiesFile;
     }
 
+    public void setStartScheduler(boolean startScheduler) {
+        this.startScheduler = startScheduler;
+    }
+    
+    public boolean getStartScheduler() {
+        return startScheduler;
+    }    
+    
     public void createService() throws Exception {
         log.info("Create QuartzService(" + jndiName + ")...");
 
         try {
             Scheduler scheduler = schedulerFactory.getScheduler();
 
-            scheduler.start();
+            if (startScheduler) {
+                scheduler.start();
+            } else {
+                log.info("Skipping starting the scheduler (will not run jobs).");
+            }
         } catch (Exception e) {
             log.error("Failed to start Scheduler", e);
 

src/jboss/org/quartz/ee/jmx/jboss/QuartzServiceMBean.java

     void setProperties(String properties);
 
     void setPropertiesFile(String propertiesFile);
-
+    
+    void setStartScheduler(boolean startScheduler);    
 }

src/jboss/org/quartz/ee/jmx/jboss/doc-files/quartz-service.xml

     -->
 
     <!--
+       Call Scheduler.start() only if requested. Most of the time this 
+       should be true. In some special cases you may want to have 
+       scheduler service available but not run the jobs (for example, 
+       if you want to administer the jobs on a particular server, only).
+       Default value is true.
+    -->
+    <!--
+     <attribute name="StartScheduler">true</attribute>
+    -->
+
+    <!--
       By default a Properties file named "quartz.properties" is
       loaded from the 'current working directory'. If that fails,
       then the "quartz.properties" file located (as a resource)