I posted this 2 days back, but it probably went un-noticed in the deluge of
posts, so here's another shot.

If my corrections are wrong, then it probably means that at least the
Non-Persistent Scheduler is defective.

----- Original Message -----
From: Kelvin Tan <[EMAIL PROTECTED]>
To: Turbine Users List <[EMAIL PROTECTED]>
Sent: Monday, January 14, 2002 12:33 PM
Subject: Documentation for Scheduler Service


At
http://jakarta.apache.org/turbine/turbine-2/services/scheduler-service.html,
the example given for a sample ScheduledJob is

public class SimpleScheduledTask extends ScheduledJob
{
    private int taskcount = 0;

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


    /**
     * Run the Jobentry from the scheduler queue.
     * From ScheduledJob.
     *
     * @param job The job to run.
     */
    public void run( JobEntry job ) throws Exception
    {
        Log.note("Scheduled job " + job.getId() + " : " +
                 "task: " + job.getTask() +
                 " ran @: " +
                 new Date(System.currentTimeMillis()).toString() +
                 " taskcount " + taskcount
                 );
        //iterate the task counter
        taskcount++;
    }
}

The expected output is the String given with an incrementing taskcount.
However, in WorkerThread, jobs are actually executed like

ScheduledJob sc = (ScheduledJob) Class.forName(
                    je.getTask()).newInstance();

                sc.execute(je);

and new WorkerThreads are instantiated each time a job executes (they are,
aren't they?). This means that taskcount will never get to increment since
the variable is re-initialized each time the job runs.

Making taskcount a static variable would be more correct, I think.
Otherwise, there's another reason why my test case isn't running correctly.
:)


Regards,
Kelvin Tan

Relevanz Pte Ltd
http://www.relevanz.com

180B Bencoolen St.
The Bencoolen, #04-01
S(189648)

Tel: 238 6229
Fax: 337 4417




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to