Package org.apache.ibatis.io
Class DefaultVFS
java.lang.Object
org.apache.ibatis.io.VFS
org.apache.ibatis.io.DefaultVFS
A default implementation of
VFS
that works for most application servers.- Author:
- Ben Gunter
-
Field Summary
Fields inherited from class org.apache.ibatis.io.VFS
IMPLEMENTATIONS, USER_IMPLEMENTATIONS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected URL
findJarForResource
(URL url) Attempts to deconstruct the given URL to find a JAR file containing the resource referenced by the URL.protected String
getPackagePath
(String packageName) Converts a Java package name to a path that can be looked up with a call toClassLoader.getResources(String)
.protected boolean
Returns true if the resource located at the given URL is a JAR file.protected boolean
Returns true if the resource located at the given URL is a JAR file.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 the resource identified by a URL.listResources
(JarInputStream jar, String path) List the names of the entries in the givenJarInputStream
that begin with the specifiedpath
.Methods inherited from class org.apache.ibatis.io.VFS
addImplClass, getClass, getInstance, getMethod, getResources, invoke, list
-
Constructor Details
-
DefaultVFS
public DefaultVFS()
-
-
Method Details
-
isValid
public boolean isValid()Description copied from class:VFS
Return true if theVFS
implementation is valid for the current environment. -
list
Description copied from class:VFS
Recursively list the full resource path of all the resources that are children of the resource identified by a URL.- Specified by:
list
in classVFS
- Parameters:
url
- The URL that identifies the resource to list.path
- The path to the resource that is identified by the URL. Generally, this is the value passed toVFS.getResources(String)
to get the resource URL.- Returns:
- A list containing the names of the child resources.
- Throws:
IOException
- If I/O errors occur
-
listResources
List the names of the entries in the givenJarInputStream
that begin with the specifiedpath
. Entries will match with or without a leading slash.- Parameters:
jar
- The JAR input streampath
- The leading path to match- Returns:
- The names of all the matching entries
- Throws:
IOException
- If I/O errors occur
-
findJarForResource
Attempts to deconstruct the given URL to find a JAR file containing the resource referenced by the URL. That is, assuming the URL references a JAR entry, this method will return a URL that references the JAR file containing the entry. If the JAR cannot be located, then this method returns null.- Parameters:
url
- The URL of the JAR entry.- Returns:
- The URL of the JAR file, if one is found. Null if not.
- Throws:
MalformedURLException
- the malformed URL exception
-
getPackagePath
Converts a Java package name to a path that can be looked up with a call toClassLoader.getResources(String)
.- Parameters:
packageName
- The Java package name to convert to a path- Returns:
- the package path
-
isJar
Returns true if the resource located at the given URL is a JAR file.- Parameters:
url
- The URL of the resource to test.- Returns:
- true, if is jar
-
isJar
Returns true if the resource located at the given URL is a JAR file.- Parameters:
url
- The URL of the resource to test.buffer
- A buffer into which the first few bytes of the resource are read. The buffer must be at least the size ofJAR_MAGIC
. (The same buffer may be reused for multiple calls as an optimization.)- Returns:
- true, if is jar
-