[JBoss jBPM] - Re: Job Executor and Spring
by oravecz
I haven't yet got timers working for me so take that code with a grain of salt. Also note that I use the LocalJbpmConfigurationFactoryBean in my spring config, so I don't want to declare the same config twice. For this reason my spring.xml file looks like this:
| <bean id="jbpmConfig" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean"
| p:sessionFactory-ref="sessionFactory"
| p:configuration="classpath:org/jbpm/default.jbpm.cfg.xml"
| >
| <property name="processDefinitionsResources">
| <list>
| <value>classpath:workflow/**/processdefinition.xml</value>
| </list>
| </property>
|
| </bean>
|
| <bean id="jbpmTemplate" class="org.springmodules.workflow.jbpm31.JbpmTemplate">
| <constructor-arg index="0" ref="jbpmConfig"/>
| </bean>
|
| <bean class="md.signmeup.workflow.jbpm.JobExecutorInitializingBean"
| p:jbpmConfiguration-ref="jbpmConfig" />
|
and I had a problem in my code. This overcomes it:
| 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;
|
| public void afterPropertiesSet() throws Exception {
| JobExecutor jobExecutor = _jbpmConfiguration.getJobExecutor();
| if (jobExecutor != null) {
| jobExecutor.setJbpmConfiguration(_jbpmConfiguration);
| jobExecutor.start();
| } else {
| if (LOG.isWarnEnabled())
| LOG.warn("No JobExecutor was found in the jBPM configuration.");
| }
| }
|
|
| 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=4181361#4181361
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4181361
16 years, 1 month
[JBoss jBPM] - Re: Job Executor and Spring
by oravecz
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
16 years, 1 month