public class ManifestLoader extends Object
Manifest
s from your classpath. After construction an instance of this class allows you
to get
the list of Manifest
s. This allows you to determine details (e.g. the name and
version) about the libraries in your classpath.Modifier and Type | Field and Description |
---|---|
private static String |
JAR_SUFFIX
The JAR suffix.
|
static Attributes.Name |
MANIFEST_SOURCE
The
Attributes.Name of the source of the Manifest . |
private List<Manifest> |
manifests
the list of the manifests
|
Modifier | Constructor and Description |
---|---|
|
ManifestLoader()
The constructor.
|
private |
ManifestLoader(ClassLoader classloader)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
private static void |
completeManifest(Manifest manifest,
URL url)
This method adds dynamic attributes to the given
manifest . |
List<Manifest> |
getManifests()
This method gets an unmodifiable list with all available
Manifest s. |
static String |
getValue(Manifest manifest,
Attributes.Name name)
This method gets an attribute-value from a
Manifest in a pragmatic way. |
static Manifest |
loadManifest(Class<?> type)
|
public static final Attributes.Name MANIFEST_SOURCE
Attributes.Name
of the source of the Manifest
. This is a property that is NOT
intended to be defined in the manifest file itself but is set dynamically as main-property
to the source of the manifest (e.g. the name of the JAR-file) if loaded via ManifestLoader
.private static final String JAR_SUFFIX
public ManifestLoader() throws RuntimeIoException
RuntimeIoException
- if a general I/O error occurred while reflectively reading the manifests.private ManifestLoader(ClassLoader classloader) throws RuntimeIoException
classloader
- is the ClassLoader
used to find and load the Manifest
s.RuntimeIoException
- if a general I/O error occurred while reflectively reading the manifests.private static void completeManifest(Manifest manifest, URL url)
manifest
.public List<Manifest> getManifests()
Manifest
s. On a Manifest
you may call
something like this:
manifest.getMainAttributes()
.getValue
(Attributes.Name.IMPLEMENTATION_VERSION
)
Manifest.getMainAttributes()
,
Attributes.Name
,
MANIFEST_SOURCE
public static String getValue(Manifest manifest, Attributes.Name name)
Manifest
in a pragmatic way. It tries to
get
the value from the
main-attributes
. If NOT available it searches all other
available attribute entries
for the value and returns the first one found in
deterministic but unspecified order.manifest
- is the Manifest
where to get the attribute-value from.name
- is the Attributes.Name
of the requested attribute.null
if NOT available.Copyright © 2001–2016 mmm-Team. All rights reserved.