Enum ClassloaderType
- All Implemented Interfaces:
Serializable
,Comparable<ClassloaderType>
,java.lang.constant.Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe new classloader of Open-JDK since Java 11.The URLClassLoader where many appserver are based on.The default classloader of the Sun VM.Surefire provides an isolated classloader.Tomcat's classloader (till Tomcat 7).Tomcat-8's classloader.Unknown classloader.Weblogic's classloader.The Websphere classloader from IBM. -
Method Summary
Modifier and TypeMethodDescriptiongetClasspathFrom
(ClassLoader cloader) Gets the classpath from.static ClassloaderType
Looks, what type of classloader the current thread is using.static boolean
isSupported
(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
(ClassLoader cloader) Converts the given classloader into the corresponding type.static ClassloaderType
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 Details
-
UNKNOWN
Unknown classloader. -
SUN
The default classloader of the Sun VM. -
JDK
The new classloader of Open-JDK since Java 11. -
NET
The URLClassLoader where many appserver are based on. -
TOMCAT
Tomcat's classloader (till Tomcat 7). -
TOMCAT8
Tomcat-8's classloader. -
WEBLOGIC
Weblogic's classloader. -
WEBSPHERE
The Websphere classloader from IBM. -
SUREFIRE
Surefire provides an isolated classloader.
-
-
Method Details
-
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
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 nameNullPointerException
- 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
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
Looks, what type of classloader the current thread is using.- Returns:
- e.g.
SUN
for the default classloader - Since:
- 1.7.2
-
isSupported
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
Gets the classpath from.- Parameters:
cloader
- the cloader- Returns:
- the classpath from
-