This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes [EJB3.0] Providing both Remote and local views to the same Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "[EJB3.0] Providing both Remote and local views to the same Session Bean" Watch "[EJB3.0] Providing both Remote and local views to the same Session Bean" New topic
Author

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

Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
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 !!!


Only those who will risk going too far can possibly find out how far one can go !!!
Camilo Morales
Ranch Hand

Joined: Jul 14, 2007
Posts: 91
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,


Camilo Morales<br />SCJP 5, SCBCD 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [EJB3.0] Providing both Remote and local views to the same Session Bean
 
Similar Threads
loacl v/s remote interface
Remote and Local Interface for the Same Bean Class?
@Remote and @Local
Local and remote interfaces for session facade?
Implementing Remote and local interface at the same time ?