Enum ClassloaderType

java.lang.Object
java.lang.Enum<ClassloaderType>
clazzfish.monitor.ClassloaderType
All Implemented Interfaces:
Serializable, Comparable<ClassloaderType>, java.lang.constant.Constable

public enum ClassloaderType extends Enum<ClassloaderType>
This enum type can detect if a classloader is a Tomcat, WebLogic or Websphere classloader. Originally it was part of the PatternTesting project.
Author:
oliver
  • Enum Constant Details

    • UNKNOWN

      public static final ClassloaderType UNKNOWN
      Unknown classloader.
    • SUN

      public static final ClassloaderType SUN
      The default classloader of the Sun VM.
    • JDK

      public static final ClassloaderType JDK
      The new classloader of Open-JDK since Java 11.
    • NET

      public static final ClassloaderType NET
      The URLClassLoader where many appserver are based on.
    • TOMCAT

      public static final ClassloaderType TOMCAT
      Tomcat's classloader (till Tomcat 7).
    • TOMCAT8

      public static final ClassloaderType TOMCAT8
      Tomcat-8's classloader.
    • WEBLOGIC

      public static final ClassloaderType WEBLOGIC
      Weblogic's classloader.
    • WEBSPHERE

      public static final ClassloaderType WEBSPHERE
      The Websphere classloader from IBM.
    • SUREFIRE

      public static final ClassloaderType SUREFIRE
      Surefire provides an isolated classloader.
  • Method Details

    • values

      public static ClassloaderType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static ClassloaderType valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • isWeb

      public boolean isWeb()
      Here you can ask if the classloader type is a web classloader or not.
      Returns:
      true for Tomcat or application servers
      Since:
      1.7.2
    • toClassloaderType

      public static ClassloaderType toClassloaderType(ClassLoader cloader)
      Converts the given classloader into the corresponding type.

      We use also the fieldname to match the possible classloader because in some case (e.g. for Tomcat) the classname is not sufficient.

      Parameters:
      cloader - the classloader
      Returns:
      the classpath type
    • getCurrentClassloaderType

      public static ClassloaderType getCurrentClassloaderType()
      Looks, what type of classloader the current thread is using.
      Returns:
      e.g. SUN for the default classloader
      Since:
      1.7.2
    • isSupported

      public static boolean isSupported(String classloaderName)
      Checks if the given classloader is known and therefore supported. We do not use the fieldname to check if the classloader is supported because we do not know if it is really the correct classloader.
      Parameters:
      classloaderName - the classloader name
      Returns:
      true, if is supported
    • getClasspathFrom

      public Object getClasspathFrom(ClassLoader cloader)
      Gets the classpath from.
      Parameters:
      cloader - the cloader
      Returns:
      the classpath from