org.apache.axis2.jaxws.message.impl
Class BlockImpl

java.lang.Object
  extended by org.apache.axis2.jaxws.message.impl.BlockImpl
All Implemented Interfaces:
org.apache.axiom.om.OMDataSource, org.apache.axiom.om.OMDataSourceExt, Block
Direct Known Subclasses:
JAXBBlockImpl, OMBlockImpl, SOAPEnvelopeBlockImpl, SourceBlockImpl, XMLStringBlockImpl

public abstract class BlockImpl
extends java.lang.Object
implements Block

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
protected  java.lang.Object busContext
           
protected  java.lang.Object busObject
           
protected  boolean consumed
           
protected  BlockFactory factory
           
protected  org.apache.axiom.om.OMElement omElement
           
protected  Message parent
           
protected  QName qName
           
 
Constructor Summary
protected BlockImpl(java.lang.Object busObject, java.lang.Object busContext, QName qName, BlockFactory factory)
          A Block has the following components
protected BlockImpl(org.apache.axiom.om.OMElement omElement, java.lang.Object busContext, QName qName, BlockFactory factory)
          A Block has the following components
 
Method Summary
protected  java.lang.Object _getBOFromBO(java.lang.Object busObject, java.lang.Object busContext, boolean consume)
          The default implementation is to return the business object.
protected  java.lang.Object _getBOFromOM(org.apache.axiom.om.OMElement omElement, java.lang.Object busContext)
          Default method for getting business object from OM.
protected abstract  java.lang.Object _getBOFromReader(javax.xml.stream.XMLStreamReader reader, java.lang.Object busContext)
          The derived class must provide an implementation that builds the business object from the reader
protected  org.apache.axiom.om.OMElement _getOMFromBO(java.lang.Object busObject, java.lang.Object busContext)
           
protected abstract  javax.xml.stream.XMLStreamReader _getReaderFromBO(java.lang.Object busObj, java.lang.Object busContext)
          Get an XMLStreamReader for the BusinessObject The derived Block must implement this method
protected  javax.xml.stream.XMLStreamReader _getReaderFromOM(org.apache.axiom.om.OMElement omElement)
           
protected abstract  void _outputFromBO(java.lang.Object busObject, java.lang.Object busContext, javax.xml.stream.XMLStreamWriter writer)
          Output BusinessObject contents to a Writer.
protected  void _outputFromOM(org.apache.axiom.om.OMElement omElement, javax.xml.stream.XMLStreamWriter writer, boolean consume)
          Output OMElement contents to a Writer.
protected  void _outputFromReader(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.XMLStreamWriter writer)
          Output Reader contents to a Writer.
protected  javax.xml.stream.XMLStreamReader _postPivot_getXMLStreamReader()
          Called if we have passed the pivot point but someone wants to output the block.
protected  void _postPivot_outputTo(javax.xml.stream.XMLStreamWriter writer)
          Called if we have passed the pivot point but someone wants to output the block.
 org.apache.axiom.om.OMDataSourceExt copy()
           
 BlockFactory getBlockFactory()
          Get BlockFactory
 java.lang.Object getBusinessContext()
          GetBusinesContext Some business objects have an associated context object (i.e.
 java.lang.Object getBusinessObject(boolean consume)
          Get a reference to the Business Object represented by this Block
 org.apache.axiom.om.OMElement getOMElement()
          Get the OMElement represented by this Block.
 Message getParent()
          Get the Message associated with this block
 java.lang.Object getProperty(java.lang.String key)
           
 QName getQName()
          Get the QName (namespace, localpart) of the Block.
 javax.xml.stream.XMLStreamReader getReader()
           
 javax.xml.stream.XMLStreamReader getXMLStreamReader(boolean consume)
          Get the XMLStreamReader represented by this Block
 boolean hasProperty(java.lang.String key)
           
protected  boolean isBusinessObject()
           
 boolean isConsumed()
          isConsumed Return true if the block is consumed.
 boolean isQNameAvailable()
           
 void outputTo(javax.xml.stream.XMLStreamWriter writer, boolean consume)
          Write out the Block
 void serialize(java.io.OutputStream output, org.apache.axiom.om.OMOutputFormat format)
           
 void serialize(java.io.Writer writerTarget, org.apache.axiom.om.OMOutputFormat format)
           
 void serialize(javax.xml.stream.XMLStreamWriter writer)
           
 void setConsumed(boolean consume)
          Once consumed, all instance data objects are nullified to prevent subsequent access
 void setParent(Message p)
          Set the Message associated with this block (This method is intended to be called by the Message Implementation only)
 java.lang.Object setProperty(java.lang.String key, java.lang.Object value)
           
protected  void setQName(QName qName)
          This method is intended for derived objects to set the qName
 java.lang.String traceString(java.lang.String indent)
          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 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.OMDataSourceExt
close, getObject, getXMLBytes, getXMLInputStream, isDestructiveRead, isDestructiveWrite
 

Field Detail

busObject

protected java.lang.Object busObject

busContext

protected java.lang.Object 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 Detail

BlockImpl

protected BlockImpl(java.lang.Object busObject,
                    java.lang.Object 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,
                    java.lang.Object 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
Method Detail

getBlockFactory

public BlockFactory getBlockFactory()
Description copied from interface: Block
Get BlockFactory

Specified by:
getBlockFactory in interface Block
Returns:
BlockFactory that created the Block

getBusinessContext

public java.lang.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
Returns:
Context Object or null

getParent

public Message getParent()
Description copied from interface: Block
Get the Message associated with this block

Specified by:
getParent in interface Block
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

getBusinessObject

public java.lang.Object getBusinessObject(boolean consume)
                                   throws javax.xml.stream.XMLStreamException,
                                          WebServiceException
Description copied from interface: Block
Get a reference to the Business Object represented by this Block

Specified by:
getBusinessObject in interface Block
Parameters:
consume - true if this is the last request on the block.
Returns:
Object (JAXB, String etc.)
Throws:
javax.xml.stream.XMLStreamException
WebServiceException

getQName

public QName getQName()
               throws 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
Returns:
QName of the block
Throws:
WebServiceException
See Also:
isQNameAvailable

setQName

protected void setQName(QName qName)
This method is intended for derived objects to set the qName

Parameters:
qName -

getXMLStreamReader

public javax.xml.stream.XMLStreamReader getXMLStreamReader(boolean consume)
                                                    throws javax.xml.stream.XMLStreamException,
                                                           WebServiceException
Description copied from interface: Block
Get the XMLStreamReader represented by this Block

Specified by:
getXMLStreamReader in interface Block
Parameters:
consume - true if this is the last request on the block.
Returns:
XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException
WebServiceException

getReader

public javax.xml.stream.XMLStreamReader getReader()
                                           throws javax.xml.stream.XMLStreamException
Specified by:
getReader in interface org.apache.axiom.om.OMDataSource
Specified by:
getReader in interface org.apache.axiom.om.OMDataSourceExt
Throws:
javax.xml.stream.XMLStreamException

serialize

public void serialize(java.io.OutputStream output,
                      org.apache.axiom.om.OMOutputFormat format)
               throws javax.xml.stream.XMLStreamException
Specified by:
serialize in interface org.apache.axiom.om.OMDataSource
Specified by:
serialize in interface org.apache.axiom.om.OMDataSourceExt
Throws:
javax.xml.stream.XMLStreamException

serialize

public void serialize(java.io.Writer writerTarget,
                      org.apache.axiom.om.OMOutputFormat format)
               throws javax.xml.stream.XMLStreamException
Specified by:
serialize in interface org.apache.axiom.om.OMDataSource
Specified by:
serialize in interface org.apache.axiom.om.OMDataSourceExt
Throws:
javax.xml.stream.XMLStreamException

serialize

public void serialize(javax.xml.stream.XMLStreamWriter writer)
               throws javax.xml.stream.XMLStreamException
Specified by:
serialize in interface org.apache.axiom.om.OMDataSource
Specified by:
serialize in interface org.apache.axiom.om.OMDataSourceExt
Throws:
javax.xml.stream.XMLStreamException

getOMElement

public org.apache.axiom.om.OMElement getOMElement()
                                           throws javax.xml.stream.XMLStreamException,
                                                  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
Returns:
Throws:
javax.xml.stream.XMLStreamException
WebServiceException

isConsumed

public 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
Returns:
true if the block is consumed (a method was called with consume=true)

setConsumed

public void setConsumed(boolean consume)
Once consumed, all instance data objects are nullified to prevent subsequent access

Parameters:
consume -

isQNameAvailable

public boolean isQNameAvailable()
Specified by:
isQNameAvailable in interface Block
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 void outputTo(javax.xml.stream.XMLStreamWriter writer,
                     boolean consume)
              throws javax.xml.stream.XMLStreamException,
                     WebServiceException
Description copied from interface: Block
Write out the Block

Specified by:
outputTo in interface Block
Parameters:
writer - XMLStreamWriter
consume - true if this is the last request on the block.
Throws:
javax.xml.stream.XMLStreamException
WebServiceException

_postPivot_outputTo

protected void _postPivot_outputTo(javax.xml.stream.XMLStreamWriter writer)
                            throws javax.xml.stream.XMLStreamException,
                                   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:
javax.xml.stream.XMLStreamException
WebServiceException

_postPivot_getXMLStreamReader

protected javax.xml.stream.XMLStreamReader _postPivot_getXMLStreamReader()
                                                                  throws javax.xml.stream.XMLStreamException,
                                                                         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:
javax.xml.stream.XMLStreamException
WebServiceException

isBusinessObject

protected 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 java.lang.String traceString(java.lang.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
Returns:
String containing trace information

_getBOFromBO

protected java.lang.Object _getBOFromBO(java.lang.Object busObject,
                                        java.lang.Object 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:

_getBOFromReader

protected abstract java.lang.Object _getBOFromReader(javax.xml.stream.XMLStreamReader reader,
                                                     java.lang.Object busContext)
                                              throws javax.xml.stream.XMLStreamException,
                                                     WebServiceException
The derived class must provide an implementation that builds the business object from the reader

Parameters:
reader - XMLStreamReader, which is consumed
busContext -
Returns:
Throws:
javax.xml.stream.XMLStreamException
WebServiceException

_getBOFromOM

protected java.lang.Object _getBOFromOM(org.apache.axiom.om.OMElement omElement,
                                        java.lang.Object busContext)
                                 throws javax.xml.stream.XMLStreamException,
                                        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:
javax.xml.stream.XMLStreamException
WebServiceException

_getReaderFromBO

protected abstract javax.xml.stream.XMLStreamReader _getReaderFromBO(java.lang.Object busObj,
                                                                     java.lang.Object busContext)
                                                              throws javax.xml.stream.XMLStreamException,
                                                                     WebServiceException
Get an XMLStreamReader for the BusinessObject The derived Block must implement this method

Parameters:
busObj -
busContext -
Returns:
Throws:
javax.xml.stream.XMLStreamException
WebServiceException

_getReaderFromOM

protected javax.xml.stream.XMLStreamReader _getReaderFromOM(org.apache.axiom.om.OMElement omElement)
Parameters:
omElement -
Returns:
XMLStreamReader

_getOMFromBO

protected org.apache.axiom.om.OMElement _getOMFromBO(java.lang.Object busObject,
                                                     java.lang.Object busContext)
                                              throws javax.xml.stream.XMLStreamException,
                                                     WebServiceException
Parameters:
busObject -
busContext -
Returns:
OMElement
Throws:
javax.xml.stream.XMLStreamException
WebServiceException

_outputFromReader

protected void _outputFromReader(javax.xml.stream.XMLStreamReader reader,
                                 javax.xml.stream.XMLStreamWriter writer)
                          throws javax.xml.stream.XMLStreamException
Output Reader contents to a Writer. The default implementation is probably sufficient for most derived classes.

Parameters:
reader -
writer -
Throws:
javax.xml.stream.XMLStreamException

_outputFromOM

protected void _outputFromOM(org.apache.axiom.om.OMElement omElement,
                             javax.xml.stream.XMLStreamWriter writer,
                             boolean consume)
                      throws javax.xml.stream.XMLStreamException
Output OMElement contents to a Writer. The default implementation is probably sufficient for most derived classes.

Parameters:
om -
writer -
Throws:
javax.xml.stream.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
Throws:
org.apache.axiom.om.OMException

_outputFromBO

protected abstract void _outputFromBO(java.lang.Object busObject,
                                      java.lang.Object busContext,
                                      javax.xml.stream.XMLStreamWriter writer)
                               throws javax.xml.stream.XMLStreamException,
                                      WebServiceException
Output BusinessObject contents to a Writer. Derived classes must provide this implementation

Parameters:
busObject -
busContext -
writer -
Throws:
javax.xml.stream.XMLStreamException
WebServiceException

getProperty

public java.lang.Object getProperty(java.lang.String key)
Specified by:
getProperty in interface org.apache.axiom.om.OMDataSourceExt

setProperty

public java.lang.Object setProperty(java.lang.String key,
                                    java.lang.Object value)
Specified by:
setProperty in interface org.apache.axiom.om.OMDataSourceExt

hasProperty

public boolean hasProperty(java.lang.String key)
Specified by:
hasProperty in interface org.apache.axiom.om.OMDataSourceExt


Copyright © 2007 Apache Web Services Project. All Rights Reserved.