936 WebSphere Application Server V8.5 Administration and Configuration Guide for the Full Profile
You can also use other tools to build your OSGi applications, such as Ant or Maven, and
automate them with wsadmin scripts. To learn more about these technologies, refer to the
following web sites:
http://ant.apache.org
http://maven.apache.org
Additional considerations when exporting OSGi applications
Because of the complexities of the OSGi class loader, give special consideration to importing
an exported package. When a package is exported, the package can be used by a separate
bundle before the exported bundle is even started. This situation can be a problem when
singletons and static fields are used because an imported class is loaded by a separate class
loader than the class loader that is used by the bundle. This creates separate instances of the
service object.
For example, suppose bundleA exports a service object that is responsible for generating
sequential order numbers. Also, suppose that three other bundles import and use that service
object for generating order numbers. Those three other bundles use the
framework class
loader
and share the same instance of the service object. If bundleA also imports the
package, it also uses the same instance. However, if bundleA does not import the package,
the
bundle class loader instantiates a new instance of the service object and possibly
produces a duplicate list of order numbers.
So the practices noted indicate that you typically must import any packages that you export to
reduce the number of copies of that package in memory and to ensure that the object
instances come from the same class loader.
For more information about OSGi class loaders, refer to 22.5, “OSGi class loaders” on
page 810.
26.5 Deploying OSGi applications
You can deploy an OSGi application by adding an enterprise bundle archive asset to a
business-level application. The deployment can be done using the administrative console or
wsadmin. Installing through the administrative console is useful when dealing with complex
application structures involving multiple versions and sharing. Using the administrative
console for the first installation is also useful for capturing script commands for future use with
wsadmin.
OSGi applications are packaged in enterprise bundle archive files. Deploying applications
packaged this way involves completing the following steps:
1. Import the enterprise bundle archive file as an asset.
2. Add that asset to the business-level application as a composition unit.
26.5.1 Importing the enterprise bundle archive file as an asset
To import the enterprise bundle archive file as an asset:
1. In the administrative console, click Applications Application Types Assets. Click
Import, and select the itsobank.eba file exported in 26.4.3, “Exporting OSGi applications”
on page 935. Click Next.
2. In the wizard, as shown in Figure 26-8 on page 937, accept all the defaults and then click
Next.