Create EJB
IntelliJ IDEA provides the following ways to create beans:
-
Manually, by means of direct editing the ejb-jar.xml file, using the extensive coding assistance provided by IntelliJ IDEA.
-
Using the context menu commands.
To create an Enterprise Java bean using the editor
-
Open the deployment descriptor file ejb-jar.xml for editing.
-
Create the
<enterprise-beans>
section. -
In this section, create tags for the desired bean types:
<session>
,<entity>
, or<message-driven >
-
Specify the bean name and class by adding tags
<ejb-name>
. and<ejb-class>
. Note that you can specify the target package in this tag, for example,samples.ejb.ManuallyCreatedEntity
, using code completion after each dot. - If the declared class does not yet exist, IntelliJ IDEA suggests a quick fix:
Choose
from the suggestion list. If the target package was not defined in the<ejb-class>
tag, select the desired package in the Choose Destination Directory dialog box. The stub class is created in the specified location. -
Proceed with defining the other bean components.
To create an Enterprise Java bean, follow these general steps
-
Open the EJB tool window.
- Right-click the desired module, choose
The New <bean type> Bean dialog box opens.
on the context menu, and then select the bean type on the submenu.
-
Specify the bean name, class and package.
- Define the bean-specific settings:
-
For Entity beans (1.x and 2.x) and Session beans (1.x and 2.x), configure local and remote interfaces.
-
For Entity beans (1.x and 2.x), configure primary keys and CMP bean fields.
-
For Message beans, configure message listener.
-
For Session beans, configure service endpoint.
-