net.shibboleth.metadata.pipeline
Class PipelineDemultiplexerStage<ItemType extends Item<?>>

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<ItemType>
              extended by net.shibboleth.metadata.pipeline.PipelineDemultiplexerStage<ItemType>
Type Parameters:
ItemType - type of items upon which this stage operates
All Implemented Interfaces:
Stage<ItemType>, 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 PipelineDemultiplexerStage<ItemType extends Item<?>>
extends BaseStage<ItemType>

A stage which, given an item collection and a list of Pipeline and Predicate pairs, sends the collection of item copies selected by the predicate to the associated pipeline. This stage is similar to SplitMergeStage but a given item, or more precisely a copy of it, may end up going to more than one pipeline (or no pipeline).

This stage requires the following properties be set prior to initialization:

If no executorService is provided, one will be created using Executors.newFixedThreadPool(int) with 6 threads. If no collectionFactory is given, then SimpleItemCollectionFactory is used.


Field Summary
private  com.google.common.base.Supplier<Collection<ItemType>> collectionFactory
          Factory used to create the Item collection that is then given to the pipelines.
private  ExecutorService executorService
          Service used to execute the selected and/or non-selected item pipelines.
private  Logger log
          Class logger.
private  List<net.shibboleth.utilities.java.support.collection.Pair<Pipeline<ItemType>,com.google.common.base.Predicate<ItemType>>> pipelineAndStrategies
          The pipelines through which items are sent and the selection strategy used for that pipeline.
private  boolean waitingForPipelines
          Whether this child waits for all the invoked pipelines to complete before proceeding.
 
Constructor Summary
PipelineDemultiplexerStage()
           
 
Method Summary
protected  void doDestroy()
          
protected  void doExecute(Collection<ItemType> itemCollection)
          Performs the stage processing on the given Item collection.
protected  void doInitialize()
          
 com.google.common.base.Supplier<Collection<ItemType>> getCollectionFactory()
          Gets the factory used to create the Item collection that is then given to the pipelines.
 ExecutorService getExecutorService()
          Gets the executor service used to run the selected and non-selected item pipelines.
 List<net.shibboleth.utilities.java.support.collection.Pair<Pipeline<ItemType>,com.google.common.base.Predicate<ItemType>>> getPipelineAndSelectionStrategies()
          Gets the pipeline and item selection strategies used to demultiplex item collections within this stage.
 boolean isWaitingForPipelines()
          Gets whether this child waits for all the invoked pipelines to complete before proceeding.
 void setCollectionFactory(com.google.common.base.Supplier<Collection<ItemType>> factory)
          Sets the factory used to create the Item collection that is then given to the pipelines.
 void setExecutorService(ExecutorService service)
          Sets the executor service used to run the selected and non-selected item pipelines.
 void setPipelineAndSelectionStrategies(List<net.shibboleth.utilities.java.support.collection.Pair<Pipeline<ItemType>,com.google.common.base.Predicate<ItemType>>> passes)
          Sets the pipeline and item selection strategies used to demultiplex item collections within this stage.
 void setWaitingForPipelines(boolean isWaiting)
          Sets whether this child waits for all the invoked pipelines to complete before proceeding.
 
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

log

private final Logger log
Class logger.


executorService

private ExecutorService executorService
Service used to execute the selected and/or non-selected item pipelines.


waitingForPipelines

private boolean waitingForPipelines
Whether this child waits for all the invoked pipelines to complete before proceeding.


collectionFactory

private com.google.common.base.Supplier<Collection<ItemType extends Item<?>>> collectionFactory
Factory used to create the Item collection that is then given to the pipelines.


pipelineAndStrategies

private List<net.shibboleth.utilities.java.support.collection.Pair<Pipeline<ItemType extends Item<?>>,com.google.common.base.Predicate<ItemType extends Item<?>>>> pipelineAndStrategies
The pipelines through which items are sent and the selection strategy used for that pipeline.

Constructor Detail

PipelineDemultiplexerStage

public PipelineDemultiplexerStage()
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

isWaitingForPipelines

public boolean isWaitingForPipelines()
Gets whether this child waits for all the invoked pipelines to complete before proceeding.

Returns:
whether this child waits for all the invoked pipelines to complete before proceeding

setWaitingForPipelines

public void setWaitingForPipelines(boolean isWaiting)
Sets whether this child waits for all the invoked pipelines to complete before proceeding.

Parameters:
isWaiting - whether this child waits for all the invoked pipelines to complete before proceeding

getCollectionFactory

@Nonnull
public com.google.common.base.Supplier<Collection<ItemType>> getCollectionFactory()
Gets the factory used to create the Item collection that is then given to the pipelines.

Returns:
factory used to create the Item collection that is then given to the pipelines

setCollectionFactory

public void setCollectionFactory(@Nonnull
                                 com.google.common.base.Supplier<Collection<ItemType>> factory)
Sets the factory used to create the Item collection that is then given to the pipelines.

Parameters:
factory - factory used to create the Item collection that is then given to the pipelines

getPipelineAndSelectionStrategies

@Nonnull
@NonnullElements
@Unmodifiable
public List<net.shibboleth.utilities.java.support.collection.Pair<Pipeline<ItemType>,com.google.common.base.Predicate<ItemType>>> getPipelineAndSelectionStrategies()
Gets the pipeline and item selection strategies used to demultiplex item collections within this stage.

Returns:
pipeline and item selection strategies used to demultiplex item collections within this stage

setPipelineAndSelectionStrategies

public void setPipelineAndSelectionStrategies(@Nonnull@NonnullElements
                                              List<net.shibboleth.utilities.java.support.collection.Pair<Pipeline<ItemType>,com.google.common.base.Predicate<ItemType>>> passes)
Sets the pipeline and item selection strategies used to demultiplex item collections within this stage.

Parameters:
passes - pipeline and item selection strategies used to demultiplex item collections within this stage

doExecute

protected void doExecute(@Nonnull@NonnullElements
                         Collection<ItemType> 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<ItemType extends 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.