Class VFS

java.lang.Object
org.apache.ibatis.io.VFS
Direct Known Subclasses:
DefaultVFS, JBoss6VFS

public abstract class VFS extends Object
Provides a very simple API for accessing resources within an application server.
Author:
Ben Gunter
  • Constructor Summary

    Constructors
    Constructor
    Description
    VFS()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addImplClass(Class<? extends VFS> clazz)
    Adds the specified class to the list of VFS implementations.
    protected static Class<?>
    getClass(String className)
    Get a class by name.
    static VFS
    Get the singleton VFS instance.
    protected static Method
    getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes)
    Get a method by name and parameter types.
    protected static List<URL>
    Get a list of URLs from the context classloader for all the resources found at the specified path.
    protected static <T> T
    invoke(Method method, Object object, Object... parameters)
    Invoke a method on an object and return whatever it returns.
    abstract boolean
    Return true if the VFS implementation is valid for the current environment.
    list(String path)
    Recursively list the full resource path of all the resources that are children of all the resources found at the specified path.
    protected abstract List<String>
    list(URL url, String forPath)
    Recursively list the full resource path of all the resources that are children of the resource identified by a URL.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VFS

      public VFS()
  • Method Details

    • getInstance

      public static VFS getInstance()
      Get the singleton VFS instance. If no VFS implementation can be found for the current environment, then this method returns null.
      Returns:
      single instance of VFS
    • addImplClass

      public static void addImplClass(Class<? extends VFS> clazz)
      Adds the specified class to the list of VFS implementations. Classes added in this manner are tried in the order they are added and before any of the built-in implementations.
      Parameters:
      clazz - The VFS implementation class to add.
    • getClass

      protected static Class<?> getClass(String className)
      Get a class by name. If the class is not found then return null.
      Parameters:
      className - the class name
      Returns:
      the class
    • getMethod

      protected static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes)
      Get a method by name and parameter types. If the method is not found then return null.
      Parameters:
      clazz - The class to which the method belongs.
      methodName - The name of the method.
      parameterTypes - The types of the parameters accepted by the method.
      Returns:
      the method
    • invoke

      protected static <T> T invoke(Method method, Object object, Object... parameters) throws IOException, RuntimeException
      Invoke a method on an object and return whatever it returns.
      Type Parameters:
      T - the generic type
      Parameters:
      method - The method to invoke.
      object - The instance or class (for static methods) on which to invoke the method.
      parameters - The parameters to pass to the method.
      Returns:
      Whatever the method returns.
      Throws:
      IOException - If I/O errors occur
      RuntimeException - If anything else goes wrong
    • getResources

      protected static List<URL> getResources(String path) throws IOException
      Get a list of URLs from the context classloader for all the resources found at the specified path.
      Parameters:
      path - The resource path.
      Returns:
      A list of URLs, as returned by ClassLoader.getResources(String).
      Throws:
      IOException - If I/O errors occur
    • isValid

      public abstract boolean isValid()
      Return true if the VFS implementation is valid for the current environment.
      Returns:
      true, if is valid
    • list

      protected abstract List<String> list(URL url, String forPath) throws IOException
      Recursively list the full resource path of all the resources that are children of the resource identified by a URL.
      Parameters:
      url - The URL that identifies the resource to list.
      forPath - The path to the resource that is identified by the URL. Generally, this is the value passed to getResources(String) to get the resource URL.
      Returns:
      A list containing the names of the child resources.
      Throws:
      IOException - If I/O errors occur
    • list

      public List<String> list(String path) throws IOException
      Recursively list the full resource path of all the resources that are children of all the resources found at the specified path.
      Parameters:
      path - The path of the resource(s) to list.
      Returns:
      A list containing the names of the child resources.
      Throws:
      IOException - If I/O errors occur