Apache CXF API

org.apache.cxf.jaxrs.provider
Class AbstractJAXBProvider<T>

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

public abstract class AbstractJAXBProvider<T>
extends AbstractConfigurableProvider
implements javax.ws.rs.ext.MessageBodyReader<T>, javax.ws.rs.ext.MessageBodyWriter<T>


Nested Class Summary
protected static class AbstractJAXBProvider.CollectionWrapper
           
protected static class AbstractJAXBProvider.JAXBCollectionWrapperReader
           
 
Field Summary
protected static ResourceBundle BUNDLE
           
protected  Set<Class<?>> collectionContextClasses
           
protected  Map<String,String> inAppendMap
           
protected  List<String> inDropElements
           
protected  Map<String,String> inElementsMap
           
protected  Map<String,String> jaxbElementClassMap
           
protected static Logger LOG
           
protected  boolean marshalAsJaxbElement
           
protected static String NS_MAPPER_PROPERTY
           
protected static String NS_MAPPER_PROPERTY_INT
           
protected  Map<String,String> outAppendMap
           
protected  List<String> outDropElements
           
protected  Map<String,String> outElementsMap
           
protected  boolean unmarshalAsJaxbElement
           
 
Constructor Summary
AbstractJAXBProvider()
           
 
Method Summary
protected  boolean canBeReadAsJaxbElement(Class<?> type)
           
protected static Object checkAdapter(Object obj, Class<?> cls, Annotation[] anns, boolean marshal)
           
 void clearContexts()
           
protected  Object convertToJaxbElementIfNeeded(Object obj, Class<?> cls, Type genericType)
           
protected  javax.xml.stream.XMLStreamReader createDepthReaderIfNeeded(javax.xml.stream.XMLStreamReader reader, InputStream is)
           
protected  javax.xml.bind.Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType, String enc)
           
protected  javax.xml.stream.XMLStreamReader createTransformReaderIfNeeded(javax.xml.stream.XMLStreamReader reader, InputStream is)
           
protected  javax.xml.stream.XMLStreamWriter createTransformWriterIfNeeded(javax.xml.stream.XMLStreamWriter writer, OutputStream os)
           
protected  javax.xml.bind.Unmarshaller createUnmarshaller(Class<?> cls, Type genericType)
           
protected  javax.xml.bind.Unmarshaller createUnmarshaller(Class<?> cls, Type genericType, boolean isCollection)
           
protected  Class<?> getActualType(Class<?> type, Type genericType, Annotation[] anns)
           
 javax.xml.bind.JAXBContext getClassContext(Class<?> type)
           
protected  javax.xml.bind.JAXBContext getCollectionContext(Class<?> type)
           
protected  QName getCollectionWrapperQName(Class<?> cls, Type type, Object object, boolean pluralName)
           
protected  MessageContext getContext()
           
protected  DocumentDepthProperties getDepthProperties()
           
 javax.xml.bind.JAXBContext getJAXBContext(Class<?> type, Type genericType)
           
protected  QName getJaxbQName(Class<?> cls, Type type, Object object, boolean pluralName)
           
 javax.xml.bind.JAXBContext getPackageContext(Class<?> type)
           
protected  Schema getSchema()
           
protected  Schema getSchema(Class<?> cls)
           
 long getSize(T o, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mt)
           
protected static String getStackTrace(Exception ex)
           
protected
<X> X
getStreamHandlerFromCurrentMessage(Class<X> staxCls)
           
protected static void handleExceptionEnd(Throwable t, String message, boolean read)
           
protected static StringBuilder handleExceptionStart(Exception e)
           
protected static void handleJAXBException(javax.xml.bind.JAXBException e, boolean read)
           
protected static void handleXMLStreamException(javax.xml.stream.XMLStreamException e, boolean read)
           
 void init(List<ClassResourceInfo> cris)
          Gives providers a chance to introspect the JAX-RS model classes.
protected  boolean isPayloadEmpty()
           
 boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, javax.ws.rs.core.MediaType mt)
           
 boolean isSkipJaxbChecks()
           
protected  boolean isSupported(Class<?> type, Type genericType, Annotation[] anns)
           
 boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns, javax.ws.rs.core.MediaType mt)
           
protected static boolean isXmlRoot(Class<?> cls)
           
protected  boolean objectFactoryOrIndexAvailable(Class<?> type)
           
protected  void reportEmptyContentLength()
           
 void setAttributesToElements(boolean value)
           
 void setCatalogLocation(String name)
           
 void setCollectionWrapperMap(Map<String,String> map)
           
 void setCollectionWrapperName(String wName)
           
protected  void setContext(MessageContext context)
           
 void setContextProperties(Map<String,Object> contextProperties)
           
 void setDepthProperties(DocumentDepthProperties depthProperties)
           
 void setExtraClass(Class<?>[] userExtraClass)
           
 void setInAppendElements(Map<String,String> inElements)
           
 void setInDropElements(List<String> dropElementsSet)
           
 void setInTransformElements(Map<String,String> inElements)
           
 void setJaxbElementClassMap(Map<String,String> map)
           
 void setJaxbElementClassNames(List<String> names)
           
 void setMarshallAsJaxbElement(boolean value)
           
 void setMarshallerListener(javax.xml.bind.Marshaller.Listener marshallerListener)
           
protected static void setMarshallerProp(javax.xml.bind.Marshaller ms, Object value, String name1, String name2)
           
protected static void setNamespaceMapper(javax.xml.bind.Marshaller ms, Map<String,String> map)
           
 void setOutAppendElements(Map<String,String> map)
           
 void setOutDropElements(List<String> dropElementsSet)
           
 void setOutTransformElements(Map<String,String> outElements)
           
protected  void setSchema(Schema s)
           
 void setSchemaHandler(SchemaHandler handler)
           
 void setSchemaHandlers(Map<String,SchemaHandler> handlers)
           
 void setSchemaLocations(List<String> locations)
           
 void setSchemas(List<String> locations)
          Deprecated. 
 void setSingleJaxbContext(boolean useSingleContext)
           
 void setSkipJaxbChecks(boolean skipJaxbChecks)
           
 void setUnmarshallAsJaxbElement(boolean value)
           
 void setUnmarshallerListener(javax.xml.bind.Unmarshaller.Listener unmarshallerListener)
           
 void setUnmarshallerProperties(Map<String,Object> unmarshalProperties)
           
 void setValidateBeforeWrite(boolean validateBeforeWrite)
           
 void setValidateOutput(boolean validateOutput)
           
 void setValidationHandler(javax.xml.bind.ValidationEventHandler handler)
           
protected  void validateObjectIfNeeded(javax.xml.bind.Marshaller marshaller, Class<?> cls, Object obj)
           
 void writeTo(T t, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream)
           
 
Methods inherited from class org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
getBus, getConsumeMediaTypes, getEnableBuffering, getEnableStreaming, getProduceMediaTypes, isPayloadEmpty, setBus, setConsumeMediaTypes, setEnableBuffering, setEnableStreaming, setProduceMediaTypes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.ws.rs.ext.MessageBodyReader
readFrom
 
Methods inherited from interface javax.ws.rs.ext.MessageBodyWriter
writeTo
 

Field Detail

BUNDLE

protected static final ResourceBundle BUNDLE

LOG

protected static final Logger LOG

NS_MAPPER_PROPERTY

protected static final String NS_MAPPER_PROPERTY
See Also:
Constant Field Values

NS_MAPPER_PROPERTY_INT

protected static final String NS_MAPPER_PROPERTY_INT
See Also:
Constant Field Values

collectionContextClasses

protected Set<Class<?>> collectionContextClasses

jaxbElementClassMap

protected Map<String,String> jaxbElementClassMap

unmarshalAsJaxbElement

protected boolean unmarshalAsJaxbElement

marshalAsJaxbElement

protected boolean marshalAsJaxbElement

outElementsMap

protected Map<String,String> outElementsMap

outAppendMap

protected Map<String,String> outAppendMap

outDropElements

protected List<String> outDropElements

inDropElements

protected List<String> inDropElements

inElementsMap

protected Map<String,String> inElementsMap

inAppendMap

protected Map<String,String> inAppendMap
Constructor Detail

AbstractJAXBProvider

public AbstractJAXBProvider()
Method Detail

setNamespaceMapper

protected static void setNamespaceMapper(javax.xml.bind.Marshaller ms,
                                         Map<String,String> map)
                                  throws Exception
Throws:
Exception

setMarshallerProp

protected static void setMarshallerProp(javax.xml.bind.Marshaller ms,
                                        Object value,
                                        String name1,
                                        String name2)
                                 throws Exception
Throws:
Exception

setValidationHandler

public void setValidationHandler(javax.xml.bind.ValidationEventHandler handler)

setSingleJaxbContext

public void setSingleJaxbContext(boolean useSingleContext)

setExtraClass

public void setExtraClass(Class<?>[] userExtraClass)

init

public void init(List<ClassResourceInfo> cris)
Description copied from class: AbstractConfigurableProvider
Gives providers a chance to introspect the JAX-RS model classes. For example, the JAXB provider may use the model classes to create a single composite JAXBContext supporting all the JAXB-annotated root resource classes/types.

Overrides:
init in class AbstractConfigurableProvider

setContextProperties

public void setContextProperties(Map<String,Object> contextProperties)

setUnmarshallerProperties

public void setUnmarshallerProperties(Map<String,Object> unmarshalProperties)

setUnmarshallAsJaxbElement

public void setUnmarshallAsJaxbElement(boolean value)

setMarshallAsJaxbElement

public void setMarshallAsJaxbElement(boolean value)

setJaxbElementClassNames

public void setJaxbElementClassNames(List<String> names)

setJaxbElementClassMap

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

isPayloadEmpty

protected boolean isPayloadEmpty()

reportEmptyContentLength

protected void reportEmptyContentLength()

getStreamHandlerFromCurrentMessage

protected <X> X getStreamHandlerFromCurrentMessage(Class<X> staxCls)

isXmlRoot

protected static boolean isXmlRoot(Class<?> cls)

convertToJaxbElementIfNeeded

protected Object convertToJaxbElementIfNeeded(Object obj,
                                              Class<?> cls,
                                              Type genericType)
                                       throws Exception
Throws:
Exception

setCollectionWrapperName

public void setCollectionWrapperName(String wName)

setCollectionWrapperMap

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

setContext

protected void setContext(MessageContext context)

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>

writeTo

public void writeTo(T t,
                    Type genericType,
                    Annotation[] annotations,
                    javax.ws.rs.core.MediaType mediaType,
                    javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders,
                    OutputStream entityStream)
             throws IOException,
                    javax.ws.rs.WebApplicationException
Throws:
IOException
javax.ws.rs.WebApplicationException

getCollectionContext

protected javax.xml.bind.JAXBContext getCollectionContext(Class<?> type)
                                                   throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

getCollectionWrapperQName

protected QName getCollectionWrapperQName(Class<?> cls,
                                          Type type,
                                          Object object,
                                          boolean pluralName)
                                   throws Exception
Throws:
Exception

getJaxbQName

protected QName getJaxbQName(Class<?> cls,
                             Type type,
                             Object object,
                             boolean pluralName)
                      throws Exception
Throws:
Exception

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>

canBeReadAsJaxbElement

protected boolean canBeReadAsJaxbElement(Class<?> type)

setSchemas

@Deprecated
public void setSchemas(List<String> locations)
Deprecated. 


setSchemaLocations

public void setSchemaLocations(List<String> locations)

setCatalogLocation

public void setCatalogLocation(String name)

setSchemaHandler

public void setSchemaHandler(SchemaHandler handler)

setSchemaHandlers

public void setSchemaHandlers(Map<String,SchemaHandler> handlers)

setSchema

protected void setSchema(Schema s)

getSize

public long getSize(T o,
                    Class<?> type,
                    Type genericType,
                    Annotation[] annotations,
                    javax.ws.rs.core.MediaType mt)
Specified by:
getSize in interface javax.ws.rs.ext.MessageBodyWriter<T>

getContext

protected MessageContext getContext()

getJAXBContext

public javax.xml.bind.JAXBContext getJAXBContext(Class<?> type,
                                                 Type genericType)
                                          throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

getClassContext

public javax.xml.bind.JAXBContext getClassContext(Class<?> type)
                                           throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

getPackageContext

public javax.xml.bind.JAXBContext getPackageContext(Class<?> type)

isSupported

protected boolean isSupported(Class<?> type,
                              Type genericType,
                              Annotation[] anns)

objectFactoryOrIndexAvailable

protected boolean objectFactoryOrIndexAvailable(Class<?> type)

createUnmarshaller

protected javax.xml.bind.Unmarshaller createUnmarshaller(Class<?> cls,
                                                         Type genericType)
                                                  throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

createUnmarshaller

protected javax.xml.bind.Unmarshaller createUnmarshaller(Class<?> cls,
                                                         Type genericType,
                                                         boolean isCollection)
                                                  throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

createMarshaller

protected javax.xml.bind.Marshaller createMarshaller(Object obj,
                                                     Class<?> cls,
                                                     Type genericType,
                                                     String enc)
                                              throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

validateObjectIfNeeded

protected void validateObjectIfNeeded(javax.xml.bind.Marshaller marshaller,
                                      Class<?> cls,
                                      Object obj)
                               throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

getActualType

protected Class<?> getActualType(Class<?> type,
                                 Type genericType,
                                 Annotation[] anns)

checkAdapter

protected static Object checkAdapter(Object obj,
                                     Class<?> cls,
                                     Annotation[] anns,
                                     boolean marshal)

getSchema

protected Schema getSchema()

getSchema

protected Schema getSchema(Class<?> cls)

clearContexts

public void clearContexts()

getStackTrace

protected static String getStackTrace(Exception ex)

handleExceptionStart

protected static StringBuilder handleExceptionStart(Exception e)

handleExceptionEnd

protected static void handleExceptionEnd(Throwable t,
                                         String message,
                                         boolean read)

handleJAXBException

protected static void handleJAXBException(javax.xml.bind.JAXBException e,
                                          boolean read)

handleXMLStreamException

protected static void handleXMLStreamException(javax.xml.stream.XMLStreamException e,
                                               boolean read)

setOutTransformElements

public void setOutTransformElements(Map<String,String> outElements)

setInAppendElements

public void setInAppendElements(Map<String,String> inElements)

setInTransformElements

public void setInTransformElements(Map<String,String> inElements)

setOutAppendElements

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

setOutDropElements

public void setOutDropElements(List<String> dropElementsSet)

setInDropElements

public void setInDropElements(List<String> dropElementsSet)

setAttributesToElements

public void setAttributesToElements(boolean value)

setSkipJaxbChecks

public void setSkipJaxbChecks(boolean skipJaxbChecks)

isSkipJaxbChecks

public boolean isSkipJaxbChecks()

createTransformWriterIfNeeded

protected javax.xml.stream.XMLStreamWriter createTransformWriterIfNeeded(javax.xml.stream.XMLStreamWriter writer,
                                                                         OutputStream os)

createTransformReaderIfNeeded

protected javax.xml.stream.XMLStreamReader createTransformReaderIfNeeded(javax.xml.stream.XMLStreamReader reader,
                                                                         InputStream is)

createDepthReaderIfNeeded

protected javax.xml.stream.XMLStreamReader createDepthReaderIfNeeded(javax.xml.stream.XMLStreamReader reader,
                                                                     InputStream is)

getDepthProperties

protected DocumentDepthProperties getDepthProperties()

setValidateBeforeWrite

public void setValidateBeforeWrite(boolean validateBeforeWrite)

setValidateOutput

public void setValidateOutput(boolean validateOutput)

setDepthProperties

public void setDepthProperties(DocumentDepthProperties depthProperties)

setUnmarshallerListener

public void setUnmarshallerListener(javax.xml.bind.Unmarshaller.Listener unmarshallerListener)

setMarshallerListener

public void setMarshallerListener(javax.xml.bind.Marshaller.Listener marshallerListener)

Apache CXF API

Apache CXF