[jboss-user] [JBoss jBPM] - Re: [jBPM][3.1.1] Get a timer instance with API

ephemeris-lappis do-not-reply at jboss.com
Wed Jul 26 10:59:36 EDT 2006


No problem. The code is :

package my.wf.seven;
  | 
  | import java.util.Date;
  | 
  | import org.jbpm.calendar.BusinessCalendar;
  | import org.jbpm.calendar.Duration;
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | import org.jbpm.scheduler.SchedulerService;
  | import org.jbpm.scheduler.exe.Timer;
  | import org.jbpm.svc.Services;
  | 
  | public class TimerInitializationActionHandler implements ActionHandler {
  | 
  | 	public void execute(final ExecutionContext executionContext) throws Exception {
  | 		System.out.println("... Action for timer : " + executionContext.getTaskInstance());
  | 		Timer timer = new Timer(executionContext.getToken());
  | 		timer.setName("MY-TIMER");
  | 		Duration duration = new Duration("5 seconds");
  | 		BusinessCalendar businessCalendar = new BusinessCalendar();
  | 		Date dueDate = businessCalendar.add(new Date(), duration);
  | 		timer.setDueDate(dueDate);
  | 		timer.setTransitionName("to_activity-2");
  | 		timer.setGraphElement(executionContext.getEventSource());
  | 		timer.setTaskInstance(executionContext.getTaskInstance());
  | 		SchedulerService schedulerService = (SchedulerService) Services.getCurrentService(Services.SERVICENAME_SCHEDULER);
  | 		schedulerService.createTimer(timer);
  | 		System.out.println("... Timer : " + timer);
  | 	}
  | 
  | 	static private final long serialVersionUID = 701975110762314580L;
  | 
  | }

If somebody has comments... They are welcome !

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961028#3961028

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961028



More information about the jboss-user mailing list