You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2004/09/09 04:06:47 UTC
svn commit: rev 43559 - in cocoon/trunk: . src/blocks/cron/java/org/apache/cocoon/components/cron
Author: vgritsenko
Date: Wed Sep 8 19:06:46 2004
New Revision: 43559
Added:
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzDriverDelegate.java
- copied unchanged from rev 37498, cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzDriverDelegate.java
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreCMT.java
- copied unchanged from rev 37498, cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreCMT.java
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreTX.java
- copied unchanged from rev 37498, cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreTX.java
Modified:
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java
cocoon/trunk/status.xml
Log:
sync with 2.1 branch. does not work yet.
Modified: cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java
==============================================================================
--- cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java (original)
+++ cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java Wed Sep 8 19:06:46 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,36 +15,29 @@
*/
package org.apache.cocoon.components.cron;
-import java.io.OutputStream;
-import java.util.Map;
-
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceManager;
+
import org.apache.cocoon.environment.background.BackgroundEnvironment;
import org.apache.cocoon.environment.internal.EnvironmentHelper;
-import org.apache.cocoon.util.NullOutputStream;
+
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
+import java.util.Map;
/**
* This component is resposible to launch a {@link CronJob}s in a Quart Scheduler.
*
* @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
- * @version CVS $Id: QuartzJobExecutor.java,v 1.9 2004/06/04 11:08:08 cziegeler Exp $
+ * @version CVS $Id$
*
* @since 2.1.1
*/
-public class QuartzJobExecutor
-implements Job {
- /** Map key for the run status */
- static final String DATA_MAP_KEY_ISRUNNING = "QuartzJobExecutor.isRunning";
-
- /** Shared instance (no state, as it does nothing) */
- static final OutputStream NULL_OUTPUT = new NullOutputStream();
+public class QuartzJobExecutor implements Job {
/* (non-Javadoc)
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
@@ -60,12 +53,11 @@
final boolean canRunConcurrently = ((canRunConcurrentlyB == null) ? true : canRunConcurrentlyB.booleanValue());
if (!canRunConcurrently) {
- Boolean isRunning = (Boolean)data.get(DATA_MAP_KEY_ISRUNNING);
+ Boolean isRunning = (Boolean)data.get(QuartzJobScheduler.DATA_MAP_KEY_ISRUNNING);
if ((null != isRunning) && isRunning.booleanValue()) {
logger.warn("Cron job name '" + name +
" already running but configured to not allow concurrent runs. Will discard this scheduled run");
-
return;
}
}
@@ -74,16 +66,18 @@
logger.info("Scheduling cron job named '" + name + "'");
}
+ 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);
+
+ BackgroundEnvironment env = new BackgroundEnvironment(logger, envContext);
+
Object job = null;
String jobrole = null;
-
- 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);
- BackgroundEnvironment env;
- env = new BackgroundEnvironment(logger, envContext);
+
boolean release = false;
try {
+ env.startingProcessing();
EnvironmentHelper.enterProcessor(env.getProcessor(), manager, env);
jobrole = (String)data.get(QuartzJobScheduler.DATA_MAP_ROLE);
@@ -101,7 +95,7 @@
((ConfigurableCronJob)job).setup(params, objects);
}
- data.put(DATA_MAP_KEY_ISRUNNING, Boolean.TRUE);
+ data.put(QuartzJobScheduler.DATA_MAP_KEY_ISRUNNING, Boolean.TRUE);
if (job instanceof Job) {
((Job)job).execute(context);
@@ -119,11 +113,12 @@
throw (JobExecutionException)t;
}
} finally {
- data.put(DATA_MAP_KEY_ISRUNNING, Boolean.FALSE);
-
+ data.put(QuartzJobScheduler.DATA_MAP_KEY_ISRUNNING, Boolean.FALSE);
+
EnvironmentHelper.leaveProcessor();
+ env.finishingProcessing();
- if (release && null != manager) {
+ if (release && manager != null) {
manager.release(job);
}
}
Modified: cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
==============================================================================
--- cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java (original)
+++ cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java Wed Sep 8 19:06:46 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,12 +15,6 @@
*/
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;
@@ -38,7 +32,12 @@
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;
@@ -48,16 +47,19 @@
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
import org.quartz.impl.DirectSchedulerFactory;
-import org.quartz.impl.jdbcjobstore.JobStoreCMT;
+import org.quartz.impl.jdbcjobstore.InvalidConfigurationException;
import org.quartz.impl.jdbcjobstore.JobStoreSupport;
-import org.quartz.impl.jdbcjobstore.JobStoreTX;
import org.quartz.simpl.RAMJobStore;
import org.quartz.spi.JobStore;
+import org.quartz.utils.ConnectionProvider;
+import org.quartz.utils.DBConnectionManager;
+import org.quartz.utils.JNDIConnectionProvider;
-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 java.text.ParseException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Map;
+import java.util.NoSuchElementException;
/**
* This component can either schedule jobs or directly execute one.
@@ -67,13 +69,14 @@
*
* @since 2.1.1
*/
-public class QuartzJobScheduler
-extends AbstractLogEnabled
-implements JobScheduler, Component, ThreadSafe, Serviceable, Configurable, Startable, Disposable,
- Contextualizable, Initializable {
- private org.apache.cocoon.environment.Context environmentContext;
+public class QuartzJobScheduler extends AbstractLogEnabled
+ implements JobScheduler, Component, ThreadSafe,
+ Serviceable, Configurable, Startable,
+ Disposable, Contextualizable, Initializable {
+
+ private org.apache.cocoon.environment.Context environmentContext;
- /** ThreadPool policy RUN */
+ /** ThreadPool policy RUN */
private static final String POLICY_RUN = "RUN";
/** ThreadPool policy WAIT */
@@ -88,6 +91,7 @@
/** ThreadPool policy DISCARD-OLDEST */
private static final String POLICY_DISCARD_OLDEST = "DISCARDOLDEST";
+
/** Map key for the component role */
static final String DATA_MAP_ROLE = "QuartzJobScheduler.ROLE";
@@ -99,7 +103,7 @@
/** 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";
@@ -118,6 +122,10 @@
/** Map key for the last JobExecutionContext */
static final String DATA_MAP_JOB_EXECUTION_CONTEXT = "QuartzJobScheduler.JobExecutionContext";
+ /** Map key for the run status */
+ static final String DATA_MAP_KEY_ISRUNNING = "QuartzJobExecutor.isRunning";
+
+
/** The group name */
static final String DEFAULT_QUARTZ_JOB_GROUP = "Cocoon";
@@ -132,7 +140,7 @@
/** The ServiceManager instance */
private ServiceManager manager;
-
+
/** The configuration, parsed in initialize() */
private Configuration config;
@@ -236,7 +244,7 @@
addJob(name, jobDataMap, timeEntry, canRunConcurrently, params, objects);
}
-
+
/**
* Schedule a periodic job. The job is started the first time when the period has passed. Note that if a job with
* the same name has already beed added it is overwritten.
@@ -258,12 +266,12 @@
}
final JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put(DATA_MAP_OBJECT, job);
-
+
final long ms = period * 1000;
final SimpleTrigger timeEntry =
new SimpleTrigger(name, DEFAULT_QUARTZ_JOB_GROUP, new Date(System.currentTimeMillis() + ms), null,
SimpleTrigger.REPEAT_INDEFINITELY, ms);
-
+
addJob(name, jobDataMap, timeEntry, canRunConcurrently, params, objects);
}
@@ -272,7 +280,7 @@
*/
public void configure(final Configuration config)
throws ConfigurationException {
- this.config = config;
+ this.config = config;
}
/* (non-Javadoc)
@@ -295,38 +303,37 @@
this.executor = null;
}
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
- */
- public void contextualize(Context context) throws ContextException {
- this.environmentContext = (org.apache.cocoon.environment.Context)context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
- }
-
- public void initialize() throws Exception {
- try {
- // If cocoon reloads (or is it the container that reload us?)
- // we cannot create the same scheduler again
- final String runID = new Date().toString().replace(' ', '_');
- final ThreadPool pool = createThreadPool(this.config.getChild("thread-pool"));
- final JobStore store = createJobStore(this.config.getChild("job-store"));
- DirectSchedulerFactory.getInstance().createScheduler(DEFAULT_QUARTZ_SCHEDULER_NAME, runID, pool,store);
- // scheduler = DirectSchedulerFactory.getInstance().getScheduler(DEFAULT_QUARTZ_SCHEDULER_NAME, runID);
- scheduler = DirectSchedulerFactory.getInstance().getScheduler(DEFAULT_QUARTZ_SCHEDULER_NAME);
- } catch (final SchedulerException se) {
- throw new ConfigurationException("cannot create a quartz scheduler", se);
- }
-
- final Configuration[] triggers = this.config.getChild("triggers").getChildren("trigger");
- createTriggers(triggers);
-
- // We're finished with the configuration
- this.config = null;
-
- if (getLogger().isDebugEnabled() && (triggers.length == 0)) {
- getLogger().debug("no triggers configured at startup");
- }
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.environmentContext = (org.apache.cocoon.environment.Context)context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
+ }
+
+ public void initialize() throws Exception {
+ try {
+ // If cocoon reloads (or is it the container that reload us?)
+ // we cannot create the same scheduler again
+ final String runID = new Date().toString().replace(' ', '_');
+ final ThreadPool pool = createThreadPool(this.config.getChild("thread-pool"));
+ final JobStore store = createJobStore(DEFAULT_QUARTZ_SCHEDULER_NAME, runID, this.config.getChild("store"));
+ DirectSchedulerFactory.getInstance().createScheduler(DEFAULT_QUARTZ_SCHEDULER_NAME, runID, pool, store);
+ // scheduler = DirectSchedulerFactory.getInstance().getScheduler(DEFAULT_QUARTZ_SCHEDULER_NAME, runID);
+ scheduler = DirectSchedulerFactory.getInstance().getScheduler(DEFAULT_QUARTZ_SCHEDULER_NAME);
+ } catch (final SchedulerException se) {
+ throw new ConfigurationException("cannot create a quartz scheduler", se);
+ }
- }
+ final Configuration[] triggers = this.config.getChild("triggers").getChildren("trigger");
+ createTriggers(triggers);
+
+ // We're finished with the configuration
+ this.config = null;
+
+ if (getLogger().isDebugEnabled() && (triggers.length == 0)) {
+ getLogger().debug("no triggers configured at startup");
+ }
+ }
/* (non-Javadoc)
* @see org.apache.cocoon.components.cron.JobScheduler#fireTarget(java.lang.Object)
@@ -540,9 +547,9 @@
jobDataMap.put(DATA_MAP_NAME, name);
jobDataMap.put(DATA_MAP_LOGGER, getLogger());
- jobDataMap.put(DATA_MAP_MANAGER, manager);
- jobDataMap.put(DATA_MAP_RUN_CONCURRENT, new Boolean(canRunConcurrently));
+ 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) {
jobDataMap.put(DATA_MAP_PARAMETERS, params);
@@ -690,23 +697,56 @@
}
}
- private JobStore createJobStore(final Configuration configuration)
+ private JobStore createJobStore(String instanceName, String instanceID, final Configuration configuration)
throws ConfigurationException {
String type = configuration.getAttribute("type", "ram");
if (type.equals("ram")) {
return new RAMJobStore();
}
+
JobStoreSupport store = null;
if (type.equals("tx")) {
- store = new JobStoreTX();
+ store = new QuartzJobStoreTX(getLogger(), this.manager, this.environmentContext);
+ } else if (type.equals("cmt")) {
+ store = new QuartzJobStoreCMT(getLogger(), this.manager, this.environmentContext);
+ } else {
+ throw new ConfigurationException("Unknown store type: " + type);
}
- else if (type.equals("cmt")) {
- store = new JobStoreCMT();
+
+ Configuration dsConfig = configuration.getChild("datasource", false);
+ if (dsConfig == null) {
+ throw new ConfigurationException("Store " + type + " requires datasource configuration.");
}
- else {
- throw new ConfigurationException("Unknown store type: " + type);
+
+ String dsName = dsConfig.getValue();
+ String dsType = dsConfig.getAttribute("provider", "jndi");
+
+ ConnectionProvider provider;
+ if (dsType.equals("jndi")) {
+ provider = new JNDIConnectionProvider(dsName, false);
+ } else {
+ // assume class name
+ try {
+ provider = (ConnectionProvider)Class.forName(dsType).newInstance();
+ } catch (Exception e) {
+ throw new ConfigurationException("Could not instantiate ConnectionProvider class " + dsType);
+ }
}
- store.setDataSource(configuration.getChild("datasource").getValue());
+
+ store.setInstanceName(instanceName);
+ store.setInstanceId(instanceID);
+ store.setDataSource(dsType + ":" + dsName);
+ DBConnectionManager.getInstance().addConnectionProvider(dsType + ":" + dsName, provider);
+
+ String delegate = configuration.getAttribute("delegate", null);
+ try {
+ if (delegate != null) {
+ store.setDriverDelegateClass(delegate);
+ }
+ } catch (InvalidConfigurationException e) {
+ throw new ConfigurationException("Could not instantiate DriverDelegate class " + delegate, e);
+ }
+
return store;
}
Modified: cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java
==============================================================================
--- cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java (original)
+++ cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java Wed Sep 8 19:06:46 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,15 +26,14 @@
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
-
/**
* Implementation of the JobSchedulerEntry interface for the QuartzJobScheduler
*
* @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
- * @version CVS $Id: QuartzJobSchedulerEntry.java,v 1.4 2004/03/05 13:01:49 bdelacretaz Exp $
+ * @version CVS $Id$
*/
-public class QuartzJobSchedulerEntry
-implements JobSchedulerEntry {
+public class QuartzJobSchedulerEntry implements JobSchedulerEntry {
+
/** The data map */
private final JobDataMap m_data;
@@ -101,8 +100,7 @@
* @see org.apache.cocoon.components.cron.JobSchedulerEntry#isRunning()
*/
public boolean isRunning() {
- Boolean runs = (Boolean)m_data.get(QuartzJobExecutor.DATA_MAP_KEY_ISRUNNING);
-
+ Boolean runs = (Boolean)m_data.get(QuartzJobScheduler.DATA_MAP_KEY_ISRUNNING);
if (null != runs) {
return runs.booleanValue();
}
Modified: cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java
==============================================================================
--- cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java (original)
+++ cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java Wed Sep 8 19:06:46 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,94 +28,93 @@
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
-
/**
* A simple test CronJob which also calls a pipeline internally.
*
* @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
- * @author <a href="http://apache.org/~reinhard">Reinhard Poetz</a>
- * @version CVS $Id: TestCronJob.java,v 1.8 2004/05/25 07:28:24 cziegeler Exp $
- *
+ * @author <a href="http://apache.org/~reinhard">Reinhard Poetz</a>
+ * @version CVS $Id$
* @since 2.1.1
*/
public class TestCronJob extends ServiceableCronJob
- implements Configurable, ConfigurableCronJob {
-
+ implements Configurable, ConfigurableCronJob {
+
/** Parameter key for the message */
public static final String PARAMETER_MESSAGE = "TestCronJob.Parameter.Message";
/** Parameter key for the sleep value */
public static final String PARAMETER_SLEEP = "TestCronJob.Parameter.Sleep";
- /** Parameter key for the pipeline to be called */
- public static final String PARAMETER_PIPELINE = "TestCronJob.Parameter.Pipeline";
+ /** Parameter key for the pipeline to be called */
+ public static final String PARAMETER_PIPELINE = "TestCronJob.Parameter.Pipeline";
/** The configured message */
private String m_msg;
/** The configured sleep time */
private int m_sleep;
-
+
/** The pipeline to be called */
- private String pipeline = null;
-
+ private String pipeline;
+
/* (non-Javadoc)
* @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(final Configuration config)
- throws ConfigurationException {
+ throws ConfigurationException {
m_msg = config.getChild("msg").getValue("I was not configured");
m_sleep = config.getChild("sleep").getValueAsInteger(11000);
pipeline = config.getChild("pipeline").getValue("samples/hello-world/hello.xhtml");
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.components.cron.CronJob#execute(java.lang.String)
*/
public void execute(String name) {
- getLogger().info("CronJob " + name + " launched at " + new Date() + " with message '" + m_msg +
- "' and sleep timeout of " + m_sleep + "ms");
-
+ getLogger().info("CronJob " + name + " launched at " + new Date() + " with message '" + m_msg +
+ "' and sleep timeout of " + m_sleep + "ms");
+
SourceResolver resolver = null;
Source src = null;
try {
- resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
- src = resolver.resolveURI("cocoon://" + pipeline);
- InputStream is = src.getInputStream();
-
- InputStreamReader reader = new InputStreamReader(is);
- StringBuffer sb = new StringBuffer();
- char[] b = new char[8192];
- int n;
-
- while((n = reader.read(b)) > 0) {
- sb.append(b, 0, n);
- }
-
- reader.close();
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ src = resolver.resolveURI("cocoon://" + this.pipeline);
+
+ InputStreamReader r = new InputStreamReader(src.getInputStream());
+ try {
+ StringBuffer sb = new StringBuffer();
+ char[] b = new char[8192];
+ int n;
+
+ while((n = r.read(b)) > 0) {
+ sb.append(b, 0, n);
+ }
+
+ getLogger().info("CronJob " + name + " called pipeline " + pipeline +
+ " and received following content:\n" + sb.toString());
+ } finally {
+ r.close();
+ }
- getLogger().info("Cronjob " + name + " called pipeline " + pipeline +
- " and received following content:\n" + sb.toString() );
} catch(Exception e) {
throw new CascadingRuntimeException("CronJob " + name + " raised an exception", e);
} finally {
- if ( resolver != null ) {
- resolver.release(src);
+ if (resolver != null) {
+ resolver.release(src);
this.manager.release(resolver);
resolver = null;
- src = null;
+ src = null;
}
}
-
- try {
- Thread.sleep(m_sleep);
- } catch (final InterruptedException ie) {
- //getLogger().error("CronJob " + name + " interrupted", ie);
- }
-
- getLogger().info("CronJob " + name + " finished at " + new Date() + " with message '" + m_msg +
- "' and sleep timeout of " + m_sleep + "ms");
-
+
+ try {
+ Thread.sleep(m_sleep);
+ } catch (final InterruptedException ie) {
+ //getLogger().error("CronJob " + name + " interrupted", ie);
+ }
+
+ getLogger().info("CronJob " + name + " finished at " + new Date() + " with message '" + m_msg +
+ "' and sleep timeout of " + m_sleep + "ms");
}
/* (non-Javadoc)
@@ -126,7 +125,7 @@
m_msg = params.getParameter(PARAMETER_MESSAGE, m_msg);
m_sleep = params.getParameterAsInteger(PARAMETER_SLEEP, m_sleep);
pipeline = params.getParameter(PARAMETER_PIPELINE, pipeline );
-
+
}
- }
+ }
}
Modified: cocoon/trunk/status.xml
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Wed Sep 8 19:06:46 2004
@@ -320,8 +320,14 @@
</action>
</release>
<release version="2.1.6" date="TBD">
+ <action dev="VG" type="fix">
+ Cron block: Fixed memory leak, QuartzJobExecutor was not releasing pipelines.
+ </action>
<action dev="CZ" type="add">
Portal block: New Group Based Profile Manager.
+ </action>
+ <action dev="VG" type="update">
+ Cron block: Add support for persistent job stores, type "tx" and "cmt".
</action>
<action dev="AG" type="update">
Updated rhino to 1.5r4-20040629T1232,