You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Hoang, Hai" <Ha...@coair.com> on 2002/08/01 17:48:53 UTC

Scheduler has not end date

How come the scheduler has no end date?  For example, let say, I want a task
to run everyday until a given end date?  Has any one modify the scheduler to
accommodate this feature?

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Scheduler has not end date

Posted by Rajeev Kaul <Ra...@customercaresolutions.com>.
Better still, have the task remove itself from the scheduler as shown below:

public void run( JobEntry job ) throws Exception
{
         if ( System.currentTimeMillis() >= endDate )
        {
             // access the service singleton
             ScheduleService ss =  (ScheduleService)
TurbineServices.getInstance().getServic (ScheduleService.SERVICE_NAME);
//
            // remove the stored job
            ss.removeJob(job);
        }
        else
        {
             //... do task here
        }
}

----- Original Message -----
From: "Kris Woodbeck" <kr...@webmotion.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Thursday, August 01, 2002 9:07 AM
Subject: Re: Scheduler has not end date


> I'm not terribly familiar with the scheduler, but here's one simple way:
>
> public class SimpleScheduledTask extends ScheduledJob
> {
>     protected long endDate;
>
>     /**
>      * Constructor
>      */
>      public SimpleScheduledTask()
>      {
>          //do Task initialization here
>
>          //end date in 5 days
>          endDate = System.currentTimeMillis() + ( 86400 * 1000 * 5 );
>      }
>
>
>     /**
>      * Run the Jobentry from the scheduler queue.
>      * From ScheduledJob.
>      *
>      * @param job The job to run.
>      */
>     public void run( JobEntry job ) throws Exception
>     {
>         if ( System.currentTimeMillis() >= endDate )
>             return;
>         //... do task here
>     }
> }
>
>
> of course, the task still runs past your given date, but just doesn't do
> anything...
>
> Kris
>
> Hoang, Hai wrote:
>
> >How come the scheduler has no end date?  For example, let say, I want a
task
> >to run everyday until a given end date?  Has any one modify the scheduler
to
> >accommodate this feature?
> >
> >--
> >To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> >For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Scheduler has not end date

Posted by Kris Woodbeck <kr...@webmotion.com>.
I'm not terribly familiar with the scheduler, but here's one simple way:

public class SimpleScheduledTask extends ScheduledJob
{
    protected long endDate;

    /**
     * Constructor
     */
     public SimpleScheduledTask()
     {
         //do Task initialization here

         //end date in 5 days
         endDate = System.currentTimeMillis() + ( 86400 * 1000 * 5 );
     }


    /**
     * Run the Jobentry from the scheduler queue.
     * From ScheduledJob.
     *
     * @param job The job to run.
     */
    public void run( JobEntry job ) throws Exception
    {
        if ( System.currentTimeMillis() >= endDate )
            return;
        //... do task here
    }
}


of course, the task still runs past your given date, but just doesn't do 
anything...

Kris

Hoang, Hai wrote:

>How come the scheduler has no end date?  For example, let say, I want a task
>to run everyday until a given end date?  Has any one modify the scheduler to
>accommodate this feature?
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>  
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>