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

@Produces(value={"application/xml","application/*+xml","text/xml"})
@Consumes(value={"application/xml","application/*+xml","text/xml"})
@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, classContexts, collectionContextClasses, inAppendMap, inDropElements, inElementsMap, jaxbElementClassMap, LOG, marshalAsJaxbElement, NS_MAPPER_PROPERTY_RI, NS_MAPPER_PROPERTY_RI_INT, outAppendMap, outDropElements, outElementsMap, packageContexts, unmarshalAsJaxbElement, xmlTypeAsJaxbElementOnly
 
Constructor Summary
JAXBElementProvider()
           
 
Method Summary
protected  void addAttachmentMarshaller(Marshaller ms)
           
protected  void addAttachmentUnmarshaller(Unmarshaller um)
           
protected  boolean canBeReadAsJaxbElement(Class<?> type)
           
protected  Object doUnmarshal(Unmarshaller unmarshaller, Class<?> type, InputStream is, Annotation[] anns, javax.ws.rs.core.MediaType mt)
           
protected  XMLStreamReader getStreamReader(InputStream is, Class<?> type, javax.ws.rs.core.MediaType mt)
           
protected  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, Annotation[] anns, javax.ws.rs.core.MediaType mt, Marshaller ms)
           
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 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, Annotation[] anns, javax.ws.rs.core.MediaType mt, String ns)
           
protected  void marshalToOutputStream(Marshaller ms, Object obj, OutputStream os, Annotation[] anns, javax.ws.rs.core.MediaType mt)
           
protected  void marshalToWriter(Marshaller ms, Object obj, XMLStreamWriter writer, Annotation[] anns, javax.ws.rs.core.MediaType mt)
           
protected  boolean objectFactoryOrIndexAvailable(Class<?> type)
           
 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)
           
protected  String resolveXMLResourceURI(String path)
           
 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)
           
protected  void setXmlPiProperty(Marshaller ms, String value)
           
 void setXmlPiPropertyName(String xmlPiPropertyName)
           
 void setXmlResourceOffset(String value)
           
protected  Object unmarshalFromInputStream(Unmarshaller unmarshaller, InputStream is, Annotation[] anns, javax.ws.rs.core.MediaType mt)
           
protected  Object unmarshalFromReader(Unmarshaller unmarshaller, XMLStreamReader reader, Annotation[] anns, 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, configureReaderRestrictions, convertToJaxbElementIfNeeded, createDepthReaderIfNeeded, createMarshaller, createTransformReaderIfNeeded, createTransformWriterIfNeeded, createUnmarshaller, createUnmarshaller, getActualType, getClassContext, getClassContext, getCollectionContext, getCollectionWrapperQName, getContext, getDepthProperties, getJAXBContext, getJaxbElementClass, getJaxbQName, getPackageContext, getPackageContext, getSchema, getSchema, getSize, getStackTrace, getStreamHandlerFromCurrentMessage, handleExceptionEnd, handleExceptionStart, handleJAXBException, handleXMLStreamException, init, isReadable, isSkipJaxbChecks, isSupported, isWriteable, isXmlRoot, isXmlType, reportEmptyContentLength, setAttributesToElements, setCatalogLocation, setCollectionWrapperMap, setCollectionWrapperName, setContext, setContextProperties, setDepthProperties, setExtraClass, setInAppendElements, setInDropElements, setInTransformElements, setJaxbElementClassMap, setJaxbElementClassNames, setMarshallAsJaxbElement, setMarshallerListener, setMarshallerProp, setNamespaceMapper, setNamespaceMapperPropertyName, setOutAppendElements, setOutDropElements, setOutTransformElements, setSchema, setSchemaHandler, setSchemaHandlers, setSchemaLocations, setSingleJaxbContext, setSkipJaxbChecks, setUnmarshallAsJaxbElement, setUnmarshallerListener, setUnmarshallerProperties, setUseSingleContextForPackages, setValidateBeforeWrite, setValidateInput, setValidateOutput, setValidationHandler, setXmlRootAsJaxbElement, setXmlTypeAsJaxbElementOnly, validateObjectIfNeeded, writeTo
 
Methods inherited from class org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
getBus, getConsumeMediaTypes, getEnableBuffering, getEnableStreaming, getProduceMediaTypes, isPayloadEmpty, 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

objectFactoryOrIndexAvailable

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

setXmlResourceOffset

public void setXmlResourceOffset(String value)

setNamespacePrefixes

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

setXmlPiProperty

protected void setXmlPiProperty(Marshaller ms,
                                String value)
                         throws Exception
Throws:
Exception

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(Unmarshaller unmarshaller,
                             Class<?> type,
                             InputStream is,
                             Annotation[] anns,
                             javax.ws.rs.core.MediaType mt)
                      throws JAXBException
Throws:
JAXBException

getStreamReader

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

unmarshalFromInputStream

protected Object unmarshalFromInputStream(Unmarshaller unmarshaller,
                                          InputStream is,
                                          Annotation[] anns,
                                          javax.ws.rs.core.MediaType mt)
                                   throws JAXBException
Throws:
JAXBException

unmarshalFromReader

protected Object unmarshalFromReader(Unmarshaller unmarshaller,
                                     XMLStreamReader reader,
                                     Annotation[] anns,
                                     javax.ws.rs.core.MediaType mt)
                              throws JAXBException
Throws:
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,
                                       Annotation[] anns,
                                       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

resolveXMLResourceURI

protected String resolveXMLResourceURI(String path)

addAttachmentMarshaller

protected void addAttachmentMarshaller(Marshaller ms)

addAttachmentUnmarshaller

protected void addAttachmentUnmarshaller(Unmarshaller um)

marshal

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

getStreamWriter

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

marshalToOutputStream

protected void marshalToOutputStream(Marshaller ms,
                                     Object obj,
                                     OutputStream os,
                                     Annotation[] anns,
                                     javax.ws.rs.core.MediaType mt)
                              throws Exception
Throws:
Exception

marshalToWriter

protected void marshalToWriter(Marshaller ms,
                               Object obj,
                               XMLStreamWriter writer,
                               Annotation[] anns,
                               javax.ws.rs.core.MediaType mt)
                        throws Exception
Throws:
Exception

setXmlPiPropertyName

public void setXmlPiPropertyName(String xmlPiPropertyName)

Apache CXF API

Apache CXF