public class ClassLoaderResourceAccessor extends AbstractResourceAccessor
DirectoryResourceAccessor
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
ResourceAccessor.NotFoundResource
Modifier and Type | Field and Description |
---|---|
protected SortedSet<String> |
description |
Constructor and Description |
---|
ClassLoaderResourceAccessor() |
ClassLoaderResourceAccessor(ClassLoader classLoader) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
configureAdditionalResourceAccessors(ClassLoader classLoader)
The classloader search logic in
search(String, boolean) does not handle jar files well. |
List<String> |
describeLocations()
Returns a description of the places this classloader will look for paths.
|
List<Resource> |
getAll(String path)
Returns all
Resource s at the given path. |
protected void |
init()
Performs the configuration of this resourceAccessor.
|
List<Resource> |
search(String path,
boolean recursive)
Returns the path to all resources contained in the given path.
|
clone, describe, equals, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, hashCode, set, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
get, getExisting, list, openStream, openStreams
public ClassLoaderResourceAccessor()
public ClassLoaderResourceAccessor(ClassLoader classLoader)
public List<String> describeLocations()
ResourceAccessor
protected void init()
protected void configureAdditionalResourceAccessors(ClassLoader classLoader)
search(String, boolean)
does not handle jar files well.
This method is called by that method to configure an internal ResourceAccessor
with paths to search.public List<Resource> search(String path, boolean recursive) throws IOException
ResourceAccessor
path
- The path to lookup resources in.recursive
- Set to true and will return paths to contents in subdirectories as well.IOException
- if there is an error searching the system.public List<Resource> getAll(String path) throws IOException
ResourceAccessor
Resource
s at the given path.
For many resource accessors (such as a file system), only one resource can exist at a given spot,
but some accessors (such as CompositeResourceAccessor
or ClassLoaderResourceAccessor
) can have multiple resources for a single path.
If the resourceAccessor returns multiple values, the returned List should be considered sorted for that resource accessor.
For example, ClassLoaderResourceAccessor
returns them in order based on the configured classloader.
Order is important to pay attention to, because users may set GlobalConfiguration.DUPLICATE_FILE_MODE
to pick the "best" file which is defined as
"the first file from this function".
IOException
- if there is an unexpected error determining what is at the pathCopyright © 2023 Liquibase.org. All rights reserved.