org.springframework.plugin.core
Class OrderAwarePluginRegistry<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>
          extended by org.springframework.plugin.core.OrderAwarePluginRegistry<T,S>
All Implemented Interfaces:
Iterable<T>, PluginRegistry<T,S>

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

PluginRegistry implementation that be made aware of a certain ordering of Plugins. By default it orders Plugins by regarding Ordered interface or Order annotation. To alter ordering behaviour use one of the factory methods accepting a Comparator as parameter.

Author:
Oliver Gierke

Constructor Summary
protected OrderAwarePluginRegistry(List<? extends T> plugins, Comparator<? super T> comparator)
          Creates a new OrderAwarePluginRegistry with the given Plugins and Comparator.
 
Method Summary
static
<S,T extends Plugin<S>>
OrderAwarePluginRegistry<T,S>
create()
          Creates a new OrderAwarePluginRegistry using the #DEFAULT_COMPARATOR.
static
<S,T extends Plugin<S>>
OrderAwarePluginRegistry<T,S>
create(Comparator<? super T> comparator)
          Creates a new OrderAwarePluginRegistry using the given Comparator for ordering contained Plugins.
static
<S,T extends Plugin<S>>
OrderAwarePluginRegistry<T,S>
create(List<? extends T> plugins)
          Creates a new OrderAwarePluginRegistry with the given plugins.
static
<S,T extends Plugin<S>>
OrderAwarePluginRegistry<T,S>
create(List<? extends T> plugins, Comparator<? super T> comparator)
          Creates a new OrderAwarePluginRegistry with the given plugins.
static
<S,T extends Plugin<S>>
OrderAwarePluginRegistry<T,S>
createReverse(List<? extends T> plugins)
          Creates a new OrderAwarePluginRegistry with the given plugins and the order of the plugins reverted.
protected  List<T> initialize(List<T> plugins)
          Callback to initialize the plugin List.
 OrderAwarePluginRegistry<T,S> reverse()
          Returns a new OrderAwarePluginRegistry with the order of the plugins reverted.
 
Methods inherited from class org.springframework.plugin.core.SimplePluginRegistry
contains, countPlugins, getPluginFor, getPluginFor, getPluginFor, getPlugins, getPluginsFor, getPluginsFor, getPluginsFor, hasPluginFor
 
Methods inherited from class org.springframework.plugin.core.PluginRegistrySupport
iterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderAwarePluginRegistry

protected OrderAwarePluginRegistry(List<? extends T> plugins,
                                   Comparator<? super T> comparator)
Creates a new OrderAwarePluginRegistry with the given Plugins and Comparator.

Parameters:
plugins - the Plugins to be contained in the registry or null if the registry shall be empty initally.
comparator - the Comparator to be used for ordering the Plugins or null if the #DEFAULT_COMPARATOR shall be used.
Method Detail

create

public static <S,T extends Plugin<S>> OrderAwarePluginRegistry<T,S> create()
Creates a new OrderAwarePluginRegistry using the #DEFAULT_COMPARATOR.

Type Parameters:
T -
S -
Returns:

create

public static <S,T extends Plugin<S>> OrderAwarePluginRegistry<T,S> create(Comparator<? super T> comparator)
Creates a new OrderAwarePluginRegistry using the given Comparator for ordering contained Plugins.

Type Parameters:
T -
S -
Returns:

create

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

Type Parameters:
S -
T -
Parameters:
plugins -
Returns:

createReverse

public static <S,T extends Plugin<S>> OrderAwarePluginRegistry<T,S> createReverse(List<? extends T> plugins)
Creates a new OrderAwarePluginRegistry with the given plugins and the order of the plugins reverted.

Type Parameters:
S -
T -
Parameters:
plugins -
Returns:

create

public static <S,T extends Plugin<S>> OrderAwarePluginRegistry<T,S> create(List<? extends T> plugins,
                                                                           Comparator<? super T> comparator)
Creates a new OrderAwarePluginRegistry with the given plugins.

Type Parameters:
S -
T -
Parameters:
plugins -
Returns:

initialize

protected List<T> initialize(List<T> plugins)
Description copied from class: PluginRegistrySupport
Callback to initialize the plugin List. Will create a defensive copy of the List to potentially unwrap a List proxy. Will filter null values from the source list as well.

Overrides:
initialize in class PluginRegistrySupport<T extends Plugin<S>,S>
Parameters:
plugins - must not be null.
Returns:

reverse

public OrderAwarePluginRegistry<T,S> reverse()
Returns a new OrderAwarePluginRegistry with the order of the plugins reverted.

Returns:


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