Exposing EJBs as OSGi services
You can include EJBs in OSGi bundles and expose EJBs as OSGi services.
About this task
Important: Applicable to WebSphere® Application Server traditional
Procedure
-
Configure an OSGi bundle for EJB support.
There are two primary methods to configure an OSGi bundle for EJB support:
- Convert an EJB project to an OSGi bundle project
- To convert an EJB project to an OSGi bundle project, right-click the project and select Configure > Convert to OSGi Bundle Project. After you convert the EJB project, the OSGi bundle facet is added to the project and a bundle manifest file is created.
- Add EJB support when you create an OSGi bundle
- You can add EJB support when you create an OSGi bundle. To add EJB support, click File > New > OSGi Bundle Project. In the bundle project wizard, select Add EJB support and select the EJB level that you want to use.
-
Manage EJB exports.
To control the EJBs that you want to expose as OSGi services, right-click the OSGi bundle project and select OSGi > Expose EJBs as OSGi services. In the manage EJB exports dialog that opens, select the EJBs that you want to expose as services.
-
Understand the manifest.
Double-click the Manifest file in a bundle project to open it in the manifest editor. Select the MANIFEST.MF tab to view the manifest source. OSGi bundle projects that have EJB support have a header called Export-EJB. EJBs are entered as a comma-separated list. This example shows two EJBs exported as services:
Export-EJB: EJB1,EJB2
Note: There are two special cases of the Export-EJB header to be aware of:- NONE
- If you specify NONE as an entry for the Export-EJB header, no EJBs are exposed as services. If you specify NONE, but then also add an EJB to the list, a warning is displayed by the tools.
- BLANK
- If you have an Export-EJB header in the manifest but there are no entries, by default all EJBs in the project are exposed as services.
-
Add and delete EJBs automatically.
By default, when you add or delete an EJB to an OSGi bundle project with EJB support, the EJB entry is automatically added or removed from the Export-EJB header in the manifest file.