[jboss-user] [jBPM] - Re: Problem in JPAWorkItemManager when completing a task

Juan Gago do-not-reply at jboss.com
Thu Jan 12 12:21:42 EST 2012


Juan Gago [https://community.jboss.org/people/juan.gago] created the discussion

"Re: Problem in JPAWorkItemManager when completing a task"

To view the discussion, visit: https://community.jboss.org/message/646522#646522

--------------------------------------------------------------
Solved!

Thanks for answers. I finally found a Spring 3 JPA JBPM 5.2 correct configuration. Here is (I hope it helps someone):

+<!-- First: declare JBPM JPA Session with a process definition -->+
+  <jbpm:kbase id="kbase">+
+    <jbpm:resources>+
+      <jbpm:resource type="BPMN2" source="classpath:workflows/Test.bpmn" />+
+    </jbpm:resources>+
+  </jbpm:kbase>+
+  <jbpm:ksession id="ksession" type="stateful" kbase="kbase">+
+    <jbpm:configuration>+
+      <jbpm:jpa-persistence>+
+        <jbpm:entity-manager-factory ref="entityManagerFactory"/>+
+        <jbpm:transaction-manager ref="transactionManager"/>+
+      </jbpm:jpa-persistence>+
+    </jbpm:configuration>+
+  </jbpm:ksession>+

+  <!-- Declare a TaskServer -->+
+  <bean class="org.jbpm.task.service.TaskService" id="taskService">+
+    <constructor-arg ref="entityManagerFactory"/>+
+    <constructor-arg>+
+      <bean class="org.drools.SystemEventListenerFactory" factory-method="getSystemEventListener"/>+
+    </constructor-arg>+
+  </bean>+
+  <bean class="org.jbpm.task.service.mina.MinaTaskServer" id="taskServer">+
+    <constructor-arg ref="taskService"/>+
+    <constructor-arg><value>${jbpm.task.server.port}</value></constructor-arg>+
+  </bean>+
+  <!-- And start TaskServer on the configured port -->+
+  <bean class="java.lang.Thread" id="taskServerThread" init-method="start">+
+    <constructor-arg ref="taskServer"/>+
+  </bean>+

+  <!-- Declare a TaskClient -->+
+  <bean class="org.jbpm.task.service.mina.MinaTaskClientConnector" id="taskClientConnector">+
+    <constructor-arg value="taskClient"/>+
+    <constructor-arg>+
+      <bean class="org.jbpm.task.service.mina.MinaTaskClientHandler">+
+        <constructor-arg>+
+          <bean class="org.drools.SystemEventListenerFactory" factory-method="getSystemEventListener"/>+
+        </constructor-arg>+
+      </bean>+
+    </constructor-arg>+
+  </bean>+
+  <bean class="org.jbpm.task.service.TaskClient" id="taskClient">+
+    <constructor-arg ref="taskClientConnector"/>+
+  </bean>+

+  <!-- Declare a HumanTaskHandler -->+
+  <bean class="org.jbpm.task.service.AsyncTaskServiceWrapper" id="humanTaskClient">+
+    <constructor-arg ref="taskClient"/>+
+  </bean>+
+  <!-- It uses previously created TaskClient -->+
+  <bean class="org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler" id="humanTaskHandler">+
+    <constructor-arg ref="humanTaskClient"/>+
+    <constructor-arg ref="ksession"/>+
+  </bean>+
+  <!-- Configure its connection to the local server -->+
+  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="humanTaskHandler" id="setConnection">+
+    <property name="targetObject" ref="humanTaskHandler"/>+
+    <property name="targetMethod" value="setConnection"/>+
+    <property name="arguments">+
+      <list>+
+        <value>${jbpm.task.client.address}</value>+
+        <value>${jbpm.task.client.port}</value>+
+      </list>+
+    </property>+
+  </bean>+
+  <!-- And connect HumanTaskHandler (implicit TaskClient connection) -->+
+  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="setConnection">+
+    <property name="targetObject" ref="humanTaskHandler"/>+
+    <property name="targetMethod" value="connect"/>+
+  </bean>+

+  <!-- Finnaly, register HumanTaskHandler in the session -->+
+  <bean factory-bean="ksession" factory-method="getWorkItemManager" id="workItemManager"/>+
+  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">+
+    <property name="targetObject" ref="workItemManager"/>+
+    <property name="targetMethod" value="registerWorkItemHandler"/>+
+    <property name="arguments">+
+      <list>+
+        <value>Human Task</value>+
+        <ref bean="humanTaskHandler"/>+
+      </list>+
+    </property>+
+  </bean>+

This way, I can configure JBPM with Tasks (server and client) without any lines of JAVA code, using Spring.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/646522#646522]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120112/2fbd97f7/attachment.html 


More information about the jboss-user mailing list