Class JPMSModule
java.lang.Object
aQute.bnd.osgi.JPMSModule
Multi Release jars are another error magnet extension to Java. Instead of
having the flat class space of Java and Javac, it allows developers to put
multiple versions of a class in versioned directory.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcleanupName(String bsn) Cleanup a bsn so that it matches a JPMS module namestatic ManifestCopies specified headers from one manifest to another.findResource(String path, int release) Find a resource from a Jar.getJar()Get the underlying JARgetManifest(int release) Return a manifest for OSGi.Returns the name of the module, either from the module descriptor or automatically generated from the JAR file manifest.Returns the version of the module, if present in the module descriptor.intgetNextRelease(int release) Gets the release number of the next version after the specified release.getRelease(int release) Gets a new JAR file that includes all the files from this JAR file and all previous versions up to and including the specified release.getReleaseOnly(int release) Return a Jar that contains only the resources for a specific release version.getResource(int release, String path) Get a resource from a Jar that is in the versioned area.static StringgetVersionedPath(int release, String path) Get the path to a resource in a version directoryReturn the available releases in this modules.booleanChecks if this JAR has version directories.booleanputResource(int release, String path, Resource resource) Put a resource in a Jar in the META-INF/versions/ subtree for Multi Release Jars.
-
Field Details
-
MULTI_RELEASE_HEADER
- See Also:
-
VERSIONS_PATH
- See Also:
-
MODULE_INFO_CLASS
- See Also:
-
OSGI_VERSIONED_MANIFEST_PATH
- See Also:
-
-
Constructor Details
-
JPMSModule
-
-
Method Details
-
getJar
Get the underlying JAR -
getVersionedPath
-
getVersions
-
getReleaseOnly
Return a Jar that contains only the resources for a specific release version.- Parameters:
release- the release number- Returns:
- the Jar will only the release classes invalid input: '&' resources
-
putResource
Put a resource in a Jar in the META-INF/versions/ subtree for Multi Release Jars.- Parameters:
release- the release number (> 8)path- the relative path of the resourceresource- the resource- Returns:
- true if this modified the set of resources
-
getResource
-
findResource
Find a resource from a Jar. Start in the normal space than look in the increasing versioned areas.- Parameters:
path- the pathrelease- the release to start. If invalid input: '<' 0, start from default and go up in releases. If invalid input: '<'9, use default. Otherwise start there and go down, ending in default- Returns:
- the resource or null if not existent
-
isMultiRelease
public boolean isMultiRelease()Checks if this JAR has version directories. This does not look at the manifest header.- Returns:
- if this is a multi release JAR (has versions)
-
getModuleName
Returns the name of the module, either from the module descriptor or automatically generated from the JAR file manifest.- Returns:
- An optional string containing the module name, or an empty optional if the module name cannot be determined.
- Throws:
Exception- If an error occurs while parsing the module descriptor or manifest.
-
getModuleVersion
Returns the version of the module, if present in the module descriptor.- Returns:
- An optional string containing the module version, or an empty optional if the module version cannot be determined.
- Throws:
Exception- If an error occurs while parsing the module descriptor.
-
getManifest
Return a manifest for OSGi.The Framework must first look in the versioned directory for the major version of the current Java platform and then prior versioned directories in descending order. The first supplemental manifest file found must be used and the Framework must replace the values of the following manifest headers in the manifest with the values of these headers, if present, in the supplemental manifest file.
Import-Package Require-CapabilityAny other headers in the supplemental manifest file must be ignored.- Parameters:
release- the version of the VM- Returns:
- a Manifest
-
copy
Copies specified headers from one manifest to another.- Parameters:
result- The manifest to copy the headers to. If null, a new manifest will be created.r- The manifest to copy the headers from. If null, no headers will be copied.headers- The headers to copy.- Returns:
- The manifest with the copied headers.
-
getRelease
Gets a new JAR file that includes all the files from this JAR file and all previous versions up to and including the specified release.- Parameters:
release- The release number to include in the new JAR file.- Returns:
- A new JAR file containing all the files from this JAR file and all previous versions up to and including the specified release.
-
getNextRelease
public int getNextRelease(int release) Gets the release number of the next version after the specified release.- Parameters:
release- The release number.- Returns:
- The release number of the next version after the specified release, or Integer.MAX_VALUE if there are no more versions.
-
cleanupName
-