Class VersionInfo

java.lang.Object
org.craftercms.commons.monitoring.VersionInfo
Direct Known Subclasses:
SysInfo

public class VersionInfo extends Object
Get's current version information about: 1. Build Information from a given manifest file. 2. Name and version from a given manifest file.
Since:
3.0
Author:
Carlos Ortiz
  • Field Details

    • KEY_BUILD_ON

      public static final String KEY_BUILD_ON
      Manifest key for the date in ms when the package was build.
      See Also:
    • KEY_IMPLEMENTATION_TITLE

      public static final String KEY_IMPLEMENTATION_TITLE
      Manifest key for name of the Lib/app in the jar (usually maven name tag value).
      See Also:
    • KEY_IMPLEMENTATION_VERSION

      public static final String KEY_IMPLEMENTATION_VERSION
      Manifest key for VersionInfo of the code (usually matches Mvn packageVersion)
      See Also:
    • KEY_IMPLEMENTATION_BUILD

      public static final String KEY_IMPLEMENTATION_BUILD
      Manifest key for codebase packageVersion (usually git hash or svn id).
      See Also:
    • MANIFEST_PATH

      public static final String MANIFEST_PATH
      Manifest Default Path
      See Also:
    • WAR_PATH

      public static final String WAR_PATH
      The path for classes loaded from a WAR file
      See Also:
    • SPRING_PATH

      public static final String SPRING_PATH
      The path for classes loaded from a Spring Boot JAR file
      See Also:
  • Constructor Details

    • VersionInfo

      protected VersionInfo(Manifest manifest)
  • Method Details

    • getVersion

      public static VersionInfo getVersion(Manifest manifest)
      Gets the current VersionInfo based on Manifest & current JVM information.
      Parameters:
      manifest - Manifest were to get the information.
      Returns:
      A VersionInfo pojo with information.
    • getVersion

      public static VersionInfo getVersion(Class<?> clazz) throws IOException
      Gets the current VersionInfo base on a Class that will load it's manifest file.
      Parameters:
      clazz - Class that will load the manifest MF file
      Returns:
      A VersionInfo pojo with the information.
      Throws:
      IOException - If Unable to read the Manifest file.
    • findManifest

      protected static Manifest findManifest(Class<?> clazz) throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getPackageName

      public String getPackageName()
    • getPackageVersion

      public String getPackageVersion()
    • getPackageBuild

      public String getPackageBuild()
    • getPackageBuildDate

      public String getPackageBuildDate()