Package com.okta.commons.lang
Class Classes
java.lang.Object
com.okta.commons.lang.Classes
- Since:
- 0.5.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Class<T> Attempts to load the specified class name from the current thread'scontext class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order.static <T> Constructor<T> getConstructor(Class<T> clazz, Class... argTypes) static InputStreamgetResourceAsStream(String name) Returns the specified resource by checking the current thread'scontext class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order, usinggetResourceAsStream(name).static <T> Tinstantiate(Constructor<T> ctor, Object... args) static booleanisAvailable(String fullyQualifiedClassName) static <T> TloadFromService(Class<T> clazz) static <T> TloadFromService(Class<T> clazz, String errorMessage) static <T> TnewInstance(Class<T> clazz) static <T> TnewInstance(Class<T> clazz, Object... args) static <T> TnewInstance(String fqcn) static <T> TnewInstance(String fqcn, Object... args)
-
Constructor Details
-
Classes
public Classes()
-
-
Method Details
-
forName
Attempts to load the specified class name from the current thread'scontext class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order. If any of them cannot locate the specified class, anUnknownClassExceptionis thrown (our RuntimeException equivalent of the JRE'sClassNotFoundException.- Type Parameters:
T- type of class- Parameters:
fqcn- the fully qualified class name to load- Returns:
- the located class
- Throws:
UnknownClassException- if the class cannot be found.
-
getResourceAsStream
Returns the specified resource by checking the current thread'scontext class loader, then the current ClassLoader (Classes.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order, usinggetResourceAsStream(name).- Parameters:
name- the name of the resource to acquire from the classloader(s).- Returns:
- the InputStream of the resource found, or
nullif the resource cannot be found from any of the three mentioned ClassLoaders.
-
isAvailable
-
newInstance
-
newInstance
-
newInstance
-
newInstance
-
getConstructor
-
instantiate
-
loadFromService
-
loadFromService
-