The {@link oaj.microservice.Microservice.Builder#manifest(Object)} method can be used to specify the contents or location of of the main
manifest file of the executable jar.
If you do not specify the location/contents of the manifest file, the microservice will attempt to resolve it through the following methods:
-
Looking on the file system for a file at "META-INF/MANIFEST.MF".
This is primarily to allow for running microservices from within eclipse workspaces where the manifest file
is located in the project root.
-
Using the class loader for this class to find the file at the URL "META-INF/MANIFEST.MF".
If you do manually specify the manifest file, you can pass in any of the following types:
- {@link oaj.utils.ManifestFile} - A pre-parsed manifest file.
- {@link java.util.jar.Manifest} - A pre-parsed manifest file.
- {@link java.io.Reader} - Containing the raw contents of the manifest.
- {@link java.io.InputStream} - Containing the raw contents of the manifest.
- {@link java.io.File} - File containing the raw contents of the manifest.
- {@link java.lang.String} - Path to file containing the raw contents of the manifest.
- {@link java.lang.Class} - Finds and loads the manifest file of the jar file that the specified class is contained within.
The manifest file can be retrieved using the the {@link oaj.microservice.Microservice#getManifest()} method which
provides an API for accessing manifest file entries.
This method returns an instance of {@link oaj.utils.ManifestFile} which extends from {@link oaj.collections.JsonMap} allowing
you to retrieve entries as any data types supported by that class.
| ManifestFile manifestFile = Microservice.getInstance().getManifest();
|
| String mainClass = manifestFile.getString("Main-Class");
| int myInt = manifestFile.getInt("My-Int", 123);
| boolean myBoolean = manifestFile.getBoolean("My-Boolean");
The manifest is also used for the {@link oaj.svl.vars.ManifestFileVar $MF} SVL variable.
| // $MF used in variable resolver.
| VarResolver var = Microservice.getInstance().getVarResolver();
| System.out.println(vr.resolve("The main class is $MF{Main-Class}"));
| // $MF used in annotation.
| @Rest(
| title="$MF{Application-Title}",
| ...
| )