Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[EJB3.0] Providing both Remote and local views to the same Session Bean

 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to provide both Remote and local views to the same Session Bean?

There will be two different interfaces for Remote and Local client views. Do I need to add implements clause in my Bean class for both of these interfaces?

How to make use of annotations in this case?

Thanks in Advance !!!
 
Camilo Morales
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kalyana Sundaram:
How to provide both Remote and local views to the same Session Bean?

There will be two different interfaces for Remote and Local client views. Do I need to add implements clause in my Bean class for both of these interfaces?

How to make use of annotations in this case?

Thanks in Advance !!!


Yes, your Session Bean must implement (or not if the bean's business interfaces are is especified in the deployment descriptor) an inteterface with a @Local annotation (or deployment descriptor tag) and ANOTHER interface with the @Remote annotation (or deployment descriptor tag). One session may have more than 1 Local interface and more than 1 Remote interface. One interface CAN NOT BE Local AND Remote, or in other words, @Local and @Remote annotations can not be used in the same interface.

There is a special case where you dont have to use any @Local or @Remote annotations: If your Session beans implements one interface, and this interface do not have any annotations (Local nor Remote), this interface is assumed to be the LOCAL business interface of the bean.

Here are some fragments of the Specification (EJBCore - page 94-95) which may be a lot more clear about what I'm saying:


A bean class is permitted to have more than one interface. If a bean class has more than one interface�excluding the interfaces listed below (java.io.Serializable; java.io.Externalizable; any of the interfaces defined by the javax.ejb package)�any business interface of the bean class must be explicitly designated as a business interface of the bean by means of the Local or Remote annotation on the bean class or interface or in the deployment descriptor.



The bean class must implement the interface or the interface must be designated as a local or remote business interface of the bean by means of the Local or Remote annotation or in the deployment descriptor.



While it is expected that the bean class will typically implement its business interface(s), if the bean class uses annotations 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).



If bean class implements a single interface, that interface is assumed to be the business interface of the bean. This business interface will be a local interface unless the interface is designated as a remote business interface by use of the Remote annotation on the bean class or interface or by means of the deployment descriptor.



The same business interface cannot be both a local and a remote business interface of the bean.


Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic