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:
OMDataSource
,OMDataSourceExt
,Block<T,C>
- Direct Known Subclasses:
DataSourceBlockImpl
,JAXBBlockImpl
,OMBlockImpl
,SOAPEnvelopeBlockImpl
,SourceBlockImpl
,XMLStringBlockImpl
public abstract class BlockImpl<T,C> extends 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.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BlockImpl(C busContext, OMElement omElement, QName qName, BlockFactory factory)
protected
BlockImpl(OMElement omElement, C busContext, QName qName, BlockFactory factory)
A Block has the following componentsprotected
BlockImpl(T busObject, C busContext, QName qName, BlockFactory factory)
A Block has the following components
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods 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(OMElement omElement, C busContext)
Default method for getting business object from OM.protected 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 methodprotected abstract void
_outputFromBO(T busObject, C busContext, XMLStreamWriter writer)
Output BusinessObject contents to a Writer.protected void
_outputFromOM(OMElement omElement, XMLStreamWriter writer, boolean consume)
Output OMElement contents to a Writer.protected void
_outputFromReader(XMLStreamReader reader, XMLStreamWriter writer)
Output Reader contents to a Writer.protected XMLStreamReader
_postPivot_getXMLStreamReader()
Called if we have passed the pivot point but someone wants to output the block.protected void
_postPivot_outputTo(XMLStreamWriter writer)
Called if we have passed the pivot point but someone wants to output the block.OMDataSourceExt
copy()
BlockFactory
getBlockFactory()
Get BlockFactoryObject
getBusinessContext()
GetBusinesContext Some business objects have an associated context object (i.e.T
getBusinessObject(boolean consume)
Get a reference to the Business Object represented by this BlockOMElement
getOMElement()
Get the OMElement represented by this Block.Message
getParent()
Get the Message associated with this blockQName
getQName()
Get the QName (namespace, localpart) of the Block.XMLStreamReader
getReader()
XMLStreamReader
getXMLStreamReader(boolean consume)
Get the XMLStreamReader represented by this Blockprotected boolean
isBusinessObject()
boolean
isConsumed()
isConsumed Return true if the block is consumed.boolean
isQNameAvailable()
void
outputTo(XMLStreamWriter writer, boolean consume)
Write out the Blockvoid
serialize(XMLStreamWriter writer)
void
setConsumed(boolean consume)
Once consumed, all instance data objects are nullified to prevent subsequent accessvoid
setParent(Message p)
Set the Message associated with this block (This method is intended to be called by the Message Implementation only)protected void
setQName(QName qName)
This method is intended for derived objects to set the qNameString
traceString(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 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
-
-
-
-
Constructor Detail
-
BlockImpl
protected BlockImpl(T busObject, C busContext, QName qName, BlockFactory factory)
A Block has the following components- Parameters:
busObject
-busContext
- or nullqName
- or null if unknownfactory
- that creates the Block
-
BlockImpl
protected BlockImpl(OMElement omElement, C busContext, QName qName, BlockFactory factory)
A Block has the following components- Parameters:
reader
-busContext
- or nullqName
- or null if unknownfactory
- that creates the Block
-
BlockImpl
protected BlockImpl(C busContext, OMElement omElement, QName qName, BlockFactory factory)
-
-
Method Detail
-
getBlockFactory
public final BlockFactory getBlockFactory()
Description copied from interface:Block
Get BlockFactory- Specified by:
getBlockFactory
in interfaceBlock<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 interfaceBlock<T,C>
- Returns:
- Context Object or null
-
getParent
public final Message getParent()
Description copied from interface:Block
Get the Message associated with this block
-
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)
-
getBusinessObject
public final T getBusinessObject(boolean consume) throws XMLStreamException, WebServiceException
Description copied from interface:Block
Get a reference to the Business Object represented by this Block- Specified by:
getBusinessObject
in interfaceBlock<T,C>
- Parameters:
consume
- true if this is the last request on the block.- Returns:
- Object (JAXB, String etc.)
- Throws:
XMLStreamException
WebServiceException
-
getQName
public final 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 interfaceBlock<T,C>
- Returns:
- QName of the block
- Throws:
WebServiceException
- See Also:
Block.isQNameAvailable()
-
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, WebServiceException
Description copied from interface:Block
Get the XMLStreamReader represented by this Block- Specified by:
getXMLStreamReader
in interfaceBlock<T,C>
- Parameters:
consume
- true if this is the last request on the block.- Returns:
- XMLStreamReader
- Throws:
XMLStreamException
WebServiceException
-
getReader
public final XMLStreamReader getReader() throws XMLStreamException
- Specified by:
getReader
in interfaceOMDataSource
- Throws:
XMLStreamException
-
serialize
public final void serialize(XMLStreamWriter writer) throws XMLStreamException
- Specified by:
serialize
in interfaceOMDataSource
- Throws:
XMLStreamException
-
getOMElement
public OMElement getOMElement() throws 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 interfaceBlock<T,C>
- Returns:
- Throws:
XMLStreamException
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 interfaceBlock<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 interfaceBlock<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, WebServiceException
Description copied from interface:Block
Write out the Block- Specified by:
outputTo
in interfaceBlock<T,C>
- Parameters:
writer
- XMLStreamWriterconsume
- true if this is the last request on the block.- Throws:
XMLStreamException
WebServiceException
-
_postPivot_outputTo
protected final void _postPivot_outputTo(XMLStreamWriter writer) throws 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
-
_postPivot_getXMLStreamReader
protected final XMLStreamReader _postPivot_getXMLStreamReader() throws 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.
-
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 interfaceBlock<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(OMElement omElement, C busContext) throws 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:
XMLStreamException
WebServiceException
-
_getReaderFromBO
protected abstract XMLStreamReader _getReaderFromBO(T busObj, C busContext) throws XMLStreamException, WebServiceException
Get an XMLStreamReader for the BusinessObject The derived Block must implement this method- Parameters:
busObj
-busContext
-- Returns:
- Throws:
XMLStreamException
WebServiceException
-
_getOMFromBO
protected OMElement _getOMFromBO(T busObject, C busContext) throws XMLStreamException, WebServiceException
- Parameters:
busObject
-busContext
-- Returns:
- OMElement
- Throws:
XMLStreamException
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(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 OMDataSourceExt copy() throws OMException
- Specified by:
copy
in interfaceOMDataSourceExt
- Overrides:
copy
in classAbstractOMDataSource
- Throws:
OMException
-
_outputFromBO
protected abstract void _outputFromBO(T busObject, C busContext, XMLStreamWriter writer) throws XMLStreamException, WebServiceException
Output BusinessObject contents to a Writer. Derived classes must provide this implementation- Parameters:
busObject
-busContext
-writer
-- Throws:
XMLStreamException
WebServiceException
-
-