cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r291647 - in /cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron: CocoonPipelineCronJob.java CocoonQuartzJobExecutor.java
Date Mon, 26 Sep 2005 16:05:10 GMT
Author: sylvain
Date: Mon Sep 26 09:05:06 2005
New Revision: 291647

URL: http://svn.apache.org/viewcvs?rev=291647&view=rev
Log:
Propagate parameters and objectmap passed to FireJob as request parameters in the job environment

Modified:
    cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java
    cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonQuartzJobExecutor.java

Modified: cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java?rev=291647&r1=291646&r2=291647&view=diff
==============================================================================
--- cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java
(original)
+++ cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java
Mon Sep 26 09:05:06 2005
@@ -45,11 +45,13 @@
 public class CocoonPipelineCronJob extends ServiceableCronJob
                                    implements Configurable, ConfigurableCronJob  {
 
-	public static final String PIPELINE_PARAM = "pipeline";
+    public static final String PIPELINE_PARAM = "pipeline";
 
-	private String pipeline;
+    private String configuredPipeline;
+    private String pipeline;
 
 	public void execute(String name) {
+
 		if (getLogger ().isDebugEnabled ()) {
 			getLogger().debug ("CocoonPipelineCronJob: " + name + ", calling pipeline: " + pipeline);
 		}
@@ -86,7 +88,7 @@
 	}
 
 	public void configure(final Configuration config) throws ConfigurationException {
-		this.pipeline = config.getChild(PIPELINE_PARAM).getValue("samples/hello-world/hello.xhtml");
+		this.configuredPipeline = config.getChild(PIPELINE_PARAM).getValue(null);
 	}
 
 	/* (non-Javadoc)
@@ -94,7 +96,9 @@
 	 */
 	public void setup(Parameters params, Map objects) {
 		if (null != params) {
-			pipeline = params.getParameter(PIPELINE_PARAM, pipeline);
-		}
+			pipeline = params.getParameter(PIPELINE_PARAM, configuredPipeline);
+		} else {
+             pipeline = configuredPipeline;      
+        }
 	}
 }

Modified: cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonQuartzJobExecutor.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonQuartzJobExecutor.java?rev=291647&r1=291646&r2=291647&view=diff
==============================================================================
--- cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonQuartzJobExecutor.java
(original)
+++ cocoon/blocks/cron/trunk/java/org/apache/cocoon/components/cron/CocoonQuartzJobExecutor.java
Mon Sep 26 09:05:06 2005
@@ -15,19 +15,32 @@
  */
 package org.apache.cocoon.components.cron;
 
+import java.util.Map;
+
 import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.Constants;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.background.BackgroundEnvironment;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.quartz.JobDataMap;
 import org.quartz.JobExecutionException;
 
 /**
- * This component is resposible to launch a {@link CronJob}s in a Quart Scheduler.
+ * This component is resposible to launch a {@link CronJob}s in a Quartz Scheduler.
+ * <p>
+ * Jobs started with this executor have a {@link BackgroundEnvironment} already set up,
+ * meaning they can use the SourceResolver to access "cocoon:" pipelines.
+ * <p>
+ * Also, these pipelines will be able to access the job's parameters and objectmap defined
+ * by the various {@link org.apache.cocoon.components.cron.JobScheduler#fireJob(String, Parameters,
Map)}
+ * methods using the "<code>cron-parameters</code>" and "<code>cron-objectmap</code>"
request
+ * attributes, respectively.
  *
  * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
  * @version CVS $Id$
@@ -50,6 +63,17 @@
         }
         
         m_env = new BackgroundEnvironment(m_logger, envContext);
+        
+        Request req = ObjectModelHelper.getRequest(m_env.getObjectModel());
+        Map objects = (Map)data.get(QuartzJobScheduler.DATA_MAP_OBJECTMAP);
+        if (objects != null) {
+            req.setAttribute("cron-objectmap", objects);
+        }
+
+        Parameters params = (Parameters)data.get(QuartzJobScheduler.DATA_MAP_PARAMETERS);
+        if (params != null) {
+            req.setAttribute("cron-parameters", params);
+        }
         
         try {
             m_processor = (Processor) m_manager.lookup(Processor.ROLE);



Mime
View raw message