net.shibboleth.metadata.pipeline
Class SerializationStage<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.SerializationStage<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 SerializationStage<ItemType extends Item<?>>
extends BaseStage<ItemType>

A stage which writes the given item collection out to a file.

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


Field Summary
private  Logger log
          Class logger.
private  File outputFile
          File to which the item will be written.
private  boolean overwritingExistingOutputFile
          Whether an existing output file should be overwritten.
private  ItemSerializer<ItemType> serializer
          Serializer used to write the item to the output stream.
 
Constructor Summary
SerializationStage()
           
 
Method Summary
protected  void doDestroy()
          
protected  void doExecute(Collection<ItemType> itemCollection)
          Performs the stage processing on the given Item collection.
protected  void doInitialize()
          
 File getOutputFile()
          Gets the file to which the item will be written.
 ItemSerializer<ItemType> getSerializer()
          Gets the serializer used to write item to the output file.
 boolean isOverwritingExistingOutputFile()
          Gets whether an existing output file should be overwritten.
 void setOutputFile(File file)
          Sets the file to which the item will be written.
 void setOverwritingExistingOutputFile(boolean isOverwriting)
          Sets whether an existing output file should be overwritten.
 void setSerializer(ItemSerializer<ItemType> itemSerializer)
          Sets the serializer used to write item to the output file.
 
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.


outputFile

private File outputFile
File to which the item will be written.


overwritingExistingOutputFile

private boolean overwritingExistingOutputFile
Whether an existing output file should be overwritten. Default value: true


serializer

private ItemSerializer<ItemType extends Item<?>> serializer
Serializer used to write the item to the output stream.

Constructor Detail

SerializationStage

public SerializationStage()
Method Detail

getOutputFile

@Nullable
public File getOutputFile()
Gets the file to which the item will be written.

Returns:
file to which the item will be written

setOutputFile

public void setOutputFile(@Nonnull
                          File file)
Sets the file to which the item will be written.

Parameters:
file - file to which the item will be written

isOverwritingExistingOutputFile

public boolean isOverwritingExistingOutputFile()
Gets whether an existing output file should be overwritten.

Returns:
whether an existing output file should be overwritten

setOverwritingExistingOutputFile

public void setOverwritingExistingOutputFile(boolean isOverwriting)
Sets whether an existing output file should be overwritten.

Parameters:
isOverwriting - whether an existing output file should be overwritten

getSerializer

@Nullable
public ItemSerializer<ItemType> getSerializer()
Gets the serializer used to write item to the output file.

Returns:
serializer used to write item to the output file

setSerializer

public void setSerializer(@Nonnull
                          ItemSerializer<ItemType> itemSerializer)
Sets the serializer used to write item to the output file.

Parameters:
itemSerializer - serializer used to write item to the output file

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.