To create session beans, use the Create EJB 3.0 Session Bean wizard to create the session bean class source file and implement the business methods in the file. The method is described below.
Creating Session Bean Classes with the Create EJB 3.0 Session Bean Wizard
From the [New] wizard, select [EJB] > [Session Bean], and the wizard creates the session bean. Refer to the following for the wizard settings:
EJB project
Specify the EJB project that will generate the session bean.
Source folder
Specify the folder that stores the session bean sources.
Java package
Specify the package name of the session bean class and the business interface.
Class name
Specify the bean class name of the session bean.
State type
Select either "Stateful" or "Stateless" in accordance with the type of session bean you want to create.
Create business interface
Select the business interface to be generated as "Remote" or "Local", then specify the interface name to be generated.
Bean name
Specify the EJB name of the session bean.
Mapped name
Specify the JNDI name mapped to the session bean.
Transaction type
Select the transaction type as "Container" or "Bean".
Interfaces
Specify the interface to be used by the session bean.
Home and Components Interfaces (EJB 2.x)
If generating an EJB2.x format interface, select "Remote" or "Local", then specify the interface name to be generated.
When the wizard is executed, the Java source of the session bean class and the business interface is generated.
Implementing the Business Method
After the source is generated, implement the business method in the session bean. The procedure for implementing the business method is as follows:
Code the method declaration in the business interface.
Code the implementation of that method in the session bean class.
The method declared in the business interface is automatically handled as a session bean business method.
The methods for declaring and implementing these methods are the same as for ordinary Java interfaces and Java classes. Use the Java editor to declare and implement the methods.