cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: rev 47048 - cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron
Date Wed, 22 Sep 2004 14:42:03 GMT
Author: unico
Date: Wed Sep 22 07:42:00 2004
New Revision: 47048

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
Log:
apply avalon lifecycle methods to jobs that are not looked up from the service manager
similar to createObject FOM functionality

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
Wed Sep 22 07:42:00 2004
@@ -16,6 +16,8 @@
 package org.apache.cocoon.components.cron;
 
 import org.apache.avalon.framework.component.WrapperComponentManager;
+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.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
@@ -70,6 +72,7 @@
             logger.info("Scheduling cron job named '" + name + "'");
         }
 
+        Context appContext = (Context) data.get(QuartzJobScheduler.DATA_MAP_CONTEXT);
         ServiceManager manager = (ServiceManager)data.get(QuartzJobScheduler.DATA_MAP_MANAGER);
         org.apache.cocoon.environment.Context envContext =
                 (org.apache.cocoon.environment.Context)data.get(QuartzJobScheduler.DATA_MAP_ENV_CONTEXT);
@@ -100,6 +103,9 @@
 
             if (null == jobrole) {
                 job = data.get(QuartzJobScheduler.DATA_MAP_OBJECT);
+                ContainerUtil.enableLogging(job, logger);
+                ContainerUtil.contextualize(job, appContext);
+                ContainerUtil.service(job, manager);
             } else {
                 job = manager.lookup(jobrole);
                 release = true;
@@ -136,6 +142,9 @@
 
             if (release) {
                 manager.release(job);
+            }
+            else {
+            	ContainerUtil.dispose(job);
             }
             manager.release(processor);
         }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
Wed Sep 22 07:42:00 2004
@@ -74,8 +74,6 @@
                                            Serviceable, Configurable, Startable,
                                            Disposable, Contextualizable, Initializable {
 
-    private org.apache.cocoon.environment.Context environmentContext;
-
     /** ThreadPool policy RUN */
     private static final String POLICY_RUN = "RUN";
 
@@ -101,6 +99,9 @@
     /** Map key for the job name */
     static final String DATA_MAP_NAME = "QuartzJobScheduler.JobName";
 
+    /** Map key for the avalon context */
+    static final String DATA_MAP_CONTEXT = "QuartzJobScheduler.Context";
+
     /** Map key for the service manager */
     static final String DATA_MAP_MANAGER = "QuartzJobScheduler.ServiceManager";
 
@@ -132,6 +133,12 @@
     /** The scheduler name */
     static final String DEFAULT_QUARTZ_SCHEDULER_NAME = "Cocoon";
 
+    /** The Avalon Context instance */
+    private Context applicationContext;
+
+    /** The Cocoon environment Context instance */
+    private org.apache.cocoon.environment.Context environmentContext;
+
     /** The PooledExecutor instance */
     private PooledExecutor executor;
 
@@ -307,6 +314,7 @@
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
     public void contextualize(Context context) throws ContextException {
+    	this.applicationContext = context;
         this.environmentContext = (org.apache.cocoon.environment.Context)context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
     }
 
@@ -547,6 +555,7 @@
 
         jobDataMap.put(DATA_MAP_NAME, name);
         jobDataMap.put(DATA_MAP_LOGGER, getLogger());
+        jobDataMap.put(DATA_MAP_CONTEXT, this.applicationContext);
         jobDataMap.put(DATA_MAP_MANAGER, this.manager);
         jobDataMap.put(DATA_MAP_ENV_CONTEXT, this.environmentContext);
         jobDataMap.put(DATA_MAP_RUN_CONCURRENT, new Boolean(canRunConcurrently));

Mime
View raw message