1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
public class TestJob implements Job {
public TestJob() {}
public void execute(JobExecutionContext context)
throws JobExecutionException
{
try
{
/*HashMap ctx = new HashMap();
ctx.put(ActionContext.PARAMETERS, context.getJobDetail()
.getJobDataMap());
ctx.put(ComponentInterceptor.COMPONENT_MANAGER, ???);
ctx.put(???, ???)
ServletDispatcher.createContextMap();
*/
ActionProxy proxy= new StrutsActionProxyFactory()
.createActionProxy ("", context.getJobDetail()
.getName(), null);
proxy.execute ();
}
catch (Exception e) { throw new JobExecutionException(e); }
}
public final static void main (String [] args)
{
try
{
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
JobDetail jobDetail = new JobDetail("test", scheduler.DEFAULT_GROUP, com.lds.gde.metier.TestJob.class);
long ctime = System.currentTimeMillis();
SimpleTrigger simpleTrigger = new SimpleTrigger("simpleTrigger", "triggerGroup-s1");
simpleTrigger.setStartTime(new Date(ctime));
simpleTrigger.setRepeatInterval(2000);
simpleTrigger.setRepeatCount(1);
scheduler.scheduleJob(jobDetail, simpleTrigger);
scheduler.start();
}
catch(Exception e){}
}
} |
Partager