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/27 15:43:05 UTC
svn commit: rev 47290 - in cocoon/trunk/src/blocks/cron: conf java/org/apache/cocoon/components/cron
Author: vgritsenko
Date: Mon Sep 27 06:43:04 2004
New Revision: 47290
Modified:
cocoon/trunk/src/blocks/cron/conf/cron.xconf
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java
Log:
cleanup
Modified: cocoon/trunk/src/blocks/cron/conf/cron.xconf
==============================================================================
--- cocoon/trunk/src/blocks/cron/conf/cron.xconf (original)
+++ cocoon/trunk/src/blocks/cron/conf/cron.xconf Mon Sep 27 06:43:04 2004
@@ -1,4 +1,5 @@
<?xml version="1.0"?>
+
<!--
Copyright 1999-2004 The Apache Software Foundation
@@ -14,6 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+
<xconf xpath="/cocoon" unless="component[@role='org.apache.cocoon.components.cron.JobScheduler']">
<component role="org.apache.cocoon.components.cron.JobScheduler"
@@ -114,47 +116,55 @@
+-->
<!--+
- | Sample trigger definitions
- <trigger name="test-job1"
+ | Sample trigger definitions, use components defined below.
+ <trigger name="test-job1"
target="org.apache.cocoon.components.cron.CronJob/test"
concurrent-runs="false">
- <cron>*/12 * * * * ? *</cron>
- </trigger>
- <trigger name="test-job2"
+ <cron>*/12 * * * * ? *</cron>
+ </trigger>
+ <trigger name="test-job2"
target="org.apache.cocoon.components.cron.CronJob/test"
concurrent-runs="true">
- <seconds>*/12</seconds>
- <minutes>*/5</minutes>
- <hours>8,10,12,14,16,18</hours>
- <days>?</days>
- <months>*</months>
- <weekdays>SUN-FRI</weekdays>
- </trigger>
- <trigger name="pipeline-test"
- target="org.apache.cocoon.components.cron.CronJob/pipeline-test"
- concurrent-runs="true">
- <minutes>0</minutes>
- <hours>12</hours>
- <days>?</days>
- <months>*</months>
- <weekdays>MON-FRI</weekdays>
- </trigger>
- -->
+ <seconds>*/12</seconds>
+ <minutes>*/5</minutes>
+ <hours>8,10,12,14,16,18</hours>
+ <days>?</days>
+ <months>*</months>
+ <weekdays>SUN-FRI</weekdays>
+ </trigger>
+ <trigger name="pipeline-test"
+ target="org.apache.cocoon.components.cron.CronJob/pipeline-test"
+ concurrent-runs="true">
+ <minutes>0</minutes>
+ <hours>12</hours>
+ <days>?</days>
+ <months>*</months>
+ <weekdays>MON-FRI</weekdays>
+ </trigger>
+ +-->
</triggers>
</component>
- <!-- sample definition of cron job -->
- <component role="org.apache.cocoon.components.cron.CronJob/test"
- class="org.apache.cocoon.components.cron.TestCronJob"
- logger="cron.test">
- <msg>I'm here</msg>
- <sleep>23000</sleep>
- </component>
+ <!--+
+ | Sample definition of the TestCronJob cron job, used by
+ | trigger configuration above.
+ <component role="org.apache.cocoon.components.cron.CronJob/test"
+ class="org.apache.cocoon.components.cron.TestCronJob"
+ logger="cron.test">
+ <msg>I'm here</msg>
+ <sleep>23000</sleep>
+ <pipeline>samples/hello-world/hello.xhtml</pipeline>
+ </component>
+ +-->
+
+ <!--+
+ | Sample definition of the CocoonPipelineCronJob cron job, used by
+ | trigger configuration above.
+ <component role="org.apache.cocoon.components.cron.CronJob/pipeline-test"
+ class="org.apache.cocoon.components.cron.CocoonPipelineCronJob"
+ logger="cron.pipeline">
+ <pipeline>samples/hello-world/hello.xhtml</pipeline>
+ </component>
+ +-->
- <!-- sample definition of CocoonPipelineCronJob
- <component role="org.apache.cocoon.components.cron.CronJob/pipeline-test"
- class="org.apache.cocoon.components.cron.CocoonPipelineCronJob"
- logger="cron.pipeline">
- <pipeline>samples/hello-world/hello.xhtml</pipeline>
- </component> -->
</xconf>
Modified: cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java
==============================================================================
--- cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java (original)
+++ cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/CocoonPipelineCronJob.java Mon Sep 27 06:43:04 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,59 +15,61 @@
*/
package org.apache.cocoon.components.cron;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
-import org.apache.cocoon.components.cron.ServiceableCronJob;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
/**
* A simple CronJob which calls an internal cocoon:// pipeline.
- *
+ *
* You must provide it with a <pipeline>pipeline/to/call</pipeline> parameter in cocoon.xconf
* Your supplied pipeline String will have "cocoon://" prepended to it.
* If you set info log enabled, this will write the output of the pipeline to the cron log
*
* @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
- * @author <a href="http://apache.org/~reinhard">Reinhard Poetz</a>
+ * @author <a href="http://apache.org/~reinhard">Reinhard Poetz</a>
* @author <a href="http://apache.org/~jeremy/">Jeremy Quinn</a>
- * @version CVS $Id: CocoonPipelineCronJob.java,v 1.2 2004/07/21 07:30:07 cziegeler Exp $
+ * @version CVS $Id$
*
* @since 2.1.5
*/
-public class CocoonPipelineCronJob
- extends ServiceableCronJob
- implements Configurable {
-
- private String CONFIG_FILE_PARAM = "pipeline";
- private String CONFIG_FILE_DEAFAULT= "";
- private String pipeline = "";
+public class CocoonPipelineCronJob extends ServiceableCronJob
+ implements Configurable {
+
+ private static final String CONFIG_FILE_PARAM = "pipeline";
+
+ private String pipeline;
public void execute(String name) {
if (getLogger ().isDebugEnabled ()) {
getLogger().debug ("CocoonPipelineCronJob: " + name + ", calling pipeline: " + pipeline);
}
+
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);
+ sb.append (b, 0, n);
}
reader.close ();
if (getLogger ().isInfoEnabled ()) {
- getLogger ().info ("CocoonPipelineCronJob: " + name + ", called pipeline: " + pipeline + ", and received following content:\n" + sb.toString() );
+ getLogger ().info ("CocoonPipelineCronJob: " + name + ", called pipeline: " +
+ pipeline + ", and received following content:\n" + sb.toString() );
}
} catch(Exception e) {
throw new CascadingRuntimeException ("CocoonPipelineCronJob: " + name + ", raised an exception: ", e);
@@ -82,10 +84,9 @@
}
public void configure(final Configuration config) throws ConfigurationException {
- pipeline = config.getChild (CONFIG_FILE_PARAM).getValue (CONFIG_FILE_DEAFAULT);
- if ("".equals (pipeline)) {
- throw new ConfigurationException ("CocoonPipelineCronJob has no pipeline configured.");
+ this.pipeline = config.getChild(CONFIG_FILE_PARAM).getValue(null);
+ if (this.pipeline == null) {
+ throw new ConfigurationException("CocoonPipelineCronJob has no pipeline configured.");
}
}
-
}