Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
EJB 3.0 greatly simplifies the development of stateless session beans, removing many complex development tasks. For example:
The bean class can be a plain old Java object (POJO); it does not need to implement javax.ejb.SessionBean
.
The business interface is optional.
Home (javax.ejb.EJBHome
and javax.ejb.EJBLocalHome
) and component (javax.ejb.EJBObject
and javax.ejb.EJBLocalObject
) business interfaces are not required.
The EJB 3.0 local or remote client of a session bean written to the EJB 3.0 API accesses a session bean through its business interface. The business interface of an EJB 3.0 session bean is an ordinary Java interface, regardless of whether or not local or remote access is provided for the bean.
Annotations are used for many features.
A SessionContext
is not required: you can simply use this
to resolve a session bean to itself.
For more information, see the following:
Note:
You can download an EJB 3.0 stateless session bean code example from:http://www.oracle.com/technology/tech/java/oc4j/10131/how_to/how-to-ejb30-stateless-ejb/doc/how-to-ejb30-stateless-ejb.html
.To implement an EJB 3.0 stateless session bean, do the following:
Create the stateless session bean class.
You can create a plain old Java object (POJO) and define it as a stateless session bean with the @Stateless
annotation.
Note:
OC4J ignores the@Stateless
attribute mappedName
. For more information, see "OC4J Support for Annotation Attribute mappedName".Implement your business methods.
Note:
A stateless session bean does not need a remove method.Optionally, define life cycle callback methods using the appropriate annotations.
You do not need to define life cycle methods: OC4J provides an implementation for all such methods. Define a method of your stateless session bean class as a life cycle callback method only if you want to take some action of your own at a particular point in the stateless session bean's life cycle.
For more information, see "Configuring a Life Cycle Callback Interceptor Method on an EJB 3.0 Session Bean".
Optionally, define OC4J-proprietary deployment options.
In an EJB 3.0 application, you can do this by annotating your stateless session bean class with the OC4J-proprietary oracle.j2ee.ejb.@StatelessDeployment
annotation (see "Configuring OC4J-Proprietary Deployment Options on an EJB 3.0 Session Bean").
Complete the configuration of your session bean (see "Using an EJB 3.0 Session Bean").