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.PluginProviderspecial. If it is used with a type, it will expand when it encounters aPluginsContainer.PluginProviderplugin, 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 interfacePluginsContainer.PluginProviderA Plugin Provider provides plugins when accessed with a type selector.
-
Constructor Summary
Constructors Modifier Constructor Description protectedPluginsContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Object plugin)booleanaddAll(java.util.Collection<? extends java.lang.Object> collection)protected voidclose()<T> TgetPlugin(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 voidinit(Processor processor)Init actions occur inside of the first-level memoizer.java.util.Iterator<java.lang.Object>iterator()protected voidloadPlugins(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 voidpostInit(Processor processor)Post init actions must occur outside of the first level memoizer.booleanremove(java.lang.Object plugin)intsize()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.StringtoString()-
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.PluginProviders themselves, if any, rather than any plugins thePluginsContainer.PluginProviders may provide.Use
stream(Class)or @{linkspliterator(Class)to return the complete plugins including any plugins thePluginsContainer.PluginProviders 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.PluginProviders 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.PluginProviders that match the specified type.- Specified by:
getPluginsin interfaceRegistry
-
add
public boolean add(java.lang.Object plugin)
- Specified by:
addin interfacejava.util.Collection<java.lang.Object>- Specified by:
addin interfacejava.util.Set<java.lang.Object>- Overrides:
addin classjava.util.AbstractCollection<java.lang.Object>
-
addAll
public boolean addAll(java.util.Collection<? extends java.lang.Object> collection)
- Specified by:
addAllin interfacejava.util.Collection<java.lang.Object>- Specified by:
addAllin interfacejava.util.Set<java.lang.Object>- Overrides:
addAllin classjava.util.AbstractCollection<java.lang.Object>
-
remove
public boolean remove(java.lang.Object plugin)
- Specified by:
removein interfacejava.util.Collection<java.lang.Object>- Specified by:
removein interfacejava.util.Set<java.lang.Object>- Overrides:
removein classjava.util.AbstractCollection<java.lang.Object>
-
iterator
public java.util.Iterator<java.lang.Object> iterator()
- Specified by:
iteratorin interfacejava.util.Collection<java.lang.Object>- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Object>- Specified by:
iteratorin interfacejava.util.Set<java.lang.Object>- Specified by:
iteratorin classjava.util.AbstractCollection<java.lang.Object>
-
spliterator
public java.util.Spliterator<java.lang.Object> spliterator()
- Specified by:
spliteratorin interfacejava.util.Collection<java.lang.Object>- Specified by:
spliteratorin interfacejava.lang.Iterable<java.lang.Object>- Specified by:
spliteratorin interfacejava.util.Set<java.lang.Object>
-
stream
public java.util.stream.Stream<java.lang.Object> stream()
- Specified by:
streamin interfacejava.util.Collection<java.lang.Object>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<java.lang.Object>- Specified by:
sizein interfacejava.util.Set<java.lang.Object>- Specified by:
sizein classjava.util.AbstractCollection<java.lang.Object>
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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()
-
-