Package patterntesting.runtime.monitor
Enum ClassloaderType
- java.lang.Object
-
- java.lang.Enum<ClassloaderType>
-
- patterntesting.runtime.monitor.ClassloaderType
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ClassloaderType>
public enum ClassloaderType extends java.lang.Enum<ClassloaderType>
This enum type can detect if a classloader is a Tomcat, WebLogic or Websphere classloader.- Since:
- 1.5 (26.08.2014)
- Author:
- oliver
-
-
Enum Constant Summary
Enum Constants Enum Constant Description JDK
The default classloader of Open JDK (since Java 9).NET
The URLClassLoader where many appserver are based on.SUN
The default classloader of the Sun VM (till Java 8).SUREFIRE
Surefire provides an isolated classloader.TOMCAT
Tomcat's classloader (till Tomcat 7).TOMCAT8
Tomcat-8's classloader.UNKNOWN
Unknown classloader.WEBLOGIC
Weblogic's classloader.WEBSPHERE
The Websphere classloader from IBM.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getClasspathFrom(java.lang.ClassLoader cloader)
Gets the classpath from.static ClassloaderType
getCurrentClassloaderType()
Looks, what type of classloader the current thread is using.static boolean
isSupported(java.lang.String classloaderName)
Checks if the given classloader is known and therefore supported.boolean
isWeb()
Here you can ask if the classloader type is a web classloader or not.static ClassloaderType
toClassloaderType(java.lang.ClassLoader cloader)
Converts the given classloader into the corresponding type.static ClassloaderType
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ClassloaderType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
UNKNOWN
public static final ClassloaderType UNKNOWN
Unknown classloader.
-
SUN
public static final ClassloaderType SUN
The default classloader of the Sun VM (till Java 8).
-
JDK
public static final ClassloaderType JDK
The default classloader of Open JDK (since Java 9).
-
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 Detail
-
values
public static ClassloaderType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ClassloaderType c : ClassloaderType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ClassloaderType valueOf(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.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(java.lang.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(java.lang.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 java.lang.Object getClasspathFrom(java.lang.ClassLoader cloader)
Gets the classpath from.- Parameters:
cloader
- the cloader- Returns:
- the classpath from
-
-