Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3)
B14428-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Implementing an EJB 3.0 Stateless Session Bean

EJB 3.0 greatly simplifies the development of stateless session beans, removing many complex development tasks. For example:

For more information, see "What is a Stateless Session Bean?".


Note:

You can download an EJB 3.0 stateless session bean code example from: http://www.oracle.com/technology/tech/java/oc4j/ejb3/howtos-ejb3/howtoejb30slsb/doc/how-to-ejb30-stateless-ejb.html.

To implement an EJB 3.0 stateless session bean:

  1. Optionally, create one or more remote component interfaces and/or local interfaces for your stateless session bean.

    You can create a plain old Java interface (POJI) and define it as a remote interface with the @Remote annotation or as a local interface using the @Local annotation.

    You can specify multiple interfaces using the annotation's value attribute:

    @Stateless
    @Local (value={Local1.class})
    @Remote (value={Remote1.class, Remote2.class})
    
    
  2. 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.

    Implement your remote interface, if used.

  3. Implement your business methods.


    Note:

    A stateless session bean does not need a remove method.

  4. Optionally, define lifecycle callback methods using the appropriate annotations.

    You do not need to define lifecycle methods: OC4J provides an implementation for all such methods. Define a method of your stateless session bean class as a lifecycle callback method only if you want to take some action of your own at a particular point in the stateless session bean's lifecycle.

    For more information, see "Configuring a Lifecycle Callback Method for an EJB 3.0 Session Bean".

  5. Complete the configuration of your session bean (see "Using EJB 3.0 Session Bean API").