Apache CXF API

org.apache.cxf.jaxrs.provider
Class JAXBElementProvider<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.JAXBElementProvider<T>
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<T>, javax.ws.rs.ext.MessageBodyWriter<T>
Direct Known Subclasses:
XSLTJaxbProvider

@Provider
public class JAXBElementProvider<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
JAXBElementProvider()
           
 
Method Summary
protected  void addAttachmentMarshaller(javax.xml.bind.Marshaller ms)
           
protected  void addAttachmentUnmarshaller(javax.xml.bind.Unmarshaller um)
           
protected  boolean canBeReadAsJaxbElement(Class<?> type)
           
protected  Object doUnmarshal(javax.xml.bind.Unmarshaller unmarshaller, Class<?> type, InputStream is, javax.ws.rs.core.MediaType mt)
           
protected  javax.xml.stream.XMLStreamReader getStreamReader(InputStream is, Class<?> type, javax.ws.rs.core.MediaType mt)
           
protected  javax.xml.stream.XMLStreamWriter getStreamWriter(Object obj, OutputStream os, javax.ws.rs.core.MediaType mt)
           
protected  void marshal(Object obj, Class<?> cls, Type genericType, String enc, OutputStream os, javax.ws.rs.core.MediaType mt)
           
protected  void marshal(Object obj, Class<?> cls, Type genericType, String enc, OutputStream os, javax.ws.rs.core.MediaType mt, Annotation[] anns)
           
protected  void marshal(Object obj, Class<?> cls, Type genericType, String enc, OutputStream os, javax.ws.rs.core.MediaType mt, javax.xml.bind.Marshaller ms)
           
protected  void marshalCollection(Class<?> originalCls, Object collection, Type genericType, String enc, OutputStream os, javax.ws.rs.core.MediaType m, Annotation[] anns)
           
protected  void marshalCollectionMember(Object obj, Class<?> cls, Type genericType, String enc, OutputStream os, javax.ws.rs.core.MediaType mt, String ns)
           
protected  void marshalToOutputStream(javax.xml.bind.Marshaller ms, Object obj, OutputStream os, javax.ws.rs.core.MediaType mt)
           
protected  void marshalToWriter(javax.xml.bind.Marshaller ms, Object obj, javax.xml.stream.XMLStreamWriter writer, javax.ws.rs.core.MediaType mt)
           
 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 setConsumeMediaTypes(List<String> types)
          Sets custom Consumes media types; can be used to override static Consumes annotation value set on the provider.
 void setEnableBuffering(boolean enableBuf)
          Enables the buffering mode.
 void setMarshallerProperties(Map<String,Object> marshallProperties)
           
 void setMessageContext(MessageContext mc)
           
 void setNamespacePrefixes(Map<String,String> prefixes)
           
 void setProduceMediaTypes(List<String> types)
          Sets custom Produces media types; can be used to override static Produces annotation value set on the provider.
 void setSchemaLocation(String schemaLocation)
           
 void setXmlResourceOffset(String value)
           
protected  Object unmarshalFromInputStream(javax.xml.bind.Unmarshaller unmarshaller, InputStream is, javax.ws.rs.core.MediaType mt)
           
protected  Object unmarshalFromReader(javax.xml.bind.Unmarshaller unmarshaller, javax.xml.stream.XMLStreamReader reader, javax.ws.rs.core.MediaType mt)
           
 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
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, isReadable, isSkipJaxbChecks, isSupported, isWriteable, isXmlRoot, objectFactoryOrIndexAvailable, reportEmptyContentLength, setAttributesToElements, 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

JAXBElementProvider

public JAXBElementProvider()
Method Detail

setXmlResourceOffset

public void setXmlResourceOffset(String value)

setNamespacePrefixes

public void setNamespacePrefixes(Map<String,String> prefixes)

canBeReadAsJaxbElement

protected boolean canBeReadAsJaxbElement(Class<?> type)
Overrides:
canBeReadAsJaxbElement in class AbstractJAXBProvider<T>

setMessageContext

@Context
public void setMessageContext(MessageContext mc)

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

setMarshallerProperties

public void setMarshallerProperties(Map<String,Object> marshallProperties)

setSchemaLocation

public void setSchemaLocation(String schemaLocation)

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

doUnmarshal

protected Object doUnmarshal(javax.xml.bind.Unmarshaller unmarshaller,
                             Class<?> type,
                             InputStream is,
                             javax.ws.rs.core.MediaType mt)
                      throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

getStreamReader

protected javax.xml.stream.XMLStreamReader getStreamReader(InputStream is,
                                                           Class<?> type,
                                                           javax.ws.rs.core.MediaType mt)

unmarshalFromInputStream

protected Object unmarshalFromInputStream(javax.xml.bind.Unmarshaller unmarshaller,
                                          InputStream is,
                                          javax.ws.rs.core.MediaType mt)
                                   throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

unmarshalFromReader

protected Object unmarshalFromReader(javax.xml.bind.Unmarshaller unmarshaller,
                                     javax.xml.stream.XMLStreamReader reader,
                                     javax.ws.rs.core.MediaType mt)
                              throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

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

marshalCollection

protected void marshalCollection(Class<?> originalCls,
                                 Object collection,
                                 Type genericType,
                                 String enc,
                                 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,
                                       javax.ws.rs.core.MediaType mt,
                                       String ns)
                                throws Exception
Throws:
Exception

marshal

protected void marshal(Object obj,
                       Class<?> cls,
                       Type genericType,
                       String enc,
                       OutputStream os,
                       javax.ws.rs.core.MediaType mt)
                throws Exception
Throws:
Exception

marshal

protected void marshal(Object obj,
                       Class<?> cls,
                       Type genericType,
                       String enc,
                       OutputStream os,
                       javax.ws.rs.core.MediaType mt,
                       Annotation[] anns)
                throws Exception
Throws:
Exception

addAttachmentMarshaller

protected void addAttachmentMarshaller(javax.xml.bind.Marshaller ms)

addAttachmentUnmarshaller

protected void addAttachmentUnmarshaller(javax.xml.bind.Unmarshaller um)

marshal

protected void marshal(Object obj,
                       Class<?> cls,
                       Type genericType,
                       String enc,
                       OutputStream os,
                       javax.ws.rs.core.MediaType mt,
                       javax.xml.bind.Marshaller ms)
                throws Exception
Throws:
Exception

getStreamWriter

protected javax.xml.stream.XMLStreamWriter getStreamWriter(Object obj,
                                                           OutputStream os,
                                                           javax.ws.rs.core.MediaType mt)

marshalToOutputStream

protected void marshalToOutputStream(javax.xml.bind.Marshaller ms,
                                     Object obj,
                                     OutputStream os,
                                     javax.ws.rs.core.MediaType mt)
                              throws Exception
Throws:
Exception

marshalToWriter

protected void marshalToWriter(javax.xml.bind.Marshaller ms,
                               Object obj,
                               javax.xml.stream.XMLStreamWriter writer,
                               javax.ws.rs.core.MediaType mt)
                        throws Exception
Throws:
Exception

Apache CXF API

Apache CXF