[jboss-user] [jBPM Users] - Re: How to start JobExecutor with jBPM 4 + Spring

vchira do-not-reply at jboss.com
Wed Oct 7 05:35:08 EDT 2009


I have done something like this:

  | import org.jbpm.api.ProcessEngine;
  | import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
  | import org.springframework.beans.factory.annotation.Required;
  | import org.springframework.context.ApplicationEvent;
  | import org.springframework.context.ApplicationListener;
  | import org.springframework.context.event.ContextClosedEvent;
  | import org.springframework.context.event.ContextRefreshedEvent;
  | 
  | 
  | public class JbpmJobExecutorLoader implements ApplicationListener {
  | 
  | 	private ProcessEngine processEngine;
  | 
  | 	@Required
  | 	public void setProcessEngine(ProcessEngine processEngine) {
  | 		this.processEngine = processEngine;
  | 	}
  | 
  | 	public void onApplicationEvent(ApplicationEvent applicationEvent) {
  | 		if (applicationEvent instanceof ContextRefreshedEvent) {
  | 			JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
  | 			if (!jobExecutor.isActive()) {
  | 				jobExecutor.start();
  | 			}
  | 		} else if (applicationEvent instanceof ContextClosedEvent) {
  | 			JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
  | 			jobExecutor.stop();
  | 		}
  | 	}
  | 

processEngine will be wired by Spring.

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

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



More information about the jboss-user mailing list