9-6 Developing Applications for Oracle WebLogic Server
filename or exploded archive directory name as the deployment name. If you redeploy a standalone shared Java EE library from a different file or location, the deployment
name and URI also change, and referencing applications that use the wrong URI cannot access the deployed library.
If you choose to deploy a shared Java EE library as a standalone Java EE module, always specify a known deployment name during deployment and use that name as
the URI in referencing applications.
9.2.2 Assembling Optional Package Class Files
Any set of classes can be organized into an optional package file. The collection of shared classes will eventually be packaged into a standard JAR archive. However,
because you will need to edit the manifest file for the JAR, begin by assembling all class files into a working directory:
1.
Create a working directory for the new optional package. For example: mkdir appsmyOptPkg
2.
Copy the compiled class files into the working directory, creating the appropriate package sudirectories as necessary. For example:
mkdir -p appsmyOptPkgorgmyorgmyProduct cp buildclassesmyOptPkgorgmyOrgmyProduct.class
appsmyOptPkgorgmyOrgmyProduct
3.
If you already have a JAR file that you want to use as an optional package, extract its contents into the working directory so that you can edit the manifest file:
cd appsmyOptPkg jar xvf buildlibrariesmyLib.jar
9.2.3 Editing Manifest Attributes for Shared Java EE Libraries
The name and version information for a shared Java EE library are specified in the META-INFMANIFEST.MF file.
Table 9–1 describes the valid shared Java EE library
manifest attributes.
Creating Shared Java EE Libraries and Optional Packages 9-7
To specify attributes in a manifest file:
1. Open or create the manifest file using a text editor. For the example shared Java
EE library, you would use the commands: cd appsmyLibrary
mkdir META-INF emacs META-INFMANIFEST.MF
For the optional package example, use: cd appsmyOptPkg
mkdir META-INF emacs META-INFMANIFEST.MF
2. In the text editor, add a string value to specify the name of the shared Java EE
library. For example: Extension-Name: myExtension
Table 9–1 Manifest Attributes for Java EE Libraries
Attribute Description
Extension-Name An optional string value that identifies the name of the shared Java EE library.
Referencing applications must use the exact Extension-Name value to use the library.
As a best practice, always specify an Extension-Name value for each library. If you do not specify an extension name, one is derived from the deployment name of
the library. Default deployment names are different for archive and exploded archive deployments, and they can be set to arbitrary values in the deployment
command.
Specification-Version An optional String value that defines the specification version of the shared Java EE
library. Referencing applications can optionally specify a required Specification-Version for a library; if the exact specification version is not
available, deployment of the referencing application fails.
The Specification-Version uses the following format: Majorminor version format, with version and revision numbers separated by
periods such as 9.0.1.1 Referencing applications can be configured to require either an exact version of the
shared Java EE library, a minimum version, or the latest available version. The specification version for a shared Java EE library can also be set at the
command-line when deploying the library, with some restrictions. See Section 9.7,
Deploying Shared Java EE Libraries and Dependent Applications .
Implementation-Version An optional String value that defines the code implementation version of the shared
Java EE library. You can provide an Implementation-Version only if you have also defined a Specification-Version.
Implementation-Version uses the following formats:
■
Majorminor version format, with version and revision numbers separated by periods such as 9.0.1.1
■
Text format, with named versions such as 9011Beta or 9.0.1.1.B If you use the majorminor version format, referencing applications can be
configured to require either an exact version of the shared Java EE library, a minimum version, or the latest available version. If you use the text format,
referencing applications must specify the exact version of the library.
The implementation version for a shared Java EE library can also be set at the command-line when deploying the library, with some restrictions. See
Section 9.7, Deploying Shared Java EE Libraries and Dependent Applications
.
9-8 Developing Applications for Oracle WebLogic Server
Applications that reference the library must specify the exact Extension-Name in order to use the shared files.
3.
As a best practice, enter the optional version information for the shared Java EE library. For example:
Extension-Name: myExtension Specification-Version: 2.0
Implementation-Version: 9.0.0
Using the majorminor format for the version identifiers provides the most flexibility when referencing the library from another application see
Table 9–2
9.2.4 Packaging Shared Java EE Libraries for Distribution and Deployment