public class ResteasyProviderFactory extends RuntimeDelegate implements Providers
Modifier and Type | Class and Description |
---|---|
protected static class |
ResteasyProviderFactory.SortedKey<T>
Allow us to sort message body implementations that are more specific for their types
i.e.
|
RuntimeDelegate.HeaderDelegate<T>
JAXRS_RUNTIME_DELEGATE_PROPERTY
Constructor and Description |
---|
ResteasyProviderFactory() |
setInstance
protected MediaTypeMap<ResteasyProviderFactory.SortedKey<MessageBodyReader>> messageBodyReaders
protected MediaTypeMap<ResteasyProviderFactory.SortedKey<MessageBodyWriter>> messageBodyWriters
protected Map<Class<?>,ExceptionMapper> exceptionMappers
protected Map<Class<?>,ClientExceptionMapper> clientExceptionMappers
protected Map<Class<?>,MediaTypeMap<ResteasyProviderFactory.SortedKey<ContextResolver>>> contextResolvers
protected Map<Class<?>,StringConverter> stringConverters
protected Map<Class<?>,Class<? extends StringParameterUnmarshaller>> stringParameterUnmarshallers
protected Map<Class<?>,RuntimeDelegate.HeaderDelegate> headerDelegates
protected static AtomicReference<ResteasyProviderFactory> pfr
protected static ThreadLocalStack<Map<Class<?>,Object>> contextualData
protected static int maxForwards
protected static volatile ResteasyProviderFactory instance
public static boolean registerBuiltinByDefault
protected InterceptorRegistry<MessageBodyReaderInterceptor> serverMessageBodyReaderInterceptorRegistry
protected InterceptorRegistry<MessageBodyWriterInterceptor> serverMessageBodyWriterInterceptorRegistry
protected InterceptorRegistry<PreProcessInterceptor> serverPreProcessInterceptorRegistry
protected InterceptorRegistry<PostProcessInterceptor> serverPostProcessInterceptorRegistry
protected InterceptorRegistry<MessageBodyReaderInterceptor> clientMessageBodyReaderInterceptorRegistry
protected InterceptorRegistry<MessageBodyWriterInterceptor> clientMessageBodyWriterInterceptorRegistry
protected InterceptorRegistry<ClientExecutionInterceptor> clientExecutionInterceptorRegistry
protected List<ClientErrorInterceptor> clientErrorInterceptors
protected boolean builtinsRegistered
protected boolean registerBuiltins
protected InjectorFactory injectorFactory
protected void registerDefaultInterceptorPrecedences(InterceptorRegistry registry)
protected void registerDefaultInterceptorPrecedences()
public void appendInterceptorPrecedence(String precedence)
precedence
- public void insertInterceptorPrecedenceAfter(String after, String newPrecedence)
after
- put newPrecedence after thisnewPrecedence
- public void insertInterceptorPrecedenceBefore(String before, String newPrecedence)
before
- put newPrecedence before thisnewPrecedence
- public static <T> void pushContext(Class<T> type, T data)
public static <T> T getContextData(Class<T> type)
public static <T> T popContextData(Class<T> type)
public static void clearContextData()
public static int getContextDataLevelCount()
public static void removeContextDataLevel()
public static ResteasyProviderFactory peekInstance()
public static void clearInstanceIfEqual(ResteasyProviderFactory factory)
public static void setInstance(ResteasyProviderFactory factory)
public static ResteasyProviderFactory getInstance()
public static void setRegisterBuiltinByDefault(boolean registerBuiltinByDefault)
protected void initialize()
public boolean isRegisterBuiltins()
public void setRegisterBuiltins(boolean registerBuiltins)
public InjectorFactory getInjectorFactory()
public void setInjectorFactory(InjectorFactory injectorFactory)
public InterceptorRegistry<MessageBodyReaderInterceptor> getServerMessageBodyReaderInterceptorRegistry()
public InterceptorRegistry<MessageBodyWriterInterceptor> getServerMessageBodyWriterInterceptorRegistry()
public InterceptorRegistry<PreProcessInterceptor> getServerPreProcessInterceptorRegistry()
public InterceptorRegistry<PostProcessInterceptor> getServerPostProcessInterceptorRegistry()
public InterceptorRegistry<MessageBodyReaderInterceptor> getClientMessageBodyReaderInterceptorRegistry()
public InterceptorRegistry<MessageBodyWriterInterceptor> getClientMessageBodyWriterInterceptorRegistry()
public InterceptorRegistry<ClientExecutionInterceptor> getClientExecutionInterceptorRegistry()
public boolean isBuiltinsRegistered()
public void setBuiltinsRegistered(boolean builtinsRegistered)
public UriBuilder createUriBuilder()
RuntimeDelegate
UriBuilder
.createUriBuilder
in class RuntimeDelegate
UriBuilder
public Response.ResponseBuilder createResponseBuilder()
RuntimeDelegate
Response.ResponseBuilder
.createResponseBuilder
in class RuntimeDelegate
Response.ResponseBuilder
public Variant.VariantListBuilder createVariantListBuilder()
RuntimeDelegate
Variant.VariantListBuilder
.createVariantListBuilder
in class RuntimeDelegate
Variant.VariantListBuilder
public <T> RuntimeDelegate.HeaderDelegate<T> createHeaderDelegate(Class<T> tClass)
RuntimeDelegate
Cookie
, CacheControl
,
EntityTag
, NewCookie
,
MediaType
and java.util.Date
.createHeaderDelegate
in class RuntimeDelegate
tClass
- the class of the headerpublic void addHeaderDelegate(Class clazz, RuntimeDelegate.HeaderDelegate header)
public void addMessageBodyReader(Class<? extends MessageBodyReader> provider)
public void addMessageBodyReader(Class<? extends MessageBodyReader> provider, boolean isBuiltin)
public void addMessageBodyReader(MessageBodyReader provider)
public void addBuiltInMessageBodyReader(MessageBodyReader provider)
public void addMessageBodyReader(MessageBodyReader provider, boolean isBuiltin)
public void addMessageBodyReader(MessageBodyReader provider, Class providerClass, boolean isBuiltin)
provider
- providerClass
- isBuiltin
- public void addMessageBodyWriter(Class<? extends MessageBodyWriter> provider)
public void addMessageBodyWriter(Class<? extends MessageBodyWriter> provider, boolean isBuiltin)
public void addMessageBodyWriter(MessageBodyWriter provider)
public void addBuiltInMessageBodyWriter(MessageBodyWriter provider)
public void addMessageBodyWriter(MessageBodyWriter provider, boolean isBuiltin)
public void addMessageBodyWriter(MessageBodyWriter provider, Class providerClass, boolean isBuiltin)
provider
- providerClass
- isBuiltin
- public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType)
Providers
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.getMessageBodyReader
in interface Providers
type
- the class of object that is to be read.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.public void addExceptionMapper(Class<? extends ExceptionMapper> providerClass)
public void addExceptionMapper(ExceptionMapper provider)
public void addExceptionMapper(ExceptionMapper provider, Class providerClass)
public void addExceptionMapper(ExceptionMapper provider, Type exceptionType)
public void addClientExceptionMapper(Class<? extends ClientExceptionMapper<?>> providerClass)
public void addClientExceptionMapper(ClientExceptionMapper<?> provider)
public void addClientExceptionMapper(ClientExceptionMapper<?> provider, Class<?> providerClass)
public void addClientExceptionMapper(ClientExceptionMapper<?> provider, Type exceptionType)
public void addClientErrorInterceptor(ClientErrorInterceptor handler)
ClientErrorInterceptor
to this provider factory instance.
Duplicate handlers are ignored. (For Client Proxy API only)public List<ClientErrorInterceptor> getClientErrorInterceptors()
ClientErrorInterceptor
instances.public void addContextResolver(Class<? extends ContextResolver> resolver)
public void addContextResolver(Class<? extends ContextResolver> resolver, boolean builtin)
public void addContextResolver(ContextResolver provider)
public void addContextResolver(ContextResolver provider, boolean builtin)
public void addContextResolver(ContextResolver provider, Class providerClass, boolean builtin)
public void addContextResolver(ContextResolver provider, Type typeParameter)
public void addContextResolver(ContextResolver provider, Type typeParameter, boolean builtin)
public void addContextResolver(ContextResolver provider, Type typeParameter, Class providerClass, boolean builtin)
public void injectProperties(Object o)
public void addStringConverter(Class<? extends StringConverter> resolver)
public void addStringConverter(StringConverter provider)
public void addStringConverter(StringConverter provider, Class providerClass)
public void addStringConverter(StringConverter provider, Type typeParameter)
public void addStringParameterUnmarshaller(Class<? extends StringParameterUnmarshaller> provider)
public List<ContextResolver> getContextResolvers(Class<?> clazz, MediaType type)
public StringConverter getStringConverter(Class<?> clazz)
public <T> StringParameterUnmarshaller<T> createStringParameterUnmarshaller(Class<T> clazz)
public void registerProvider(Class provider)
public void registerProvider(Class provider, boolean isBuiltin)
provider
- public void registerProviderInstance(Object provider)
provider
- public <T> T getProvider(Class<T> providerClass)
public <T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T> type)
Providers
type
.getExceptionMapper
in interface Providers
type
- the class of exceptionExceptionMapper
for the supplied type or null if none
is found.public <T extends Throwable> ClientExceptionMapper<T> getClientExceptionMapper(Class<T> type)
public <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType)
Providers
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.getMessageBodyWriter
in interface Providers
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.public <T> T createEndpoint(Application applicationConfig, Class<T> endpointType) throws IllegalArgumentException, UnsupportedOperationException
createEndpoint
in class RuntimeDelegate
applicationConfig
- endpointType
- IllegalArgumentException
UnsupportedOperationException
public <T> ContextResolver<T> getContextResolver(Class<T> contextType, MediaType mediaType)
Providers
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.getContextResolver
in interface Providers
contextType
- the class of context desiredmediaType
- the media type of data for which a context is required.protected <T> T getProviderInstance(Class<? extends T> clazz)
Copyright © 2018 JBoss by Red Hat. All rights reserved.