+

Search Tips   |   Advanced Search

OSGi application design guidelines


Use OSGi services to configure EJB dependencies

If the OSGi application has a client bundle that references an EJB in a service bundle, use OSGi services to configure the EJB dependency.

To configure EJB dependencies by using OSGi services...

  1. Declare the EJB in the Export-EJB header in the bundle manifest file of the service bundle, so that the EJB is registered in the OSGi service registry.

  2. Use a reference element in the Blueprint XML file of the client bundle to inject and call the EJB; for more information, see References and the Blueprint Container

Configuring EJB dependencies by using OSGi services reduces the risk of the web or EJB container of the client bundle being recycled, or the client bundle itself being restarted, either of which might result in the temporary unavailability of one or more application endpoints.


Do not use the java:global or java:app namespaces

Do not use the java:global or java:app namespace references to bind to EJBs unless necessary.

These namespace references have the following fixed formats:

However, the constituent parts of these references can change after an OSGi application is updated, so that the references must be modified accordingly, which makes this approach impractical. Furthermore, the exposure of the name of the underlying EJB in the reference, rather than using an abstraction such as an intermediate JNDI name, violates the principles of modular application design.

Instead, use OSGi services to configure EJB dependencies, or declare an EJB reference and map it to the EJB JNDI name.

If we define java:global or java:app references in an @EJB annotation, or in a binding file, you receive a warning when you deploy the OSGi application as a business-level application.


Parent topic: Develop OSGi applications


Related tasks

Develop an OSGi application
  • Create an OSGi application
  • Create a client bundle
  • Create a service bundle
    Best practices for developing and working with OSGi applications
    Develop enterprise OSGi applications for WebSphere Application Server
  • Writing extensible OSGi applications