deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject deltaspike git commit: DELTASPIKE-1055 configurable JobRunnableAdapter
Date Wed, 30 Dec 2015 20:00:03 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master aa1893f71 -> 07bf170e8


DELTASPIKE-1055 configurable JobRunnableAdapter


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/07bf170e
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/07bf170e
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/07bf170e

Branch: refs/heads/master
Commit: 07bf170e8a8a039b47922b6f660ef2b1c8f9d2cd
Parents: aa1893f
Author: gpetracek <gpetracek@apache.org>
Authored: Wed Dec 30 20:53:52 2015 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Wed Dec 30 20:58:04 2015 +0100

----------------------------------------------------------------------
 .../scheduler/impl/RunnableQuartzScheduler.java       | 14 +++++++++++++-
 .../scheduler/impl/SchedulerBaseConfig.java           |  7 +++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/07bf170e/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/RunnableQuartzScheduler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/RunnableQuartzScheduler.java
b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/RunnableQuartzScheduler.java
index 9d11f29..5fa533b 100644
--- a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/RunnableQuartzScheduler.java
+++ b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/RunnableQuartzScheduler.java
@@ -18,11 +18,23 @@
  */
 package org.apache.deltaspike.scheduler.impl;
 
+import org.apache.deltaspike.core.util.ClassUtils;
 import org.quartz.Job;
 
 //vetoed class (see SchedulerExtension)
 public class RunnableQuartzScheduler extends AbstractQuartzScheduler<Runnable>
 {
+    private Class<? extends Job> runnableAdapter;
+
+    @Override
+    public void start()
+    {
+        String configuredAdapterClassName = SchedulerBaseConfig.JobCustomization.RUNNABLE_ADAPTER_CLASS_NAME;
+        this.runnableAdapter = ClassUtils.tryToLoadClassForName(configuredAdapterClassName,
Job.class);
+
+        super.start();
+    }
+
     @Override
     protected String getJobName(Class<?> jobClass)
     {
@@ -32,6 +44,6 @@ public class RunnableQuartzScheduler extends AbstractQuartzScheduler<Runnable>
     @Override
     protected Class<? extends Job> createFinalJobClass(Class<? extends Runnable>
jobClass)
     {
-        return JobRunnableAdapter.class;
+        return runnableAdapter;
     }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/07bf170e/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerBaseConfig.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerBaseConfig.java
b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerBaseConfig.java
index 4a2d16f..225891e 100644
--- a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerBaseConfig.java
+++ b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerBaseConfig.java
@@ -27,6 +27,7 @@ public interface SchedulerBaseConfig extends DeltaSpikeBaseConfig
     interface JobCustomization
     {
         String JOB_CLASS_NAME_KEY = "deltaspike.scheduler.job-class";
+        String RUNNABLE_ADAPTER_CLASS_NAME_KEY = "deltaspike.scheduler.runnable-adapter-class";
 
         //don't type it to class to keep quartz optional
         String DEFAULT_JOB_FACTORY_CLASS_NAME = ConfigResolver.resolve("deltaspike.scheduler.DefaultJobFactory")
@@ -39,6 +40,12 @@ public interface SchedulerBaseConfig extends DeltaSpikeBaseConfig
                 .withCurrentProjectStage(true)
                 .withDefault("org.quartz.Job")
                 .getValue();
+
+        //don't type it to class to keep quartz optional (JobRunnableAdapter imports classes
from quartz)
+        String RUNNABLE_ADAPTER_CLASS_NAME = ConfigResolver.resolve(RUNNABLE_ADAPTER_CLASS_NAME_KEY)
+                .withCurrentProjectStage(true)
+                .withDefault("org.apache.deltaspike.scheduler.impl.JobRunnableAdapter")
+                .getValue();
     }
 
     String SCHEDULER_CONFIG_FILE = ConfigResolver.resolve("deltaspike.scheduler.quartz_config-file")


Mime
View raw message