Class XStreamReaderWriter

  • All Implemented Interfaces:
    javax.ws.rs.ext.MessageBodyReader<java.lang.Object>, javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>

    @Provider
    @Produces({"application/*+xml","text/*+xml"})
    @Consumes({"application/*+xml","text/*+xml"})
    public class XStreamReaderWriter
    extends java.lang.Object
    implements javax.ws.rs.ext.MessageBodyReader<java.lang.Object>, javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static com.thoughtworks.xstream.io.xml.XppDriver HIERARCHICAL_STREAM_DRIVER  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.thoughtworks.xstream.converters.Converter constructConverter​(java.lang.Class<?> clazz)
      Default implementation is to call the parameterless constructor of the Converter.
      protected com.thoughtworks.xstream.converters.DataHolder createDataHolder()  
      static com.thoughtworks.xstream.XStream getConfiguredXStream()  
      long getSize​(java.lang.Object o, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)  
      protected void init()  
      protected boolean isForRegisteredConverter​(java.lang.Class<?> type, java.lang.reflect.Type genericType)  
      boolean isReadable​(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)  
      boolean isWriteable​(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)  
      java.lang.Object readFrom​(java.lang.Class<java.lang.Object> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> httpHeaders, java.io.InputStream entityStream)  
      static void registerConfigurationItemAliases()
      This is separate, as remote we need to have fetched the descriptors first, before we have the types to initialize XStream with.
      static void registerConverter​(com.thoughtworks.xstream.converters.Converter converter)  
      void writeTo​(java.lang.Object o, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.Object> httpHeaders, java.io.OutputStream entityStream)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • HIERARCHICAL_STREAM_DRIVER

        public static final com.thoughtworks.xstream.io.xml.XppDriver HIERARCHICAL_STREAM_DRIVER
    • Constructor Detail

      • XStreamReaderWriter

        public XStreamReaderWriter()
    • Method Detail

      • init

        protected void init()
      • registerConverter

        public static void registerConverter​(com.thoughtworks.xstream.converters.Converter converter)
      • registerConfigurationItemAliases

        public static void registerConfigurationItemAliases()
        This is separate, as remote we need to have fetched the descriptors first, before we have the types to initialize XStream with.
      • constructConverter

        protected com.thoughtworks.xstream.converters.Converter constructConverter​(java.lang.Class<?> clazz)
        Default implementation is to call the parameterless constructor of the Converter. But can be overridden to look for the correct converter in for instance a Spring context.
        Parameters:
        clazz - The converter class
        Returns:
        The instantiated converter.
      • isReadable

        public boolean isReadable​(java.lang.Class<?> type,
                                  java.lang.reflect.Type genericType,
                                  java.lang.annotation.Annotation[] annotations,
                                  javax.ws.rs.core.MediaType mediaType)
        Specified by:
        isReadable in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>
      • isForRegisteredConverter

        protected boolean isForRegisteredConverter​(java.lang.Class<?> type,
                                                   java.lang.reflect.Type genericType)
      • readFrom

        public java.lang.Object readFrom​(java.lang.Class<java.lang.Object> type,
                                         java.lang.reflect.Type genericType,
                                         java.lang.annotation.Annotation[] annotations,
                                         javax.ws.rs.core.MediaType mediaType,
                                         javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> httpHeaders,
                                         java.io.InputStream entityStream)
                                  throws java.io.IOException,
                                         javax.ws.rs.WebApplicationException
        Specified by:
        readFrom in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>
        Throws:
        java.io.IOException
        javax.ws.rs.WebApplicationException
      • createDataHolder

        protected com.thoughtworks.xstream.converters.DataHolder createDataHolder()
      • isWriteable

        public boolean isWriteable​(java.lang.Class<?> type,
                                   java.lang.reflect.Type genericType,
                                   java.lang.annotation.Annotation[] annotations,
                                   javax.ws.rs.core.MediaType mediaType)
        Specified by:
        isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
      • getSize

        public long getSize​(java.lang.Object o,
                            java.lang.Class<?> type,
                            java.lang.reflect.Type genericType,
                            java.lang.annotation.Annotation[] annotations,
                            javax.ws.rs.core.MediaType mediaType)
        Specified by:
        getSize in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
      • writeTo

        public void writeTo​(java.lang.Object o,
                            java.lang.Class<?> type,
                            java.lang.reflect.Type genericType,
                            java.lang.annotation.Annotation[] annotations,
                            javax.ws.rs.core.MediaType mediaType,
                            javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.Object> httpHeaders,
                            java.io.OutputStream entityStream)
                     throws java.io.IOException,
                            javax.ws.rs.WebApplicationException
        Specified by:
        writeTo in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
        Throws:
        java.io.IOException
        javax.ws.rs.WebApplicationException
      • getConfiguredXStream

        public static com.thoughtworks.xstream.XStream getConfiguredXStream()