Hey guys,I found four ways to call a method of a Stateless EJB. Which one do you recommend?My environment: Activiti5.beta1; EJB3; JBoss AS 5.1.) In the first listing I have an EJB which is already injected via JBoss AS. I'm setting the EJB as variable when the process is started.
…
@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);
…
In the process I call the EJB the following way:
…
<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?2.) The second way is to implement ActivityBehavior and to extend BpmnActivityBehavior (like it's described in the user manual).
…
@Stateless
public class FriendsService extends BpmnActivityBehavior implements FriendsServiceRemote, ActivityBehavior {
…
public void execute(ActivityExecution execution) throws Exception {
System.out.println("huhu");
performDefaultOutgoingBehavior(execution);
}
}
…
In the process I call the EJB the following way:
…
<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. 3.) The third one is to call my EJB from a Spring bean. Actually, I have no clue about Spring and so I haven't tested it… I had the idea because of the new chapter(Spring Integration) in the user manual. What exactly does "Integration" mean? Is their a "special" way how Activiti handles the Spring beans? Is it possible to inject EJBs like Spring beans and to use them the same way like you use the Spring beans?4.) Last but not least the WebServiceTask. I can make all my methods available as Web Services and call them in the WebServiceTask. I hope I can try it out in the next release! What do you think about that?Thanks in advance.Cheers,Marc