Class JaxRsProviders
- java.lang.Object
-
- org.restlet.ext.jaxrs.internal.wrappers.provider.JaxRsProviders
-
- All Implemented Interfaces:
javax.ws.rs.ext.Providers,MessageBodyReaderSet
@Deprecated public class JaxRsProviders extends java.lang.Object implements javax.ws.rs.ext.Providers, MessageBodyReaderSet
Deprecated.Will be removed in next minor release.Contains the entity providers and has some methods to pick the wished out.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<ProviderWrapper>allDeprecated.private java.util.Collection<ProviderWrapper>contextResolversDeprecated.ThisSetcontains all availableContextResolvers.
This field is final, because it is shared with other objects.private java.util.Map<java.lang.Class<? extends java.lang.Throwable>,ProviderWrapper>excMappersDeprecated.private ExtensionBackwardMappingextensionBackwardMappingDeprecated.private static java.util.logging.LoggerlocalLoggerDeprecated.private java.util.logging.LoggerloggerDeprecated.private java.util.List<ProviderWrapper>messageBodyReaderWrappersDeprecated.private java.util.List<ProviderWrapper>messageBodyWriterWrappersDeprecated.private ObjectFactoryobjectFactoryDeprecated.private ThreadLocalizedContexttlContextDeprecated.
-
Constructor Summary
Constructors Constructor Description JaxRsProviders(ObjectFactory objectFactory, ThreadLocalizedContext tlContext, ExtensionBackwardMapping extensionBackwardMapping, java.util.logging.Logger logger)Deprecated.Creates a new JaxRsProviders.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidadd(ProviderWrapper provider, boolean defaultProvider)Deprecated.Adds the given provider to this JaxRsProviders.booleanaddClass(java.lang.Class<?> jaxRsProviderClass)Deprecated.private voidaddExcMapper(ProviderWrapper excMapperWrapper)Deprecated.Adds the givenExceptionMapperto this ExceptionMappers.booleanaddSingleton(java.lang.Object jaxRsProviderObject, boolean defaultProvider)Deprecated.javax.ws.rs.core.Responseconvert(java.lang.Throwable cause)Deprecated.converts the cause of the given InvocationTargetException to aResponse, if anExceptionMappercould be found.
Otherwise this method returns an Response with an internal server error.MessageBodyReadergetBestReader(java.lang.Class<?> paramType, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, MediaType mediaType)Deprecated.Returns theMessageBodyReader, that best matches the given criteria.<T> javax.ws.rs.ext.ContextResolver<T>getContextResolver(java.lang.Class<T> contextType, javax.ws.rs.core.MediaType mediaType)Deprecated.Get a context resolver for a particular type of context and media type.private static java.lang.Class<?>getCtxResGenClass(java.lang.Class<?> crClaz)Deprecated.Returns the generic class of the givenContextResolverclass.<T extends java.lang.Throwable>
javax.ws.rs.ext.ExceptionMapper<T>getExceptionMapper(java.lang.Class<T> causeClass)Deprecated.<T> javax.ws.rs.ext.MessageBodyReader<T>getMessageBodyReader(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)Deprecated.<T> javax.ws.rs.ext.MessageBodyWriter<T>getMessageBodyWriter(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)Deprecated.voidinitAll()Deprecated.Init all providers.private voidremove(ProviderWrapper provider)Deprecated.voidsetObjectFactory(ObjectFactory objectFactory)Deprecated.Sets the ObjectFactoryMessageBodyWriterSubSetwriterSubSet(java.lang.Class<?> entityClass, java.lang.reflect.Type genericType)Deprecated.Returns a Collection ofMessageBodyWriters, which generic type supports the given entityClass.
-
-
-
Field Detail
-
localLogger
private static final java.util.logging.Logger localLogger
Deprecated.
-
all
private final java.util.Set<ProviderWrapper> all
Deprecated.
-
contextResolvers
private final java.util.Collection<ProviderWrapper> contextResolvers
Deprecated.ThisSetcontains all availableContextResolvers.
This field is final, because it is shared with other objects.
-
excMappers
private final java.util.Map<java.lang.Class<? extends java.lang.Throwable>,ProviderWrapper> excMappers
Deprecated.
-
extensionBackwardMapping
private final ExtensionBackwardMapping extensionBackwardMapping
Deprecated.
-
logger
private final java.util.logging.Logger logger
Deprecated.
-
messageBodyReaderWrappers
private final java.util.List<ProviderWrapper> messageBodyReaderWrappers
Deprecated.
-
messageBodyWriterWrappers
private final java.util.List<ProviderWrapper> messageBodyWriterWrappers
Deprecated.
-
objectFactory
private volatile ObjectFactory objectFactory
Deprecated.
-
tlContext
private final ThreadLocalizedContext tlContext
Deprecated.
-
-
Constructor Detail
-
JaxRsProviders
public JaxRsProviders(ObjectFactory objectFactory, ThreadLocalizedContext tlContext, ExtensionBackwardMapping extensionBackwardMapping, java.util.logging.Logger logger)
Deprecated.Creates a new JaxRsProviders.- Parameters:
objectFactory-tlContext-extensionBackwardMapping-logger-
-
-
Method Detail
-
getCtxResGenClass
private static java.lang.Class<?> getCtxResGenClass(java.lang.Class<?> crClaz)
Deprecated.Returns the generic class of the givenContextResolverclass.
-
add
private void add(ProviderWrapper provider, boolean defaultProvider)
Deprecated.Adds the given provider to this JaxRsProviders. If the Provider is not an entity provider, it doesn't matter.- Parameters:
provider-defaultProvider-
-
addClass
public boolean addClass(java.lang.Class<?> jaxRsProviderClass)
Deprecated.- Parameters:
jaxRsProviderClass-- Returns:
- true if the provider was added, or false if not
-
addExcMapper
private void addExcMapper(ProviderWrapper excMapperWrapper)
Deprecated.Adds the givenExceptionMapperto this ExceptionMappers.- Parameters:
excMapper-- Throws:
java.lang.NullPointerException- if null is given
-
addSingleton
public boolean addSingleton(java.lang.Object jaxRsProviderObject, boolean defaultProvider) throws javax.ws.rs.WebApplicationExceptionDeprecated.- Parameters:
jaxRsProviderObject-defaultProvider-- Returns:
- true if the object was added, false if not.
- Throws:
javax.ws.rs.WebApplicationException
-
convert
public javax.ws.rs.core.Response convert(java.lang.Throwable cause)
Deprecated.converts the cause of the given InvocationTargetException to aResponse, if anExceptionMappercould be found.
Otherwise this method returns an Response with an internal server error.- Parameters:
cause- the thrown exception (was wrapped by anInvocationTargetException)- Returns:
- the created Response
- Throws:
java.lang.NullPointerException- ifnullis given- See Also:
ExceptionMapper#toResponse(Object)
-
getBestReader
public MessageBodyReader getBestReader(java.lang.Class<?> paramType, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, MediaType mediaType)
Deprecated.Returns theMessageBodyReader, that best matches the given criteria.- Specified by:
getBestReaderin interfaceMessageBodyReaderSet- Parameters:
paramType-genericType-annotations-mediaType- TheMediaType, that should be supported.- Returns:
- the
MessageBodyReader, that best matches the given criteria, or null if no matching MessageBodyReader could be found. - See Also:
MessageBodyReaderSet.getBestReader(Class, Type, Annotation[], MediaType)
-
getContextResolver
public <T> javax.ws.rs.ext.ContextResolver<T> getContextResolver(java.lang.Class<T> contextType, javax.ws.rs.core.MediaType mediaType)Deprecated.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 ofmediaTypewith the value of each resolver'sProduces, ensuring the generic type of the context resolver is assignable to the supplied value ofcontextType, 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 ofProduces(x/y > x/* > */*) sorted first. A proxy is returned that delegates calls toContextResolver.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:
getContextResolverin interfacejavax.ws.rs.ext.Providers- Parameters:
contextType- the class of context desiredmediaType- 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.
- See Also:
Providers.getContextResolver(Class, javax.ws.rs.core.MediaType)
-
getExceptionMapper
public <T extends java.lang.Throwable> javax.ws.rs.ext.ExceptionMapper<T> getExceptionMapper(java.lang.Class<T> causeClass)
Deprecated.- Specified by:
getExceptionMapperin interfacejavax.ws.rs.ext.Providers- Parameters:
causeClass-- Returns:
- the ExceptionMapper for the given Throwable class, or null, if none was found.
-
getMessageBodyReader
public <T> javax.ws.rs.ext.MessageBodyReader<T> getMessageBodyReader(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)Deprecated.- Specified by:
getMessageBodyReaderin interfacejavax.ws.rs.ext.Providers- See Also:
Providers.getMessageBodyReader(Class, Type, Annotation[], javax.ws.rs.core.MediaType)
-
getMessageBodyWriter
public <T> javax.ws.rs.ext.MessageBodyWriter<T> getMessageBodyWriter(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)Deprecated.- Specified by:
getMessageBodyWriterin interfacejavax.ws.rs.ext.Providers- See Also:
Providers.getMessageBodyWriter(Class, Type, Annotation[], javax.ws.rs.core.MediaType)
-
initAll
public void initAll()
Deprecated.Init all providers. If an error for one provider occurs, this provider is ignored and the next provider initialized.- Parameters:
tlContext-extensionBackwardMapping-
-
remove
private void remove(ProviderWrapper provider)
Deprecated.- Parameters:
provider-
-
setObjectFactory
public void setObjectFactory(ObjectFactory objectFactory)
Deprecated.Sets the ObjectFactory- Parameters:
objectFactory-
-
writerSubSet
public MessageBodyWriterSubSet writerSubSet(java.lang.Class<?> entityClass, java.lang.reflect.Type genericType)
Deprecated.Returns a Collection ofMessageBodyWriters, which generic type supports the given entityClass.- Parameters:
entityClass-genericType- may be nullannotations-mediaType-- Returns:
- a sub set of message body writers
- See Also:
javax.ws.rs.ext.MessageBodyWriter#isWriteable(Class, Type, Annotation[])
-
-