Top Description Fields Constructors Methods
liquibase.plugin

public abstract Class AbstractPluginFactory<T extends Plugin>

extends Object
implements PluginFactory
Class Inheritance
All Implemented Interfaces
liquibase.plugin.PluginFactory, liquibase.SingletonObject
Known Direct Subclasses
liquibase.report.ShowSummaryGeneratorFactory, liquibase.resource.PathHandlerFactory, liquibase.ui.UIServiceFactory, liquibase.change.ChangeFactory, liquibase.changelog.ChangeLogHistoryServiceFactory, liquibase.changeset.ChangeSetServiceFactory, liquibase.command.LiquibaseCommandFactory, liquibase.executor.ExecutorService, liquibase.license.LicenseServiceFactory, liquibase.logging.LogFactory, liquibase.logging.core.LogServiceFactory, liquibase.logging.mdc.MdcManagerFactory, liquibase.parser.SqlParserFactory
Imports
liquibase.Scope, liquibase.exception.UnexpectedLiquibaseException, liquibase.servicelocator.ServiceLocator, java.util.*

Convenience base class for all factories that find correct Plugin implementations.

Field Summary

Modifier and TypeField and Description
private Collection<T>

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected synchronized Collection<T>
findAllInstances()

Finds implementations of the given interface or class and returns instances of them.

private Optional<T>
protected T

Returns:

null if no plugins are found or have a priority greater than zero.
getPlugin
(final Object... args)

Finds the plugin for which getPriority(Plugin, Object...) returns the highest value for the given scope and args.

protected abstract Class<T>
protected Set<T>
getPlugins(final Object... args)

protected abstract int
getPriority(T obj, Object... args)

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

public synchronized void
register(T plugin)

protected synchronized void
removeInstance(T instance)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allInstancesback to summary
private Collection<T> allInstances

Constructor Detail

AbstractPluginFactoryback to summary
protected AbstractPluginFactory()

Method Detail

findAllInstancesback to summary
protected synchronized Collection<T> findAllInstances()

Finds implementations of the given interface or class and returns instances of them. Standard implementation uses ServiceLoader to find implementations and caches results in allInstances which means the same objects are always returned. If the instances should not be treated as singletons, clone the objects before returning them from getPlugin(Object...).

getForcedPluginIfAvailableback to summary
private Optional<T> getForcedPluginIfAvailable()
getPluginback to summary
protected T getPlugin(final Object... args)

Finds the plugin for which getPriority(Plugin, Object...) returns the highest value for the given scope and args. This method is called by a public implementation-specific methods. Normally this does not need to be overridden, instead override getPriority(Plugin, Object...) to compute the priority of each object for the scope and arguments passed to this method.

However, if there is a Scope key of "liquibase.plugin.${plugin.interface.class.Name}", an instance of that class will always be ran first.

Returns:T

null if no plugins are found or have a priority greater than zero.

getPluginClassback to summary
protected abstract Class<T> getPluginClass()
getPluginsback to summary
protected Set<T> getPlugins(final Object... args)
getPriorityback to summary
protected abstract int getPriority(T obj, Object... args)

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...)

registerback to summary
public synchronized void register(T plugin)
removeInstanceback to summary
protected synchronized void removeInstance(T instance)