Top Description Inners Constructors Methods
liquibase.resource

public Class PathHandlerFactory

extends AbstractPluginFactory<PathHandler>
Class Inheritance
Imports
liquibase.exception.UnexpectedLiquibaseException, liquibase.plugin.AbstractPluginFactory, java.io.IOException, .OutputStream, java.util.Collections, .List

Singleton for working with PathHandlers.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
PathHandlerFactory.FoundResourceAccessor

Adapts a resource found by the PathHandlerFactory to the ResourceAccessor interface so it can be used with the standard "duplicate file logic" in the ResourceAccessors

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public OutputStream
createResource(String resourcePath)

Creates a new resource at the specified path and returns an OutputStream for writing to it.

protected Class<PathHandler>
protected int
getPriority(PathHandler obj, Object... args)

Implements abstract liquibase.plugin.AbstractPluginFactory.getPriority.

Returns the priority of the given object based on the passed args array.

public Resource

Returns:

A resource, regardless of whether it exists or not.
getResource
(String resourcePath)

Return the resource for the given path.

public ResourceAccessor
getResourceAccessor(String root)

Creates a ResourceAccessor for the given path.

public OutputStream

Returns:

null if resourcePath does not exist and createIfNotExists is false
openResourceOutputStream
(String resourcePath, boolean createIfNotExists)

Returns the outputStream from getResource(String) if it exists, and the outputStream from createResource(String) if it does not.

public OutputStream

Returns:

null if resourcePath does not exist and OpenOptions#isCreateIfNeeded() is false
openResourceOutputStream
(String resourcePath, OpenOptions openOptions)

Returns the outputStream from getResource(String), using settings from the passed OpenOptions.

Inherited from liquibase.plugin.AbstractPluginFactory:
findAllInstancesgetPlugingetPluginsregisterremoveInstance

Constructor Detail

PathHandlerFactoryback to summary
private PathHandlerFactory()

Method Detail

createResourceback to summary
public OutputStream createResource(String resourcePath) throws IOException

Creates a new resource at the specified path and returns an OutputStream for writing to it.

Exceptions
IOException:
if the path cannot be written to
FileAlreadyExistsException:
if the file already exists
getPluginClassback to summary
protected Class<PathHandler> getPluginClass()

Implements abstract liquibase.plugin.AbstractPluginFactory.getPluginClass.

Annotations
@Override
getPriorityback to summary
protected int getPriority(PathHandler obj, Object... args)

Implements abstract liquibase.plugin.AbstractPluginFactory.getPriority.

Doc from liquibase.plugin.AbstractPluginFactory.getPriority.

Returns the priority of the given object based on the passed args array. The args are created as part of the custom public getPlugin method in implementations are passed through getPlugin(Object...)

Annotations
@Override
getResourceback to summary
public Resource getResource(String resourcePath) throws IOException

Return the resource for the given path.

Returns:Resource

A resource, regardless of whether it exists or not.

Annotations
@SuppressWarnings:java:S2095
Exceptions
IOException:
  • if the path cannot be understood or if there is a problem parsing the path
  • if the path exists as both a direct resourcePath and also in the resourceAccessor (if included). Unless liquibase.GlobalConfiguration#DUPLICATE_FILE_MODE overrides that behavior.
getResourceAccessorback to summary
public ResourceAccessor getResourceAccessor(String root) throws IOException

Creates a ResourceAccessor for the given path.

openResourceOutputStreamback to summary
public OutputStream openResourceOutputStream(String resourcePath, boolean createIfNotExists) throws IOException

Returns the outputStream from getResource(String) if it exists, and the outputStream from createResource(String) if it does not.

Returns:OutputStream

null if resourcePath does not exist and createIfNotExists is false

Annotations
@Deprecated
Exceptions
IOException:
if there is an error opening the stream
openResourceOutputStreamback to summary
public OutputStream openResourceOutputStream(String resourcePath, OpenOptions openOptions) throws IOException

Returns the outputStream from getResource(String), using settings from the passed OpenOptions.

Returns:OutputStream

null if resourcePath does not exist and OpenOptions#isCreateIfNeeded() is false

Exceptions
IOException:
if there is an error opening the stream
liquibase.resource back to summary

private Class PathHandlerFactory.FoundResourceAccessor

extends Object
implements ResourceAccessor
Class Inheritance
All Implemented Interfaces
liquibase.resource.ResourceAccessor, java.lang.AutoCloseable

Adapts a resource found by the PathHandlerFactory to the ResourceAccessor interface so it can be used with the standard "duplicate file logic" in the ResourceAccessors

Field Summary

Modifier and TypeField and Description
private final Resource
private final String

Constructor Summary

AccessConstructor and Description
public
FoundResourceAccessor(String location, Resource foundResource)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public List<String>
describeLocations()

Implements liquibase.resource.ResourceAccessor.describeLocations.

Returns a description of the places this classloader will look for paths.

public List<Resource>
getAll(String path)

Implements liquibase.resource.ResourceAccessor.getAll.

Returns all Resources at the given path.

public List<Resource>
search(String
The path to lookup resources in.
path
,
ResourceAccessor.SearchOptions
A set of criteria for how resources should be found/filtered
searchOptions
)

Overrides default liquibase.resource.ResourceAccessor.search.

Returns the path to all resources contained in the given path that match the searchOptions criteria.

public List<Resource>
search(String
The path to lookup resources in.
path
,
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

foundResourceback to summary
private final Resource foundResource
locationback to summary
private final String location

Constructor Detail

FoundResourceAccessorback to summary
public FoundResourceAccessor(String location, Resource foundResource)

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
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
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
searchback to summary
public List<Resource> search(String path, ResourceAccessor.SearchOptions searchOptions) throws IOException

Overrides default liquibase.resource.ResourceAccessor.search.

Doc from liquibase.resource.ResourceAccessor.search.

Returns the path to all resources contained in the given path that match the searchOptions criteria. 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 or maxDepth less or equals than zero
Should throw an exception if:
  • Path is null
  • Path is not a "directory"
  • Path exists but cannot be read from
Parameters
path:String

The path to lookup resources in.

searchOptions:ResourceAccessor.SearchOptions

A set of criteria for how resources should be found/filtered

Returns:List<Resource>

empty set if nothing was found

Annotations
@Override
Exceptions
IOException:
if there is an error searching the system.
searchback to summary
public List<Resource> search(String path, 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
path: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.