incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1095668 - in /sling/trunk/bundles/commons/scheduler: ./ src/main/java/org/apache/sling/commons/scheduler/impl/
Date Thu, 21 Apr 2011 11:57:02 GMT
Author: cziegeler
Date: Thu Apr 21 11:57:01 2011
New Revision: 1095668

URL: http://svn.apache.org/viewvc?rev=1095668&view=rev
Log:
SLING-1964 : Create a WebConsole plugin for Scheduler
SLING-2055 : Upgrade to latest Quartz

Added:
    sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/NonParallelQuartzJobExecutor.java
  (with props)
    sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/WebConsolePrinter.java
  (with props)
Removed:
    sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/JobHandler.java
Modified:
    sling/trunk/bundles/commons/scheduler/pom.xml
    sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
    sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java

Modified: sling/trunk/bundles/commons/scheduler/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/scheduler/pom.xml?rev=1095668&r1=1095667&r2=1095668&view=diff
==============================================================================
--- sling/trunk/bundles/commons/scheduler/pom.xml (original)
+++ sling/trunk/bundles/commons/scheduler/pom.xml Thu Apr 21 11:57:01 2011
@@ -72,7 +72,8 @@
                             org.apache.commons.logging.impl,
                             javax.jms,
                             javax.mail,
-                            javax.mail.internet
+                            javax.mail.internet,
+                            com.mchange.v2.c3p0
                         </DynamicImport-Package>
                         <Embed-Dependency>
                             quartz,commons-pool,commons-dbcp,commons-beanutils,commons-digester
@@ -97,6 +98,10 @@
     </reporting>
     <dependencies>
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
         </dependency>
@@ -116,9 +121,9 @@
         </dependency>
         <!-- The following dependencies will be replaced by using the quartz wrapper bundle
-->
         <dependency>
-            <groupId>opensymphony</groupId>
+            <groupId>org.quartz-scheduler</groupId>
             <artifactId>quartz</artifactId>
-            <version>1.6.3</version>
+            <version>2.0.1</version>
         </dependency>
 		<dependency>
 		    <groupId>commons-pool</groupId>

Added: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/NonParallelQuartzJobExecutor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/NonParallelQuartzJobExecutor.java?rev=1095668&view=auto
==============================================================================
--- sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/NonParallelQuartzJobExecutor.java
(added)
+++ sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/NonParallelQuartzJobExecutor.java
Thu Apr 21 11:57:01 2011
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.sling.commons.scheduler.impl;
+
+import org.quartz.DisallowConcurrentExecution;
+
+
+/**
+ * This component is resposible to launch a {@link org.apache.sling.commons.scheduler.Job}
+ * or {@link Runnable} in a Quartz Scheduler but non concurrently.
+ *
+ */
+@DisallowConcurrentExecution
+public class NonParallelQuartzJobExecutor extends QuartzJobExecutor {
+
+    // nothing to code here
+}

Propchange: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/NonParallelQuartzJobExecutor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/NonParallelQuartzJobExecutor.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/NonParallelQuartzJobExecutor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java?rev=1095668&r1=1095667&r2=1095668&view=diff
==============================================================================
--- sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
(original)
+++ sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
Thu Apr 21 11:57:01 2011
@@ -40,15 +40,6 @@ public class QuartzJobExecutor implement
 
         final JobDataMap data = context.getJobDetail().getJobDataMap();
 
-        final JobHandler handler = (JobHandler)data.get(QuartzScheduler.DATA_MAP_JOB_HANDLER);
-        final boolean canRunConcurrently = (handler == null ? true : handler.runConcurrently);
-
-        if (!canRunConcurrently) {
-            if ( !handler.isRunning.compareAndSet(false, true) ) {
-                return;
-            }
-        }
-
         final Object job = data.get(QuartzScheduler.DATA_MAP_OBJECT);
         final Logger logger = (Logger)data.get(QuartzScheduler.DATA_MAP_LOGGER);
 
@@ -73,10 +64,6 @@ public class QuartzJobExecutor implement
             }
             // there is nothing we can do here, so we just log
             logger.error("Exception during job execution of " + job + " : " + t.getMessage(),
t);
-        } finally {
-            if (!canRunConcurrently) {
-                handler.isRunning.set(false);
-            }
         }
     }
 

Modified: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java?rev=1095668&r1=1095667&r2=1095668&view=diff
==============================================================================
--- sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java
(original)
+++ sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java
Thu Apr 21 11:57:01 2011
@@ -26,20 +26,30 @@ import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.UUID;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.References;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.commons.scheduler.Job;
 import org.apache.sling.commons.scheduler.Scheduler;
 import org.apache.sling.commons.threads.ThreadPool;
 import org.apache.sling.commons.threads.ThreadPoolManager;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
-import org.quartz.CronTrigger;
+import org.quartz.CronScheduleBuilder;
+import org.quartz.JobBuilder;
 import org.quartz.JobDataMap;
 import org.quartz.JobDetail;
+import org.quartz.JobKey;
 import org.quartz.SchedulerException;
 import org.quartz.SchedulerFactory;
-import org.quartz.SimpleTrigger;
+import org.quartz.SimpleScheduleBuilder;
 import org.quartz.Trigger;
+import org.quartz.TriggerBuilder;
 import org.quartz.impl.DirectSchedulerFactory;
 import org.quartz.impl.StdSchedulerFactory;
 import org.quartz.simpl.RAMJobStore;
@@ -49,11 +59,13 @@ import org.slf4j.LoggerFactory;
 /**
  * The quartz based implementation of the scheduler.
  *
- * @scr.component metatype="no" immediate="true"
- * @scr.service interface="org.apache.sling.commons.scheduler.Scheduler"
- * @scr.reference name="job" interface="org.apache.sling.commons.scheduler.Job" cardinality="0..n"
policy="dynamic"
- * @scr.reference name="task" interface="java.lang.Runnable" cardinality="0..n" policy="dynamic"
  */
+@Component(immediate=true)
+@Service(value=Scheduler.class)
+@References({
+    @Reference(name="job", referenceInterface=Job.class, cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE,
policy=ReferencePolicy.DYNAMIC),
+    @Reference(name="task", referenceInterface=Runnable.class, cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE,
policy=ReferencePolicy.DYNAMIC)
+})
 public class QuartzScheduler implements Scheduler {
 
     /** Default log. */
@@ -77,9 +89,6 @@ public class QuartzScheduler implements 
     /** Map key for the logger. */
     static final String DATA_MAP_LOGGER = "QuartzJobScheduler.Logger";
 
-    /** Map key for the job handler */
-    static final String DATA_MAP_JOB_HANDLER = "QuartzJobExecutor.JobHandler";
-
     /** Theq quartz scheduler. */
     protected volatile org.quartz.Scheduler scheduler;
 
@@ -89,11 +98,14 @@ public class QuartzScheduler implements 
     /** The component context. */
     protected volatile ComponentContext context;
 
-    /** @scr.reference */
+    @Reference
     protected ThreadPoolManager threadPoolManager;
 
     protected ThreadPool threadPool;
 
+    /** Service registration for the plugin. */
+    private ServiceRegistration plugin;
+
     /**
      * Activate this component.
      * Start the scheduler.
@@ -119,6 +131,7 @@ public class QuartzScheduler implements 
                 this.logger.error("Exception during registering " + reg.componentName + "
service " + reg.reference, e);
             }
         }
+        this.plugin = WebConsolePrinter.initPlugin(ctx.getBundleContext(), this);
     }
 
     /**
@@ -127,6 +140,8 @@ public class QuartzScheduler implements 
      * @param ctx The component context.
      */
     protected void deactivate(final ComponentContext ctx) {
+        WebConsolePrinter.destroyPlugin(this.plugin);
+        this.plugin = null;
         final org.quartz.Scheduler s = this.scheduler;
         this.scheduler = null;
         this.dispose(s);
@@ -227,7 +242,7 @@ public class QuartzScheduler implements 
         // if there is already a job with the name, remove it first
         if ( name != null ) {
             try {
-                final JobDetail jobdetail = s.getJobDetail(name, DEFAULT_QUARTZ_JOB_GROUP);
+                final JobDetail jobdetail = s.getJobDetail(JobKey.jobKey(name));
                 if (jobdetail != null) {
                     this.removeJob(name);
                 }
@@ -238,9 +253,9 @@ public class QuartzScheduler implements 
         final String jobName = this.getJobName(name);
 
         // create the data map
-        final JobDataMap jobDataMap = this.initDataMap(jobName, job, config, canRunConcurrently);
+        final JobDataMap jobDataMap = this.initDataMap(jobName, job, config);
 
-        final JobDetail detail = this.createJobDetail(jobName, jobDataMap);
+        final JobDetail detail = this.createJobDetail(jobName, jobDataMap, canRunConcurrently);
 
         this.logger.debug("Scheduling job {} with name {} and trigger {}", new Object[] {job,
jobName, trigger});
         s.scheduleJob(detail, trigger);
@@ -256,15 +271,12 @@ public class QuartzScheduler implements 
      */
     protected JobDataMap initDataMap(final String  jobName,
                                      final Object  job,
-                                     final Map<String, Serializable> config,
-                                     final boolean concurrent) {
+                                     final Map<String, Serializable> config) {
         final JobDataMap jobDataMap = new JobDataMap();
 
         jobDataMap.put(DATA_MAP_OBJECT, job);
 
         jobDataMap.put(DATA_MAP_NAME, jobName);
-        final JobHandler handler = new JobHandler(concurrent);
-        jobDataMap.put(DATA_MAP_JOB_HANDLER, handler);
         jobDataMap.put(DATA_MAP_LOGGER, this.logger);
         if ( config != null ) {
             jobDataMap.put(DATA_MAP_CONFIGURATION, config);
@@ -279,9 +291,13 @@ public class QuartzScheduler implements 
      * @param jobDataMap
      * @return
      */
-    protected JobDetail createJobDetail(final String name, final JobDataMap jobDataMap) {
-        final JobDetail detail = new JobDetail(name, DEFAULT_QUARTZ_JOB_GROUP, QuartzJobExecutor.class);
-        detail.setJobDataMap(jobDataMap);
+    protected JobDetail createJobDetail(final String name,
+                                        final JobDataMap jobDataMap,
+                                        final boolean concurrent) {
+        final JobDetail detail = JobBuilder.newJob((concurrent ? QuartzJobExecutor.class
: NonParallelQuartzJobExecutor.class))
+                .withIdentity(name)
+                .usingJobData(jobDataMap)
+                .build();
         return detail;
     }
 
@@ -304,14 +320,16 @@ public class QuartzScheduler implements 
                        final String schedulingExpression,
                        final boolean canRunConcurrently)
     throws SchedulerException {
-        final CronTrigger cronJobEntry = new CronTrigger(name, DEFAULT_QUARTZ_JOB_GROUP);
-
+        final Trigger cronTrigger;
         try {
-            cronJobEntry.setCronExpression(schedulingExpression);
+            cronTrigger = TriggerBuilder.newTrigger()
+                .withIdentity(name)
+                .withSchedule(CronScheduleBuilder.cronSchedule(schedulingExpression))
+                .build();
         } catch (final ParseException pe) {
             throw new IllegalArgumentException("Error during parsing of cron '" + schedulingExpression
+ "' : " + pe.getMessage(), pe);
         }
-        this.scheduleJob(name, job, config, cronJobEntry, canRunConcurrently);
+        this.scheduleJob(name, job, config, cronTrigger, canRunConcurrently);
     }
 
     /**
@@ -326,11 +344,13 @@ public class QuartzScheduler implements 
         final long ms = period * 1000;
         final String jobName = this.getJobName(name);
 
-        final SimpleTrigger timeEntry =
-            new SimpleTrigger(jobName, DEFAULT_QUARTZ_JOB_GROUP, new Date(System.currentTimeMillis()
+ ms), null,
-                              SimpleTrigger.REPEAT_INDEFINITELY, ms);
+        final Trigger trigger = TriggerBuilder.newTrigger()
+            .withIdentity(jobName)
+            .startAt(new Date(System.currentTimeMillis() + ms))
+            .withSchedule(SimpleScheduleBuilder.simpleSchedule().repeatForever().withIntervalInMilliseconds(ms))
+            .build();
 
-        this.scheduleJob(jobName, job, config, timeEntry, canRunConcurrently);
+        this.scheduleJob(jobName, job, config, trigger, canRunConcurrently);
     }
 
     /**
@@ -340,11 +360,15 @@ public class QuartzScheduler implements 
     throws SchedulerException {
         this.checkJob(job);
         final String jobName = job.getClass().getName();
-        final JobDataMap dataMap = this.initDataMap(jobName, job, config, true);
+        final JobDataMap dataMap = this.initDataMap(jobName, job, config);
+
+        final JobDetail detail = this.createJobDetail(jobName, dataMap, true);
 
-        final JobDetail detail = this.createJobDetail(jobName, dataMap);
+        final Trigger trigger = TriggerBuilder.newTrigger()
+            .withIdentity(jobName)
+            .startNow()
+            .build();
 
-        final Trigger trigger = new SimpleTrigger(jobName, DEFAULT_QUARTZ_JOB_GROUP);
         this.scheduler.scheduleJob(detail, trigger);
     }
 
@@ -354,7 +378,10 @@ public class QuartzScheduler implements 
     public void fireJobAt(final String name, final Object job, final Map<String, Serializable>
config, final Date date)
     throws SchedulerException {
         final String jobName = this.getJobName(name);
-        final SimpleTrigger trigger = new SimpleTrigger(jobName, DEFAULT_QUARTZ_JOB_GROUP,
date);
+        final Trigger trigger = TriggerBuilder.newTrigger()
+        .withIdentity(jobName)
+        .startAt(date)
+        .build();
         this.scheduleJob(jobName, job, config, trigger, true);
     }
 
@@ -371,11 +398,16 @@ public class QuartzScheduler implements 
         }
         final long ms = period * 1000;
         final String jobName = job.getClass().getName();
-        final JobDataMap dataMap = this.initDataMap(jobName, job, config, true);
+        final JobDataMap dataMap = this.initDataMap(jobName, job, config);
 
-        final JobDetail detail = this.createJobDetail(jobName, dataMap);
+        final JobDetail detail = this.createJobDetail(jobName, dataMap, true);
+
+        final Trigger trigger = TriggerBuilder.newTrigger()
+            .withIdentity(jobName)
+            .startNow()
+            .withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(times).withIntervalInMilliseconds(ms))
+            .build();
 
-        final Trigger trigger = new SimpleTrigger(jobName, DEFAULT_QUARTZ_JOB_GROUP, times,
ms);
         try {
             this.scheduler.scheduleJob(detail, trigger);
         } catch (final SchedulerException se) {
@@ -399,7 +431,13 @@ public class QuartzScheduler implements 
         }
         final String jobName = job.getClass().getName();
         final long ms = period * 1000;
-        final SimpleTrigger trigger = new SimpleTrigger(jobName, DEFAULT_QUARTZ_JOB_GROUP,
date, null, times, ms);
+
+        final Trigger trigger = TriggerBuilder.newTrigger()
+            .withIdentity(jobName)
+            .startAt(date)
+            .withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(times).withIntervalInMilliseconds(ms))
+            .build();
+
         try {
             this.scheduleJob(jobName, job, config, trigger, true);
         } catch (final SchedulerException se) {
@@ -427,7 +465,7 @@ public class QuartzScheduler implements 
         final org.quartz.Scheduler s = this.scheduler;
         if ( s != null ) {
             try {
-                s.deleteJob(name, DEFAULT_QUARTZ_JOB_GROUP);
+                s.deleteJob(JobKey.jobKey(name));
                 this.logger.debug("Unscheduling job with name {}", name);
             } catch (final SchedulerException se) {
                 throw new NoSuchElementException(se.getMessage());
@@ -559,6 +597,10 @@ public class QuartzScheduler implements 
         }
     }
 
+    org.quartz.Scheduler getScheduler() {
+        return this.scheduler;
+    }
+
     /**
      * Helper class holding a registration if this service is not active yet.
      */
@@ -592,7 +634,7 @@ public class QuartzScheduler implements 
     }
 
 
-    private static final class QuartzThreadPool implements org.quartz.spi.ThreadPool {
+    public static final class QuartzThreadPool implements org.quartz.spi.ThreadPool {
 
         /** Our executor thread pool */
         private ThreadPool executor;
@@ -618,6 +660,14 @@ public class QuartzScheduler implements 
             // nothing to do
         }
 
+        public void setInstanceId(final String id) {
+            // we ignore this
+        }
+
+        public void setInstanceName(final String name) {
+            // we ignore this
+        }
+
         /* (non-Javadoc)
          * @see org.quartz.spi.QuartzThreadPool#runInThread(java.lang.Runnable)
          */

Added: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/WebConsolePrinter.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/WebConsolePrinter.java?rev=1095668&view=auto
==============================================================================
--- sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/WebConsolePrinter.java
(added)
+++ sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/WebConsolePrinter.java
Thu Apr 21 11:57:01 2011
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.sling.commons.scheduler.impl;
+
+import java.io.PrintWriter;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.quartz.JobDetail;
+import org.quartz.JobKey;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.Trigger;
+import org.quartz.impl.matchers.GroupMatcher;
+
+/**
+ * This is a configuration printer for the web console which
+ * prints out the current configuration/status.
+ *
+ */
+public class WebConsolePrinter {
+
+    public static ServiceRegistration initPlugin(final BundleContext bundleContext,
+                                                 final QuartzScheduler qs) {
+        final WebConsolePrinter propertiesPrinter = new WebConsolePrinter(qs);
+        final Dictionary<String, String> props = new Hashtable<String, String>();
+        props.put(Constants.SERVICE_DESCRIPTION,
+            "Apache Sling Scheduler Configuration Printer");
+        props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
+        props.put("felix.webconsole.label", "slingscheduler");
+        props.put("felix.webconsole.title", "Sling Scheduler");
+        props.put("felix.webconsole.configprinter.modes", "always");
+
+        return bundleContext.registerService(WebConsolePrinter.class.getName(),
+                                               propertiesPrinter, props);
+    }
+
+    public static void destroyPlugin(final ServiceRegistration plugin) {
+        if ( plugin != null) {
+            plugin.unregister();
+        }
+    }
+
+    private static String HEADLINE = "Apache Sling Scheduler";
+
+    private final QuartzScheduler scheduler;
+
+    public WebConsolePrinter(final QuartzScheduler qs) {
+        this.scheduler = qs;
+    }
+
+    /**
+     * Print out the configuration
+     * @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
+     */
+    public void printConfiguration(PrintWriter pw) {
+        pw.println(HEADLINE);
+        pw.println();
+        final Scheduler s = this.scheduler.getScheduler();
+        if ( s != null ) {
+            pw.println("Status : active");
+            try {
+                pw.print  ("Name   : ");
+                pw.println(s.getSchedulerName());
+                pw.print  ("Id     : ");
+                pw.println(s.getSchedulerInstanceId());
+                final List<String> groups = s.getJobGroupNames();
+                for(final String group : groups) {
+                    pw.println();
+                    pw.print  ("Group ");
+                    pw.println(group);
+                    pw.println("---------------------------------------------------------------------------");
+                    final Set<JobKey> keys = s.getJobKeys(GroupMatcher.groupEquals(group));
+                    for(final JobKey key : keys) {
+                        final JobDetail detail = s.getJobDetail(key);
+                        pw.print("Job : ");
+                        pw.print(key.getName());
+                        if ( detail.getDescription() != null && detail.getDescription().length()
> 0 ) {
+                            pw.print(" (");
+                            pw.print(detail.getDescription());
+                            pw.print(")");
+                        }
+                        pw.print(", concurrent: ");
+                        pw.print(!detail.isConcurrentExectionDisallowed());
+                        pw.println();
+                        for(final Trigger trigger : s.getTriggersOfJob(key)) {
+                            pw.print("Trigger : ");
+                            pw.print(trigger);
+                            pw.println();
+                        }
+                        pw.println();
+                    }
+                }
+            } catch ( final SchedulerException se ) {
+                pw.print  ("Unable to print complete configuration: ");
+                pw.println(se.getMessage());
+            }
+        } else {
+            pw.println("Status : not active");
+        }
+    }
+}

Propchange: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/WebConsolePrinter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/WebConsolePrinter.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/WebConsolePrinter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message