cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: rev 47062 - cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron
Date Wed, 22 Sep 2004 16:37:31 GMT
Author: unico
Date: Wed Sep 22 09:37:29 2004
New Revision: 47062

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzDriverDelegate.java
   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
   cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreCMT.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreTX.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java
Log:
pass the application context instead of the environment context 
and remove and add transient context object to the data map

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzDriverDelegate.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzDriverDelegate.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzDriverDelegate.java
Wed Sep 22 09:37:29 2004
@@ -15,10 +15,10 @@
  */
 package org.apache.cocoon.components.cron;
 
+import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
-
-import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.Constants;
 
 import org.quartz.Calendar;
 import org.quartz.CronTrigger;
@@ -89,8 +89,8 @@
         if (map != null) {
             this.logger.debug("QuartzDriverDelegate: Removing transient data");
             map.remove(QuartzJobScheduler.DATA_MAP_LOGGER);
+            map.remove(QuartzJobScheduler.DATA_MAP_CONTEXT);
             map.remove(QuartzJobScheduler.DATA_MAP_MANAGER);
-            map.remove(QuartzJobScheduler.DATA_MAP_ENV_CONTEXT);
         }
     }
 
@@ -104,8 +104,8 @@
             if (map != null) {
                 this.logger.debug("QuartzDriverDelegate: Adding transient data");
                 map.put(QuartzJobScheduler.DATA_MAP_LOGGER, this.logger);
+                map.put(QuartzJobScheduler.DATA_MAP_CONTEXT, this.context);
                 map.put(QuartzJobScheduler.DATA_MAP_MANAGER, this.manager);
-                map.put(QuartzJobScheduler.DATA_MAP_ENV_CONTEXT, this.context);
             }
         }
         return job;

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 09:37:29 2004
@@ -18,11 +18,13 @@
 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.context.ContextException;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 
+import org.apache.cocoon.Constants;
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.components.CocoonComponentManager;
 import org.apache.cocoon.environment.background.BackgroundEnvironment;
@@ -74,8 +76,14 @@
 
         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);
+        org.apache.cocoon.environment.Context envContext;
+        try {
+            envContext =
+                (org.apache.cocoon.environment.Context) appContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
+        }
+        catch (ContextException e) {
+        	throw new JobExecutionException(e);
+        }
 
         BackgroundEnvironment env;
         try {

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 09:37:29 2004
@@ -15,6 +15,12 @@
  */
 package org.apache.cocoon.components.cron;
 
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
 import org.apache.avalon.framework.CascadingException;
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
@@ -32,12 +38,6 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
-
-import org.apache.cocoon.Constants;
-
-import EDU.oswego.cs.dl.util.concurrent.BoundedBuffer;
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
 import org.quartz.CronTrigger;
 import org.quartz.Job;
 import org.quartz.JobDataMap;
@@ -55,11 +55,9 @@
 import org.quartz.utils.DBConnectionManager;
 import org.quartz.utils.JNDIConnectionProvider;
 
-import java.text.ParseException;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Map;
-import java.util.NoSuchElementException;
+import EDU.oswego.cs.dl.util.concurrent.BoundedBuffer;
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
 
 /**
  * This component can either schedule jobs or directly execute one.
@@ -105,9 +103,6 @@
     /** Map key for the service manager */
     static final String DATA_MAP_MANAGER = "QuartzJobScheduler.ServiceManager";
 
-    /** Map key for the environment context (needed by BackgroundEnvironment) */
-    static final String DATA_MAP_ENV_CONTEXT = "QuartzJobScheduler.EnvironmentContext";
-
     /** Map key for the logger */
     static final String DATA_MAP_LOGGER = "QuartzJobScheduler.Logger";
 
@@ -134,10 +129,7 @@
     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;
+    private Context context;
 
     /** The PooledExecutor instance */
     private PooledExecutor executor;
@@ -314,8 +306,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);
+    	this.context = context;
     }
 
     public void initialize() throws Exception {
@@ -555,9 +546,8 @@
 
         jobDataMap.put(DATA_MAP_NAME, name);
         jobDataMap.put(DATA_MAP_LOGGER, getLogger());
-        jobDataMap.put(DATA_MAP_CONTEXT, this.applicationContext);
+        jobDataMap.put(DATA_MAP_CONTEXT, this.context);
         jobDataMap.put(DATA_MAP_MANAGER, this.manager);
-        jobDataMap.put(DATA_MAP_ENV_CONTEXT, this.environmentContext);
         jobDataMap.put(DATA_MAP_RUN_CONCURRENT, new Boolean(canRunConcurrently));
 
         if (null != params) {
@@ -715,9 +705,9 @@
 
         JobStoreSupport store = null;
         if (type.equals("tx")) {
-            store = new QuartzJobStoreTX(getLogger(), this.manager, this.environmentContext);
+            store = new QuartzJobStoreTX(getLogger(), this.manager, this.context);
         } else if (type.equals("cmt")) {
-            store = new QuartzJobStoreCMT(getLogger(), this.manager, this.environmentContext);
+            store = new QuartzJobStoreCMT(getLogger(), this.manager, this.context);
         } else {
             throw new ConfigurationException("Unknown store type: " + type);
         }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreCMT.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreCMT.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreCMT.java
Wed Sep 22 09:37:29 2004
@@ -15,11 +15,10 @@
  */
 package org.apache.cocoon.components.cron;
 
+import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
 
-import org.apache.cocoon.environment.Context;
-
 import org.quartz.impl.jdbcjobstore.DriverDelegate;
 import org.quartz.impl.jdbcjobstore.JobStoreCMT;
 import org.quartz.impl.jdbcjobstore.NoSuchDelegateException;
@@ -31,9 +30,10 @@
  * @since 2.1.6
  */
 public class QuartzJobStoreCMT extends JobStoreCMT {
-    private Logger logger;
-    private ServiceManager manager;
-    private Context context;
+	
+    private final Logger logger;
+    private final ServiceManager manager;
+    private final Context context;
     private DriverDelegate delegate;
 
     public QuartzJobStoreCMT(Logger logger, ServiceManager manager, Context context) {

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreTX.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreTX.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreTX.java
Wed Sep 22 09:37:29 2004
@@ -15,11 +15,10 @@
  */
 package org.apache.cocoon.components.cron;
 
+import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
 
-import org.apache.cocoon.environment.Context;
-
 import org.quartz.impl.jdbcjobstore.JobStoreTX;
 import org.quartz.impl.jdbcjobstore.DriverDelegate;
 import org.quartz.impl.jdbcjobstore.NoSuchDelegateException;
@@ -31,9 +30,10 @@
  * @since 2.1.6
  */
 public class QuartzJobStoreTX extends JobStoreTX {
-    private Logger logger;
-    private ServiceManager manager;
-    private Context context;
+
+	private final Logger logger;
+    private final ServiceManager manager;
+    private final Context context;
     private DriverDelegate delegate;
 
     public QuartzJobStoreTX(Logger logger, ServiceManager manager, Context context) {

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java
Wed Sep 22 09:37:29 2004
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.components.cron;
 
-import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.Date;
 import java.util.Map;

Mime
View raw message