net.shibboleth.metadata.pipeline
Class PipelineMergeStage

java.lang.Object
  extended by net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent
      extended by net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent
          extended by net.shibboleth.metadata.pipeline.BaseStage<Item<?>>
              extended by net.shibboleth.metadata.pipeline.PipelineMergeStage
All Implemented Interfaces:
Stage<Item<?>>, net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.IdentifiableComponent, net.shibboleth.utilities.java.support.component.InitializableComponent

@ThreadSafe
public class PipelineMergeStage
extends BaseStage<Item<?>>

This Stage allows the merging of multiple pipeline outputs into a single Collection that can then be used as the input source for another pipeline. This source works producing a Collection by means of the registered Supplier . Then each of its registered Pipeline is invoked in turn (no ordering is guaranteed and pipelines may execute concurrently). After each pipeline has completed the results are merged in to the Item collection given to this stage by means of the an CollectionMergeStrategy.


Field Summary
private  com.google.common.base.Supplier<Collection> collectionFactory
          The factory used to create the item returned by this source.
private  ExecutorService executorService
          Service used to execute the pipelines whose results will be merged.
private  List<Pipeline<? extends Item<?>>> mergedPipelines
          Pipelines whose results become the output of this source.
private  CollectionMergeStrategy mergeStrategy
          Strategy used to merge all the joined pipeline results in to the final Item collection.
 
Constructor Summary
PipelineMergeStage()
           
 
Method Summary
protected  void doDestroy()
          
protected  void doExecute(Collection<Item<?>> itemCollection)
          Performs the stage processing on the given Item collection.
protected  void doInitialize()
          
 com.google.common.base.Supplier<Collection> getCollectionFactory()
          Gets the factory used to create the Item collection produced by this source.
 CollectionMergeStrategy getCollectionMergeStrategy()
          Gets the strategy used to merge all the joined pipeline results in to the final Item collection.
 ExecutorService getExecutorService()
          Gets the executor service used to run the selected and non-selected item pipelines.
 List<Pipeline<? extends Item<?>>> getMergedPipelines()
          Gets the unmodifiable set of pipelines used by this stage.
 void setCollectionFactory(com.google.common.base.Supplier<Collection> factory)
          Sets the factory used to create the Item collection produced by this source.
 void setCollectionMergeStrategy(CollectionMergeStrategy strategy)
          Sets the strategy used to merge all the joined pipeline results in to the final Item collection.
 void setExecutorService(ExecutorService service)
          Sets the executor service used to run the selected and non-selected item pipelines.
 void setMergedPipelines(List<? extends Pipeline<? extends Item<?>>> pipelines)
          Sets the pipelines joined by this stage.
 
Methods inherited from class net.shibboleth.metadata.pipeline.BaseStage
execute, setId
 
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent
getId
 
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent
destroy, initialize, isDestroyed, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.DestructableComponent
destroy, isDestroyed
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiableComponent
getId
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
 

Field Detail

executorService

private ExecutorService executorService
Service used to execute the pipelines whose results will be merged.


collectionFactory

private com.google.common.base.Supplier<Collection> collectionFactory
The factory used to create the item returned by this source. Default implementation is SimpleItemCollectionFactory.


mergeStrategy

private CollectionMergeStrategy mergeStrategy
Strategy used to merge all the joined pipeline results in to the final Item collection.


mergedPipelines

private List<Pipeline<? extends Item<?>>> mergedPipelines
Pipelines whose results become the output of this source.

Constructor Detail

PipelineMergeStage

public PipelineMergeStage()
Method Detail

getExecutorService

@Nonnull
public ExecutorService getExecutorService()
Gets the executor service used to run the selected and non-selected item pipelines.

Returns:
executor service used to run the selected and non-selected item pipelines

setExecutorService

public void setExecutorService(@Nonnull
                               ExecutorService service)
Sets the executor service used to run the selected and non-selected item pipelines.

Parameters:
service - executor service used to run the selected and non-selected item pipelines

getMergedPipelines

@Nonnull
@NonnullElements
@Unmodifiable
public List<Pipeline<? extends Item<?>>> getMergedPipelines()
Gets the unmodifiable set of pipelines used by this stage.

Returns:
unmodifiable set of pipelines used by this stage

setMergedPipelines

public void setMergedPipelines(@Nullable@NullableElements
                               List<? extends Pipeline<? extends Item<?>>> pipelines)
Sets the pipelines joined by this stage.

Parameters:
pipelines - pipelines joined by this stage

getCollectionFactory

@Nonnull
public com.google.common.base.Supplier<Collection> getCollectionFactory()
Gets the factory used to create the Item collection produced by this source.

Returns:
factory used to create the Item collection produced by this source

setCollectionFactory

public void setCollectionFactory(@Nonnull
                                 com.google.common.base.Supplier<Collection> factory)
Sets the factory used to create the Item collection produced by this source.

Parameters:
factory - factory used to create the Item collection produced by this source

getCollectionMergeStrategy

@Nonnull
public CollectionMergeStrategy getCollectionMergeStrategy()
Gets the strategy used to merge all the joined pipeline results in to the final Item collection.

Returns:
strategy used to merge all the joined pipeline results in to the final Item collection, never null

setCollectionMergeStrategy

public void setCollectionMergeStrategy(@Nonnull
                                       CollectionMergeStrategy strategy)
Sets the strategy used to merge all the joined pipeline results in to the final Item collection.

Parameters:
strategy - strategy used to merge all the joined pipeline results in to the final Item collection, never null

doExecute

protected void doExecute(@Nonnull@NonnullElements
                         Collection<Item<?>> itemCollection)
                  throws StageProcessingException
Performs the stage processing on the given Item collection.

The stage is guaranteed to be have been initialized and not destroyed when this is invoked.

Specified by:
doExecute in class BaseStage<Item<?>>
Parameters:
itemCollection - collection to be processed
Throws:
StageProcessingException - thrown if there is an unrecoverable problem when processing the stage

doDestroy

protected void doDestroy()

Overrides:
doDestroy in class net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent

doInitialize

protected void doInitialize()
                     throws net.shibboleth.utilities.java.support.component.ComponentInitializationException

Overrides:
doInitialize in class net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent
Throws:
net.shibboleth.utilities.java.support.component.ComponentInitializationException


Copyright © 1999-2012. All Rights Reserved.