![]() | |
|
Classes and Interfaces
The session Bean Provider is responsible for providing the following class files:
Session bean class.
Session bean's business interface(s), if the session bean provides an EJB 3.0 local or remote client view.
Session bean's remote interface and remote home interface, if the session bean provides an EJB 2.1 remote client view.
Session bean's local interface and local home interface, if the session bean provides an EJB 2.1 local client view.
Session bean's web service endpoint interface, if any.
Interceptor classes, if any.
The Bean Provider for a stateless session bean that provides a web service client view may also define JAX-WS or JAX-RPC message handlers for the bean.
Session Bean's Business Interface
The following are the requirements for the session bean's business interface:
The interface MUST NOT extend the javax.ejb.EJBObject or javax.ejb.EJBLocalObject interface.
If the business interface is a remote business interface, the argument and return values must be of valid types for RMI/IIOP. The remote business interface is NOT required or expected to be a java.rmi.Remote interface. The throws clause should NOT include the java.rmi.RemoteException. The methods of the business interface may only throw the java.rmi.RemoteException if the interface extends java.rmi.Remote.
The interface is allowed to have superinterfaces.
If the interface is a remote business interface, its methods MUST NOT expose local interface types, timers or timer handles, or the managed collection classes that are used for EJB 2.1 entity beans with container-managed persistence as arguments or results.
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. The following rules apply:
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.
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 тАФ 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 following interfaces are excluded when determining whether the bean class has more than one interface: java.io.Serializable; java.io.Externalizable; any of the interfaces defined by the javax.ejb package.
The same business interface cannot be both a local and a remote business interface of the bean.
It is also an error if the Local and/or Remote annotations are specified both on the bean class and on the referenced interface and the values differ.
This is WRONG:
import javax.ejb.Local; @Local public interface ProcessPayment { ... } @Stateless @Remote(ProcessPayment.class) public class ProcessPaymentBean { ... }
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).
![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |