Class 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 @{link 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 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.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
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        clear, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
    • Constructor Detail

      • PluginsContainer

        protected PluginsContainer()
    • 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.
      • 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.

        Specified by:
        getPlugin in interface Registry
      • 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:
        getPlugins in interface Registry
      • add

        public boolean add​(java.lang.Object plugin)
        Specified by:
        add in interface java.util.Collection<java.lang.Object>
        Specified by:
        add in interface java.util.Set<java.lang.Object>
        Overrides:
        add in class java.util.AbstractCollection<java.lang.Object>
      • addAll

        public boolean addAll​(java.util.Collection<? extends java.lang.Object> collection)
        Specified by:
        addAll in interface java.util.Collection<java.lang.Object>
        Specified by:
        addAll in interface java.util.Set<java.lang.Object>
        Overrides:
        addAll in class java.util.AbstractCollection<java.lang.Object>
      • remove

        public boolean remove​(java.lang.Object plugin)
        Specified by:
        remove in interface java.util.Collection<java.lang.Object>
        Specified by:
        remove in interface java.util.Set<java.lang.Object>
        Overrides:
        remove in class java.util.AbstractCollection<java.lang.Object>
      • iterator

        public java.util.Iterator<java.lang.Object> iterator()
        Specified by:
        iterator in interface java.util.Collection<java.lang.Object>
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Object>
        Specified by:
        iterator in interface java.util.Set<java.lang.Object>
        Specified by:
        iterator in class java.util.AbstractCollection<java.lang.Object>
      • spliterator

        public java.util.Spliterator<java.lang.Object> spliterator()
        Specified by:
        spliterator in interface java.util.Collection<java.lang.Object>
        Specified by:
        spliterator in interface java.lang.Iterable<java.lang.Object>
        Specified by:
        spliterator in interface java.util.Set<java.lang.Object>
      • stream

        public java.util.stream.Stream<java.lang.Object> stream()
        Specified by:
        stream in interface java.util.Collection<java.lang.Object>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.lang.Object>
        Specified by:
        size in interface java.util.Set<java.lang.Object>
        Specified by:
        size in class java.util.AbstractCollection<java.lang.Object>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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()