After you have created your Java™ or
EJB project, you can create session beans, message-driven beans, and
JPA entities to add to your project.
Before you begin
You must have a Java project,
an EJB project, or a web project created in your workspace.
About this task
In the earlier versions of Enterprise Java bean specifications, two interfaces, home
and remote, wer defined for accessing the enterprise bean. They can
be remote or local depending on the way the client accesses the bean.
In EJB 3.1 specification, the home or remote interface is not required:
only one interface is defined, the business interface. The business
interface is a simple POJI (Plain Old Java Interface)
and the type of the business interface (remote or local) is specified
using annotations. All annotations required for writing EJB are defined
in the javax.ejb package. Using these annotations, you can create
session beans, message-driven beans, or entity beans.
Procedure
- The first step in creating an enterprise bean is to create
a simple Java class. Right-click
your project, and select .
- Add a component-defining annotation, which indicates to
the tools that this Java class
should be treated as an EJB. Component-defining annotations for EJBs
include:
- @Stateless: Component-defining annotation for a stateless
session bean.
- @Stateful: Component-defining annotation for a stateful
session bean.
- @MessageDriven: Component-defining annotation for a message
driven bean.
- Right-click the
Quick-fix icon,
and select the appropriate action for you project: - If this class is contained in a Java project,
the tools provides a quick fix action to help convert this project
to an EJB project for you:
Select Add
WebSphere Application Server v7.0 EJB 3.0 support, and
your Java project is converted
into an EJB 3.0 project, and quick fix and content assist are available
for all EJB 3.0 annotations while in the Java Editor.
- If this class is contained in an EJB project, the tools provide
a quick fix action to add the required import statement:
Select Import
'Stateless' (javax.ejb), and the import statement import
javax.ejb.Stateless; is added to your class.