Two Laptop Bag*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Annotating a Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Annotating a Session Bean" Watch "Annotating a Session Bean" New topic
Author

Annotating a Session Bean

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Hi Guys,

I have a small question on annotating a session bean class. Imagine I have a session bean and I want to provide both the Local and Remote interfaces for it. Can I just annotate at the class level



please advise!


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9954
    
163

Yes you can. But also remember to "implement" both these interfaces on the session bean:



[My Blog] [JavaRanch Journal]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Another way of implementing it would be like,


Any coments on this?
[ August 12, 2008: Message edited by: Jothi Shankar Kumar Sankararaj ]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9954
    
163

Even this is possible. I have even seen examples where the local and remote interfaces extend from a common interface. It's all upto the bean developer and also on what APIs you want to expose in a local interface and a remote interface.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Thanks for your comments!
Michael Wiezik
Ranch Hand

Joined: Mar 19, 2004
Posts: 70
Originally posted by Jaikiran Pai:
Yes you can. But also remember to "implement" both these interfaces on the session bean:



As far as I can remember, session bean class does not have to explicitely implement its local/remote interfaces, in terms you don't have to put 'implements LocalInterface, RemoteInterface' clause at all, as long as bean implementation defines all methods declared in local/remote interfaces. Please correct me if I'm wrong.


SCJP 1.4 - 88%
SCBCD 5.0 - 90%
SCEA - 81%
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
The annotations are sufficient.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9954
    
163

Just went through the spec. You guys are right. Implementing the interfaces is optional:

The bean class may implement its business interface(s).

While it is expected that the bean class will typically implement its business interface(s), if the bean class uses annotations on the
bean class or the deployment descriptor to designate its business interface(s), it is not required that the bean class also be specified
as implementing the interface(s).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Annotating a Session Bean
 
Similar Threads
EJB 3 Local Lookup not working with Weblogic 10.3 and JDK 1.6_05
@Remote and @Local
1 or 2 homes
Remote and Local Interface for the Same Bean Class?
Local and remote interfaces for session facade?