-
1. Re: Persist Entity from within ScriptTask - best practice?
swiderski.maciej Jan 20, 2012 8:46 AM (in response to wtimpany)In my opinion using script task to perform logic is not best practice - mainly because you embed your java code inside the process definition (bpmn2). You could give a try with following approaches:
- use Service task that executes (with default work item handler) your java class
- use domain specific nodes that allows you to do whatever you like
For details about domain specific nodes please refer to the documentation http://docs.jboss.org/jbpm/v5.2/userguide/ch13.html and for ServiceTask take a look at example shipped with jBPM.
HTH
-
2. Re: Persist Entity from within ScriptTask - best practice?
wtimpany Jan 20, 2012 11:54 AM (in response to swiderski.maciej)Thanks for the advice,
Setting up and using the Service Task(s) were easier than I expected.
Following the instructions in the example worked. Just a little bit of extra config was required to get the "Service Task Handler" added to the "KnowledgeSession" in our "Spring" configuration
e.g. Spring Config
<
bean id="jboss.jbpm.serviceTaskHandler" class="org.jbpm.bpmn2.handler.ServiceTaskHandler" />
<
bean id="jboss.jbpm.knowledgeSession1.workItemManager" factory-bean="jboss.jbpm.knowledgeSession1" factory-method="getWorkItemManager"/>
<
bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="jboss.jbpm.knowledgeSession1.workItemManager"/> -
3. Re: Persist Entity from within ScriptTask - best practice?
sepideh May 6, 2016 10:36 PM (in response to wtimpany)hi william
i try to use your practise(script task) but i have a problem
the value of em (EntityManager em = (EntityManager) env.get(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER);) is null.
please to help me to in solving this problem