You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Fabio Daprile <fa...@wuerth.it> on 2002/02/21 11:36:24 UTC

How to start Scheduler automatically!!

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:fabio.daprile@wuerth-phoenix.com
http://www.wuerth-phoenix.com



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


Re: How to start Scheduler automatically!!

Posted by Christian Asmussen <kr...@kriconet.com.br>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to start Scheduler automatically!!

Posted by Colin Chalmers <co...@maxware.nl>.
You're absolutely correct!! And you also don't need any scripts to fire a
HTTP request.

/colin


----- Original Message -----
From: "Dave Hollar" <da...@bizpiranha.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Thursday, February 21, 2002 10:16 PM
Subject: Re: How to start Scheduler automatically!!


> I may be missing something but I use the scheduler and don't do anything
> explicitly to start the scheduler - I only change the
TurbineResources.props
> as below:
>
> scheduler.enabled=true
> If you don't set this I'm fairly certain that the default is false.
>
> ----- Original Message -----
> From: "Colin Chalmers" <co...@maxware.nl>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Thursday, February 21, 2002 8:30 AM
> Subject: Re: How to start Scheduler automatically!!
>
>
> > An easier way is to start the servlet automatically when the *server*
> > starts. In catalina you should have the following settings in your
web.xml
> > file.
> >
> > /colin
> >
> > <snip>
> >     <servlet>
> >         <servlet-name>foo</servlet-name>
> >         <servlet-class>
> >             org.apache.turbine.Turbine
> >         </servlet-class>
> >         <init-param>
> >             <param-name>properties</param-name>
> >             <!-- This is relative to the docBase -->
> >             <param-value>
> >                 /WEB-INF/conf/TurbineResources.properties
> >             </param-value>
> >         </init-param>
> >         <load-on-startup>
> >             1
> >         </load-on-startup>
> >     </servlet>
> > </snip>
> >
> > ----- Original Message -----
> > From: "Gareth Coltman" <ga...@majorband.co.uk>
> > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Sent: Thursday, February 21, 2002 2:29 PM
> > Subject: RE: How to start Scheduler automatically!!
> >
> >
> > > One easy way would be to fire off a command line HTTP request from
your
> > > startup script to the action below. http@ can be called from a unix
> script
> > > like:
> > >
> > > http@ host page port
> > >
> > > Hope this helps
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Fabio Daprile [mailto:fabio.daprile@wuerth.it]
> > > > Sent: 21 February 2002 10:36
> > > > To: Turbine Users List
> > > > Subject: How to start Scheduler automatically!!
> > > >
> > > >
> > > > 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
> > > >  */
> > > >
> > > > file://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
> > > >         {
> > > >             file://access the service singleton
> > > >             TurbineSchedulerService ss =
> > > > (TurbineSchedulerService)TurbineServices.getInstance().getService(
> > > TurbineSchedulerService.SERVICE_NAME);
> > > >
> > > >             ss.init(data.getServletConfig());
> > > >
> > > >             file://set the Message
> > > >             file://System.out.println("Task started successfully");
> > > >
> > > >             file://System.out.println(ss.listJobs().size());
> > > >         }
> > > >         catch (Exception e)
> > > >         {
> > > >             file://set the Message
> > > >             data.setMessage("Task failed to start!");
> > > >         }
> > > >
> > > >         file://setTemplate(schedule,SchedulerStatus.vm);
> > > >
> > > >      }
> > > > }
> > > >
> > > >
> > > > --
> > > >
> > > >
> > > > Würth Phoenix Srl
> > > > Via Kravogl 4, I-39100 Bolzano
> > > > Tel: +39 0471/564111
> > > > Fax: +39 0471/564122
> > > >
> > > > mailto:fabio.daprile@wuerth-phoenix.com
> > > > http://www.wuerth-phoenix.com
> > > >
> > > >
> > > >
> > > > --
> > > > 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>
> >
> >
>
>
>
> --
> 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: How to start Scheduler automatically!!

Posted by Dave Hollar <da...@bizpiranha.com>.
I may be missing something but I use the scheduler and don't do anything
explicitly to start the scheduler - I only change the TurbineResources.props
as below:

scheduler.enabled=true
If you don't set this I'm fairly certain that the default is false.

----- Original Message -----
From: "Colin Chalmers" <co...@maxware.nl>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Thursday, February 21, 2002 8:30 AM
Subject: Re: How to start Scheduler automatically!!


> An easier way is to start the servlet automatically when the *server*
> starts. In catalina you should have the following settings in your web.xml
> file.
>
> /colin
>
> <snip>
>     <servlet>
>         <servlet-name>foo</servlet-name>
>         <servlet-class>
>             org.apache.turbine.Turbine
>         </servlet-class>
>         <init-param>
>             <param-name>properties</param-name>
>             <!-- This is relative to the docBase -->
>             <param-value>
>                 /WEB-INF/conf/TurbineResources.properties
>             </param-value>
>         </init-param>
>         <load-on-startup>
>             1
>         </load-on-startup>
>     </servlet>
> </snip>
>
> ----- Original Message -----
> From: "Gareth Coltman" <ga...@majorband.co.uk>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Thursday, February 21, 2002 2:29 PM
> Subject: RE: How to start Scheduler automatically!!
>
>
> > One easy way would be to fire off a command line HTTP request from your
> > startup script to the action below. http@ can be called from a unix
script
> > like:
> >
> > http@ host page port
> >
> > Hope this helps
> >
> >
> >
> > > -----Original Message-----
> > > From: Fabio Daprile [mailto:fabio.daprile@wuerth.it]
> > > Sent: 21 February 2002 10:36
> > > To: Turbine Users List
> > > Subject: How to start Scheduler automatically!!
> > >
> > >
> > > 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
> > >  */
> > >
> > > file://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
> > >         {
> > >             file://access the service singleton
> > >             TurbineSchedulerService ss =
> > > (TurbineSchedulerService)TurbineServices.getInstance().getService(
> > TurbineSchedulerService.SERVICE_NAME);
> > >
> > >             ss.init(data.getServletConfig());
> > >
> > >             file://set the Message
> > >             file://System.out.println("Task started successfully");
> > >
> > >             file://System.out.println(ss.listJobs().size());
> > >         }
> > >         catch (Exception e)
> > >         {
> > >             file://set the Message
> > >             data.setMessage("Task failed to start!");
> > >         }
> > >
> > >         file://setTemplate(schedule,SchedulerStatus.vm);
> > >
> > >      }
> > > }
> > >
> > >
> > > --
> > >
> > >
> > > Würth Phoenix Srl
> > > Via Kravogl 4, I-39100 Bolzano
> > > Tel: +39 0471/564111
> > > Fax: +39 0471/564122
> > >
> > > mailto:fabio.daprile@wuerth-phoenix.com
> > > http://www.wuerth-phoenix.com
> > >
> > >
> > >
> > > --
> > > 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>
>
>



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


Re: How to start Scheduler automatically!!

Posted by Colin Chalmers <co...@maxware.nl>.
An easier way is to start the servlet automatically when the *server*
starts. In catalina you should have the following settings in your web.xml
file.

/colin

<snip>
    <servlet>
        <servlet-name>foo</servlet-name>
        <servlet-class>
            org.apache.turbine.Turbine
        </servlet-class>
        <init-param>
            <param-name>properties</param-name>
            <!-- This is relative to the docBase -->
            <param-value>
                /WEB-INF/conf/TurbineResources.properties
            </param-value>
        </init-param>
        <load-on-startup>
            1
        </load-on-startup>
    </servlet>
</snip>

----- Original Message -----
From: "Gareth Coltman" <ga...@majorband.co.uk>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Thursday, February 21, 2002 2:29 PM
Subject: RE: How to start Scheduler automatically!!


> One easy way would be to fire off a command line HTTP request from your
> startup script to the action below. http@ can be called from a unix script
> like:
>
> http@ host page port
>
> Hope this helps
>
>
>
> > -----Original Message-----
> > From: Fabio Daprile [mailto:fabio.daprile@wuerth.it]
> > Sent: 21 February 2002 10:36
> > To: Turbine Users List
> > Subject: How to start Scheduler automatically!!
> >
> >
> > 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
> >  */
> >
> > file://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
> >         {
> >             file://access the service singleton
> >             TurbineSchedulerService ss =
> > (TurbineSchedulerService)TurbineServices.getInstance().getService(
> TurbineSchedulerService.SERVICE_NAME);
> >
> >             ss.init(data.getServletConfig());
> >
> >             file://set the Message
> >             file://System.out.println("Task started successfully");
> >
> >             file://System.out.println(ss.listJobs().size());
> >         }
> >         catch (Exception e)
> >         {
> >             file://set the Message
> >             data.setMessage("Task failed to start!");
> >         }
> >
> >         file://setTemplate(schedule,SchedulerStatus.vm);
> >
> >      }
> > }
> >
> >
> > --
> >
> >
> > Würth Phoenix Srl
> > Via Kravogl 4, I-39100 Bolzano
> > Tel: +39 0471/564111
> > Fax: +39 0471/564122
> >
> > mailto:fabio.daprile@wuerth-phoenix.com
> > http://www.wuerth-phoenix.com
> >
> >
> >
> > --
> > 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: How to start Scheduler automatically!!

Posted by Gareth Coltman <ga...@majorband.co.uk>.
One easy way would be to fire off a command line HTTP request from your
startup script to the action below. http@ can be called from a unix script
like:

http@ host page port

Hope this helps



> -----Original Message-----
> From: Fabio Daprile [mailto:fabio.daprile@wuerth.it]
> Sent: 21 February 2002 10:36
> To: Turbine Users List
> Subject: How to start Scheduler automatically!!
>
>
> 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:fabio.daprile@wuerth-phoenix.com
> http://www.wuerth-phoenix.com
>
>
>
> --
> 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>