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-1059 improved exception handling for JobRunnableAdapter
Date Fri, 01 Jan 2016 23:30:51 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master e81a1a45a -> 3d8a30629


DELTASPIKE-1059 improved exception handling for JobRunnableAdapter


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

Branch: refs/heads/master
Commit: 3d8a30629d9784e5991d7c8c167f836403f5678d
Parents: e81a1a4
Author: gpetracek <gpetracek@apache.org>
Authored: Fri Jan 1 23:42:53 2016 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Sat Jan 2 00:29:16 2016 +0100

----------------------------------------------------------------------
 .../scheduler/impl/JobRunnableAdapter.java      | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/3d8a3062/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java
b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java
index ab03f27..7891fb2 100644
--- a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java
+++ b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.deltaspike.scheduler.impl;
 
+import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.core.util.ClassUtils;
 import org.quartz.Job;
@@ -25,10 +26,16 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 
 import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
 
+//configured via SchedulerBaseConfig
 @Typed()
 public class JobRunnableAdapter implements Job
 {
+    @Inject
+    private BeanManager beanManager;
+
     @Override
     public void execute(JobExecutionContext context) throws JobExecutionException
     {
@@ -36,6 +43,17 @@ public class JobRunnableAdapter implements Job
             ClassUtils.tryToLoadClassForName(context.getJobDetail().getKey().getName(), Runnable.class);
 
         Runnable runnableBean = BeanProvider.getContextualReference(jobClass);
-        runnableBean.run();
+
+        try
+        {
+            runnableBean.run();
+        }
+        catch (Throwable t)
+        {
+            //just in this case to reduce the implementation(s) of runnable (annotated with
@Scheduled)
+            //to an absolute minimum.
+            //(custom implementations of org.quartz.Job need to do it on their own)
+            this.beanManager.fireEvent(new ExceptionToCatchEvent(t));
+        }
     }
 }


Mime
View raw message