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 protectedBlockImpl(C busContext, OMElement omElement, QName qName, BlockFactory factory)protectedBlockImpl(OMElement omElement, C busContext, QName qName, BlockFactory factory)A Block has the following componentsprotectedBlockImpl(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.OMDataSourceExtcopy()BlockFactorygetBlockFactory()Get BlockFactoryObjectgetBusinessContext()GetBusinesContext Some business objects have an associated context object (i.e.TgetBusinessObject(boolean consume)Get a reference to the Business Object represented by this BlockOMElementgetOMElement()Get the OMElement represented by this Block.MessagegetParent()Get the Message associated with this blockQNamegetQName()Get the QName (namespace, localpart) of the Block.XMLStreamReadergetReader()XMLStreamReadergetXMLStreamReader(boolean consume)Get the XMLStreamReader represented by this Blockprotected booleanisBusinessObject()booleanisConsumed()isConsumed Return true if the block is consumed.booleanisQNameAvailable()voidoutputTo(XMLStreamWriter writer, boolean consume)Write out the Blockvoidserialize(XMLStreamWriter writer)voidsetConsumed(boolean consume)Once consumed, all instance data objects are nullified to prevent subsequent accessvoidsetParent(Message p)Set the Message associated with this block (This method is intended to be called by the Message Implementation only)protected voidsetQName(QName qName)This method is intended for derived objects to set the qNameStringtraceString(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:BlockGet BlockFactory- Specified by:
getBlockFactoryin interfaceBlock<T,C>- Returns:
- BlockFactory that created the Block
-
getBusinessContext
public final Object getBusinessContext()
Description copied from interface:BlockGetBusinesContext Some business objects have an associated context object (i.e. JAXBContext)- Specified by:
getBusinessContextin interfaceBlock<T,C>- Returns:
- Context Object or null
-
getParent
public final Message getParent()
Description copied from interface:BlockGet the Message associated with this block
-
setParent
public void setParent(Message p)
Description copied from interface:BlockSet 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:BlockGet a reference to the Business Object represented by this Block- Specified by:
getBusinessObjectin interfaceBlock<T,C>- Parameters:
consume- true if this is the last request on the block.- Returns:
- Object (JAXB, String etc.)
- Throws:
XMLStreamExceptionWebServiceException
-
getQName
public final QName getQName() throws WebServiceException
Description copied from interface:BlockGet 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:
getQNamein 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:BlockGet the XMLStreamReader represented by this Block- Specified by:
getXMLStreamReaderin interfaceBlock<T,C>- Parameters:
consume- true if this is the last request on the block.- Returns:
- XMLStreamReader
- Throws:
XMLStreamExceptionWebServiceException
-
getReader
public final XMLStreamReader getReader() throws XMLStreamException
- Specified by:
getReaderin interfaceOMDataSource- Throws:
XMLStreamException
-
serialize
public final void serialize(XMLStreamWriter writer) throws XMLStreamException
- Specified by:
serializein interfaceOMDataSource- Throws:
XMLStreamException
-
getOMElement
public OMElement getOMElement() throws XMLStreamException, WebServiceException
Description copied from interface:BlockGet the OMElement represented by this Block. This call always consumes the block because you are taking control of the underlying OM- Specified by:
getOMElementin interfaceBlock<T,C>- Returns:
- Throws:
XMLStreamExceptionWebServiceException
-
isConsumed
public final boolean isConsumed()
Description copied from interface:BlockisConsumed Return true if the block is consumed. Once consumed, the information in the block is no longer available.- Specified by:
isConsumedin 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:
isQNameAvailablein 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:BlockWrite out the Block- Specified by:
outputToin interfaceBlock<T,C>- Parameters:
writer- XMLStreamWriterconsume- true if this is the last request on the block.- Throws:
XMLStreamExceptionWebServiceException
-
_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:BlockGet a traceString...the trace string dumps the contents of the Block without forcing an underlying ill-performant transformation of the message.- Specified by:
traceStringin 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:
XMLStreamExceptionWebServiceException
-
_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:
XMLStreamExceptionWebServiceException
-
_getOMFromBO
protected OMElement _getOMFromBO(T busObject, C busContext) throws XMLStreamException, WebServiceException
- Parameters:
busObject-busContext-- Returns:
- OMElement
- Throws:
XMLStreamExceptionWebServiceException
-
_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:
copyin interfaceOMDataSourceExt- Overrides:
copyin 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:
XMLStreamExceptionWebServiceException
-
-