Package liquibase.plugin
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
,PathHandlerFactory
,ShowSummaryGeneratorFactory
,SqlParserFactory
,TestSystemFactory
,UIServiceFactory
public abstract class AbstractPluginFactory<T extends Plugin> extends Object implements PluginFactory
Convenience base class for all factories that find correctPlugin
implementations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPluginFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Collection<T>
findAllInstances()
Finds implementations of the given interface or class and returns instances of them.protected T
getPlugin(Object... args)
Finds the plugin for whichgetPriority(Plugin, Object...)
returns the highest value for the given scope and args.protected abstract Class<T>
getPluginClass()
protected Set<T>
getPlugins(Object... args)
protected abstract int
getPriority(T obj, Object... args)
Returns the priority of the given object based on the passed args array.void
register(T plugin)
protected void
removeInstance(T instance)
-
-
-
Method Detail
-
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 throughgetPlugin(Object...)
-
getPlugin
protected T getPlugin(Object... args)
Finds the plugin for whichgetPriority(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 overridegetPriority(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:
- null if no plugins are found or have a priority greater than zero.
-
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 usesServiceLoader
to find implementations and caches results inallInstances
which means the same objects are always returned. If the instances should not be treated as singletons, clone the objects before returning them fromgetPlugin(Object...)
.
-
removeInstance
protected void removeInstance(T instance)
-
-