Top Fields Constructors Methods
liquibase.integration.spring

public Class SpringResourceAccessor

extends AbstractResourceAccessor
Class Inheritance
Imports
liquibase.Scope, liquibase.exception.UnexpectedLiquibaseException, liquibase.resource.AbstractResourceAccessor, org.springframework.core.io.*, org.springframework.core.io.support.ResourcePatternUtils, org.springframework.util.StringUtils, java.io.IOException, .UnsupportedEncodingException, java.lang.UnsupportedOperationException, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .List

Field Summary

Modifier and TypeField and Description
private final DefaultResourceLoader
private final ResourceLoader

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

private String
decodeUrl(Resource resource, String url)

public List<String>
describeLocations()

Implements liquibase.resource.ResourceAccessor.describeLocations.

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.

public List<Resource>
getAll(String path)

Implements liquibase.resource.ResourceAccessor.getAll.

Returns all Resources at the given path.

protected String
getCompletePath(String relativeTo, String path)

Returns the complete path to the resource, taking the relative path into account

protected Resource
getResource(String resourcePath)

Looks up the given resource.

protected String
getResourcePath(Resource resource)

Returns the lookup path to the given resource.

protected boolean
resourceIsFile(Resource resource)

Return true if the given resource is a standard file.

public List<Resource>
search(String
The path to lookup resources in.
searchPath
,
boolean
Set to true and will return paths to contents in subdirectories as well.
recursive
)

Implements liquibase.resource.ResourceAccessor.search.

Returns the path to all resources contained in the given path.

Field Detail

fallbackResourceLoaderback to summary
private final DefaultResourceLoader fallbackResourceLoader
resourceLoaderback to summary
private final ResourceLoader resourceLoader

Constructor Detail

SpringResourceAccessorback to summary
public SpringResourceAccessor(ResourceLoader resourceLoader)

Method Detail

closeback to summary
public void close() throws Exception

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
Exceptions
Exception:
if this resource cannot be closed
decodeUrlback to summary
private String decodeUrl(Resource resource, String url) throws IOException
describeLocationsback to summary
public List<String> describeLocations()

Implements liquibase.resource.ResourceAccessor.describeLocations.

Doc from liquibase.resource.ResourceAccessor.describeLocations.

Returns a description of the places this classloader will look for paths. Used in error messages and other troubleshooting cases.

Annotations
@Override
finalizeSearchPathback to summary
protected String finalizeSearchPath(String searchPath)

Ensure the given searchPath is a valid searchPath. Default implementation adds "classpath:" and removes duplicated /'s and classpath:'s

getAllback to summary
public List<Resource> getAll(String path) throws IOException

Implements liquibase.resource.ResourceAccessor.getAll.

Doc from liquibase.resource.ResourceAccessor.getAll.

Returns all Resources 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".

Returns:List<Resource>

null if no resources match the path

Annotations
@Override
Exceptions
IOException:
if there is an unexpected error determining what is at the path
getCompletePathback to summary
protected String getCompletePath(String relativeTo, String path) throws IOException

Returns the complete path to the resource, taking the relative path into account

getResourceback to summary
protected Resource getResource(String resourcePath)

Looks up the given resource.

getResourcePathback to summary
protected String getResourcePath(Resource resource)

Returns the lookup path to the given resource.

resourceIsFileback to summary
protected boolean resourceIsFile(Resource resource) throws IOException

Return true if the given resource is a standard file. Return false if it is a directory.

searchback to summary
public List<Resource> search(String searchPath, boolean recursive) throws IOException

Implements liquibase.resource.ResourceAccessor.search.

Doc from liquibase.resource.ResourceAccessor.search.

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
Should throw an exception if:
  • Path is null
  • Path is not a "directory"
  • Path exists but cannot be read from
Parameters
searchPath:String

The path to lookup resources in.

recursive:boolean

Set to true and will return paths to contents in subdirectories as well.

Returns:List<Resource>

empty set if nothing was found

Annotations
@Override
Exceptions
IOException:
if there is an error searching the system.