All this sounds very complex, what's wrong with encoding the time in the
url (securely) and testing it when you perform the action? Alternatively
store the request time and id on the server.

Paul
------------------------------------------------------------
Global Equity Derivatives Technology
Deutsche Bank [/]
Office +44 (0)20 754 55458
Mobile +44 (0)7736 299483
Fax +44 (0)20 7547 2752
------------------------------------------------------------

-----Original Message-----
From: Daniel Perry [mailto:[EMAIL PROTECTED] 
Sent: 19 August 2004 18:15
To: Struts Users Mailing List
Subject: RE: Help on Action implementing thread for checking user
registration thru email?

I previously posted a message on how i did this as a struts plugin, so
i've
reposted below.

To do what you require, instead of scheduling a job for each entry after
24hrs, i would include a timestamp in the database, then say every hour,
check for expired entries and delete them.

----------------------------
Nope, you dont need to start another process - i use a struts plugin to
load
and initialise Quartz.  It will run in other threads, but this will all
be
done for you behind the scenes.

The code for my struts plugin is below (if it's of any help).  Add the
following entry to the struts-config-default.xml in the plug-in section
to
load it:

<plug-in className="com.netcase.pdp.service.SchedulerService"></plug-in>

It runs a "Job" every 30 mins.

This job takes the form:

public class RemoveOldProvisionalTrainingJob implements StatefulJob {
public void execute(JobExecutionContext arg0) throws
JobExecutionException {
// code to do actual work here
}
}


Note that i'm implementing StatfulJob - this stops it running two of the
same job at the same time.

Daniel.


---------------------SchedulerService.java-------------------------
package com.netcase.pdp.service;

import java.util.Date;

import javax.servlet.ServletException;

import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleTrigger;

import
com.netcase.pdp.service.scheduledjobs.RemoveOldProvisionalTrainingJob;

/**
 * @author Daniel Perry
 *
 */
public class SchedulerService implements PlugIn {

        Scheduler sched;

        public void init(ActionServlet servlet, ModuleConfig moduleConf)
                        throws ServletException {
                System.out.println("Starting scheduler service...");

                SchedulerFactory schedFact = new
org.quartz.impl.StdSchedulerFactory();
                try {
                        sched = schedFact.getScheduler();
                        sched.start();

                                JobDetail jobDetail = new JobDetail(
        
"removeOldProvisionalTrainingJob",
                                                Scheduler.DEFAULT_GROUP,
        
RemoveOldProvisionalTrainingJob.class);

                                // new trigger - repeat every 30 mins
starting in 5 mins time
                                // (delay for startup)
                                SimpleTrigger trigger = new
SimpleTrigger("30MinTrigger",
                                                Scheduler.DEFAULT_GROUP,
new Date(new Date().getTime()
                                                                + (5L*
60L * 1000L)), null,
        
SimpleTrigger.REPEAT_INDEFINITELY, 30 * 60L * 1000L);

                                sched.scheduleJob(jobDetail, trigger);


                } catch (SchedulerException ex) {
                        ex.printStackTrace();
                }

        }

        public void destroy() {
                try {
                        sched.shutdown();
                } catch (SchedulerException ex) {
                        ex.printStackTrace();
                }
                sched = null;
        }

}
-------------------------------------------------------------------



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

R

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

Reply via email to