Hello Gentlemen,

I've implemented the scheduler service in my application.

I  use the turbine_scheduled_job table to keep the jobs.

The problem is that i need to start the scheduler when the servlets starts.
Now i start the scheduler calling an action from an HTML page, and you 
can see the code of this action below.

Can i do this automatically?

Thank you in advance.

Best Regards,

Fabio Daprile.
Systems engineer.

W�rth Phoenix International


/**
 * Title:        Bug tracking system
 * Description:  Development of a Bug Tracking and Enhancement request 
system
 * Copyright:    Copyright (c) 2001
 * Company:
 * @author Fabio Daprile
 * @version 1.0
 */

//Turbine
import org.apache.velocity.context.Context;
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.schedule.JobEntry;
import org.apache.turbine.services.schedule.JobEntryPeer;
import org.apache.turbine.services.schedule.ScheduleService;
import org.apache.turbine.services.schedule.TurbineSchedulerService;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.modules.actions.VelocityAction;
import org.apache.turbine.util.ParameterParser;
import org.apache.turbine.util.db.Criteria;

import java.util.*;


public class SchedulerStart extends VelocityAction
{

     public void doPerform(RunData data, Context context) throws Exception
     {
        Criteria _criteria = null;
        Criteria.Criterion _criterion1 = null;

        Vector _schedulerParams = null;
        JobEntry je;
        ParameterParser params = data.getParameters();

        _criteria = new Criteria();
        _criterion1 = _criteria.getNewCriterion(JobEntryPeer.OID,
                                                 new Integer(0),
                                                  Criteria.GREATER_THAN);
        try
        {
          _schedulerParams = JobEntryPeer.doSelect(_criteria);
        }
        catch(Exception e)
        {
          e.printStackTrace();
        }

        try
        {
            //access the service singleton
            TurbineSchedulerService ss = 
(TurbineSchedulerService)TurbineServices.getInstance().getService(TurbineSchedulerService.SERVICE_NAME);

            ss.init(data.getServletConfig());

            //set the Message
            //System.out.println("Task started successfully");

            //System.out.println(ss.listJobs().size());
        }
        catch (Exception e)
        {
            //set the Message
            data.setMessage("Task failed to start!");
        }

        //setTemplate(schedule,SchedulerStatus.vm);

     }
}


-- 


W�rth Phoenix Srl
Via Kravogl 4, I-39100 Bolzano
Tel: +39 0471/564111
Fax: +39 0471/564122

mailto:[EMAIL PROTECTED]
http://www.wuerth-phoenix.com



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

Reply via email to