Package org.apache.commons.discovery
Class ResourceClass<T>
java.lang.Object
org.apache.commons.discovery.Resource
org.apache.commons.discovery.ResourceClass<T>
- Type Parameters:
T
- The SPI type
'Resource' located by discovery.
Naming of methods becomes a real pain ('getClass()')
so I've patterned this after ClassLoader...
I think it works well as it will give users a point-of-reference.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionResourceClass
(Class<S> resourceClass, URL resource) Create a newResource
class located by discovery.ResourceClass
(String resourceName, URL resource, ClassLoader loader) Create a newResource
class located by discovery. -
Method Summary
Methods inherited from class org.apache.commons.discovery.Resource
getClassLoader, getName, getResource, getResourceAsStream, toArray
-
Field Details
-
resourceClass
-
-
Constructor Details
-
ResourceClass
Create a newResource
class located by discovery.- Type Parameters:
S
- Any type extends T- Parameters:
resourceClass
- The resource class has to be locatedresource
- The resource URL has to be located
-
ResourceClass
Create a newResource
class located by discovery.- Parameters:
resourceName
- The resource class name has to be locatedresource
- The resource URL has to be locatedloader
- The class loaders holder
-
-
Method Details
-
setLog
Deprecated.This method is not thread-safeSets theLog
for this class.- Parameters:
_log
- This classLog
-
loadClass
Get the value of resourceClass. Loading the class does NOT guarentee that the class can be instantiated. Go figure. The class can be instantiated when the class is linked/resolved, and all dependencies are resolved. Various JDKs do this at different times, so beware: java.lang.NoClassDefFoundError when calling Class.getDeclaredMethod() (JDK14), java.lang.reflect.InvocationTargetException (wrapping java.lang.NoClassDefFoundError) when calling java.lang.newInstance (JDK13), and who knows what else..- Type Parameters:
S
- Any type extends T- Returns:
- value of resourceClass.
-
toString
-