This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.