09-13-2010 06:56 PM
…
@EJB(name="ejb/friends")
private FriendsServiceRemote friendsServiceRemote;
…
ProcessEngineImpl engine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("friendsServiceRemote", friendsServiceRemote);
engine.getRuntimeService().startProcessInstanceByKey("helloWorld", variables);
…
…
<serviceTask id="javaService" name="javaService" activiti:method-expr="#{friendsServiceRemote.doSomething}" />
…
doSomething is a method of my EJB. This solution works without any problems. What's happening behind the scenes? Is it a good idea to set the whole EJB as variable?
…
@Stateless
public class FriendsService extends BpmnActivityBehavior implements FriendsServiceRemote, ActivityBehavior {
…
public void execute(ActivityExecution execution) throws Exception {
System.out.println("huhu");
performDefaultOutgoingBehavior(execution);
}
}
…
…
<serviceTask id="javaService" name="javaService" activiti:class="de.backend.services.friends.impl.FriendsService" />
…
Works, but I have to implement and extend the Activiti stuff and I can't invoke different methods of the same EJB. 09-14-2010 01:40 AM
09-14-2010 03:56 AM
09-14-2010 06:26 AM
09-15-2010 05:07 AM
09-15-2010 07:04 AM
public interface ServiceTaskBehavior {
void execute(ServiceTaskExecution execution) throws Exception;
}
with ServiceTaskExecution being the following subset of ActivityExecution:
public interface ServiceTaskExecution extends DelegateExecution {
PvmActivity getActivity();
ActivityExecution getParent();
List<? extends ActivityExecution> getExecutions();
boolean isActive();
boolean isConcurrent();
boolean isProcessInstance();
List<ActivityExecution> findInactiveConcurrentExecutions(PvmActivity activity);
}
However, one could argue, whether it is good to have Service Tasks the behave differently, based on their location in a process definition and the execution state of the process instance. If not, a DelegateExecution would be enough. Any opinions on that?09-16-2010 03:37 AM
wever, one could argue, whether it is good to have Service Tasks the behave differently, based on their location in a process definition and the execution state of the process instance. If not, a DelegateExecution would be enough. Any opinions on that?
09-25-2010 05:05 AM
11-03-2010 08:49 AM
11-03-2010 10:05 AM
To implement a class that can be called during process execution, this class needs to implement the org.activiti.engine.delegate.JavaDelegation interface and provide the required logic in the execute method. When process execution arrives at this particular step, it will execute this logic defined in that method and leave the activity in the default BPMN 2.0 way.
[EXPERIMENTAL] It is also possible to provide a class that implements the org.activiti.engine.impl.pvm.delegate.ActivityBehavior interface. Implementations have then access to the more powerful ActivityExecution that for example also allows to influence the control flow of the process. Note however that this is not a very good practice, and should be avoided as much as possible. So, it is advised to use the ActivityBehavior interface only for advanced use cases and if you know exactly what you're doing.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.