Class ResourceClass<T>

java.lang.Object
org.apache.commons.discovery.Resource
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 Details

  • Constructor Details

    • ResourceClass

      public ResourceClass(Class<S> resourceClass, URL resource)
      Create a new Resource class located by discovery.
      Type Parameters:
      S - Any type extends T
      Parameters:
      resourceClass - The resource class has to be located
      resource - The resource URL has to be located
    • ResourceClass

      public ResourceClass(String resourceName, URL resource, ClassLoader loader)
      Create a new Resource class located by discovery.
      Parameters:
      resourceName - The resource class name has to be located
      resource - The resource URL has to be located
      loader - The class loaders holder
  • Method Details

    • setLog

      @Deprecated public static void setLog(org.apache.commons.logging.Log _log)
      Deprecated.
      This method is not thread-safe
      Sets the Log for this class.
      Parameters:
      _log - This class Log
    • loadClass

      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
      Returns:
      value of resourceClass.
    • toString

      public String toString()
      Overrides:
      toString in class Resource