org.jboss.resteasy.core
Class ThreadLocalResteasyProviderFactory

java.lang.Object
  extended by javax.ws.rs.ext.RuntimeDelegate
      extended by org.jboss.resteasy.spi.ResteasyProviderFactory
          extended by org.jboss.resteasy.core.ThreadLocalResteasyProviderFactory
All Implemented Interfaces:
Providers, ProviderFactoryDelegate

public class ThreadLocalResteasyProviderFactory
extends ResteasyProviderFactory
implements ProviderFactoryDelegate

Allow applications to push/pop provider factories onto the stack

Version:
$Revision: 1 $
Author:
Bill Burke

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.resteasy.spi.ResteasyProviderFactory
ResteasyProviderFactory.MessageBodyKey<T>
 
Nested classes/interfaces inherited from class javax.ws.rs.ext.RuntimeDelegate
RuntimeDelegate.HeaderDelegate<T>
 
Field Summary
 
Fields inherited from class org.jboss.resteasy.spi.ResteasyProviderFactory
builtinsRegistered, clientExecutionInterceptorRegistry, clientMessageBodyReaderInterceptorRegistry, clientMessageBodyWriterInterceptorRegistry, contextResolvers, contextualData, exceptionMappers, headerDelegates, maxForwards, messageBodyReaders, messageBodyWriters, pfr, providers, serverMessageBodyReaderInterceptorRegistry, serverMessageBodyWriterInterceptorRegistry, serverPostProcessInterceptorRegistry, serverPreProcessInterceptorRegistry, stringConverters
 
Fields inherited from class javax.ws.rs.ext.RuntimeDelegate
JAXRS_RUNTIME_DELEGATE_PROPERTY
 
Constructor Summary
ThreadLocalResteasyProviderFactory(ResteasyProviderFactory defaultFactory)
           
 
Method Summary
 void addBuiltInMessageBodyReader(MessageBodyReader provider)
           
 void addBuiltInMessageBodyWriter(MessageBodyWriter provider)
           
 void addContextResolver(java.lang.Class<? extends ContextResolver> resolver)
           
 void addContextResolver(ContextResolver provider)
           
 void addExceptionMapper(java.lang.Class<? extends ExceptionMapper> provider)
           
 void addExceptionMapper(ExceptionMapper provider)
           
 void addHeaderDelegate(java.lang.Class clazz, RuntimeDelegate.HeaderDelegate header)
           
 void addMessageBodyReader(java.lang.Class<? extends MessageBodyReader> provider)
           
 void addMessageBodyReader(java.lang.Class<? extends MessageBodyReader> provider, boolean isBuiltin)
           
 void addMessageBodyReader(MessageBodyReader provider)
           
 void addMessageBodyReader(MessageBodyReader provider, boolean isBuiltin)
           
 void addMessageBodyWriter(java.lang.Class<? extends MessageBodyWriter> provider)
           
 void addMessageBodyWriter(java.lang.Class<? extends MessageBodyWriter> provider, boolean isBuiltin)
           
 void addMessageBodyWriter(MessageBodyWriter provider)
           
 void addMessageBodyWriter(MessageBodyWriter provider, boolean isBuiltin)
           
 void addStringConverter(java.lang.Class<? extends StringConverter> resolver)
           
 void addStringConverter(StringConverter provider)
           
 void appendInterceptorPrecedence(java.lang.String precedence)
          Append interceptor predence
<T> T
createEndpoint(Application applicationConfig, java.lang.Class<T> endpointType)
          this is a spec method that is unsupported.
<T> RuntimeDelegate.HeaderDelegate<T>
createHeaderDelegate(java.lang.Class<T> tClass)
          Obtain an instance of a HeaderDelegate for the supplied class.
 Response.ResponseBuilder createResponseBuilder()
          Create a new instance of a Response.ResponseBuilder.
 UriBuilder createUriBuilder()
          Create a new instance of a UriBuilder.
 Variant.VariantListBuilder createVariantListBuilder()
          Create a new instance of a Variant.VariantListBuilder.
 InterceptorRegistry<ClientExecutionInterceptor> getClientExecutionInterceptorRegistry()
           
 InterceptorRegistry<MessageBodyReaderInterceptor> getClientMessageBodyReaderInterceptorRegistry()
           
 InterceptorRegistry<MessageBodyWriterInterceptor> getClientMessageBodyWriterInterceptorRegistry()
           
<T> ContextResolver<T>
getContextResolver(java.lang.Class<T> contextType, MediaType mediaType)
          Get a context resolver for a particular type of context and media type.
 java.util.List<ContextResolver> getContextResolvers(java.lang.Class<?> clazz, MediaType type)
           
 ResteasyProviderFactory getDelegate()
           
<T extends java.lang.Throwable>
ExceptionMapper<T>
getExceptionMapper(java.lang.Class<T> type)
          Get an exception mapping provider for a particular class of exception.
<T> MessageBodyReader<T>
getMessageBodyReader(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, MediaType mediaType)
          Get a message body reader that matches a set of criteria.
<T> MessageBodyWriter<T>
getMessageBodyWriter(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, MediaType mediaType)
          Get a message body writer that matches a set of criteria.
<T> T
getProvider(java.lang.Class<T> providerClass)
          Obtain a registered @Provider instance keyed by class.
 InterceptorRegistry<MessageBodyReaderInterceptor> getServerMessageBodyReaderInterceptorRegistry()
           
 InterceptorRegistry<MessageBodyWriterInterceptor> getServerMessageBodyWriterInterceptorRegistry()
           
 InterceptorRegistry<PostProcessInterceptor> getServerPostProcessInterceptorRegistry()
           
 InterceptorRegistry<PreProcessInterceptor> getServerPreProcessInterceptorRegistry()
           
 StringConverter getStringConverter(java.lang.Class<?> clazz)
           
protected  void initialize()
           
 void insertInterceptorPrecedenceAfter(java.lang.String after, java.lang.String newPrecedence)
           
 void insertInterceptorPrecedenceBefore(java.lang.String before, java.lang.String newPrecedence)
           
 boolean isBuiltinsRegistered()
           
static void pop()
           
static void push(ResteasyProviderFactory factory)
           
 void registerProvider(java.lang.Class provider)
           
 void registerProvider(java.lang.Class provider, boolean isBuiltin)
          Register a @Provider class.
 void registerProviderInstance(java.lang.Object provider)
          Register a @Provider object.
 void setBuiltinsRegistered(boolean builtinsRegistered)
           
 
Methods inherited from class org.jboss.resteasy.spi.ResteasyProviderFactory
addContextDataLevel, clearContextData, getContextData, getContextDataLevelCount, getContextDataMap, getInstance, popContextData, pushContext, pushContextDataMap, registerDefaultInterceptorPrecedences, registerDefaultInterceptorPrecedences, removeContextDataLevel, setInstance
 
Methods inherited from class javax.ws.rs.ext.RuntimeDelegate
setInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLocalResteasyProviderFactory

public ThreadLocalResteasyProviderFactory(ResteasyProviderFactory defaultFactory)
Method Detail

getDelegate

public ResteasyProviderFactory getDelegate()
Specified by:
getDelegate in interface ProviderFactoryDelegate

isBuiltinsRegistered

public boolean isBuiltinsRegistered()
Overrides:
isBuiltinsRegistered in class ResteasyProviderFactory

setBuiltinsRegistered

public void setBuiltinsRegistered(boolean builtinsRegistered)
Overrides:
setBuiltinsRegistered in class ResteasyProviderFactory

addMessageBodyReader

public void addMessageBodyReader(MessageBodyReader provider,
                                 boolean isBuiltin)
Overrides:
addMessageBodyReader in class ResteasyProviderFactory

addMessageBodyWriter

public void addMessageBodyWriter(MessageBodyWriter provider,
                                 boolean isBuiltin)
Overrides:
addMessageBodyWriter in class ResteasyProviderFactory

getServerMessageBodyReaderInterceptorRegistry

public InterceptorRegistry<MessageBodyReaderInterceptor> getServerMessageBodyReaderInterceptorRegistry()
Overrides:
getServerMessageBodyReaderInterceptorRegistry in class ResteasyProviderFactory

getClientExecutionInterceptorRegistry

public InterceptorRegistry<ClientExecutionInterceptor> getClientExecutionInterceptorRegistry()
Overrides:
getClientExecutionInterceptorRegistry in class ResteasyProviderFactory

getClientMessageBodyWriterInterceptorRegistry

public InterceptorRegistry<MessageBodyWriterInterceptor> getClientMessageBodyWriterInterceptorRegistry()
Overrides:
getClientMessageBodyWriterInterceptorRegistry in class ResteasyProviderFactory

getClientMessageBodyReaderInterceptorRegistry

public InterceptorRegistry<MessageBodyReaderInterceptor> getClientMessageBodyReaderInterceptorRegistry()
Overrides:
getClientMessageBodyReaderInterceptorRegistry in class ResteasyProviderFactory

getServerPreProcessInterceptorRegistry

public InterceptorRegistry<PreProcessInterceptor> getServerPreProcessInterceptorRegistry()
Overrides:
getServerPreProcessInterceptorRegistry in class ResteasyProviderFactory

getServerPostProcessInterceptorRegistry

public InterceptorRegistry<PostProcessInterceptor> getServerPostProcessInterceptorRegistry()
Overrides:
getServerPostProcessInterceptorRegistry in class ResteasyProviderFactory

getServerMessageBodyWriterInterceptorRegistry

public InterceptorRegistry<MessageBodyWriterInterceptor> getServerMessageBodyWriterInterceptorRegistry()
Overrides:
getServerMessageBodyWriterInterceptorRegistry in class ResteasyProviderFactory

initialize

protected void initialize()
Overrides:
initialize in class ResteasyProviderFactory

push

public static void push(ResteasyProviderFactory factory)

pop

public static void pop()

createUriBuilder

public UriBuilder createUriBuilder()
Description copied from class: RuntimeDelegate
Create a new instance of a UriBuilder.

Overrides:
createUriBuilder in class ResteasyProviderFactory
Returns:
new UriBuilder instance
See Also:
UriBuilder

createResponseBuilder

public Response.ResponseBuilder createResponseBuilder()
Description copied from class: RuntimeDelegate
Create a new instance of a Response.ResponseBuilder.

Overrides:
createResponseBuilder in class ResteasyProviderFactory
Returns:
new ResponseBuilder instance
See Also:
Response.ResponseBuilder

createVariantListBuilder

public Variant.VariantListBuilder createVariantListBuilder()
Description copied from class: RuntimeDelegate
Create a new instance of a Variant.VariantListBuilder.

Overrides:
createVariantListBuilder in class ResteasyProviderFactory
Returns:
new VariantListBuilder instance
See Also:
Variant.VariantListBuilder

createHeaderDelegate

public <T> RuntimeDelegate.HeaderDelegate<T> createHeaderDelegate(java.lang.Class<T> tClass)
Description copied from class: RuntimeDelegate
Obtain an instance of a HeaderDelegate for the supplied class. An implementation is required to support the following values for type: Cookie, CacheControl, EntityTag, NewCookie, MediaType and java.util.Date.

Overrides:
createHeaderDelegate in class ResteasyProviderFactory
Parameters:
tClass - the class of the header
Returns:
an instance of HeaderDelegate for the supplied type

addHeaderDelegate

public void addHeaderDelegate(java.lang.Class clazz,
                              RuntimeDelegate.HeaderDelegate header)
Overrides:
addHeaderDelegate in class ResteasyProviderFactory

addMessageBodyReader

public void addMessageBodyReader(java.lang.Class<? extends MessageBodyReader> provider)
Overrides:
addMessageBodyReader in class ResteasyProviderFactory

addMessageBodyReader

public void addMessageBodyReader(MessageBodyReader provider)
Overrides:
addMessageBodyReader in class ResteasyProviderFactory

addBuiltInMessageBodyReader

public void addBuiltInMessageBodyReader(MessageBodyReader provider)
Overrides:
addBuiltInMessageBodyReader in class ResteasyProviderFactory

addMessageBodyWriter

public void addMessageBodyWriter(java.lang.Class<? extends MessageBodyWriter> provider)
Overrides:
addMessageBodyWriter in class ResteasyProviderFactory

addMessageBodyWriter

public void addMessageBodyWriter(MessageBodyWriter provider)
Overrides:
addMessageBodyWriter in class ResteasyProviderFactory

addBuiltInMessageBodyWriter

public void addBuiltInMessageBodyWriter(MessageBodyWriter provider)
Overrides:
addBuiltInMessageBodyWriter in class ResteasyProviderFactory

getMessageBodyReader

public <T> MessageBodyReader<T> getMessageBodyReader(java.lang.Class<T> type,
                                                     java.lang.reflect.Type genericType,
                                                     java.lang.annotation.Annotation[] annotations,
                                                     MediaType mediaType)
Description copied from interface: Providers
Get a message body reader that matches a set of criteria. The set of readers is first filtered by comparing the supplied value of mediaType with the value of each reader's Consumes, ensuring the supplied value of type is assignable to the generic type of the reader, and eliminating those that do not match. The list of matching readers is then ordered with those with the best matching values of Consumes (x/y > x/* > */*) sorted first. Finally, the MessageBodyReader.isReadable(java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType) method is called on each reader in order using the supplied criteria and the first reader that returns true is selected and returned.

Specified by:
getMessageBodyReader in interface Providers
Overrides:
getMessageBodyReader in class ResteasyProviderFactory
Parameters:
type - the class of object that is to be written.
genericType - the type of object to be produced. E.g. if the message body is to be converted into a method parameter, this will be the formal type of the method parameter as returned by Class.getGenericParameterTypes.
annotations - an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned by Class.getParameterAnnotations.
mediaType - the media type of the data that will be read.
Returns:
a MessageBodyReader that matches the supplied criteria or null if none is found.

addExceptionMapper

public void addExceptionMapper(java.lang.Class<? extends ExceptionMapper> provider)
Overrides:
addExceptionMapper in class ResteasyProviderFactory

addExceptionMapper

public void addExceptionMapper(ExceptionMapper provider)
Overrides:
addExceptionMapper in class ResteasyProviderFactory

addContextResolver

public void addContextResolver(java.lang.Class<? extends ContextResolver> resolver)
Overrides:
addContextResolver in class ResteasyProviderFactory

addContextResolver

public void addContextResolver(ContextResolver provider)
Overrides:
addContextResolver in class ResteasyProviderFactory

addStringConverter

public void addStringConverter(java.lang.Class<? extends StringConverter> resolver)
Overrides:
addStringConverter in class ResteasyProviderFactory

addStringConverter

public void addStringConverter(StringConverter provider)
Overrides:
addStringConverter in class ResteasyProviderFactory

getContextResolvers

public java.util.List<ContextResolver> getContextResolvers(java.lang.Class<?> clazz,
                                                           MediaType type)
Overrides:
getContextResolvers in class ResteasyProviderFactory

getStringConverter

public StringConverter getStringConverter(java.lang.Class<?> clazz)
Overrides:
getStringConverter in class ResteasyProviderFactory

registerProvider

public void registerProvider(java.lang.Class provider)
Overrides:
registerProvider in class ResteasyProviderFactory

registerProviderInstance

public void registerProviderInstance(java.lang.Object provider)
Description copied from class: ResteasyProviderFactory
Register a @Provider object. Can be a MessageBodyReader/Writer or ExceptionMapper.

Overrides:
registerProviderInstance in class ResteasyProviderFactory

getProvider

public <T> T getProvider(java.lang.Class<T> providerClass)
Description copied from class: ResteasyProviderFactory
Obtain a registered @Provider instance keyed by class. This can get you access to any @Provider: MessageBodyReader/Writer or ExceptionMapper

Overrides:
getProvider in class ResteasyProviderFactory

getExceptionMapper

public <T extends java.lang.Throwable> ExceptionMapper<T> getExceptionMapper(java.lang.Class<T> type)
Description copied from interface: Providers
Get an exception mapping provider for a particular class of exception. Returns the provider whose generic type is the nearest superclass of type.

Specified by:
getExceptionMapper in interface Providers
Overrides:
getExceptionMapper in class ResteasyProviderFactory
Parameters:
type - the class of exception
Returns:
an ExceptionMapper for the supplied type or null if none is found.

getMessageBodyWriter

public <T> MessageBodyWriter<T> getMessageBodyWriter(java.lang.Class<T> type,
                                                     java.lang.reflect.Type genericType,
                                                     java.lang.annotation.Annotation[] annotations,
                                                     MediaType mediaType)
Description copied from interface: Providers
Get a message body writer that matches a set of criteria. The set of writers is first filtered by comparing the supplied value of mediaType with the value of each writer's Produces, ensuring the supplied value of type is assignable to the generic type of the reader, and eliminating those that do not match. The list of matching writers is then ordered with those with the best matching values of Produces (x/y > x/* > */*) sorted first. Finally, the MessageBodyWriter.isWriteable(java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType) method is called on each writer in order using the supplied criteria and the first writer that returns true is selected and returned.

Specified by:
getMessageBodyWriter in interface Providers
Overrides:
getMessageBodyWriter in class ResteasyProviderFactory
Parameters:
type - the class of object that is to be written.
genericType - the type of object to be written. E.g. if the message body is to be produced from a field, this will be the declared type of the field as returned by Field.getGenericType.
annotations - an array of the annotations on the declaration of the artifact that will be written. E.g. if the message body is to be produced from a field, this will be the annotations on that field returned by Field.getDeclaredAnnotations.
mediaType - the media type of the data that will be written.
Returns:
a MessageBodyReader that matches the supplied criteria or null if none is found.

createEndpoint

public <T> T createEndpoint(Application applicationConfig,
                            java.lang.Class<T> endpointType)
                 throws java.lang.IllegalArgumentException,
                        java.lang.UnsupportedOperationException
Description copied from class: ResteasyProviderFactory
this is a spec method that is unsupported. it is an optional method anyways.

Overrides:
createEndpoint in class ResteasyProviderFactory
Parameters:
applicationConfig - the application configuration
endpointType - the type of endpoint instance to be created.
Returns:
a configured instance of the requested type.
Throws:
java.lang.IllegalArgumentException - if application is null or the requested endpoint type is not supported.
java.lang.UnsupportedOperationException - if the implementation supports no endpoint types.

getContextResolver

public <T> ContextResolver<T> getContextResolver(java.lang.Class<T> contextType,
                                                 MediaType mediaType)
Description copied from interface: Providers
Get a context resolver for a particular type of context and media type. The set of resolvers is first filtered by comparing the supplied value of mediaType with the value of each resolver's Produces, ensuring the generic type of the context resolver is assignable to the supplied value of contextType, and eliminating those that do not match. If only one resolver matches the criteria then it is returned. If more than one resolver matches then the list of matching resolvers is ordered with those with the best matching values of Produces (x/y > x/* > */*) sorted first. A proxy is returned that delegates calls to ContextResolver.getContext(java.lang.Class) to each matching context resolver in order and returns the first non-null value it obtains or null if all matching context resolvers return null.

Specified by:
getContextResolver in interface Providers
Overrides:
getContextResolver in class ResteasyProviderFactory
Parameters:
contextType - the class of context desired
mediaType - the media type of data for which a context is required.
Returns:
a matching context resolver instance or null if no matching context providers are found.

addMessageBodyReader

public void addMessageBodyReader(java.lang.Class<? extends MessageBodyReader> provider,
                                 boolean isBuiltin)
Overrides:
addMessageBodyReader in class ResteasyProviderFactory

addMessageBodyWriter

public void addMessageBodyWriter(java.lang.Class<? extends MessageBodyWriter> provider,
                                 boolean isBuiltin)
Overrides:
addMessageBodyWriter in class ResteasyProviderFactory

registerProvider

public void registerProvider(java.lang.Class provider,
                             boolean isBuiltin)
Description copied from class: ResteasyProviderFactory
Register a @Provider class. Can be a MessageBodyReader/Writer or ExceptionMapper.

Overrides:
registerProvider in class ResteasyProviderFactory

appendInterceptorPrecedence

public void appendInterceptorPrecedence(java.lang.String precedence)
Description copied from class: ResteasyProviderFactory
Append interceptor predence

Overrides:
appendInterceptorPrecedence in class ResteasyProviderFactory

insertInterceptorPrecedenceAfter

public void insertInterceptorPrecedenceAfter(java.lang.String after,
                                             java.lang.String newPrecedence)
Overrides:
insertInterceptorPrecedenceAfter in class ResteasyProviderFactory
Parameters:
after - put newPrecedence after this

insertInterceptorPrecedenceBefore

public void insertInterceptorPrecedenceBefore(java.lang.String before,
                                              java.lang.String newPrecedence)
Overrides:
insertInterceptorPrecedenceBefore in class ResteasyProviderFactory
Parameters:
before - put newPrecedence before this


Copyright © 2009. All Rights Reserved.