New Session Bean Wizard
See Also
This wizard creates a new session
bean in an EJB module. You open the wizard by right-clicking the
project node and choosing New > Session Bean.
You can also use the wizard to create session beans in Java EE 6 web projects.
You set the following information in the wizard:
- EJB Name. Set the name of the session bean.
The name is used as the basis for the session bean's class and interface names.
- Location. Select the source folder where you want to create the session
bean files.
- Package. Select an existing package or type the name of a new package.
- Session Type. Select one of the following:
- Stateless. The bean does not save state information during its
conversation with the user. These enterprise beans are useful for simple
interactions between client and application service, interactions that
are complete in a single method invocation.
An example is an enterprise bean that processes orders. Each order
can be processed by an invocation of one method, such as processOrder().
All the information needed for processing is contained in the method
parameters.
- Stateful. The bean saves state information during its conversation
with the user. These enterprise beans are useful for business processes
that require an interaction between client and application service that
lasts longer than a single method invocation and requires memory of the
state of the interaction.
An example is an online shopping cart. The end user, through the client
program, can order a number of items. The stateful session bean managing
the interaction must accumulate items until the end user is ready to
review the accumulated order, approve or reject items, and initiate
processing of the lot. The stateful session bean has to store the unprocessed
items and enable the end user to add more.
- Singleton. (Java EE 6) A singleton session bean is instantiated only once per application
and exists for the lifecycle of the application.
You can create a singleton bean that the container instantiates when the application
starts up by using the @Startup annotation.
An example is a bean that is used to intialize data for an application that can be concurrently accessed by many clients.
- Create Interface. Specify which interfaces to create for the session
bean:
- Local. Allow your session bean to be accessed from clients that
are running in the same Java Virtual Machine.
- Remote. Allow your session bean to be accessed from remote clients
using remote method calls. This usually means clients that are not running
on the session bean's application server.
If you select Remote, the IDE can generate a remote interface for the session bean
in a Java class library project if the project that you want to contain the interface is open in the IDE.
You can choose the project from the dropdown list that lists the open
Java class library projects.
- See Also
- About Session Beans
- Creating an EJB Module Project
- Creating an Enterprise Bean
- Defining a Business Method
Legal Notices