[jboss-user] [JBoss jBPM] - Re: Job Executor and Spring

oravecz do-not-reply at jboss.com
Thu Oct 9 22:13:10 EDT 2008


Funny, but I just wrote this class:



  | 
  | import org.jbpm.JbpmConfiguration;
  | import org.jbpm.job.executor.JobExecutor;
  | import org.slf4j.Logger;
  | import org.slf4j.LoggerFactory;
  | import org.springframework.beans.factory.DisposableBean;
  | import org.springframework.beans.factory.InitializingBean;
  | import org.springframework.beans.factory.annotation.Required;
  | 
  | /**
  |  *
  |  */
  | public class JobExecutorInitializingBean implements InitializingBean, DisposableBean {
  | 
  |     // Statics -----------------------------------------------------------------
  | 
  |     private static final Logger LOG = LoggerFactory.getLogger(JobExecutorInitializingBean.class);
  | 
  |     // Instances ---------------------------------------------------------------
  | 
  |     private JbpmConfiguration _jbpmConfiguration;
  | 
  |     /**
  |      * Invoked by a BeanFactory after it has set all bean properties supplied
  |      * (and satisfied BeanFactoryAware and ApplicationContextAware).
  |      * <p>This method allows the bean instance to perform initialization only
  |      * possible when all bean properties have been set and to throw an
  |      * exception in the event of misconfiguration.
  |      *
  |      * @throws Exception in the event of misconfiguration (such
  |      *                   as failure to set an essential property) or if initialization fails.
  |      */
  |     public void afterPropertiesSet() throws Exception {
  |         JobExecutor jobExecutor = _jbpmConfiguration.getJobExecutor();
  |         if (jobExecutor != null)
  |             jobExecutor.start();
  |         else
  |             LOG.warn("No JobExecutor was found in the jBPM configuration.");
  |     }
  | 
  | 
  |     /**
  |      * Invoked by a BeanFactory on destruction of a singleton.
  |      *
  |      * @throws Exception in case of shutdown errors.
  |      *                   Exceptions will get logged but not rethrown to allow
  |      *                   other beans to release their resources too.
  |      */
  |     public void destroy() throws Exception {
  |         JobExecutor jobExecutor = _jbpmConfiguration.getJobExecutor();
  |         if (jobExecutor != null) jobExecutor.stop();
  |     }
  | 
  |     @Required
  |     public void setJbpmConfiguration(final JbpmConfiguration jbpmConfiguration) {
  |         _jbpmConfiguration = jbpmConfiguration;
  |     }
  | }
  | 
  | 

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

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



More information about the jboss-user mailing list