public abstract class AbstractPluginFactory<T extends Plugin> extends Object implements PluginFactory
Plugin
implementations.Modifier | Constructor and Description |
---|---|
protected |
AbstractPluginFactory() |
Modifier and Type | Method and 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 which
getPriority(Plugin, Object...) returns the highest value for the given scope and args. |
protected abstract Class<T> |
getPluginClass() |
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) |
protected abstract int getPriority(T obj, Object... args)
getPlugin(Object...)
protected T getPlugin(Object... args)
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.public void register(T plugin)
protected Collection<T> findAllInstances()
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...)
.protected void removeInstance(T instance)
Copyright © 2023 Liquibase.org. All rights reserved.