![]() | |
|
Session Bean Class
The following are the requirements for the session bean class:
The class MUST be defined as public, MUST NOT be final, and MUST NOT be abstract. The class MUST be a top level class.
The class MUST HAVE a public constructor that takes NO parameters. The container uses this constructor to create instances of the session bean class.
The class MUST NOT define the finalize() method.
The class must implement the bean's business interface(s) OR the methods of the bean's business interface(s), if any.
The class must implement the business methods of the bean's EJB 2.1 client view interfaces, if any.
Optionally:
The class may implement, directly or indirectly, the javax.ejb.SessionBean interface.
If the class is a STATEFUL session bean, it may implement the javax.ejb.SessionSynchronization interface.
The class may implement the session bean's web service endpoint or component interface.
If the class is a STATELESS session bean, it may implement the javax.ejb.TimedObject interface.
The class may implement the ejbCreate method(s).
The session bean class may have superclasses and/or superinterfaces. If the session bean has superclasses, the business methods, lifecycle callback interceptor methods, the timeout callback method, the methods of the optional SessionSynchronization interface, the Init or ejbCreate<METHOD> methods, the Remove methods, and the methods of the SessionBean interface, may be defined in the session bean class, or in any of its superclasses. A session bean class MUST NOT have a superclass that is itself a session bean class.
The session bean class is allowed to implement other methods (for example helper methods invoked internally by the business methods) in addition to the methods required by the EJB specification.
A STATELESS session bean MUST be annotated with the Stateless annotation or denoted in the deployment descriptor as a stateless session bean. The bean class NEED NOT implement the javax.ejb.SessionBean interface.
A STATEFUL session bean MUST be annotated with the Stateful annotation or denoted in the deployment descriptor as a stateful session bean. The bean class NEED NOT implement the javax.ejb.SessionBean interface or the java.io.Serializable interface (the container must be able to handle the passivation of the bean instance even if the bean class does not implement the Serializable interface).
A STATEFUL session bean MAY implement the SessionSynchronization interface.
![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |