Class ResourceClass<T>

  extended by org.apache.commons.discovery.Resource
      extended by org.apache.commons.discovery.ResourceClass<T>
Type Parameters:
T - The SPI type

public class ResourceClass<T>
extends Resource

'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
protected  Class<? extends T> resourceClass
Fields inherited from class org.apache.commons.discovery.Resource
loader, name, resource
Constructor Summary
ResourceClass(Class<S> resourceClass, URL resource)
          Create a new Resource class located by discovery.
ResourceClass(String resourceName, URL resource, ClassLoader loader)
          Create a new Resource class located by discovery.
Method Summary
<S extends T>
          Get the value of resourceClass.
static void setLog(org.apache.commons.logging.Log _log)
          Deprecated. This method is not thread-safe
 String toString()
Methods inherited from class org.apache.commons.discovery.Resource
getClassLoader, getName, getResource, getResourceAsStream, toArray
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


protected Class<? extends T> resourceClass
Constructor Detail


public ResourceClass(Class<S> resourceClass,
                     URL resource)
Create a new Resource class located by discovery.

Type Parameters:
S - Any type extends T
resourceClass - The resource class has to be located
resource - The resource URL has to be located


public ResourceClass(String resourceName,
                     URL resource,
                     ClassLoader loader)
Create a new Resource class located by discovery.

resourceName - The resource class name has to be located
resource - The resource URL has to be located
loader - The class loaders holder
Method Detail


public static void setLog(org.apache.commons.logging.Log _log)
Deprecated. This method is not thread-safe

Sets the Log for this class.

_log - This class Log


public <S extends T> Class<S> 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
value of resourceClass.


public String toString()

toString in class Resource

Copyright © 2002-2011 The Apache Software Foundation. All Rights Reserved.