Class PluginsContainer
PluginsContainer.PluginProvider
special. If it is used with a type, it will expand when it encounters a
PluginsContainer.PluginProvider
plugin, see getPlugin(Class)
and
getPlugins(Class)
. These provided plugins are _not_ part of the this
set so they won't be explicitly returned when plugins()
is called.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) final class
static interface
A Plugin Provider provides plugins when accessed with a type selector.(package private) final class
A spliterator of plugins of the specified type ordered by the processor hierarchy. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<AutoCloseable>
private static final MethodType
private static final org.slf4j.Logger
(package private) Processor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends Object> collection) protected void
close()
<T> T
Return the first plugin of the specified type.<T> List<T>
getPlugins
(Class<T> type) Return all plugins of the specified type.protected void
Init actions occur inside of the first-level memoizer.(package private) boolean
isMissingPlugin
(String name) iterator()
private Object
loadPlugin
(Processor processor, ClassLoader loader, Attrs attrs, String className, boolean ignoreError) Load a plugin and customize it.private void
loadPluginPath
(Processor processor, String pluginPath, Processor.CL loader) Add the @linkConstants.PLUGINPATH
entries (which are file names) to the class loader.protected void
loadPlugins
(Processor processor, String pluginString, String pluginPathString) Magic to load the plugins.plugins()
Return the set of plugins added to this container.protected void
Post init actions must occur outside of the first level memoizer.boolean
int
size()
protected <T> Spliterator<T>
spliterator
(Class<T> type) Returns a spliterator of plugins of the specified type ordered by the processor hierarchy.stream()
protected <T> Stream<T>
Returns a stream of plugins of the specified type ordered by the processor hierarchy.toString()
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
clear, contains, containsAll, isEmpty, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, toArray
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
defaultConstructor
-
plugins
-
missingCommand
-
closeablePlugins
-
processor
Processor processor
-
-
Constructor Details
-
PluginsContainer
protected PluginsContainer()
-
-
Method Details
-
init
Init actions occur inside of the first-level memoizer. -
postInit
Post init actions must occur outside of the first level memoizer. This means these actions can reentrantly see the current state of the PluginsContainer, through the Processor, which may be partially complete if addExtensions adds more plugins. -
plugins
Return the set of plugins added to this container.This will include
PluginsContainer.PluginProvider
s themselves, if any, rather than any plugins thePluginsContainer.PluginProvider
s may provide.Use
stream(Class)
or @{linkspliterator(Class)
to return the complete plugins including any plugins thePluginsContainer.PluginProvider
s may provide as well as the plugins from the parent processor. The complete plugins may have duplicates if the same plugin is added into different processors in the hierarchy. -
stream
Returns a stream of plugins of the specified type ordered by the processor hierarchy.The supplied plugins may have duplicates if the same plugin is added into different processors in the hierarchy.
-
spliterator
Returns a spliterator of plugins of the specified type ordered by the processor hierarchy.The supplied plugins may have duplicates if the same plugin is added into different processors in the hierarchy.
-
getPlugin
Return the first plugin of the specified type.This may invoke any
PluginsContainer.PluginProvider
s that match the specified type. -
getPlugins
Return all plugins of the specified type. Duplicates are removed.This will invoke any
PluginsContainer.PluginProvider
s that match the specified type.- Specified by:
getPlugins
in interfaceRegistry
-
add
- Specified by:
add
in interfaceCollection<Object>
- Specified by:
add
in interfaceSet<Object>
- Overrides:
add
in classAbstractCollection<Object>
-
addAll
- Specified by:
addAll
in interfaceCollection<Object>
- Specified by:
addAll
in interfaceSet<Object>
- Overrides:
addAll
in classAbstractCollection<Object>
-
remove
- Specified by:
remove
in interfaceCollection<Object>
- Specified by:
remove
in interfaceSet<Object>
- Overrides:
remove
in classAbstractCollection<Object>
-
iterator
-
spliterator
- Specified by:
spliterator
in interfaceCollection<Object>
- Specified by:
spliterator
in interfaceIterable<Object>
- Specified by:
spliterator
in interfaceSet<Object>
-
stream
- Specified by:
stream
in interfaceCollection<Object>
-
size
public int size()- Specified by:
size
in interfaceCollection<Object>
- Specified by:
size
in interfaceSet<Object>
- Specified by:
size
in classAbstractCollection<Object>
-
toString
- Overrides:
toString
in classAbstractCollection<Object>
-
loadPlugins
Magic to load the plugins. This is quite tricky actually since we allow plugins to be downloaded (this is mainly intended for repositories since in general plugins should use extensions, however to bootstrap the extensions we need more). Since downloads might need plugins for passwords and protocols we need to first load the paths specified on the plugin clause, then check if there are any local plugins (starting with aQute.bnd and be able to load from our own class loader).After that, we load the plugin paths, these can use the built in connectors.
Last but not least, we load the remaining plugins.
-
loadPluginPath
Add the @linkConstants.PLUGINPATH
entries (which are file names) to the class loader. If this file does not exist, and there is aConstants.PLUGINPATH_URL_ATTR
attribute then we download it first from that url. You can then also specify aConstants.PLUGINPATH_SHA1_ATTR
attribute to verify the file.- Parameters:
pluginPath
- the clauses for the plugin pathloader
- The class loader to extend- See Also:
-
PLUGINPATH
-
loadPlugin
private Object loadPlugin(Processor processor, ClassLoader loader, Attrs attrs, String className, boolean ignoreError) Load a plugin and customize it. If the plugin cannot be loaded then we return null.- Parameters:
loader
- Name of the loaderattrs
-className
-
-
isMissingPlugin
-
close
protected void close()
-