You can use a servlet init() method.
Something like
public class myservlet extends HttpServlet {
public void init() throws ...{
...put code here
}
}
then on web.xml you can tell tomcat to start that servlet when
the application is loaded. Something like what there is for the
org.apache.turbine.Turbine servlet, but add a parameter.
<load-on-startup>50</load-on-startup>
This number (50) has to do with when the servlet is loaded.
The only thing I dont know is if you have to wait for something else
before starting your job.
On Thu, 21 Feb 2002, Fabio Daprile wrote:
> 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);
>
> }
> }
>
>
>
--
"If we did all the things we are capable of,
we would literally astound ourselves"
- Thomas Edison
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>