public class ClassLoaderResourceAccessor extends AbstractResourceAccessor
FileSystemResourceAccessor that builds up the file roots based on the passed ClassLoader.
If you are using a ClassLoader that isn't based on local files, you will need to use a different ResourceAccessor implementation.for OSGi-based classloaders| Modifier and Type | Field and Description |
|---|---|
protected SortedSet<String> |
description |
protected List<FileSystem> |
rootPaths |
| Constructor and Description |
|---|
ClassLoaderResourceAccessor() |
ClassLoaderResourceAccessor(ClassLoader classLoader) |
| Modifier and Type | Method and Description |
|---|---|
SortedSet<String> |
describeLocations()
Returns a description of the places this classloader will look for paths.
|
protected String |
getFinalPath(String relativeTo,
String streamPath) |
protected void |
init()
Performs the configuration of this resourceAccessor.
|
protected boolean |
isDirectory(String path)
Used by
listFromClassLoader(String, boolean, boolean, boolean) to determine if a path is a directory or not. |
SortedSet<String> |
list(String relativeTo,
String path,
boolean recursive,
boolean includeFiles,
boolean includeDirectories)
Returns the path to all resources contained in the given path.
|
protected SortedSet<String> |
listFromClassLoader(String path,
boolean recursive,
boolean includeFiles,
boolean includeDirectories)
Called by
list(String, String, boolean, boolean, boolean) to find files in classLoader. |
protected SortedSet<String> |
listFromRootPaths(String path,
boolean recursive,
boolean includeFiles,
boolean includeDirectories)
Called by
list(String, String, boolean, boolean, boolean) to find files in rootPaths. |
protected void |
loadRootPaths(ClassLoader classLoader)
The classloader search logic in
list(String, String, boolean, boolean, boolean) does not handle jar files well. |
InputStreamList |
openStreams(String relativeTo,
String streamPath)
Return the streams for each resource mapped by the given path.
|
openStreamclone, describe, equals, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, hashCode, set, toStringprotected List<FileSystem> rootPaths
public ClassLoaderResourceAccessor()
public ClassLoaderResourceAccessor(ClassLoader classLoader)
protected void init()
protected void loadRootPaths(ClassLoader classLoader)
list(String, String, boolean, boolean, boolean) does not handle jar files well.
This method is called by that method to populate rootPaths with additional paths to search.public InputStreamList openStreams(String relativeTo, String streamPath) throws IOException
ResourceAccessorInputStreamList since multiple resources can map to the same path, such as "META-INF/MAINFEST.MF".
Remember to close streams when finished with them.relativeTo - Location that streamPath should be found relative to. If null, streamPath is an absolute pathIOException - if there is an error reading an existing path.public SortedSet<String> list(String relativeTo, String path, boolean recursive, boolean includeFiles, boolean includeDirectories) throws IOException
ResourceAccessorResourceAccessor.openStreams(String, String) and return the contents.
Returned paths should normally be root-relative and therefore not be an absolute path, unless there is a good reason to be absolute.relativeTo - Location that streamPath should be found relative to. If null, path is an absolute pathpath - The path to lookup resources in.recursive - Set to true and will return paths to contents in sub directories as well.includeFiles - Set to true and will return paths to files.includeDirectories - Set to true and will return paths to directories.IOException - if there is an error reading an existing root.protected SortedSet<String> listFromRootPaths(String path, boolean recursive, boolean includeFiles, boolean includeDirectories)
list(String, String, boolean, boolean, boolean) to find files in rootPaths.protected SortedSet<String> listFromClassLoader(String path, boolean recursive, boolean includeFiles, boolean includeDirectories)
list(String, String, boolean, boolean, boolean) to find files in classLoader.protected boolean isDirectory(String path)
listFromClassLoader(String, boolean, boolean, boolean) to determine if a path is a directory or not.public SortedSet<String> describeLocations()
ResourceAccessorCopyright © 2020 Liquibase.org. All rights reserved.