Class AbstractPluginFactory<T extends Plugin>

java.lang.Object
liquibase.plugin.AbstractPluginFactory<T>
All Implemented Interfaces:
PluginFactory, SingletonObject
Direct Known Subclasses:
ChangeFactory, ChangeLogHistoryServiceFactory, ChangeSetServiceFactory, ExecutorService, LicenseServiceFactory, LogFactory, LogServiceFactory, MdcManagerFactory, OutputFileHandlerFactory, PathHandlerFactory, ShowSummaryGeneratorFactory, SqlParserFactory, TestSystemFactory, UIServiceFactory, ValidatingVisitorGeneratorFactory

public abstract class AbstractPluginFactory<T extends Plugin> extends Object implements PluginFactory
Convenience base class for all factories that find correct Plugin implementations.
  • Constructor Details

    • AbstractPluginFactory

      protected AbstractPluginFactory()
  • Method Details

    • getPluginClass

      protected abstract Class<T> getPluginClass()
    • getPriority

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

      protected T getPlugin(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 run first.

      Returns:
      null if no plugins are found or have a priority greater than zero.
    • getPlugins

      protected Set<T> getPlugins(Object... args)
    • register

      public void register(T plugin)
    • findAllInstances

      protected 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...).
    • removeInstance

      protected void removeInstance(T instance)