Class BlockImpl<T,C>

java.lang.Object
org.apache.axiom.om.ds.AbstractOMDataSource
org.apache.axis2.jaxws.message.impl.BlockImpl<T,C>
All Implemented Interfaces:
org.apache.axiom.om.OMDataSource, org.apache.axiom.om.OMDataSourceExt, Block<T,C>
Direct Known Subclasses:
DataSourceBlockImpl, JAXBBlockImpl, OMBlockImpl, SOAPEnvelopeBlockImpl, SourceBlockImpl, XMLStringBlockImpl

public abstract class BlockImpl<T,C> extends org.apache.axiom.om.ds.AbstractOMDataSource implements Block<T,C>
BlockImpl Abstract Base class for various Block Implementations.

The base class takes care of controlling the transformations between BusinessObject, XMLStreamReader and SOAPElement A derived class must minimally define the following: _getBOFromReader _getReaderFromBO _outputFromBO

In addtion, the derived class may want to override the following: _getBOFromBO ...if the BusinessObject is consumed when read (i.e. it is an InputSource)

The derived classes don't have direct access to the instance data. This ensures that BlockImpl controls the transformations.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected C
     
    protected T
     
    protected boolean
     
    protected BlockFactory
     
    protected org.apache.axiom.om.OMElement
     
    protected Message
     
    protected QName
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BlockImpl(C busContext, org.apache.axiom.om.OMElement omElement, QName qName, BlockFactory factory)
     
    protected
    BlockImpl(org.apache.axiom.om.OMElement omElement, C busContext, QName qName, BlockFactory factory)
    A Block has the following components
    protected
    BlockImpl(T busObject, C busContext, QName qName, BlockFactory factory)
    A Block has the following components
  • Method Summary

    Modifier and Type
    Method
    Description
    protected T
    _getBOFromBO(T busObject, C busContext, boolean consume)
    The default implementation is to return the business object.
    protected abstract T
    _getBOFromOM(org.apache.axiom.om.OMElement omElement, C busContext)
    Default method for getting business object from OM.
    protected org.apache.axiom.om.OMElement
    _getOMFromBO(T busObject, C busContext)
     
    protected abstract XMLStreamReader
    _getReaderFromBO(T busObj, C busContext)
    Get an XMLStreamReader for the BusinessObject The derived Block must implement this method
    protected abstract void
    _outputFromBO(T busObject, C busContext, XMLStreamWriter writer)
    Output BusinessObject contents to a Writer.
    protected final void
    _outputFromOM(org.apache.axiom.om.OMElement omElement, XMLStreamWriter writer, boolean consume)
    Output OMElement contents to a Writer.
    protected final void
    Output Reader contents to a Writer.
    protected final XMLStreamReader
    Called if we have passed the pivot point but someone wants to output the block.
    protected final void
    Called if we have passed the pivot point but someone wants to output the block.
    org.apache.axiom.om.OMDataSourceExt
     
    Get BlockFactory
    final Object
    GetBusinesContext Some business objects have an associated context object (i.e.
    final T
    getBusinessObject(boolean consume)
    Get a reference to the Business Object represented by this Block
    org.apache.axiom.om.OMElement
    Get the OMElement represented by this Block.
    final Message
    Get the Message associated with this block
    final QName
    Get the QName (namespace, localpart) of the Block.
     
    getXMLStreamReader(boolean consume)
    Get the XMLStreamReader represented by this Block
    protected final boolean
     
    final boolean
    isConsumed Return true if the block is consumed.
    final boolean
     
    final void
    outputTo(XMLStreamWriter writer, boolean consume)
    Write out the Block
    final void
     
    final void
    setConsumed(boolean consume)
    Once consumed, all instance data objects are nullified to prevent subsequent access
    void
    Set the Message associated with this block (This method is intended to be called by the Message Implementation only)
    protected final void
    setQName(QName qName)
    This method is intended for derived objects to set the qName
    final String
    Get a traceString...the trace string dumps the contents of the Block without forcing an underlying ill-performant transformation of the message.

    Methods inherited from class org.apache.axiom.om.ds.AbstractOMDataSource

    close, getObject, getProperty, getXMLBytes, getXMLInputStream, hasProperty, serialize, serialize, setProperty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.axis2.jaxws.message.Block

    isElementData

    Methods inherited from interface org.apache.axiom.om.OMDataSource

    serialize, serialize

    Methods inherited from interface org.apache.axiom.om.OMDataSourceExt

    close, getObject, getProperty, getXMLBytes, getXMLInputStream, hasProperty, isDestructiveRead, isDestructiveWrite, setProperty
  • Field Details

    • busObject

      protected T busObject
    • busContext

      protected C busContext
    • omElement

      protected org.apache.axiom.om.OMElement omElement
    • qName

      protected QName qName
    • factory

      protected BlockFactory factory
    • consumed

      protected boolean consumed
    • parent

      protected Message parent
  • Constructor Details

    • BlockImpl

      protected BlockImpl(T busObject, C busContext, QName qName, BlockFactory factory)
      A Block has the following components
      Parameters:
      busObject -
      busContext - or null
      qName - or null if unknown
      factory - that creates the Block
    • BlockImpl

      protected BlockImpl(org.apache.axiom.om.OMElement omElement, C busContext, QName qName, BlockFactory factory)
      A Block has the following components
      Parameters:
      reader -
      busContext - or null
      qName - or null if unknown
      factory - that creates the Block
    • BlockImpl

      protected BlockImpl(C busContext, org.apache.axiom.om.OMElement omElement, QName qName, BlockFactory factory)
  • Method Details

    • getBlockFactory

      public final BlockFactory getBlockFactory()
      Description copied from interface: Block
      Get BlockFactory
      Specified by:
      getBlockFactory in interface Block<T,C>
      Returns:
      BlockFactory that created the Block
    • getBusinessContext

      public final Object getBusinessContext()
      Description copied from interface: Block
      GetBusinesContext Some business objects have an associated context object (i.e. JAXBContext)
      Specified by:
      getBusinessContext in interface Block<T,C>
      Returns:
      Context Object or null
    • getParent

      public final Message getParent()
      Description copied from interface: Block
      Get the Message associated with this block
      Specified by:
      getParent in interface Block<T,C>
      Returns:
      Message
    • setParent

      public void setParent(Message p)
      Description copied from interface: Block
      Set the Message associated with this block (This method is intended to be called by the Message Implementation only)
      Specified by:
      setParent in interface Block<T,C>
    • getBusinessObject

      public final T getBusinessObject(boolean consume) throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Description copied from interface: Block
      Get a reference to the Business Object represented by this Block
      Specified by:
      getBusinessObject in interface Block<T,C>
      Parameters:
      consume - true if this is the last request on the block.
      Returns:
      Object (JAXB, String etc.)
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • getQName

      public final QName getQName() throws jakarta.xml.ws.WebServiceException
      Description copied from interface: Block
      Get the QName (namespace, localpart) of the Block. Do not depend on prefix being set correctly. Asking for the QName can cause a performant hit.
      Specified by:
      getQName in interface Block<T,C>
      Returns:
      QName of the block
      Throws:
      jakarta.xml.ws.WebServiceException
      See Also:
    • setQName

      protected final void setQName(QName qName)
      This method is intended for derived objects to set the qName
      Parameters:
      qName -
    • getXMLStreamReader

      public final XMLStreamReader getXMLStreamReader(boolean consume) throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Description copied from interface: Block
      Get the XMLStreamReader represented by this Block
      Specified by:
      getXMLStreamReader in interface Block<T,C>
      Parameters:
      consume - true if this is the last request on the block.
      Returns:
      XMLStreamReader
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • getReader

      public final XMLStreamReader getReader() throws XMLStreamException
      Specified by:
      getReader in interface org.apache.axiom.om.OMDataSource
      Throws:
      XMLStreamException
    • serialize

      public final void serialize(XMLStreamWriter writer) throws XMLStreamException
      Specified by:
      serialize in interface org.apache.axiom.om.OMDataSource
      Throws:
      XMLStreamException
    • getOMElement

      public org.apache.axiom.om.OMElement getOMElement() throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Description copied from interface: Block
      Get the OMElement represented by this Block. This call always consumes the block because you are taking control of the underlying OM
      Specified by:
      getOMElement in interface Block<T,C>
      Returns:
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • isConsumed

      public final boolean isConsumed()
      Description copied from interface: Block
      isConsumed Return true if the block is consumed. Once consumed, the information in the block is no longer available.
      Specified by:
      isConsumed in interface Block<T,C>
      Returns:
      true if the block is consumed (a method was called with consume=true)
    • setConsumed

      public final void setConsumed(boolean consume)
      Once consumed, all instance data objects are nullified to prevent subsequent access
      Parameters:
      consume -
    • isQNameAvailable

      public final boolean isQNameAvailable()
      Specified by:
      isQNameAvailable in interface Block<T,C>
      Returns:
      If QName is available without doing an expensive parse of the business object, then return true Otherwise return false Note: This method should be used in situations where it would be nice to know the qname (like logging or a special check) but we don't want to cause an ill-performant parse.
    • outputTo

      public final void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Description copied from interface: Block
      Write out the Block
      Specified by:
      outputTo in interface Block<T,C>
      Parameters:
      writer - XMLStreamWriter
      consume - true if this is the last request on the block.
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • _postPivot_outputTo

      protected final void _postPivot_outputTo(XMLStreamWriter writer) throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Called if we have passed the pivot point but someone wants to output the block. The actual block implementation may choose to override this setting
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • _postPivot_getXMLStreamReader

      protected final XMLStreamReader _postPivot_getXMLStreamReader() throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Called if we have passed the pivot point but someone wants to output the block. The actual block implementation may choose to override this setting.
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • isBusinessObject

      protected final boolean isBusinessObject()
      Returns:
      true if the representation of the block is currently a business object. Derived classes may use this information to get information in a performant way.
    • traceString

      public final String traceString(String indent)
      Description copied from interface: Block
      Get a traceString...the trace string dumps the contents of the Block without forcing an underlying ill-performant transformation of the message.
      Specified by:
      traceString in interface Block<T,C>
      Returns:
      String containing trace information
    • _getBOFromBO

      protected T _getBOFromBO(T busObject, C busContext, boolean consume)
      The default implementation is to return the business object. A derived block may want to override this class if the business object is consumed when read (thus the dervived block may want to make a buffered copy) (An example use case for overriding this method is the businessObject is an InputSource)
      Parameters:
      busObject -
      busContext -
      consume -
      Returns:
    • _getBOFromOM

      protected abstract T _getBOFromOM(org.apache.axiom.om.OMElement omElement, C busContext) throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Default method for getting business object from OM. Derived classes may override this method to get the business object from a data source.
      Parameters:
      om -
      busContext -
      Returns:
      Business Object
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • _getReaderFromBO

      protected abstract XMLStreamReader _getReaderFromBO(T busObj, C busContext) throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Get an XMLStreamReader for the BusinessObject The derived Block must implement this method
      Parameters:
      busObj -
      busContext -
      Returns:
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • _getOMFromBO

      protected org.apache.axiom.om.OMElement _getOMFromBO(T busObject, C busContext) throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Parameters:
      busObject -
      busContext -
      Returns:
      OMElement
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException
    • _outputFromReader

      protected final void _outputFromReader(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException
      Output Reader contents to a Writer. The default implementation is probably sufficient for most derived classes.
      Parameters:
      reader -
      writer -
      Throws:
      XMLStreamException
    • _outputFromOM

      protected final void _outputFromOM(org.apache.axiom.om.OMElement omElement, XMLStreamWriter writer, boolean consume) throws XMLStreamException
      Output OMElement contents to a Writer. The default implementation is probably sufficient for most derived classes.
      Parameters:
      om -
      writer -
      Throws:
      XMLStreamException
    • copy

      public org.apache.axiom.om.OMDataSourceExt copy() throws org.apache.axiom.om.OMException
      Specified by:
      copy in interface org.apache.axiom.om.OMDataSourceExt
      Overrides:
      copy in class org.apache.axiom.om.ds.AbstractOMDataSource
      Throws:
      org.apache.axiom.om.OMException
    • _outputFromBO

      protected abstract void _outputFromBO(T busObject, C busContext, XMLStreamWriter writer) throws XMLStreamException, jakarta.xml.ws.WebServiceException
      Output BusinessObject contents to a Writer. Derived classes must provide this implementation
      Parameters:
      busObject -
      busContext -
      writer -
      Throws:
      XMLStreamException
      jakarta.xml.ws.WebServiceException