Package org.apache.ibatis.migration.io
Class VFS
java.lang.Object
org.apache.ibatis.migration.io.VFS
- Direct Known Subclasses:
DefaultVFS
,JBoss6VFS
Provides a very simple API for accessing resources within an application server.
- Author:
- Ben Gunter
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Class<?>[]
The built-in implementations.The list to which implementations are added byaddImplClass(Class)
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addImplClass
(Class<? extends VFS> clazz) Adds the specified class to the list ofVFS
implementations.protected static Class
<?> Get a class by name.static VFS
Get the singletonVFS
instance.protected static Method
Get a method by name and parameter types.getResources
(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 a method on an object and return whatever it returns.abstract boolean
isValid()
Return true if theVFS
implementation is valid for the current environment.Recursively list the full resource path of all the resources that are children of all the resources found at the specified path.Recursively list the full resource path of all the resources that are children of the resource identified by a URL.
-
Field Details
-
IMPLEMENTATIONS
The built-in implementations. -
USER_IMPLEMENTATIONS
The list to which implementations are added byaddImplClass(Class)
.
-
-
Constructor Details
-
VFS
public VFS()
-
-
Method Details
-
getInstance
-
addImplClass
-
getClass
-
getMethod
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 occurRuntimeException
- If anything else goes wrong
-
getResources
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:
IOException
- If I/O errors occur
-
isValid
public abstract boolean isValid()Return true if theVFS
implementation is valid for the current environment.- Returns:
- true, if is valid
-
list
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:
IOException
- If I/O errors occur
-
list
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
-