Apache CXF API

org.apache.cxf.jaxrs.provider.json
Class JSONProvider<T>

java.lang.Object
  extended by org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
      extended by org.apache.cxf.jaxrs.provider.AbstractJAXBProvider<T>
          extended by org.apache.cxf.jaxrs.provider.json.JSONProvider<T>
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<T>, javax.ws.rs.ext.MessageBodyWriter<T>

@Provider
public class JSONProvider<T>
extends AbstractJAXBProvider<T>


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.cxf.jaxrs.provider.AbstractJAXBProvider
AbstractJAXBProvider.CollectionWrapper, AbstractJAXBProvider.JAXBCollectionWrapperReader
 
Field Summary
 
Fields inherited from class org.apache.cxf.jaxrs.provider.AbstractJAXBProvider
BUNDLE, collectionContextClasses, inAppendMap, inDropElements, inElementsMap, jaxbElementClassMap, LOG, marshalAsJaxbElement, NS_MAPPER_PROPERTY, NS_MAPPER_PROPERTY_INT, outAppendMap, outDropElements, outElementsMap, unmarshalAsJaxbElement
 
Constructor Summary
JSONProvider()
           
 
Method Summary
protected  void copyReaderToWriter(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.XMLStreamWriter writer)
           
protected  javax.xml.stream.XMLStreamReader createReader(Class<?> type, InputStream is)
           
protected  javax.xml.stream.XMLStreamReader createReader(Class<?> type, InputStream is, boolean isCollection)
           
protected  javax.xml.stream.XMLStreamWriter createWriter(Object actualObject, Class<?> actualClass, Type genericType, String enc, OutputStream os, boolean isCollection)
           
protected  InputStream getInputStream(Class<T> cls, Type type, InputStream is)
           
protected  String getRootName(Class<T> cls, Type type)
           
 boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, javax.ws.rs.core.MediaType mt)
           
 boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns, javax.ws.rs.core.MediaType mt)
           
protected  void marshal(javax.xml.bind.Marshaller ms, Object actualObject, Class<?> actualClass, Type genericType, String enc, OutputStream os, boolean isCollection)
           
protected  void marshal(Object actualObject, Class<?> actualClass, Type genericType, String enc, OutputStream os)
           
protected  void marshalCollection(Class<?> originalCls, Object collection, Type genericType, String encoding, OutputStream os, javax.ws.rs.core.MediaType m, Annotation[] anns)
           
protected  void marshalCollectionMember(Object obj, Class<?> cls, Type genericType, String enc, OutputStream os)
           
 T readFrom(Class<T> type, Type genericType, Annotation[] anns, javax.ws.rs.core.MediaType mt, javax.ws.rs.core.MultivaluedMap<String,String> headers, InputStream is)
           
 void setArrayKeys(List<String> keys)
           
 void setAttributesToElements(boolean value)
           
 void setConsumeMediaTypes(List<String> types)
          Sets custom Consumes media types; can be used to override static Consumes annotation value set on the provider.
 void setConvention(String value)
           
 void setConvertTypesToStrings(boolean convert)
           
 void setDropCollectionWrapperElement(boolean drop)
           
 void setDropRootElement(boolean drop)
           
 void setEnableBuffering(boolean enableBuf)
          Enables the buffering mode.
 void setIgnoreMixedContent(boolean ignore)
           
 void setIgnoreNamespaces(boolean ignoreNamespaces)
           
 void setMessageContext(MessageContext mc)
           
 void setNamespaceMap(Map<String,String> namespaceMap)
           
 void setProduceMediaTypes(List<String> types)
          Sets custom Produces media types; can be used to override static Produces annotation value set on the provider.
 void setReadXsiType(boolean readXsiType)
           
 void setSerializeAsArray(boolean asArray)
           
 void setSupportUnwrapped(boolean unwrap)
           
 void setTypeConverter(TypeConverter converter)
           
 void setWrapperMap(Map<String,String> map)
           
 void setWrapperName(String wName)
           
 void setWriteXsiType(boolean writeXsiType)
           
 void writeTo(T obj, Class<?> cls, Type genericType, Annotation[] anns, javax.ws.rs.core.MediaType m, javax.ws.rs.core.MultivaluedMap<String,Object> headers, OutputStream os)
           
 
Methods inherited from class org.apache.cxf.jaxrs.provider.AbstractJAXBProvider
canBeReadAsJaxbElement, checkAdapter, clearContexts, convertToJaxbElementIfNeeded, createDepthReaderIfNeeded, createMarshaller, createTransformReaderIfNeeded, createTransformWriterIfNeeded, createUnmarshaller, createUnmarshaller, getActualType, getClassContext, getCollectionContext, getCollectionWrapperQName, getContext, getDepthProperties, getJAXBContext, getJaxbQName, getPackageContext, getSchema, getSchema, getSize, getStackTrace, getStreamHandlerFromCurrentMessage, handleExceptionEnd, handleExceptionStart, handleJAXBException, handleXMLStreamException, init, isPayloadEmpty, isSkipJaxbChecks, isSupported, isXmlRoot, objectFactoryOrIndexAvailable, reportEmptyContentLength, setCatalogLocation, setCollectionWrapperMap, setCollectionWrapperName, setContext, setContextProperties, setDepthProperties, setExtraClass, setInAppendElements, setInDropElements, setInTransformElements, setJaxbElementClassMap, setJaxbElementClassNames, setMarshallAsJaxbElement, setMarshallerListener, setMarshallerProp, setNamespaceMapper, setOutAppendElements, setOutDropElements, setOutTransformElements, setSchema, setSchemaHandler, setSchemaHandlers, setSchemaLocations, setSchemas, setSingleJaxbContext, setSkipJaxbChecks, setUnmarshallAsJaxbElement, setUnmarshallerListener, setUnmarshallerProperties, setValidateBeforeWrite, setValidateOutput, setValidationHandler, validateObjectIfNeeded, writeTo
 
Methods inherited from class org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
getBus, getConsumeMediaTypes, getEnableBuffering, getEnableStreaming, getProduceMediaTypes, isPayloadEmpty, setBus, setEnableStreaming
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONProvider

public JSONProvider()
Method Detail

setAttributesToElements

public void setAttributesToElements(boolean value)
Overrides:
setAttributesToElements in class AbstractJAXBProvider<T>

setConvention

public void setConvention(String value)

setConvertTypesToStrings

public void setConvertTypesToStrings(boolean convert)

setTypeConverter

public void setTypeConverter(TypeConverter converter)

setIgnoreNamespaces

public void setIgnoreNamespaces(boolean ignoreNamespaces)

setMessageContext

@Context
public void setMessageContext(MessageContext mc)

setDropRootElement

public void setDropRootElement(boolean drop)

setDropCollectionWrapperElement

public void setDropCollectionWrapperElement(boolean drop)

setIgnoreMixedContent

public void setIgnoreMixedContent(boolean ignore)

setSupportUnwrapped

public void setSupportUnwrapped(boolean unwrap)

setWrapperName

public void setWrapperName(String wName)

setWrapperMap

public void setWrapperMap(Map<String,String> map)

setEnableBuffering

public void setEnableBuffering(boolean enableBuf)
Description copied from class: AbstractConfigurableProvider
Enables the buffering mode. If set to true then the runtime will ensure that the provider writes to a cached stream. For example, the JAXB marshalling process may fail after the initial XML tags have already been written out to the HTTP output stream. Enabling the buffering ensures no incomplete payloads are sent back to clients in case of marshalling errors at the cost of the initial buffering - which might be negligible for small payloads.

Overrides:
setEnableBuffering in class AbstractConfigurableProvider
Parameters:
enableBuf - the value of the buffering mode, false is default.

setConsumeMediaTypes

public void setConsumeMediaTypes(List<String> types)
Description copied from class: AbstractConfigurableProvider
Sets custom Consumes media types; can be used to override static Consumes annotation value set on the provider.

Overrides:
setConsumeMediaTypes in class AbstractConfigurableProvider
Parameters:
types - the media types

setProduceMediaTypes

public void setProduceMediaTypes(List<String> types)
Description copied from class: AbstractConfigurableProvider
Sets custom Produces media types; can be used to override static Produces annotation value set on the provider.

Overrides:
setProduceMediaTypes in class AbstractConfigurableProvider
Parameters:
types - the media types

setSerializeAsArray

public void setSerializeAsArray(boolean asArray)

setArrayKeys

public void setArrayKeys(List<String> keys)

setNamespaceMap

public void setNamespaceMap(Map<String,String> namespaceMap)

isReadable

public boolean isReadable(Class<?> type,
                          Type genericType,
                          Annotation[] anns,
                          javax.ws.rs.core.MediaType mt)
Specified by:
isReadable in interface javax.ws.rs.ext.MessageBodyReader<T>
Overrides:
isReadable in class AbstractJAXBProvider<T>

readFrom

public T readFrom(Class<T> type,
                  Type genericType,
                  Annotation[] anns,
                  javax.ws.rs.core.MediaType mt,
                  javax.ws.rs.core.MultivaluedMap<String,String> headers,
                  InputStream is)
           throws IOException
Throws:
IOException

createReader

protected javax.xml.stream.XMLStreamReader createReader(Class<?> type,
                                                        InputStream is,
                                                        boolean isCollection)
                                                 throws Exception
Throws:
Exception

createReader

protected javax.xml.stream.XMLStreamReader createReader(Class<?> type,
                                                        InputStream is)
                                                 throws Exception
Throws:
Exception

getInputStream

protected InputStream getInputStream(Class<T> cls,
                                     Type type,
                                     InputStream is)
                              throws Exception
Throws:
Exception

getRootName

protected String getRootName(Class<T> cls,
                             Type type)
                      throws Exception
Throws:
Exception

isWriteable

public boolean isWriteable(Class<?> type,
                           Type genericType,
                           Annotation[] anns,
                           javax.ws.rs.core.MediaType mt)
Specified by:
isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<T>
Overrides:
isWriteable in class AbstractJAXBProvider<T>

writeTo

public void writeTo(T obj,
                    Class<?> cls,
                    Type genericType,
                    Annotation[] anns,
                    javax.ws.rs.core.MediaType m,
                    javax.ws.rs.core.MultivaluedMap<String,Object> headers,
                    OutputStream os)
             throws IOException
Throws:
IOException

copyReaderToWriter

protected void copyReaderToWriter(javax.xml.stream.XMLStreamReader reader,
                                  javax.xml.stream.XMLStreamWriter writer)
                           throws Exception
Throws:
Exception

marshalCollection

protected void marshalCollection(Class<?> originalCls,
                                 Object collection,
                                 Type genericType,
                                 String encoding,
                                 OutputStream os,
                                 javax.ws.rs.core.MediaType m,
                                 Annotation[] anns)
                          throws Exception
Throws:
Exception

marshalCollectionMember

protected void marshalCollectionMember(Object obj,
                                       Class<?> cls,
                                       Type genericType,
                                       String enc,
                                       OutputStream os)
                                throws Exception
Throws:
Exception

marshal

protected void marshal(javax.xml.bind.Marshaller ms,
                       Object actualObject,
                       Class<?> actualClass,
                       Type genericType,
                       String enc,
                       OutputStream os,
                       boolean isCollection)
                throws Exception
Throws:
Exception

createWriter

protected javax.xml.stream.XMLStreamWriter createWriter(Object actualObject,
                                                        Class<?> actualClass,
                                                        Type genericType,
                                                        String enc,
                                                        OutputStream os,
                                                        boolean isCollection)
                                                 throws Exception
Throws:
Exception

marshal

protected void marshal(Object actualObject,
                       Class<?> actualClass,
                       Type genericType,
                       String enc,
                       OutputStream os)
                throws Exception
Throws:
Exception

setWriteXsiType

public void setWriteXsiType(boolean writeXsiType)

setReadXsiType

public void setReadXsiType(boolean readXsiType)

Apache CXF API

Apache CXF