Class AprLifecycleListener

  • All Implemented Interfaces:
    LifecycleListener

    public class AprLifecycleListener
    extends java.lang.Object
    implements LifecycleListener
    Implementation of LifecycleListener that will init and destroy APR.

    This listener must only be nested within Server elements.

    Only one instance of the APR/Native library may be loaded per JVM. Loading multiple instances will trigger a JVM crash - typically when the Connectors are destroyed. This listener utilises reference counting to ensure that only one instance of the APR/Native library is loaded at any one time.

    If multiple listener configurations are found, only the first one initialised will be used.

    Since:
    4.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String FIPSMode
      FIPS mode configuration.
      protected static boolean fipsModeActive
      Indicates whether FIPS mode is currently active.
      protected static StringManager sm
      The string manager for this package.
      protected static java.lang.String SSLEngine
      SSL engine configuration.
      protected static boolean sslInitialized
      Indicates whether SSL has been initialized.
      protected static java.lang.String SSLRandomSeed
      SSL random seed source.
      protected static int TCN_RECOMMENDED_MAJOR
      Recommended major version of Tomcat Native.
      protected static int TCN_RECOMMENDED_MINOR
      Recommended minor version of Tomcat Native.
      protected static int TCN_RECOMMENDED_PV
      Recommended patch version of Tomcat Native.
      protected static int TCN_REQUIRED_MAJOR
      Required major version of Tomcat Native.
      protected static int TCN_REQUIRED_MINOR
      Required minor version of Tomcat Native.
      protected static int TCN_REQUIRED_PATCH
      Required patch version of Tomcat Native.
    • Constructor Summary

      Constructors 
      Constructor Description
      AprLifecycleListener()
      Constructs a new AprLifecycleListener.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getFIPSMode()
      Returns the FIPS mode configuration.
      static java.lang.String getInstalledAprVersion()
      Get the installed APR version string, if available.
      static java.lang.String getInstalledOpenSslVersion()
      Get the installed OpenSSL version string (via APR), if available.
      static java.lang.String getInstalledTcnVersion()
      Get the installed Tomcat Native version string, if available.
      java.lang.String getSSLEngine()
      Returns the SSL engine configuration.
      java.lang.String getSSLRandomSeed()
      Returns the SSL random seed source.
      static java.lang.String getTcnVersionWarning()
      Get a warning message if the installed Tomcat Native version is older than recommended.
      static boolean getUseOpenSSL()
      Returns whether OpenSSL is in use.
      static boolean isAprAvailable()
      Checks APR availability, initializing if necessary.
      boolean isFIPSModeActive()
      Returns whether FIPS mode is currently active.
      static boolean isInstanceCreated()
      Returns whether an APR instance has been created.
      void lifecycleEvent​(LifecycleEvent event)
      Primary entry point for startup and shutdown events.
      void setFIPSMode​(java.lang.String FIPSMode)
      Sets the FIPS mode configuration.
      void setSSLEngine​(java.lang.String SSLEngine)
      Sets the SSL engine configuration.
      void setSSLRandomSeed​(java.lang.String SSLRandomSeed)
      Sets the SSL random seed source.
      void setUseOpenSSL​(boolean useOpenSSL)
      Configures whether to use OpenSSL.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sm

        protected static final StringManager sm
        The string manager for this package.
      • TCN_REQUIRED_MAJOR

        protected static final int TCN_REQUIRED_MAJOR
        Required major version of Tomcat Native.
        See Also:
        Constant Field Values
      • TCN_REQUIRED_MINOR

        protected static final int TCN_REQUIRED_MINOR
        Required minor version of Tomcat Native.
        See Also:
        Constant Field Values
      • TCN_REQUIRED_PATCH

        protected static final int TCN_REQUIRED_PATCH
        Required patch version of Tomcat Native.
        See Also:
        Constant Field Values
      • TCN_RECOMMENDED_MAJOR

        protected static final int TCN_RECOMMENDED_MAJOR
        Recommended major version of Tomcat Native.
        See Also:
        Constant Field Values
      • TCN_RECOMMENDED_MINOR

        protected static final int TCN_RECOMMENDED_MINOR
        Recommended minor version of Tomcat Native.
        See Also:
        Constant Field Values
      • TCN_RECOMMENDED_PV

        protected static final int TCN_RECOMMENDED_PV
        Recommended patch version of Tomcat Native.
        See Also:
        Constant Field Values
      • SSLEngine

        protected static java.lang.String SSLEngine
        SSL engine configuration.
      • FIPSMode

        protected static java.lang.String FIPSMode
        FIPS mode configuration.
      • SSLRandomSeed

        protected static java.lang.String SSLRandomSeed
        SSL random seed source.
      • sslInitialized

        protected static boolean sslInitialized
        Indicates whether SSL has been initialized.
      • fipsModeActive

        protected static boolean fipsModeActive
        Indicates whether FIPS mode is currently active.
    • Constructor Detail

      • AprLifecycleListener

        public AprLifecycleListener()
        Constructs a new AprLifecycleListener.
    • Method Detail

      • isAprAvailable

        public static boolean isAprAvailable()
        Checks APR availability, initializing if necessary.
        Returns:
        true if APR is available
      • getInstalledTcnVersion

        public static java.lang.String getInstalledTcnVersion()
        Get the installed Tomcat Native version string, if available.
        Returns:
        the version string, or null if APR is not available
      • getInstalledAprVersion

        public static java.lang.String getInstalledAprVersion()
        Get the installed APR version string, if available.
        Returns:
        the APR version string, or null if APR is not available
      • getInstalledOpenSslVersion

        public static java.lang.String getInstalledOpenSslVersion()
        Get the installed OpenSSL version string (via APR), if available.
        Returns:
        the OpenSSL version string, or null if not available
      • getTcnVersionWarning

        public static java.lang.String getTcnVersionWarning()
        Get a warning message if the installed Tomcat Native version is older than recommended. This performs the same version check used during Tomcat startup.
        Returns:
        a warning message if the installed version is outdated, or null if the version is acceptable or APR is not available
      • lifecycleEvent

        public void lifecycleEvent​(LifecycleEvent event)
        Primary entry point for startup and shutdown events.
        Specified by:
        lifecycleEvent in interface LifecycleListener
        Parameters:
        event - The event that has occurred
      • getSSLEngine

        public java.lang.String getSSLEngine()
        Returns the SSL engine configuration.
        Returns:
        the SSL engine configuration
      • setSSLEngine

        public void setSSLEngine​(java.lang.String SSLEngine)
        Sets the SSL engine configuration.
        Parameters:
        SSLEngine - the SSL engine configuration
      • getSSLRandomSeed

        public java.lang.String getSSLRandomSeed()
        Returns the SSL random seed source.
        Returns:
        the SSL random seed source
      • setSSLRandomSeed

        public void setSSLRandomSeed​(java.lang.String SSLRandomSeed)
        Sets the SSL random seed source.
        Parameters:
        SSLRandomSeed - the SSL random seed source
      • getFIPSMode

        public java.lang.String getFIPSMode()
        Returns the FIPS mode configuration.
        Returns:
        the FIPS mode configuration
      • setFIPSMode

        public void setFIPSMode​(java.lang.String FIPSMode)
        Sets the FIPS mode configuration.
        Parameters:
        FIPSMode - the FIPS mode configuration
      • isFIPSModeActive

        public boolean isFIPSModeActive()
        Returns whether FIPS mode is currently active.
        Returns:
        true if FIPS mode is active
      • setUseOpenSSL

        public void setUseOpenSSL​(boolean useOpenSSL)
        Configures whether to use OpenSSL.
        Parameters:
        useOpenSSL - true to use OpenSSL
      • getUseOpenSSL

        public static boolean getUseOpenSSL()
        Returns whether OpenSSL is in use.
        Returns:
        true if OpenSSL is in use
      • isInstanceCreated

        public static boolean isInstanceCreated()
        Returns whether an APR instance has been created.
        Returns:
        true if an APR instance has been created