commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/test/org/apache/commons/jelly/tags/quartz example.jelly
Date Tue, 07 Jan 2003 14:54:15 GMT
dion        2003/01/07 06:54:15

  Added:       jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz
                        TriggerTag.java QuartzTagSupport.java
                        QuartzTagLibrary.java package.html JobTag.java
                        WaitForSchedulerTag.java JellyJob.java
                        CronTriggerTag.java
               jelly/jelly-tags/quartz project.properties .cvsignore
                        maven.xml project.xml
               jelly/jelly-tags/quartz/src/test/org/apache/commons/jelly/tags/quartz
                        example.jelly
  Log:
  Move quartz taglib out of core
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/TriggerTag.java
  
  Index: TriggerTag.java
  ===================================================================
  package org.apache.commons.jelly.tags.quartz;
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/TriggerTag.java,v
1.1 2003/01/07 14:54:15 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:54:15 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  /** Abstract base for all triggers.
   *
   *  @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   */
  public abstract class TriggerTag extends QuartzTagSupport
  {
      // ------------------------------------------------------------
      //     Constructors
      // ------------------------------------------------------------
  
      /** Construct.
       */
      protected TriggerTag()
      {
          // intentionally left blank
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/QuartzTagSupport.java
  
  Index: QuartzTagSupport.java
  ===================================================================
  package org.apache.commons.jelly.tags.quartz;
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/QuartzTagSupport.java,v
1.1 2003/01/07 14:54:15 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:54:15 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  import org.apache.commons.jelly.TagSupport;
  import org.quartz.Scheduler;
  import org.quartz.SchedulerException;
  import org.quartz.impl.StdSchedulerFactory;
  
  /** Basic support for all tags requiring a Quartz scheduler.
   *
   *  @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   */
  public abstract class QuartzTagSupport extends TagSupport
  {
      /** The scheduler variable name in the JellyContext. */
      public static final String SCHED_VAR_NAME = "org.apache.commons.jelly.quartz.Scheduler";
  
  
      /** Retrieve or create a scheduler.
       *
       *  <p>
       *  If a scheduler has already been created an installed
       *  in the variable {@link #SCHED_VAR_NAME}, then that scheduler
       *  will be returned.  Otherwise, a new StdScheduler will be
       *  created, started, and installed.  Additionally, a runtime
       *  shutdown hook will be added to cleanly shutdown the scheduler.
       *
       *  @return The scheduler.
       *
       *  @throws SchedulerException If there is an error creating the
       *          scheduler.
       */
      public Scheduler getScheduler() throws SchedulerException
      {
          Scheduler sched = (Scheduler) getContext().getVariable( SCHED_VAR_NAME );
  
          if ( sched == null )
          {
              StdSchedulerFactory factory = new StdSchedulerFactory();
  
              final Scheduler newSched = factory.getScheduler();
  
              sched = newSched;
              
              getContext().setVariable( SCHED_VAR_NAME,
                                        newSched );
  
              Runtime.getRuntime().addShutdownHook(
                  new Thread() {
                      public void run()
                      {
                          try
                          {
                              if ( ! newSched.isShutdown() )
                              {
                                  newSched.shutdown();
                              }
                          }
                          catch (SchedulerException e)
                          {
                              e.printStackTrace();
                          }
                      }
                  }
                  );
              newSched.start();
          }
  
  
          return sched;
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/QuartzTagLibrary.java
  
  Index: QuartzTagLibrary.java
  ===================================================================
  package org.apache.commons.jelly.tags.quartz;
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/QuartzTagLibrary.java,v
1.1 2003/01/07 14:54:15 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:54:15 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  import org.apache.commons.jelly.TagLibrary;
  
  /** Tag library for the Quartz enterprise job scheduler.
   *
   *  <p>
   *  <a href="http://quartz.sf.net/">quartz @ sourceforge</a>
   *  </p>
   *
   *  @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   */
  public class QuartzTagLibrary extends TagLibrary
  {
      /** Construct and register tags.
       */
      public QuartzTagLibrary()
      {
          registerTag( "job",
                       JobTag.class );
  
          registerTag( "cron",
                       CronTriggerTag.class );
  
          registerTag( "wait-for-scheduler",
                       WaitForSchedulerTag.class );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>A tag library for scheduling tasks to be run using the 
    <a href="http://www.part.net/quartz.html">Quartz</a> library
    </p>
    
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/JobTag.java
  
  Index: JobTag.java
  ===================================================================
  package org.apache.commons.jelly.tags.quartz;
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/JobTag.java,v
1.1 2003/01/07 14:54:15 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:54:15 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.MissingAttributeException;
  
  import org.quartz.Scheduler;
  import org.quartz.JobDetail;
  import org.quartz.JobDataMap;
  
  /** Defines a schedulable job.
   *
   *  @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   */
  public class JobTag extends QuartzTagSupport
  {
      // ------------------------------------------------------------
      //     Instance members
      // ------------------------------------------------------------
  
      /** Group of the job. */
      private String group;
  
      /** Name of the job. */
      private String name;
  
      // ------------------------------------------------------------
      //     Constructors
      // ------------------------------------------------------------
  
      /** Construct.
       */
      public JobTag()
      {
          // intentionally left blank.
      }
  
      // ------------------------------------------------------------
      //     Instance methods
      // ------------------------------------------------------------
  
      /** Set the name of this job.
       *
       *  @param name The name of this job.
       */
      public void setName(String name)
      {
          this.name = name;
      }
  
      /** Retrieve the name of this job.
       *
       *  @return The name of this job.
       */
      public String getName()
      {
          return this.name;
      }
  
      /** Set the group of this job.
       *
       *  @param group The group of this job.
       */
      public void setGroup(String group)
      {
          this.group = group;
      }
  
      /** Retrieve the group of this job.
       *
       *  @return The group of this job.
       */
      public String getGroup()
      {
          return this.group;
      }
  
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //     org.apache.commons.jelly.Tag
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  
      /** Perform this tag.
       *
       *  @param output Output sink.
       *
       *  @throws Exception If an error occurs.
       */
      public void doTag(XMLOutput output) throws Exception
      {
          if ( getName() == null )
          {
              throw new MissingAttributeException( "name" );
          }
  
          if ( getGroup() == null )
          {
              throw new MissingAttributeException( "group" );
          }
  
          Scheduler sched = getScheduler();
  
          JobDetail detail = new JobDetail( getName(),
                                            getGroup(),
                                            JellyJob.class );
  
          detail.setDurability( true );
  
          JobDataMap data = new JobDataMap();
  
          data.put( "jelly.output",
                    output );
          
          data.put( "jelly.context",
                    getContext() );
  
          data.put( "jelly.script",
                    getBody() );
  
          detail.setJobDataMap( data );
  
          sched.addJob( detail,
                        true );
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/WaitForSchedulerTag.java
  
  Index: WaitForSchedulerTag.java
  ===================================================================
  package org.apache.commons.jelly.tags.quartz;
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/WaitForSchedulerTag.java,v
1.1 2003/01/07 14:54:15 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:54:15 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  import org.apache.commons.jelly.XMLOutput;
  
  import org.quartz.Scheduler;
  
  /** Block and wait for the Quartz scheduler to shutdown.
   *
   *  @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   */
  public class WaitForSchedulerTag extends QuartzTagSupport
  {
      // ------------------------------------------------------------
      //     Constructors
      // ------------------------------------------------------------
  
      /** Construct.
       */
      public WaitForSchedulerTag()
      {
          // intentionally left blank.
      }
      
      // ------------------------------------------------------------
      //     Instance methods
      // ------------------------------------------------------------
  
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //     org.apache.commons.jelly.Tag
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  
      /** Perform this tag.
       *
       *  @param output Output sink.
       *
       *  @throws Exception If an error occurs.
       */
      public void doTag(XMLOutput output) throws Exception
      {
          Scheduler sched = getScheduler();
  
          while ( ! sched.isShutdown() )
          {
              try
              {
                  Thread.sleep( 500 );
              }
              catch (InterruptedException e)
              {
                  break;
              }
          }
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/JellyJob.java
  
  Index: JellyJob.java
  ===================================================================
  package org.apache.commons.jelly.tags.quartz;
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/JellyJob.java,v
1.1 2003/01/07 14:54:15 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:54:15 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.quartz.Job;
  import org.quartz.JobDetail;
  import org.quartz.JobDataMap;
  import org.quartz.JobExecutionContext;
  import org.quartz.JobExecutionException;
  
  /** Implementation of a quart <code>Job</code> to execute jellyscript.
   *
   *  @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   */
  public class JellyJob implements Job
  {
      // ------------------------------------------------------------
      //     Constructors
      // ------------------------------------------------------------
  
      /** Construct.
       */
      public JellyJob()
      {
          // intentionally left blank.
      }
  
      // ------------------------------------------------------------
      //     Instance methods
      // ------------------------------------------------------------
  
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //     org.quartz.Job
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  
      /** Execute this job.
       *
       *  @param jobContext Job context data.
       *
       *  @throws JobExecutionException If an error occurs during job execution.
       */
      public void execute(JobExecutionContext jobContext) throws JobExecutionException
      {
  
          JobDetail  detail = jobContext.getJobDetail();
  
          JobDataMap data   = detail.getJobDataMap();
  
          Script script = (Script) data.get( "jelly.script" );
  
          JellyContext jellyContext = (JellyContext) data.get( "jelly.context" );
  
          XMLOutput    output       = (XMLOutput) data.get( "jelly.output" );
  
          try
          {
              script.run( jellyContext,
                          output );
              output.flush();
          }
          catch (Exception e)
          {
              e.printStackTrace();
              throw new JobExecutionException( e,
                                               false );
          }
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/CronTriggerTag.java
  
  Index: CronTriggerTag.java
  ===================================================================
  package org.apache.commons.jelly.tags.quartz;
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/CronTriggerTag.java,v
1.1 2003/01/07 14:54:15 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:54:15 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.MissingAttributeException;
  
  import org.quartz.CronTrigger;
  import org.quartz.Scheduler;
  
  import java.util.Date;
  
  /** Define a trigger using a cron time spec.
   *
   *  @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   */
  public class CronTriggerTag extends QuartzTagSupport
  {
      // ------------------------------------------------------------
      //     Instance members
      // ------------------------------------------------------------
  
      /** Cron time spec. */
      private String spec;
  
      /** Trigger name. */
      private String name;
  
      /** Trigger group. */
      private String group;
  
      /** Job name. */
      private String jobName;
  
      /** Job group. */
      private String jobGroup;
  
      // ------------------------------------------------------------
      //     COnstructors
      // ------------------------------------------------------------
  
      /** Construct.
       */
      public CronTriggerTag()
      {
          // intentionally left blank.
      }
  
      // ------------------------------------------------------------
      // ------------------------------------------------------------
  
      /** Set the name.
       *
       *  @param name.
       */
      public void setName(String name)
      {
          this.name = name;
      }
  
      /** Retrieve the name.
       *
       *  @return The name.
       */
      public String getName()
      {
          return this.name;
      }
  
      /** Set the group
       *
       *  @param group The group
       */
      public void setGroup(String group)
      {
          this.group = group;
      }
  
      /** Retrieve the group.
       *
       *  @return The group.
       */
      public String getGroup()
      {
          return this.group;
      }
  
      /** Set the cron time spec.
       *
       *  @param spec The cron time spec.
       */
      public void setSpec(String spec)
      {
          this.spec = spec;
      }
  
      /** Retrieve the cron time spec.
       *
       *  @param spec The cron time spec.
       */
      public String getSpec()
      {
          return this.spec;
      }
  
      /** Set the job name.
       *
       *  @param jobName The job name.
       */
      public void setJobName(String jobName)
      {
          this.jobName = jobName;
      }
  
      /** Retrieve the job name.
       *
       *  @return The job name.
       */
      public String getJobName()
      {
          return this.jobName;
      }
  
      /** Set the job group.
       *
       *  @param jobGroup The job group.
       */
      public void setJobGroup(String jobGroup)
      {
          this.jobGroup = jobGroup;
      }
  
      /** Retrieve the job group.
       *
       *  @return The job group.
       */
      public String getJobGroup()
      {
          return this.jobGroup;
      }
  
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //     org.apache.commons.jelly.Tag
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  
      /** Perform this tag.
       *
       *  @param output Output sink.
       *
       *  @throws Exception If an error occurs.
       */
      public void doTag(XMLOutput output) throws Exception
      {
          if ( getSpec() == null )
          {
              throw new MissingAttributeException( "spec" );
          }
  
          if ( getName() == null )
          {
              throw new MissingAttributeException( "name" );
          }
  
          if ( getGroup() == null )
          {
              throw new MissingAttributeException( "group" );
          }
  
          if ( getJobName() == null )
          {
              throw new MissingAttributeException( "jobName" );
          }
  
          if ( getJobGroup() == null )
          {
              throw new MissingAttributeException( "jobGroup" );
          }
  
          CronTrigger trigger = new CronTrigger( getName(),
                                                 getGroup() );
  
          trigger.setCronExpression( getSpec() );
          trigger.setJobName( getJobName() );
          trigger.setJobGroup( getJobGroup() );
          trigger.setStartTime( new Date() );
          Scheduler sched = getScheduler();
          sched.scheduleJob( trigger );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/project.properties
  
  Index: project.properties
  ===================================================================
  # -------------------------------------------------------------------
  # P R O J E C T  P R O P E R T I E S
  # -------------------------------------------------------------------
  
  maven.junit.fork=true
  
  maven.compile.deprecation = on
  
  # Installation dir
  maven.dist.install.dir = /usr/local/jelly
  
  maven.checkstyle.properties=../tag-checkstyle.properties
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  maven.log
  target
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="java:jar">
  
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE project [
    <!-- see file for description -->
    <!ENTITY commonDeps SYSTEM "file:../../commonDependencies.ent">
  ]>
  <project>
    <extend>../tag-project.xml</extend>
    <id>commons-jelly-tags-quartz</id>
    <name>commons-jelly-tags-quartz</name>
    <package>org.apache.commons.jelly.tags.quartz</package>
  
    <description>
        This is a Jelly interface for the Quartz Scheduler.
    </description>
    <shortDescription>Commons Jelly Quartz Tag Library</shortDescription>
    
    <siteDirectory>/www/jakarta.apache.org/commons/sandbox/jelly/tags/quartz</siteDirectory>
    <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jelly/tags/quartz</distributionDirectory>
    <repository>
      <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/jelly/jelly-tags/quartz/</connection>
      <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/jelly-tags/quartz/</url>
    </repository>
    
      
    <dependencies>
    
      &commonDeps;
    
      <!-- START for compilation -->
    
      <dependency>
        <id>commons-jelly</id>
        <version>SNAPSHOT</version>
      </dependency>
      
      <dependency>
        <id>quartz</id>
        <version>SNAPSHOT</version>
      </dependency>
    
    </dependencies>
    
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/quartz/src/test/org/apache/commons/jelly/tags/quartz/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <j:jelly xmlns:j="jelly:core"
           xmlns:q="jelly:quartz">
  
  
    <q:job group="demo" name="cheese">
      I like cheese
    </q:job>
  
    <q:cron spec="*/5 * * ? * *"
            name="every.5.seconds"
            group="demo"
            jobName="cheese"
            jobGroup="demo"/>
  
    <q:wait-for-scheduler/>
  
  </j:jelly>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message