Hello Every one,
I am trying to understand the purpose of annotation @Local , and I found that it is applicable to both business interface as well as Bean implementation class. I did not understand what is the purpose of
specifying it on the Bean implementation class.
I write a business interface as
and have written the bean implementaion class as
and I am able to successfully compile and deploy my bean in glassfish v3 server.
Logically I should not be able to compile this code.
I did not see any point of writing the @Local on the Bean implementation class. Kindly comment and share your opinion.
It's just a matter of taste - one prefer to have @Local on the interfaces directly and let the bean class just implement the interface.
Others might want to have just plain interfaces and annotate an EJB @Local. Note that in this case:
- you can share the interface with your client code as it doesn't have any dependencies on javax.ejb.* packages,
- as you pointed - you don't have to (but can) use 'implements' structure; @Local(....) is enough information for the container, but it might fail to deploy and/or use such EJB definition at runtime,
- some people prefer to keep the information about remote and local interfaces close to the bean class, so they go with @Local and @Remote on the bean class.
So once again - you can choose which way you prefer, and it's definitely not "only this way is good and the other is bad" decision.
OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.