Package liquibase.integration.spring
Class SpringResourceAccessor
java.lang.Object
liquibase.AbstractExtensibleObject
liquibase.resource.AbstractResourceAccessor
liquibase.integration.spring.SpringResourceAccessor
- All Implemented Interfaces:
AutoCloseable
,Cloneable
,ExtensibleObject
,ResourceAccessor
-
Nested Class Summary
Nested classes/interfaces inherited from interface liquibase.resource.ResourceAccessor
ResourceAccessor.NotFoundResource, ResourceAccessor.SearchOptions
-
Constructor Summary
ConstructorDescriptionSpringResourceAccessor
(org.springframework.core.io.ResourceLoader resourceLoader) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Returns a description of the places this classloader will look for paths.protected String
finalizeSearchPath
(String searchPath) Ensure the given searchPath is a valid searchPath.Returns allResource
s at the given path.protected String
getCompletePath
(String relativeTo, String path) Returns the complete path to the resource, taking the relative path into accountprotected org.springframework.core.io.Resource
getResource
(String resourcePath) Looks up the given resource.protected String
getResourcePath
(org.springframework.core.io.Resource resource) Returns the lookup path to the given resource.protected boolean
resourceIsFile
(org.springframework.core.io.Resource resource) Return true if the given resource is a standard file.Returns the path to all resources contained in the given path.Methods inherited from class liquibase.AbstractExtensibleObject
clone, describe, equals, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, hashCode, set, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface liquibase.resource.ResourceAccessor
get, getExisting, handleDuplicateFileModeLogging, list, openStream, openStreams, search
-
Constructor Details
-
SpringResourceAccessor
public SpringResourceAccessor(org.springframework.core.io.ResourceLoader resourceLoader)
-
-
Method Details
-
close
- Throws:
Exception
-
getAll
Description copied from interface:ResourceAccessor
Returns allResource
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 asCompositeResourceAccessor
orClassLoaderResourceAccessor
) 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 setGlobalConfiguration.DUPLICATE_FILE_MODE
to pick the "best" file which is defined as "the first file from this function".- Returns:
- null if no resources match the path
- Throws:
IOException
- if there is an unexpected error determining what is at the path
-
search
Description copied from interface:ResourceAccessor
Returns the path to all resources contained in the given path. Multiple resources may be returned with the same path, but only if they are actually unique files. Order is important to pay attention to, they should be returned in a user-expected manner based on this resource accessor.
Should return an empty list if:- Path does not exist
- Path is null
- Path is not a "directory"
- Path exists but cannot be read from
- Parameters:
searchPath
- The path to lookup resources in.recursive
- Set to true and will return paths to contents in subdirectories as well.- Returns:
- empty set if nothing was found
- Throws:
IOException
- if there is an error searching the system.
-
describeLocations
Description copied from interface:ResourceAccessor
Returns a description of the places this classloader will look for paths. Used in error messages and other troubleshooting cases. -
getResourcePath
Returns the lookup path to the given resource. -
getCompletePath
Returns the complete path to the resource, taking the relative path into account- Throws:
IOException
-
getResource
Looks up the given resource. -
resourceIsFile
Return true if the given resource is a standard file. Return false if it is a directory.- Throws:
IOException
-
finalizeSearchPath
Ensure the given searchPath is a valid searchPath. Default implementation adds "classpath:" and removes duplicated /'s and classpath:'s
-