Package org.apache.commons.discovery.jdk
Class JDKHooks
java.lang.Object
org.apache.commons.discovery.jdk.JDKHooks
- Direct Known Subclasses:
JDK11Hooks
,JDK12Hooks
JDK Hooks to extract properties/resources.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
JDKHooks()
Hidden constructor, this class can't be directly instantiated. -
Method Summary
Modifier and TypeMethodDescriptionstatic final JDKHooks
Return singleton object representing JVM hooks/tools.abstract Enumeration
<URL> getResources
(ClassLoader loader, String resourceName) Resolve resource with given names and make them available in the returned iterator.abstract ClassLoader
The system class loader is available for JDK 1.2 or later, if certain security conditions are met.abstract String
getSystemProperty
(String propName) Get the system propertyabstract ClassLoader
The thread context class loader is available for JDK 1.2 or later, if certain security conditions are met.
-
Constructor Details
-
JDKHooks
protected JDKHooks()Hidden constructor, this class can't be directly instantiated.
-
-
Method Details
-
getJDKHooks
Return singleton object representing JVM hooks/tools. TODO: add logic to detect JDK level.- Returns:
- The detected
JDKHooks
-
getSystemProperty
Get the system property- Parameters:
propName
- name of the property- Returns:
- value of the property
-
getThreadContextClassLoader
The thread context class loader is available for JDK 1.2 or later, if certain security conditions are met.- Returns:
- The thread context class loader, if available. Otherwise return null.
-
getSystemClassLoader
The system class loader is available for JDK 1.2 or later, if certain security conditions are met.- Returns:
- The system class loader, if available. Otherwise return null.
-
getResources
public abstract Enumeration<URL> getResources(ClassLoader loader, String resourceName) throws IOException Resolve resource with given names and make them available in the returned iterator.- Parameters:
loader
- The class loader used to resolve resourcesresourceName
- The resource name to resolve- Returns:
- The iterator over the URL resolved resources
- Throws:
IOException
- if any error occurs while loading the resource
-