Skip to content

liquibase.resource.Resource

Overview

Instances of the liquibase.resource.Resource interface wrap implementation-specific read logic. It provides a standard interface for code to use regardless of whether the underlying file is local, remote, or anywhere else.

Oftentimes, PathHandler and/or ResourceAccessor implementations will create custom Resource implementations.

API Highlights

Constructor

The base AbstractResource constructor takes a URI along with the path. Because the same path can match multiple Resources within a ResourceAccessor, the URI is the unique descriptor of this particular Resource.

Tip

The resolve methods will need to look up other Resources, so passing the ResourceAccessor accessor into the constructor is often needed.

openInputStream

Returns the contents of the file as a stream.

exists

Returns whether the resource exists or not. The resolve methods return relative Resources, without worrying about whether they are existing files or not. This method is used to check the existence of the resources.

resolve / resolveSibling

These methods return objects corresponding to other resources located relative to this resource.

Resolve is for finding a path within this resource's location (like a file in a directory), whereas resolveSibling is for finding a path next to this resource's location (like a file in the same directory).

API Details

The complete javadocs for liquibase.resource.Resource is available at https://javadocs.liquibase.com

Extension Guides

The following guides provide relevant examples: