Solved. Created the timer within an ActionHandler:

First define an event on the state:


  |     public void createTimer(State myState){
  |             Delegation delegate=new 
Delegation("com.jotatech.vgrc.action.visual.MyActionHandler");
  |             
  |             Event myEvent=new Event(Event.EVENTTYPE_NODE_ENTER);
  |             
  |             Action myAction=new Action(delegate);
  |             myAction.setName("[ACTION]");
  |             
  |             myEvent.addAction(myAction);
  |                             
  |             myState.setAction(myAction);
  |             myState.addEvent(myEvent);
  |     }
  | 

Then in the ActionHandler:


  | public class MyActionHandler implements ActionHandler{
  |     
  |     private static final long serialVersionUID = -7574831777028763706L;
  | 
  |     public void execute(ExecutionContext context) throws Exception{
  |             
  |             if(context.getTimer()==null){
  |                     System.out.println("ADDING TIMER ...");
  |                     Calendar cal=Calendar.getInstance();
  |                     BusinessCalendar bc=new BusinessCalendar();
  |                     Duration duration=new Duration("20 seconds");
  |                     Date dueDate=bc.add(cal.getTime(), duration);
  |                     
  |                     Timer myTimer=new Timer();
  |                     myTimer.setName("[TIMER] 
"+context.getEventSource().getName());
  |                     myTimer.setDueDate(dueDate);
  |                     myTimer.setRepeat("20 seconds");
  |                     myTimer.setRetries(3);
  |                     
  |                     myTimer.setAction(context.getAction());
  |                     
  |                     context.setTimer(myTimer);
  |                     
  |                     
context.getJbpmContext().getServices().getSchedulerService().createTimer(myTimer);
  |             }else{
  |                     System.out.println("EXECUTING ...");
  |                     /* CODE YOU WANT THE TIMER TO EXECUTE */
  |             }
  |     }
  | 

Hope this helps anybody with the same problem. Question: how can I inject a 
SEAM component or a Stateful session bean in the timer? I mean: I can't do 
Component.getInstance("SEAMComponent") or Component.getInstance("MySFSB"). 
Maybe a way to merge both SEAM and JBPM Contexts? Thanks in advance.

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4128486
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to