OSGi application design guidelines
When developing OSGi applications for WebSphere Application Server, consider these design guidelines to make the most efficient use of OSGi technology.
The design guidelines described in this topic are:
Details for each of these guidelines are provided in the sections that follow.
1. Use OSGi services to configure EJB dependencies
If our 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 using OSGi services:
- 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.
- 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
- Here's why
- Configure EJB dependencies 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.
2. 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.
- Here's why
- These namespace references have the following fixed formats:
java:global/application_name/module_name/ejb_namejava:app/module_name/ejb_nameHowever, 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, we receive a warning when we deploy the OSGi application as a business-level application.
Developing an OSGi application Create an OSGi application Create a client bundle Create a service bundle Best practices for developing and working with OSGi applications Developing enterprise OSGi applications for WAS Writing extensible OSGi applications
File name: was1528.html
prettyPrint();