Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Annotating a Session Bean

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can. But also remember to "implement" both these interfaces on the session bean:

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your comments!
 
Michael Wiezik
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The annotations are sufficient.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic