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  XMLStreamReader createDepthReaderIfNeeded(XMLStreamReader reader, InputStream is)
           
protected  Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType, String enc)
           
protected  XMLStreamReader createTransformReaderIfNeeded(XMLStreamReader reader, InputStream is)
           
protected  XMLStreamWriter createTransformWriterIfNeeded(XMLStreamWriter writer, OutputStream os)
           
protected  Unmarshaller createUnmarshaller(Class<?> cls, Type genericType)
           
protected  Unmarshaller createUnmarshaller(Class<?> cls, Type genericType, boolean isCollection)
           
protected  Class<?> getActualType(Class<?> type, Type genericType, Annotation[] anns)
           
 JAXBContext getClassContext(Class<?> type)
           
protected  JAXBContext getCollectionContext(Class<?> type)
           
protected  QName getCollectionWrapperQName(Class<?> cls, Type type, Object object, boolean pluralName)
           
protected  MessageContext getContext()
           
protected  DocumentDepthProperties getDepthProperties()
           
 JAXBContext getJAXBContext(Class<?> type, Type genericType)
           
protected  QName getJaxbQName(Class<?> cls, Type type, Object object, boolean pluralName)
           
 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(JAXBException e, boolean read)
           
protected static void handleXMLStreamException(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(Marshaller.Listener marshallerListener)
           
protected static void setMarshallerProp(Marshaller ms, Object value, String name1, String name2)
           
protected static void setNamespaceMapper(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(Unmarshaller.Listener unmarshallerListener)
           
 void setUnmarshallerProperties(Map<String,Object> unmarshalProperties)
           
 void setValidateBeforeWrite(boolean validateBeforeWrite)
           
 void setValidateOutput(boolean validateOutput)
           
 void setValidationHandler(ValidationEventHandler handler)
           
protected  void validateObjectIfNeeded(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(Marshaller ms,
                                         Map<String,String> map)
                                  throws Exception
Throws:
Exception

setMarshallerProp

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

setValidationHandler

public void setValidationHandler(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 JAXBContext getCollectionContext(Class<?> type)
                                    throws JAXBException
Throws:
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 JAXBContext getJAXBContext(Class<?> type,
                                  Type genericType)
                           throws JAXBException
Throws:
JAXBException

getClassContext

public JAXBContext getClassContext(Class<?> type)
                            throws JAXBException
Throws:
JAXBException

getPackageContext

public JAXBContext getPackageContext(Class<?> type)

isSupported

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

objectFactoryOrIndexAvailable

protected boolean objectFactoryOrIndexAvailable(Class<?> type)

createUnmarshaller

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

createUnmarshaller

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

createMarshaller

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

validateObjectIfNeeded

protected void validateObjectIfNeeded(Marshaller marshaller,
                                      Class<?> cls,
                                      Object obj)
                               throws JAXBException
Throws:
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(JAXBException e,
                                          boolean read)

handleXMLStreamException

protected static void handleXMLStreamException(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 XMLStreamWriter createTransformWriterIfNeeded(XMLStreamWriter writer,
                                                        OutputStream os)

createTransformReaderIfNeeded

protected XMLStreamReader createTransformReaderIfNeeded(XMLStreamReader reader,
                                                        InputStream is)

createDepthReaderIfNeeded

protected XMLStreamReader createDepthReaderIfNeeded(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(Unmarshaller.Listener unmarshallerListener)

setMarshallerListener

public void setMarshallerListener(Marshaller.Listener marshallerListener)

Apache CXF API

Apache CXF