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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlockImpl(C busContext, org.apache.axiom.om.OMElement omElement, QName qName, BlockFactory factory) protectedBlockImpl(org.apache.axiom.om.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
Modifier and TypeMethodDescriptionprotected 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 methodprotected 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_outputFromReader(XMLStreamReader reader, XMLStreamWriter writer) Output Reader contents to a Writer.protected final XMLStreamReaderCalled if we have passed the pivot point but someone wants to output the block.protected final void_postPivot_outputTo(XMLStreamWriter writer) Called if we have passed the pivot point but someone wants to output the block.org.apache.axiom.om.OMDataSourceExtcopy()final BlockFactoryGet BlockFactoryfinal ObjectGetBusinesContext Some business objects have an associated context object (i.e.final TgetBusinessObject(boolean consume) Get a reference to the Business Object represented by this Blockorg.apache.axiom.om.OMElementGet the OMElement represented by this Block.final MessageGet the Message associated with this blockfinal QNamegetQName()Get the QName (namespace, localpart) of the Block.final XMLStreamReaderfinal XMLStreamReadergetXMLStreamReader(boolean consume) Get the XMLStreamReader represented by this Blockprotected final booleanfinal booleanisConsumed Return true if the block is consumed.final booleanfinal voidoutputTo(XMLStreamWriter writer, boolean consume) Write out the Blockfinal voidserialize(XMLStreamWriter writer) final voidsetConsumed(boolean consume) Once consumed, all instance data objects are nullified to prevent subsequent accessvoidSet the Message associated with this block (This method is intended to be called by the Message Implementation only)protected final voidThis method is intended for derived objects to set the qNamefinal StringtraceString(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, setPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.axis2.jaxws.message.Block
isElementDataMethods inherited from interface org.apache.axiom.om.OMDataSource
serialize, serializeMethods inherited from interface org.apache.axiom.om.OMDataSourceExt
close, getObject, getProperty, getXMLBytes, getXMLInputStream, hasProperty, isDestructiveRead, isDestructiveWrite, setProperty
-
Field Details
-
busObject
-
busContext
-
omElement
protected org.apache.axiom.om.OMElement omElement -
qName
-
factory
-
consumed
protected boolean consumed -
parent
-
-
Constructor Details
-
BlockImpl
A Block has the following components- Parameters:
busObject-busContext- or nullqName- or null if unknownfactory- 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 nullqName- or null if unknownfactory- that creates the Block
-
BlockImpl
protected BlockImpl(C busContext, org.apache.axiom.om.OMElement omElement, QName qName, BlockFactory factory)
-
-
Method Details
-
getBlockFactory
Description copied from interface:BlockGet BlockFactory- Specified by:
getBlockFactoryin interfaceBlock<T,C> - Returns:
- BlockFactory that created the Block
-
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
Description copied from interface:BlockGet the Message associated with this block -
setParent
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, jakarta.xml.ws.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:
XMLStreamExceptionjakarta.xml.ws.WebServiceException
-
getQName
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. -
setQName
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: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:
XMLStreamExceptionjakarta.xml.ws.WebServiceException
-
getReader
- Specified by:
getReaderin interfaceorg.apache.axiom.om.OMDataSource- Throws:
XMLStreamException
-
serialize
- Specified by:
serializein interfaceorg.apache.axiom.om.OMDataSource- Throws:
XMLStreamException
-
getOMElement
public org.apache.axiom.om.OMElement getOMElement() throws XMLStreamException, jakarta.xml.ws.WebServiceExceptionDescription 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:
XMLStreamExceptionjakarta.xml.ws.WebServiceException
-
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, jakarta.xml.ws.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:
XMLStreamExceptionjakarta.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:
XMLStreamExceptionjakarta.xml.ws.WebServiceException
-
_postPivot_getXMLStreamReader
protected final XMLStreamReader _postPivot_getXMLStreamReader() throws XMLStreamException, jakarta.xml.ws.WebServiceExceptionCalled 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:
XMLStreamExceptionjakarta.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
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
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:
XMLStreamExceptionjakarta.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:
XMLStreamExceptionjakarta.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:
XMLStreamExceptionjakarta.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:
copyin interfaceorg.apache.axiom.om.OMDataSourceExt- Overrides:
copyin classorg.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:
XMLStreamExceptionjakarta.xml.ws.WebServiceException
-