Package org.apache.ibatis.io
Class VFS
- java.lang.Object
-
- org.apache.ibatis.io.VFS
-
- Direct Known Subclasses:
DefaultVFS
,JBoss6VFS
public abstract class VFS extends java.lang.Object
Provides a very simple API for accessing resources within an application server.- Author:
- Ben Gunter
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Class<?>[]
IMPLEMENTATIONS
The built-in implementations.static java.util.List<java.lang.Class<? extends VFS>>
USER_IMPLEMENTATIONS
The list to which implementations are added byaddImplClass(Class)
.
-
Constructor Summary
Constructors Constructor Description VFS()
-
Method Summary
Modifier and Type Method Description static void
addImplClass(java.lang.Class<? extends VFS> clazz)
Adds the specified class to the list ofVFS
implementations.protected static java.lang.Class<?>
getClass(java.lang.String className)
Get a class by name.static VFS
getInstance()
Get the singletonVFS
instance.protected static java.lang.reflect.Method
getMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>... parameterTypes)
Get a method by name and parameter types.protected static java.util.List<java.net.URL>
getResources(java.lang.String path)
Get a list ofURL
s from the context classloader for all the resources found at the specified path.protected static <T> T
invoke(java.lang.reflect.Method method, java.lang.Object object, java.lang.Object... parameters)
Invoke a method on an object and return whatever it returns.abstract boolean
isValid()
Return true if theVFS
implementation is valid for the current environment.java.util.List<java.lang.String>
list(java.lang.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 java.util.List<java.lang.String>
list(java.net.URL url, java.lang.String forPath)
Recursively list the full resource path of all the resources that are children of the resource identified by a URL.
-
-
-
Field Detail
-
IMPLEMENTATIONS
public static final java.lang.Class<?>[] IMPLEMENTATIONS
The built-in implementations.
-
USER_IMPLEMENTATIONS
public static final java.util.List<java.lang.Class<? extends VFS>> USER_IMPLEMENTATIONS
The list to which implementations are added byaddImplClass(Class)
.
-
-
Method Detail
-
getInstance
public static VFS getInstance()
-
addImplClass
public static void addImplClass(java.lang.Class<? extends VFS> clazz)
Adds the specified class to the list ofVFS
implementations. Classes added in this manner are tried in the order they are added and before any of the built-in implementations.- Parameters:
clazz
- TheVFS
implementation class to add.
-
getClass
protected static java.lang.Class<?> getClass(java.lang.String className)
Get a class by name. If the class is not found then return null.
-
getMethod
protected static java.lang.reflect.Method getMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.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.
-
invoke
protected static <T> T invoke(java.lang.reflect.Method method, java.lang.Object object, java.lang.Object... parameters) throws java.io.IOException, java.lang.RuntimeException
Invoke a method on an object and return whatever it returns.- 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:
java.io.IOException
- If I/O errors occurjava.lang.RuntimeException
- If anything else goes wrong
-
getResources
protected static java.util.List<java.net.URL> getResources(java.lang.String path) throws java.io.IOException
Get a list ofURL
s from the context classloader for all the resources found at the specified path.- Parameters:
path
- The resource path.- Returns:
- A list of
URL
s, as returned byClassLoader.getResources(String)
. - Throws:
java.io.IOException
- If I/O errors occur
-
isValid
public abstract boolean isValid()
Return true if theVFS
implementation is valid for the current environment.
-
list
protected abstract java.util.List<java.lang.String> list(java.net.URL url, java.lang.String forPath) throws java.io.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 togetResources(String)
to get the resource URL.- Returns:
- A list containing the names of the child resources.
- Throws:
java.io.IOException
- If I/O errors occur
-
list
public java.util.List<java.lang.String> list(java.lang.String path) throws java.io.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:
java.io.IOException
- If I/O errors occur
-
-