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.
Chapter 26. Working with OSGi applications 937
Figure 26-8 Import asset wizard
3. In the summary step, click Finish to import the asset. Enterprise bundle archive asset
conversion and resolution warnings or other information might display in the upper-left
corner.
4. After processing is complete and without error, save your changes. For OSGi applications,
provisioning happens when importing the asset. As a result of provisioning, bundles might
need to be retrieved from a bundle repository (internal or external). This process needs to
be complete before
the asset can be added to a business-level application. However,
downloads are triggered only after the asset import is saved. Thus, saving the changes
after importing the asset is required.
26.5.2 Adding the enterprise bundle archive asset to the business-level
application
To add the enterprise bundle archive asset to the business-level applications:
1. Click Applications Application Types Business-level applications.
2. Click New to create a new empty business-level application. Enter a name for the
application. ITSOBank Systems is used in this example, as shown in Figure 26-9 on
page 938. Click Apply.
938 WebSphere Application Server V8.5 Administration and Configuration Guide for the Full Profile
Figure 26-9 Create a new Business-level application
In the business-level application detail panel, click Add Add Asset in the Deployed Assets
section, as shown in Figure 26-10.
Figure 26-10 Add asset to business-level application

Get WebSphere Application Server V8.5 Administration and Configuration Guide for the Full Profile now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.