File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes @Local annotation on the bean implementation class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "@Local annotation on the bean implementation class" Watch "@Local annotation on the bean implementation class" New topic
Author

@Local annotation on the bean implementation class

Jitin Guglani
Greenhorn

Joined: Jan 01, 2009
Posts: 17
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.


Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

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.

HTH.


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.
Jitin Guglani
Greenhorn

Joined: Jan 01, 2009
Posts: 17
thanks a lot for your help Piotr Nowicki.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @Local annotation on the bean implementation class