Class PluginsContainer
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<java.lang.Object>
-
- aQute.bnd.osgi.PluginsContainer
-
- All Implemented Interfaces:
Registry
,java.lang.Iterable<java.lang.Object>
,java.util.Collection<java.lang.Object>
,java.util.Set<java.lang.Object>
public class PluginsContainer extends java.util.AbstractSet<java.lang.Object> implements java.util.Set<java.lang.Object>, Registry
The plugin set for a Processor. Plugins are general service objects and can be any type. The PluginsContainer treats the @{linkPluginsContainer.PluginProvider
special. If it is used with a type, it will expand when it encounters aPluginsContainer.PluginProvider
plugin, seegetPlugin(Class)
andgetPlugins(Class)
. These provided plugins are _not_ part of the this set so they won't be explicitly returned whenplugins()
is called.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PluginsContainer.PluginProvider
A Plugin Provider provides plugins when accessed with a type selector.
-
Constructor Summary
Constructors Modifier Constructor Description protected
PluginsContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(java.lang.Object plugin)
boolean
addAll(java.util.Collection<? extends java.lang.Object> collection)
protected void
close()
<T> T
getPlugin(java.lang.Class<T> type)
Return the first plugin of the specified type.<T> java.util.List<T>
getPlugins(java.lang.Class<T> type)
Return all plugins of the specified type.protected void
init(Processor processor)
Init actions occur inside of the first-level memoizer.java.util.Iterator<java.lang.Object>
iterator()
protected void
loadPlugins(Processor processor, java.lang.String pluginString, java.lang.String pluginPathString)
Magic to load the plugins.protected java.util.Set<java.lang.Object>
plugins()
Return the set of plugins added to this container.protected void
postInit(Processor processor)
Post init actions must occur outside of the first level memoizer.boolean
remove(java.lang.Object plugin)
int
size()
java.util.Spliterator<java.lang.Object>
spliterator()
protected <T> java.util.Spliterator<T>
spliterator(java.lang.Class<T> type)
Returns a spliterator of plugins of the specified type ordered by the processor hierarchy.java.util.stream.Stream<java.lang.Object>
stream()
protected <T> java.util.stream.Stream<T>
stream(java.lang.Class<T> type)
Returns a stream of plugins of the specified type ordered by the processor hierarchy.java.lang.String
toString()
-
Methods inherited from class java.util.AbstractCollection
clear, contains, containsAll, isEmpty, retainAll, toArray, toArray
-
-
-
-
Method Detail
-
init
protected void init(Processor processor)
Init actions occur inside of the first-level memoizer.
-
postInit
protected void postInit(Processor processor)
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
protected java.util.Set<java.lang.Object> 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
protected <T> java.util.stream.Stream<T> stream(java.lang.Class<T> type)
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
protected <T> java.util.Spliterator<T> spliterator(java.lang.Class<T> type)
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
public <T> T getPlugin(java.lang.Class<T> type)
Return the first plugin of the specified type.This may invoke any
PluginsContainer.PluginProvider
s that match the specified type.
-
getPlugins
public <T> java.util.List<T> getPlugins(java.lang.Class<T> type)
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
public boolean add(java.lang.Object plugin)
- Specified by:
add
in interfacejava.util.Collection<java.lang.Object>
- Specified by:
add
in interfacejava.util.Set<java.lang.Object>
- Overrides:
add
in classjava.util.AbstractCollection<java.lang.Object>
-
addAll
public boolean addAll(java.util.Collection<? extends java.lang.Object> collection)
- Specified by:
addAll
in interfacejava.util.Collection<java.lang.Object>
- Specified by:
addAll
in interfacejava.util.Set<java.lang.Object>
- Overrides:
addAll
in classjava.util.AbstractCollection<java.lang.Object>
-
remove
public boolean remove(java.lang.Object plugin)
- Specified by:
remove
in interfacejava.util.Collection<java.lang.Object>
- Specified by:
remove
in interfacejava.util.Set<java.lang.Object>
- Overrides:
remove
in classjava.util.AbstractCollection<java.lang.Object>
-
iterator
public java.util.Iterator<java.lang.Object> iterator()
- Specified by:
iterator
in interfacejava.util.Collection<java.lang.Object>
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Object>
- Specified by:
iterator
in interfacejava.util.Set<java.lang.Object>
- Specified by:
iterator
in classjava.util.AbstractCollection<java.lang.Object>
-
spliterator
public java.util.Spliterator<java.lang.Object> spliterator()
- Specified by:
spliterator
in interfacejava.util.Collection<java.lang.Object>
- Specified by:
spliterator
in interfacejava.lang.Iterable<java.lang.Object>
- Specified by:
spliterator
in interfacejava.util.Set<java.lang.Object>
-
stream
public java.util.stream.Stream<java.lang.Object> stream()
- Specified by:
stream
in interfacejava.util.Collection<java.lang.Object>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection<java.lang.Object>
- Specified by:
size
in interfacejava.util.Set<java.lang.Object>
- Specified by:
size
in classjava.util.AbstractCollection<java.lang.Object>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<java.lang.Object>
-
loadPlugins
protected void loadPlugins(Processor processor, java.lang.String pluginString, java.lang.String pluginPathString)
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.
-
close
protected void close()
-
-