Calling an Enterprise Bean
See Also
Calling an enterprise bean is the process of getting a reference to the enterprise
bean so that you can call its methods. The IDE can assist you in calling an enterprise bean from
any Java class in an EJB module, web application, or enterprise application client.
To call an enterprise bean:
- Open the IDE project that contains the enterprise bean that you want to
call.
- Open the file from which you want to call the enterprise bean.
- In the Source Editor, right-click anywhere in the body of the class and
choose Insert Code > Call Enterprise Bean.
- In the dialog box, select the enterprise bean that you want to call.
- (Optional) Type a new name for the reference.
- Specify whether to reference the local interface or the remote interface.
To reference a bean's local interface, the class that is referencing
the bean must be packaged in the same enterprise application as the enterprise
bean.
- Click OK.
When you call an enterprise bean, the following occurs:
- Java EE 5 and Java EE 6 projects:
- J2EE 1.4 projects:
- A lookup method is created in the caller class.
- The enterprise bean project is added to the caller project's classpath.
- A reference to the entity or session bean being called is added to the deployment descriptor of the caller project.
If and where the reference is added depends on which of the following applies:
- If the lookup is made from an enterprise bean implementation class,
the reference is added to the corresponding bean.
- If the lookup is made from any class of a web application,
the reference is added to the web application.
- If the lookup is made from a plain Java class of an EJB module,
no reference is added. In this case, the reference has to be added manually
to the bean calling the plain Java class.
Notes:
- If the project uses the J2EE 1.4 specification, when you select the enterprise bean that you want to call you
need to select whether to use inline lookup code or use an existing service
locator class.
- The IDE cannot assist you when calling an enterprise bean from a free-form
web application project.
- See Also
- About Calling an Enterprise Bean
- Adding
a Module to an Enterprise Application
- Configuring EJB Deployment Descriptors
- Defining a Business Method
- Creating an Enterprise Bean
- Using Service Locators
Legal Notices