3 Replies Latest reply on Aug 19, 2015 9:12 AM by Carlo Carradori

    Configuring WorkItemHandlers as beans in Spring. JBPM 6.1.0

    Vladimir Vinn Newbie

      Hello guys!

       

      Is there a way to add workitem handlers configuration in Spring so they will be applied to each session produces by runtimeEngine?

      <bean id="runtimeManager" class="org.kie.spring.factorybeans.RuntimeManagerFactoryBean" destroy-method="close">
                  <property name="identifier" value="jbpm-rm"/>
                  <property name="type" value="PER_PROCESS_INSTANCE" />
                  <property name="runtimeEnvironment" ref="runtimeEnvironment" />
              </bean>
      
      
              <bean id="runtimeEnvironment" class="org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean">
                  <property name="type" value="DEFAULT_KJAR_CL"/>
                  <property name="groupId" value="${project.groupId}" />
                  <property name="artifactId" value="{artifactId}" />
                  <property name="version" value="${project.version}" />
                  <property name="kbaseName" value="kbase" />
                  <property name="ksessionName" value="ksession" />
      </bean>
      
      
                  <property name="entityManagerFactory" ref="kieEntityManagerFactory" />
                  <property name="transactionManager" ref="transactionManager"/>
              </bean>
      
      

       

      I know workitemhandlers can be configured in kmodule.xml, but in this case they will be out of Spring context. So this is not an option.

      Also workitem handlers can be added via api, but in this case they must be added to every session produced by:

      RuntimeEngine runtimeEngine = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get());
      StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) runtimeEngine.getKieSession();
      ksession.getWorkItemManager().registerWorkItemHandler(.......)
      
      

       

      But still preferable solution is via Spring configuration.

      Is there a way to do so?

       

      Thanks!