cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/cron/java/org/apache/cocoon/components/cron TestCronJob.java
Date Fri, 05 Sep 2003 10:22:40 GMT
giacomo     2003/09/05 03:22:40

  Modified:    src/blocks/cron/java/org/apache/cocoon/components/cron
                        TestCronJob.java
  Log:
  extended for samples
  
  Revision  Changes    Path
  1.2       +25 -9     cocoon-2.1/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java
  
  Index: TestCronJob.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -d -b -u -r1.1 -r1.2
  --- TestCronJob.java	3 Sep 2003 16:04:02 -0000	1.1
  +++ TestCronJob.java	5 Sep 2003 10:22:39 -0000	1.2
  @@ -51,12 +51,14 @@
   package org.apache.cocoon.components.cron;
   
   import java.util.Date;
  +import java.util.Map;
   
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.parameters.Parameters;
   
   
   /**
  @@ -68,9 +70,13 @@
    * @since 2.1.1
    */
   public class TestCronJob
  -    extends AbstractLogEnabled
  -    implements CronJob, Configurable, Component {
  -    //~ Instance fields ------------------------------------------------------------------------------------------------
  +extends AbstractLogEnabled
  +implements CronJob, Configurable, Component, 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";
   
       /** The configured message */
       private String m_msg;
  @@ -78,8 +84,6 @@
       /** The configured sleep time */
       private int m_sleep;
   
  -    //~ Methods --------------------------------------------------------------------------------------------------------
  -
       /* (non-Javadoc)
        * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
        */
  @@ -93,7 +97,8 @@
        * @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);
  +        getLogger().info("CronJob " + name + " launched at " + new Date() + " with message
'" + m_msg +
  +                         "' and sleep timeout of " + m_sleep + "ms");
   
           try {
               Thread.sleep(m_sleep);
  @@ -101,6 +106,17 @@
               //getLogger().error("CronJob " + name + " interrupted", ie);
           }
   
  -        getLogger().info("CronJob " + name + " finished at " + new Date() + " with message:
" + m_msg);
  +        getLogger().info("CronJob " + name + " finished at " + new Date() + " with message
'" + m_msg +
  +                         "' and sleep timeout of " + m_sleep + "ms");
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.components.cron.ConfigurableCronJob#setup(org.apache.avalon.framework.parameters.Parameters,
java.util.Map)
  +     */
  +    public void setup(Parameters params, Map objects) {
  +        if (null != params) {
  +            m_msg = params.getParameter(PARAMETER_MESSAGE, m_msg);
  +            m_sleep = params.getParameterAsInteger(PARAMETER_SLEEP, m_sleep);
  +        }
       }
   }
  
  
  

Mime
View raw message