net.shibboleth.metadata.dom
Class DomResourceSourceStage

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<DomElementItem>
              extended by net.shibboleth.metadata.dom.DomResourceSourceStage
All Implemented Interfaces:
Stage<DomElementItem>, 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 DomResourceSourceStage
extends BaseStage<DomElementItem>

A pipeline stage which reads an XML document from an Resource, parses the document, and places the resultant document (root) element in to the provided DomElementItem collection.

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


Field Summary
private  net.shibboleth.utilities.java.support.resource.Resource domResource
          Resource used to fetch remote XML document.
private  boolean errorCausesSourceFailure
          Whether an error parsing one source file causes this entire Stage to fail, or just excludes the material from the offending source file.
private  Logger log
          Class logger.
private  net.shibboleth.utilities.java.support.xml.ParserPool parserPool
          Pool of parsers used to parse incoming DOM.
 
Constructor Summary
DomResourceSourceStage()
           
 
Method Summary
protected  void doDestroy()
          
protected  void doExecute(Collection<DomElementItem> itemCollection)
          Performs the stage processing on the given Item collection.
protected  void doInitialize()
          
 net.shibboleth.utilities.java.support.resource.Resource getDomResource()
          Gets the resource from which the XML Document will be fetched.
 boolean getErrorCausesSourceFailure()
          Gets whether an error reading and parsing the XML file causes this stage to fail.
 net.shibboleth.utilities.java.support.xml.ParserPool getParserPool()
          Gets the pool of DOM parsers used to parse the XML file in to a DOM.
protected  void populateItemCollection(Collection<DomElementItem> itemCollection, InputStream data)
          Builds an DomElementItem collection from a new XML document.
 void setDomResource(net.shibboleth.utilities.java.support.resource.Resource resource)
          Sets the resource from which the XML document will be fetched.
 void setErrorCausesSourceFailure(boolean causesFailure)
          Sets whether an error reading and parsing the XML file causes this stage to fail.
 void setParserPool(net.shibboleth.utilities.java.support.xml.ParserPool pool)
          Sets the pool of DOM parsers used to parse the XML file in to a DOM.
 
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.


domResource

private net.shibboleth.utilities.java.support.resource.Resource domResource
Resource used to fetch remote XML document.


parserPool

private net.shibboleth.utilities.java.support.xml.ParserPool parserPool
Pool of parsers used to parse incoming DOM.


errorCausesSourceFailure

private boolean errorCausesSourceFailure
Whether an error parsing one source file causes this entire Stage to fail, or just excludes the material from the offending source file. Default value: true

Constructor Detail

DomResourceSourceStage

public DomResourceSourceStage()
Method Detail

getDomResource

@Nullable
public net.shibboleth.utilities.java.support.resource.Resource getDomResource()
Gets the resource from which the XML Document will be fetched.

Returns:
resource from which the XML document will be fetched

setDomResource

public void setDomResource(@Nonnull
                           net.shibboleth.utilities.java.support.resource.Resource resource)
Sets the resource from which the XML document will be fetched.

Parameters:
resource - resource from which the XML document will be fetched

getParserPool

@Nullable
public net.shibboleth.utilities.java.support.xml.ParserPool getParserPool()
Gets the pool of DOM parsers used to parse the XML file in to a DOM.

Returns:
pool of DOM parsers used to parse the XML file in to a DOM

setParserPool

public void setParserPool(@Nonnull
                          net.shibboleth.utilities.java.support.xml.ParserPool pool)
Sets the pool of DOM parsers used to parse the XML file in to a DOM.

Parameters:
pool - pool of DOM parsers used to parse the XML file in to a DOM

getErrorCausesSourceFailure

public boolean getErrorCausesSourceFailure()
Gets whether an error reading and parsing the XML file causes this stage to fail.

Returns:
whether an error reading and parsing the XML file causes this stage to fail

setErrorCausesSourceFailure

public void setErrorCausesSourceFailure(boolean causesFailure)
Sets whether an error reading and parsing the XML file causes this stage to fail.

Parameters:
causesFailure - whether an error reading and parsing the XML file causes this stage to fail

doExecute

protected void doExecute(@Nonnull@NonnullElements
                         Collection<DomElementItem> 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<DomElementItem>
Parameters:
itemCollection - collection to be processed
Throws:
StageProcessingException - thrown if there is an unrecoverable problem when processing the stage

populateItemCollection

protected void populateItemCollection(@Nonnull@NonnullElements
                                      Collection<DomElementItem> itemCollection,
                                      InputStream data)
                               throws StageProcessingException
Builds an DomElementItem collection from a new XML document. Also caches DOM Element in its parsed form for later use.

Parameters:
itemCollection - collection to which the read in and parsed document element is added
data - XML input file
Throws:
StageProcessingException - thrown if there is a problem reading and parsing the response

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.