org.springframework.plugin.core
Class SimplePluginRegistry<T extends Plugin<S>,S>

java.lang.Object
  extended by org.springframework.plugin.core.PluginRegistrySupport<T,S>
      extended by org.springframework.plugin.core.SimplePluginRegistry<T,S>
Type Parameters:
T - the concrete plugin interface
S - the delimiter type
All Implemented Interfaces:
Iterable<T>, PluginRegistry<T,S>
Direct Known Subclasses:
OrderAwarePluginRegistry

public class SimplePluginRegistry<T extends Plugin<S>,S>
extends PluginRegistrySupport<T,S>

Basic implementation of PluginRegistry. Simply holds all given plugins in a list dropping null values silently on adding.

Author:
Oliver Gierke

Constructor Summary
protected SimplePluginRegistry(List<? extends T> plugins)
          Creates a new SimplePluginRegistry.
 
Method Summary
 boolean contains(T plugin)
          Returns whether the registry contains a given plugin.
 int countPlugins()
          Returns the number of registered plugins.
static
<S,T extends Plugin<S>>
SimplePluginRegistry<T,S>
create()
          Creates a new SimplePluginRegistry.
static
<S,T extends Plugin<S>>
SimplePluginRegistry<T,S>
create(List<? extends T> plugins)
          Creates a new SimplePluginRegistry with the given Plugin s.
 T getPluginFor(S delimiter)
          Returns the first plugin found for the given originating system.
<E extends Exception>
T
getPluginFor(S delimiter, E ex)
          Retrieves a required plugin from the registry or throw the given exception if none can be found.
 T getPluginFor(S delimiter, T plugin)
          Returns the first Plugin supporting the given delimiter or the given plugin if none can be found.
 List<T> getPlugins()
          Returns all registered plugins.
 List<T> getPluginsFor(S delimiter)
          Returns all plugins for the given delimiter.
<E extends Exception>
List<T>
getPluginsFor(S delimiter, E ex)
          Retrieves all plugins for the given delimiter or throws an exception if no plugin can be found.
 List<T> getPluginsFor(S delimiter, List<? extends T> plugins)
          Returns all Plugins supporting the given delimiter or the given plugins if none found.
 boolean hasPluginFor(S delimiter)
          Returns whether the registry contains a Plugin matching the given delimiter.
 
Methods inherited from class org.springframework.plugin.core.PluginRegistrySupport
initialize, iterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePluginRegistry

protected SimplePluginRegistry(List<? extends T> plugins)
Creates a new SimplePluginRegistry. Will create an empty registry if null is provided.

Parameters:
plugins - must not be null.
Method Detail

create

public static <S,T extends Plugin<S>> SimplePluginRegistry<T,S> create()
Creates a new SimplePluginRegistry.

Type Parameters:
T - the plugin type
S - the delimiter type
Returns:

create

public static <S,T extends Plugin<S>> SimplePluginRegistry<T,S> create(List<? extends T> plugins)
Creates a new SimplePluginRegistry with the given Plugin s.

Type Parameters:
T - the plugin type
S - the delimiter type
Returns:

getPlugins

public List<T> getPlugins()
Description copied from class: PluginRegistrySupport
Returns all registered plugins. Only use this method if you really need to access all plugins. For distinguished access to certain plugins favour accessor methods like {link #getPluginFor} over this one. This method should only be used for testing purposes to check registry configuration.

Specified by:
getPlugins in interface PluginRegistry<T extends Plugin<S>,S>
Overrides:
getPlugins in class PluginRegistrySupport<T extends Plugin<S>,S>
Returns:
all plugins of the registry

getPluginFor

public T getPluginFor(S delimiter)
Description copied from interface: PluginRegistry
Returns the first plugin found for the given originating system. Thus, further configured plugins are ignored.

Returns:
a plugin for the given originating system or null if none found

getPluginsFor

public List<T> getPluginsFor(S delimiter)
Description copied from interface: PluginRegistry
Returns all plugins for the given delimiter.

Returns:
a list of plugins or an empty list if none found

getPluginFor

public <E extends Exception> T getPluginFor(S delimiter,
                                            E ex)
                                 throws E extends Exception
Description copied from interface: PluginRegistry
Retrieves a required plugin from the registry or throw the given exception if none can be found. If more than one plugins are found the first one will be returned.

Type Parameters:
E - the exception type to be thrown in case no plugin can be found
ex - the exception to be thrown in case no plugin can be found
Returns:
a single plugin for the given delimiter
Throws:
E - if no plugin can be found for the given delimiter
E extends Exception

getPluginsFor

public <E extends Exception> List<T> getPluginsFor(S delimiter,
                                                   E ex)
                                        throws E extends Exception
Description copied from interface: PluginRegistry
Retrieves all plugins for the given delimiter or throws an exception if no plugin can be found.

Type Parameters:
E - the exception type to be thrown
Returns:
all plugins for the given delimiter
Throws:
E - if no plugin can be found
E extends Exception

getPluginFor

public T getPluginFor(S delimiter,
                      T plugin)
Description copied from interface: PluginRegistry
Returns the first Plugin supporting the given delimiter or the given plugin if none can be found.

Returns:
a single Plugin supporting the given delimiter or the given Plugin if none found

getPluginsFor

public List<T> getPluginsFor(S delimiter,
                             List<? extends T> plugins)
Description copied from interface: PluginRegistry
Returns all Plugins supporting the given delimiter or the given plugins if none found.

Returns:
all Plugins supporting the given delimiter or the given Plugins if none found

countPlugins

public int countPlugins()
Description copied from interface: PluginRegistry
Returns the number of registered plugins.

Returns:
the number of plugins in the registry

contains

public boolean contains(T plugin)
Description copied from interface: PluginRegistry
Returns whether the registry contains a given plugin.

Returns:

hasPluginFor

public boolean hasPluginFor(S delimiter)
Description copied from interface: PluginRegistry
Returns whether the registry contains a Plugin matching the given delimiter.

Returns:


Copyright © 2008–2014 Pivotal, Inc.. All rights reserved.