Apache CXF API

org.apache.cxf.jaxrs.provider
Class AbstractJAXBProvider

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

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


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  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)
           
protected  void checkContentLength()
           
 void clearContexts()
           
protected  Object convertToJaxbElementIfNeeded(Object obj, Class<?> cls, Type genericType)
           
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  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()
           
 long getSize(Object o, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mt)
           
protected static String getStackTrace(Exception ex)
           
protected
<T> T
getStaxHandlerFromCurrentMessage(Class<T> staxCls)
           
protected static void handleJAXBException(javax.xml.bind.JAXBException e, boolean read)
           
 void init(List<ClassResourceInfo> cris)
          Gives providers a chance to introspect the JAX-RS model classes.
 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)
           
 void setAttributesToElements(boolean value)
           
 void setCollectionWrapperMap(Map<String,String> map)
           
 void setCollectionWrapperName(String wName)
           
protected  void setContext(MessageContext context)
           
 void setContextProperties(Map<String,Object> contextProperties)
           
 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 setOutAppendElements(Map<String,String> map)
           
 void setOutDropElements(List<String> dropElementsSet)
           
 void setOutTransformElements(Map<String,String> outElements)
           
 void setSchema(Schema s)
           
 void setSchemaLocations(List<String> locations)
           
 void setSingleJaxbContext(boolean useSingleContext)
           
 void setSkipJaxbChecks(boolean skipJaxbChecks)
           
 void setUnmarshallAsJaxbElement(boolean value)
           
 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, Object obj)
           
 
Methods inherited from class org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
getBus, getConsumeMediaTypes, getEnableBuffering, getEnableStreaming, getProduceMediaTypes, 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

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

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)

checkContentLength

protected void checkContentLength()

getStaxHandlerFromCurrentMessage

protected <T> T getStaxHandlerFromCurrentMessage(Class<T> 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<Object>

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<Object>

canBeReadAsJaxbElement

protected boolean canBeReadAsJaxbElement(Class<?> type)

setSchemaLocations

public void setSchemaLocations(List<String> locations)

setSchema

public void setSchema(Schema s)

getSize

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

getContext

protected MessageContext getContext()

getJAXBContext

protected 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,
                                      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()

clearContexts

public void clearContexts()

getStackTrace

protected static String getStackTrace(Exception ex)

handleJAXBException

protected static void handleJAXBException(javax.xml.bind.JAXBException 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)

setValidateBeforeWrite

public void setValidateBeforeWrite(boolean validateBeforeWrite)

setValidateOutput

public void setValidateOutput(boolean validateOutput)

Apache CXF API

Apache CXF