You can use a wizard to create a session bean and add it to your
project.
Before you can create an enterprise bean, you must:
To create a session bean, complete the following steps:
- In the Java™ EE perspective, click . Select and click Next.
- Select Session Bean and click Next.
- Select the Project that will contain the
new session bean.
- In the Folder field, select the folder for
the new bean.
- In the Java package field, enter the package
name for the new bean.
- In the Class name field, type a name for
the enterprise bean. By convention, bean names should begin with an uppercase
letter.
Note: You can use Unicode characters for the bean name,
but Unicode characters are not supported for enterprise bean packages and
classes associated with enterprise beans.
- Optional: Change the Superclass for
the bean if you want it to inherit from a class other than java.lang.Object and
click Next.
- Provide an EJB Name for the bean.
This is the name of the enterprise bean class. The next three fields
will automatically be filled in, you can change these values if you want:
- JNDI Name is the logical name used by the server
to locate an enterprise bean at runtime.
- Display Name is a short name for the enterprise
bean that is used by tools.
- Description is to help you identify the bean.
- Select the State type for the new bean:
- A Stateful session bean maintains client-specific
session information, or conversational state, across multiple method calls
and transactions. An instance of a stateful session bean has a unique identity
that is assigned by the container at create time.
- A Stateless session bean does not maintain conversational
state. Instances of a stateless session bean have no conversational state.
All instances of a stateless session bean have the same object identifier,
which is assigned by the container.
- Select a Transaction Type for the new bean:
- Container specifies that the transaction demarcation is performed
by the container.
- Bean specifies that the transaction demarcation
is performed by the bean.
Click Next.
- Select the type of Modifiers to use for
the class.
- Optional: Select the Interfaces you want the
bean to implement. Click Add to select interfaces that
you want to implement and click Remove to take away
interfaces that you no longer want to implement.
- Select the method stubs that you want the wizard to create.
- Click Finish to add the new bean to the
specified EJB project.