Package org.apache.axis2.json
Class AbstractJSONMessageFormatter
- java.lang.Object
-
- org.apache.axis2.json.AbstractJSONMessageFormatter
-
- All Implemented Interfaces:
MessageFormatter
- Direct Known Subclasses:
JSONBadgerfishMessageFormatter,JSONMessageFormatter
public abstract class AbstractJSONMessageFormatter extends Object implements MessageFormatter
Base class for JSON message formatters.
-
-
Constructor Summary
Constructors Constructor Description AbstractJSONMessageFormatter(Class<? extends AbstractJSONDataSource> dataSourceClass)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringformatSOAPAction(MessageContext msgCtxt, OMOutputFormat format, String soapActionString)StringgetContentType(MessageContext msgCtxt, OMOutputFormat format, String soapActionString)Different message formats can set their own content types Eg: JSONFormatter can set the content type as application/jsonprotected abstract XMLStreamWritergetJSONWriter(Writer writer, MessageContext messageContext)URLgetTargetAddress(MessageContext msgCtxt, OMOutputFormat format, URL targetURL)Some message formats may want to alter the target url.voidwriteTo(MessageContext msgCtxt, OMOutputFormat format, OutputStream out, boolean preserve)Writes the JSON message to the output stream with the correct convention.
-
-
-
Constructor Detail
-
AbstractJSONMessageFormatter
public AbstractJSONMessageFormatter(Class<? extends AbstractJSONDataSource> dataSourceClass)
Constructor.- Parameters:
dataSourceClass- theOMDataSourceclass corresponding to the JSON format used by this message formatter; this information is used for optimization (pass through)
-
-
Method Detail
-
getContentType
public String getContentType(MessageContext msgCtxt, OMOutputFormat format, String soapActionString)
Description copied from interface:MessageFormatterDifferent message formats can set their own content types Eg: JSONFormatter can set the content type as application/json- Specified by:
getContentTypein interfaceMessageFormatter
-
formatSOAPAction
public String formatSOAPAction(MessageContext msgCtxt, OMOutputFormat format, String soapActionString)
- Specified by:
formatSOAPActionin interfaceMessageFormatter- Returns:
- this only if you want set a transport header for SOAP Action
-
getJSONWriter
protected abstract XMLStreamWriter getJSONWriter(Writer writer, MessageContext messageContext) throws XMLStreamException
- Throws:
XMLStreamException
-
writeTo
public void writeTo(MessageContext msgCtxt, OMOutputFormat format, OutputStream out, boolean preserve) throws AxisFault
Writes the JSON message to the output stream with the correct convention. If the payload is an OMSourcedElement and it contains a JSONDataSource with a correctly formatted JSON String, gets it directly from the DataSource and writes to the output stream. If not, the OM tree is expanded and it is serialized into the output stream. *- Specified by:
writeToin interfaceMessageFormatter- Parameters:
msgCtxt- Message context which contains the soap envelope to be writtenformat- format of the message, this is ignoredout- output stream to be written in topreserve- ignored- Throws:
AxisFault- if there is an error in writing the message using StAX writer or IF THE USER TRIES TO SEND A JSON MESSAGE WITH NAMESPACES USING THE "MAPPED" CONVENTION.
-
getTargetAddress
public URL getTargetAddress(MessageContext msgCtxt, OMOutputFormat format, URL targetURL) throws AxisFault
Description copied from interface:MessageFormatterSome message formats may want to alter the target url.- Specified by:
getTargetAddressin interfaceMessageFormatter- Returns:
- the target URL
- Throws:
AxisFault
-
-