Hi,
I read a bit of theory about EJBs 3.1 but now that I'm trying to create one in practice I have some doubt, and I don't know how to proceed.
Is there anyone that can give me some help?
Ok, I would like to create a
stateless EJB with a single public method that perform some operation and returns an int. And I would like to access it
Locally, Remotely, via SOAP and via REST.
I also would like to
follow all the best practices and code/naming conventions.
This is the EJB that I created: (Please correct me if something is wrong or if I didn't follow some convention/best practice in naming, packaging, interfaces references, etc.)
And those are the local and remote interfaces that I created:
And here "some" question:
1. How can I invoke the method doProcess from a remote client? Must the client make use of the remote interface or there is a way to make a call passing the method name as parameter? for ex. int result = lookup("..").call("doProcess", {1,3,5,7,9});
1.1 If the use of the bean interface in the client is mandatory this means that the EJB remote interface should be defined in an external project (otherwise the client must have a dependency to the whole EJB project to use the interface)?
2. When I do the
JUnit tests should I create the EJB instance using "ProcessorLocal instance = new ProcessorBean();" or using an annotation like "@EJB ProcessorLocal instance;"
2.1 If the answer to the previous question is using the "new" keyword does the validator work in this case (being the EJB instance created outside the container that should provide the services)?
2.2 If otherwise the answer to the question 5 is using the "@EJB" annotation, this means that the JUnit
test can be executed only running the EJB into the server to have CDI etc?
3. The @NotNull validator is active by default or have I to update the bean.xml descriptor?
4. How can I have the same EJB method available also through SOAP and REST? It is sufficient to create two new interfaces with the annotations relative to SOAP and REST?
Thanks in advance!