org.resteasy.plugins.providers.json.jettison
Class JettisonProvider

java.lang.Object
  extended by org.resteasy.plugins.providers.json.jettison.JettisonProvider
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<java.lang.Object>, javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>

@Provider
public class JettisonProvider
extends java.lang.Object
implements javax.ws.rs.ext.MessageBodyReader<java.lang.Object>, javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>

Reader/Writer for JAXB annotated classes and JSON. Uses Jettison

Supports Badger or Mapped convention. Badger is the default convention. You can override this default by using the @Mapped/@Badged annotation on the JAXB class or parameter you are (un)marshalling. Putting it on a parameter will always override any annotation on the class.

This class creates and caches separate class specific badger and mapped JAXBContexts.

Version:
$Revision: 1 $
Author:
Bill Burke

Constructor Summary
JettisonProvider()
           
 
Method Summary
 void clearCache()
          Clear JAXBContext cache
 java.util.Map<java.lang.Class<?>,javax.xml.bind.JAXBContext> getCache()
          This provider caches JAXBContext's on a per class basis.
 javax.xml.bind.JAXBContext getContext(java.lang.Class<?> clazz)
          Lookup.
 long getSize(java.lang.Object object)
           
 boolean isReadable(java.lang.Class<?> aClass, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations)
           
 boolean isWriteable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations)
           
 java.lang.Object readFrom(java.lang.Class<java.lang.Object> aClass, 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 inputStream)
           
 void writeTo(java.lang.Object object, 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 outputStream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JettisonProvider

public JettisonProvider()
Method Detail

getCache

public java.util.Map<java.lang.Class<?>,javax.xml.bind.JAXBContext> getCache()
This provider caches JAXBContext's on a per class basis. You can use this method to clear, prune, or prepopulate the cache with your own JAXBContext instances.

You can obtain an instance of this class by doing ResteasyProviderFactory.getProvider(JettisonProvider.class);


getContext

public javax.xml.bind.JAXBContext getContext(java.lang.Class<?> clazz)
                                      throws javax.xml.bind.JAXBException
Lookup. Will create context if it doesn't exist. Might be useful for prepopulating cache.

Parameters:
clazz -
Returns:
Throws:
javax.xml.bind.JAXBException

clearCache

public void clearCache()
Clear JAXBContext cache


isReadable

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

readFrom

public java.lang.Object readFrom(java.lang.Class<java.lang.Object> aClass,
                                 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 inputStream)
                          throws java.io.IOException
Specified by:
readFrom in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>
Throws:
java.io.IOException

isWriteable

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

getSize

public long getSize(java.lang.Object object)
Specified by:
getSize in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>

writeTo

public void writeTo(java.lang.Object object,
                    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 outputStream)
             throws java.io.IOException
Specified by:
writeTo in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
Throws:
java.io.IOException


Copyright © 2008. All Rights Reserved.