cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r586218 - in /cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron: QuartzJobExecutor.java QuartzJobScheduler.java QuartzJobSchedulerEntry.java
Date Fri, 19 Oct 2007 01:48:19 GMT
Author: vgritsenko
Date: Thu Oct 18 18:48:19 2007
New Revision: 586218

URL: http://svn.apache.org/viewvc?rev=586218&view=rev
Log:
switching to new AbstractLogEnabled

Modified:
    cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
    cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
    cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java

Modified: cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java?rev=586218&r1=586217&r2=586218&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
(original)
+++ cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
Thu Oct 18 18:48:19 2007
@@ -20,9 +20,14 @@
 
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.logger.LogEnabled;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.cocoon.util.AbstractLogEnabled;
+import org.apache.cocoon.util.avalon.CLLoggerWrapper;
+
 import org.quartz.Job;
 import org.quartz.JobDataMap;
 import org.quartz.JobExecutionContext;
@@ -31,13 +36,12 @@
 /**
  * This component is resposible to launch a {@link CronJob}s in a Quart Scheduler.
  *
- * @version $Id$
- *
  * @since 2.1.1
+ * @version $Id$
  */
-public class QuartzJobExecutor implements Job {
+public class QuartzJobExecutor extends AbstractLogEnabled
+                               implements Job {
 
-    protected Logger m_logger;
     protected Context m_context;
     protected ServiceManager m_manager;
 
@@ -47,41 +51,42 @@
     public void execute(final JobExecutionContext context) throws JobExecutionException {
 
         final JobDataMap data = context.getJobDetail().getJobDataMap();
-
         final String name = (String) data.get(QuartzJobScheduler.DATA_MAP_NAME);
 
-        m_logger = (Logger) data.get(QuartzJobScheduler.DATA_MAP_LOGGER);
         m_context = (Context) data.get(QuartzJobScheduler.DATA_MAP_CONTEXT);
         m_manager = (ServiceManager) data.get(QuartzJobScheduler.DATA_MAP_MANAGER);
         
         final Boolean canRunConcurrentlyB = ((Boolean) data.get(QuartzJobScheduler.DATA_MAP_RUN_CONCURRENT));
-        final boolean canRunConcurrently = ((canRunConcurrentlyB == null) ? true : canRunConcurrentlyB.booleanValue());
+        final boolean canRunConcurrently = (canRunConcurrentlyB == null) ? true : canRunConcurrentlyB.booleanValue();
 
         if (!canRunConcurrently) {
             Boolean isRunning = (Boolean) data.get(QuartzJobScheduler.DATA_MAP_KEY_ISRUNNING);
             if (Boolean.TRUE.equals(isRunning)) {
-                m_logger.warn("Cron job name '" + name +
-                            " already running but configured to not allow concurrent runs.
Will discard this scheduled run");
+                getLogger().warn("Cron job name '" + name +
+                                 " already running but configured to not allow concurrent
runs. Will discard this scheduled run");
                 return;
             }
         }
 
-        if (m_logger.isInfoEnabled()) {
-            m_logger.info("Executing cron job named '" + name + "'");
+        if (getLogger().isInfoEnabled()) {
+            getLogger().info("Executing cron job named '" + name + "'");
         }
 
         setup(data);
 
         Object job = null;
-        String jobrole = null;
+        String jobrole;
         boolean release = false;
         boolean dispose = false;
         try {
             jobrole = (String) data.get(QuartzJobScheduler.DATA_MAP_ROLE);
 
-            if (null == jobrole) {
+            if (jobrole == null) {
                 job = data.get(QuartzJobScheduler.DATA_MAP_OBJECT);
-                ContainerUtil.enableLogging(job, m_logger);
+                // Legacy support code
+                if (job instanceof LogEnabled) {
+                    ContainerUtil.enableLogging(job, new CLLoggerWrapper(LogFactory.getLog(job.getClass())));
+                }
                 ContainerUtil.contextualize(job, m_context);
                 ContainerUtil.service(job, m_manager);
                 dispose = true;
@@ -103,16 +108,15 @@
             } else if (job instanceof Runnable) {
                 ((Runnable) job).run();
             } else {
-                m_logger.error("job named '" + name + "' is of invalid class: " + job.getClass().getName());
+                getLogger().error("job named '" + name + "' is of invalid class: " + job.getClass().getName());
             }
         } catch (final Throwable t) {
-            m_logger.error("Cron job name '" + name + "' died.", t);
+            getLogger().error("Cron job name '" + name + "' died.", t);
 
             if (t instanceof JobExecutionException) {
                 throw (JobExecutionException) t;
             }
         } finally {
-
             release(data);
 
             if (m_manager != null && release) {
@@ -131,5 +135,4 @@
     protected void release(JobDataMap data) {
         data.put(QuartzJobScheduler.DATA_MAP_KEY_ISRUNNING, Boolean.FALSE);
     }
-
 }

Modified: cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java?rev=586218&r1=586217&r2=586218&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
(original)
+++ cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
Thu Oct 18 18:48:19 2007
@@ -41,6 +41,7 @@
 import org.apache.cocoon.thread.RunnableManager;
 import org.apache.cocoon.thread.ThreadPool;
 import org.apache.cocoon.util.AbstractLogEnabled;
+import org.apache.cocoon.util.avalon.CLLoggerWrapper;
 
 import org.quartz.CronTrigger;
 import org.quartz.Job;
@@ -89,7 +90,10 @@
     /** Map key for the service manager */
     static final String DATA_MAP_MANAGER = "QuartzJobScheduler.ServiceManager";
 
-    /** Map key for the logger */
+    /**
+     * Map key for the logger
+     * @deprecated Use commons logging.
+     */
     static final String DATA_MAP_LOGGER = "QuartzJobScheduler.Logger";
 
     /** Map key for the concurrent run property */
@@ -555,7 +559,7 @@
     protected JobDataMap initDataMap(JobDataMap jobDataMap, String jobName, boolean concurent,
                                      Parameters params, Map objects) {
         jobDataMap.put(DATA_MAP_NAME, jobName);
-        jobDataMap.put(DATA_MAP_LOGGER, getLogger());
+        jobDataMap.put(DATA_MAP_LOGGER, new CLLoggerWrapper(getLogger()));
         jobDataMap.put(DATA_MAP_CONTEXT, this.context);
         jobDataMap.put(DATA_MAP_MANAGER, this.manager);
         jobDataMap.put(DATA_MAP_RUN_CONCURRENT, (concurent? Boolean.TRUE: Boolean.FALSE));

Modified: cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java?rev=586218&r1=586217&r2=586218&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java
(original)
+++ cocoon/trunk/blocks/cocoon-cron/cocoon-cron-impl/src/main/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java
Thu Oct 18 18:48:19 2007
@@ -74,8 +74,7 @@
      */
     public String getJobName() {
         String name = (String)m_data.get(QuartzJobScheduler.DATA_MAP_ROLE);
-
-        if (null == name) {
+        if (name == null) {
             name = m_data.get(QuartzJobScheduler.DATA_MAP_OBJECT).getClass().getName();
         }
 



Mime
View raw message