Class ResteasyProviderFactoryDelegate

    • Constructor Detail

      • ResteasyProviderFactoryDelegate

        public ResteasyProviderFactoryDelegate​(ResteasyProviderFactory resteasyProviderFactoryDelegator)
    • Method Detail

      • getMessageBodyReader

        public <T> MessageBodyReader<T> getMessageBodyReader​(Class<T> type,
                                                             Type genericType,
                                                             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(Class, Type, Annotation[], MediaType) method is called on each reader in order using the supplied criteria and the first reader that returns true is selected and returned.
        Type Parameters:
        T - type of the the object that is to be read.
        Parameters:
        type - the class of the 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.
        Returns:
        a MessageBodyReader that matches the supplied criteria or null if none is found.
      • getMessageBodyWriter

        public <T> MessageBodyWriter<T> getMessageBodyWriter​(Class<T> type,
                                                             Type genericType,
                                                             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(Class, Type, Annotation[], MediaType) method is called on each writer in order using the supplied criteria and the first writer that returns true is selected and returned.
        Type Parameters:
        T - type of the object that is to be written.
        Parameters:
        type - the class of the 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.
      • getExceptionMapper

        public <T extends ThrowableExceptionMapper<T> getExceptionMapper​(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.
        Type Parameters:
        T - type of the exception handled by the exception mapping provider.
        Parameters:
        type - the class of exception.
        Returns:
        an ExceptionMapper for the supplied type or null if none is found.
      • getContextResolver

        public <T> ContextResolver<T> getContextResolver​(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.
        Type Parameters:
        T - type of the context.
        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.
      • toHeaderString

        public String toHeaderString​(Object object)
        Description copied from interface: HeaderValueProcessor
        Convert an object to a header string. First try StringConverter, then HeaderDelegate, then object.toString().
        Parameters:
        object - header object
        Returns:
        header string representation
      • getConfiguration

        public Configuration getConfiguration()
        Description copied from interface: Configurable
        Get a live view of an internal configuration state of this configurable instance. Any changes made using methods of this Configurable instance will be reflected in the returned Configuration instance.

        The returned Configuration instance and the collection data it provides are not thread-safe wrt. modification made using methods on the parent configurable object.

        Returns:
        configuration live view of the internal configuration state.
      • property

        public ResteasyProviderFactory property​(String name,
                                                Object value)
        Description copied from interface: Configurable
        Set the new configuration property, if already set, the existing value of the property will be updated. Setting a null value into a property effectively removes the property from the property bag.
        Parameters:
        name - property name.
        value - (new) property value. null value removes the property with the given name.
        Returns:
        the updated configurable instance.
      • register

        public ResteasyProviderFactory register​(Class<?> componentClass)
        Description copied from interface: Configurable
        Register a class of a custom JAX-RS component (such as an extension provider or a feature meta-provider) to be instantiated and used in the scope of this configurable context. Implementations SHOULD warn about and ignore registrations that do not conform to the requirements of supported JAX-RS component types in the given configurable context. Any subsequent registration attempts for a component type, for which a class or instance-based registration already exists in the system MUST be rejected by the JAX-RS implementation and a warning SHOULD be raised to inform the user about the rejected registration. The registered JAX-RS component class is registered as a contract provider of all the recognized JAX-RS or implementation-specific extension contracts including meta-provider contracts, such as Feature or DynamicFeature.

        As opposed to component instances registered via Configurable.register(Object) method, the lifecycle of components registered using this class-based register(...) method is fully managed by the JAX-RS implementation or any underlying IoC container supported by the implementation.

        Parameters:
        componentClass - JAX-RS component class to be configured in the scope of this configurable context.
        Returns:
        the updated configurable context.
      • register

        public ResteasyProviderFactory register​(Class<?> componentClass,
                                                int priority)
        Description copied from interface: Configurable
        Register a class of a custom JAX-RS component (such as an extension provider or a feature meta-provider) to be instantiated and used in the scope of this configurable context.

        This registration method provides the same functionality as Configurable.register(Class) except that any priority specified on the registered JAX-RS component class via jakarta.annotation.Priority annotation is overridden with the supplied priority value.

        Note that in case the priority is not applicable to a particular provider contract implemented by the class of the registered component, the supplied priority value will be ignored for that contract.

        Parameters:
        componentClass - JAX-RS component class to be configured in the scope of this configurable context.
        priority - the overriding priority for the registered component and all the provider contracts the component implements.
        Returns:
        the updated configurable context.
      • register

        public ResteasyProviderFactory register​(Class<?> componentClass,
                                                Class<?>... contracts)
        Description copied from interface: Configurable
        Register a class of a custom JAX-RS component (such as an extension provider or a feature meta-provider) to be instantiated and used in the scope of this configurable context.

        This registration method provides the same functionality as Configurable.register(Class) except the JAX-RS component class is only registered as a provider of the listed extension provider or meta-provider contracts. All explicitly enumerated contract types must represent a class or an interface implemented or extended by the registered component. Contracts that are not assignable from the registered component class MUST be ignored and implementations SHOULD raise a warning to inform users about the ignored contract(s).

        Parameters:
        componentClass - JAX-RS component class to be configured in the scope of this configurable context.
        contracts - the specific extension provider or meta-provider contracts implemented by the component for which the component should be registered. Implementations MUST ignore attempts to register a component class for an empty or null collection of contracts via this method and SHOULD raise a warning about such event.
        Returns:
        the updated configurable context.
      • register

        public ResteasyProviderFactory register​(Class<?> componentClass,
                                                Map<Class<?>,​Integer> contracts)
        Description copied from interface: Configurable
        Register a class of a custom JAX-RS component (such as an extension provider or a feature meta-provider) to be instantiated and used in the scope of this configurable context.

        This registration method provides same functionality as Configurable.register(Class, Class[]) except that any priority specified on the registered JAX-RS component class via jakarta.annotation.Priority annotation is overridden for each extension provider contract type separately with an integer priority value specified as a value in the supplied map of [contract type, priority] pairs.

        Note that in case a priority is not applicable to a provider contract registered for the JAX-RS component, the supplied priority value is ignored for such contract.

        Parameters:
        componentClass - JAX-RS component class to be configured in the scope of this configurable context.
        contracts - map of the specific extension provider and meta-provider contracts and their associated priorities for which the JAX-RS component is registered. All contracts in the map must represent a class or an interface implemented or extended by the JAX-RS component. Contracts that are not assignable from the registered component class MUST be ignored and implementations SHOULD raise a warning to inform users about the ignored contract(s).
        Returns:
        the updated configurable context.
      • register

        public ResteasyProviderFactory register​(Object component)
        Description copied from interface: Configurable
        Register an instance of a custom JAX-RS component (such as an extension provider or a feature meta-provider) to be instantiated and used in the scope of this configurable context. Implementations SHOULD warn about and ignore registrations that do not conform to the requirements of supported JAX-RS component types in the given configurable context. Any subsequent registration attempts for a component type, for which a class or instance-based registration already exists in the system MUST be rejected by the JAX-RS implementation and a warning SHOULD be raised to inform the user about the rejected registration. The registered JAX-RS component is registered as a contract provider of all the recognized JAX-RS or implementation-specific extension contracts including meta-provider contracts, such as Feature or DynamicFeature.

        As opposed to components registered via Configurable.register(Class) method, the lifecycle of providers registered using this instance-based register(...) is not managed by JAX-RS runtime. The same registered component instance is used during the whole lifespan of the configurable context. Fields and properties of all registered JAX-RS component instances are injected with their declared dependencies (see Context) by the JAX-RS runtime prior to use.

        Parameters:
        component - JAX-RS component instance to be configured in the scope of this configurable context.
        Returns:
        the updated configurable context.
      • register

        public ResteasyProviderFactory register​(Object component,
                                                int priority)
        Description copied from interface: Configurable
        Register an instance of a custom JAX-RS component (such as an extension provider or a feature meta-provider) to be instantiated and used in the scope of this configurable context.

        This registration method provides the same functionality as Configurable.register(Object) except that any priority specified on the registered JAX-RS component class via jakarta.annotation.Priority annotation is overridden with the supplied priority value.

        Note that in case the priority is not applicable to a particular provider contract implemented by the class of the registered component, the supplied priority value will be ignored for that contract.

        Parameters:
        component - JAX-RS component instance to be configured in the scope of this configurable context.
        priority - the overriding priority for the registered component and all the provider contracts the component implements.
        Returns:
        the updated configurable context.
      • register

        public ResteasyProviderFactory register​(Object component,
                                                Class<?>... contracts)
        Description copied from interface: Configurable
        Register an instance of a custom JAX-RS component (such as an extension provider or a feature meta-provider) to be instantiated and used in the scope of this configurable context.

        This registration method provides the same functionality as Configurable.register(Object) except the JAX-RS component class is only registered as a provider of the listed extension provider or meta-provider contracts. All explicitly enumerated contract types must represent a class or an interface implemented or extended by the registered component. Contracts that are not assignable from the registered component class MUST be ignored and implementations SHOULD raise a warning to inform users about the ignored contract(s).

        Parameters:
        component - JAX-RS component instance to be configured in the scope of this configurable context.
        contracts - the specific extension provider or meta-provider contracts implemented by the component for which the component should be registered. Implementations MUST ignore attempts to register a component class for an empty or null collection of contracts via this method and SHOULD raise a warning about such event.
        Returns:
        the updated configurable context.
      • register

        public ResteasyProviderFactory register​(Object component,
                                                Map<Class<?>,​Integer> contracts)
        Description copied from interface: Configurable
        Register an instance of a custom JAX-RS component (such as an extension provider or a feature meta-provider) to be instantiated and used in the scope of this configurable context.

        This registration method provides same functionality as Configurable.register(Object, Class[]) except that any priority specified on the registered JAX-RS component class via jakarta.annotation.Priority annotation is overridden for each extension provider contract type separately with an integer priority value specified as a value in the supplied map of [contract type, priority] pairs.

        Note that in case a priority is not applicable to a provider contract registered for the JAX-RS component, the supplied priority value is ignored for such contract.

        Parameters:
        component - JAX-RS component instance to be configured in the scope of this configurable context.
        contracts - map of the specific extension provider and meta-provider contracts and their associated priorities for which the JAX-RS component is registered. All contracts in the map must represent a class or an interface implemented or extended by the JAX-RS component. Contracts that are not assignable from the registered component class MUST be ignored and implementations SHOULD raise a warning to inform users about the ignored contract(s).
        Returns:
        the updated configurable context.
      • getRuntimeType

        public RuntimeType getRuntimeType()
        Description copied from interface: Configuration
        Get the runtime type of this configuration context.
        Returns:
        configuration context runtime type.
      • getProperties

        public Map<String,​Object> getProperties()
        Description copied from interface: Configuration
        Get the immutable bag of configuration properties.
        Returns:
        the immutable view of configuration properties.
      • getProperty

        public Object getProperty​(String name)
        Description copied from interface: Configuration
        Get the value for the property with a given name.
        Parameters:
        name - property name.
        Returns:
        the property value for the specified property name or null if the property with such name is not configured.
      • isEnabled

        public boolean isEnabled​(Feature feature)
        Description copied from interface: Configuration
        Check if a particular feature instance has been previously enabled in the runtime configuration context.

        Method returns true only in case an instance equal to the feature instance is already present among the features previously successfully enabled in the configuration context.

        Parameters:
        feature - a feature instance to test for.
        Returns:
        true if the feature instance has been previously enabled in this configuration context, false otherwise.
      • isEnabled

        public boolean isEnabled​(Class<? extends Feature> featureClass)
        Description copied from interface: Configuration
        Check if a feature instance of featureClass class has been previously enabled in the runtime configuration context.

        Method returns true in case any instance of the featureClass class is already present among the features previously successfully enabled in the configuration context.

        Parameters:
        featureClass - a feature class to test for.
        Returns:
        true if a feature of a given class has been previously enabled in this configuration context, false otherwise.
      • isRegistered

        public boolean isRegistered​(Object component)
        Description copied from interface: Configuration
        Check if a particular JAX-RS component instance (such as providers or features) has been previously registered in the runtime configuration context.

        Method returns true only in case an instance equal to the component instance is already present among the components previously registered in the configuration context.

        Parameters:
        component - a component instance to test for.
        Returns:
        true if the component instance has been previously registered in this configuration context, false otherwise.
        See Also:
        Configuration.isEnabled(Feature)
      • isRegistered

        public boolean isRegistered​(Class<?> componentClass)
        Description copied from interface: Configuration
        Check if a JAX-RS component of the supplied componentClass class has been previously registered in the runtime configuration context.

        Method returns true in case a component of the supplied componentClass class is already present among the previously registered component classes or instances in the configuration context.

        Parameters:
        componentClass - a component class to test for.
        Returns:
        true if a component of a given class has been previously registered in this configuration context, false otherwise.
        See Also:
        Configuration.isEnabled(Class)
      • getContracts

        public Map<Class<?>,​Integer> getContracts​(Class<?> componentClass)
        Description copied from interface: Configuration
        Get the extension contract registration information for a component of a given class. For component classes that are not configured in this configuration context the method returns an empty Map. Method does not return null.
        Parameters:
        componentClass - a component class for which to get contracts.
        Returns:
        map of extension contracts and their priorities for which the component class is registered. May return an empty map in case the component has not been registered for any extension contract supported by the implementation.
      • getClasses

        public Set<Class<?>> getClasses()
        Description copied from interface: Configuration
        Get the immutable set of registered JAX-RS component (such as provider, root resource or feature) classes to be instantiated, injected and utilized in the scope of the configurable instance. In contrast to Application.getClasses() this method returns a complete runtime view and therefore also includes auto-discovered components.

        For each component type, there can be only a single class-based or instance-based registration present in the configuration context at any given time.

        Returns:
        the immutable set of registered JAX-RS component classes. The returned value may be empty but will never be null.
        See Also:
        Configuration.getInstances()
      • getInstances

        public Set<Object> getInstances()
        Description copied from interface: Configuration
        Get the immutable set of registered JAX-RS component (such as provider or feature) instances to be utilized by the configurable instance. Fields and properties of returned instances are injected with their declared dependencies (see Context) by the runtime prior to use.

        For each component type, there can be only a single class-based or instance-based registration present in the configuration context at any given time.

        Returns:
        the immutable set of registered JAX-RS component instances. The returned value may be empty but will never be null.
        See Also:
        Configuration.getClasses()
      • toString

        public String toString​(Object object,
                               Class clazz,
                               Type genericType,
                               Annotation[] annotations)
        Description copied from class: ResteasyProviderFactory
        Convert an object to a string. First try StringConverter then, object.ToString()
        Specified by:
        toString in class ResteasyProviderFactory
        Parameters:
        object - object
        clazz - class
        genericType - generic type
        annotations - array of annotation
        Returns:
        string representation
      • registerProvider

        public void registerProvider​(Class provider,
                                     boolean isBuiltin)
        Description copied from class: ResteasyProviderFactory
        Register a @Provider class. Can be a MessageBodyReader/Writer or ExceptionMapper.
        Specified by:
        registerProvider in class ResteasyProviderFactory
        Parameters:
        provider - provider class
        isBuiltin - built-in
      • createProviderInstance

        public <T> T createProviderInstance​(Class<? extends T> clazz)
        Description copied from class: ResteasyProviderFactory
        Create an instance of a class using provider allocation rules of the specification as well as the InjectorFactory only does constructor injection.
        Specified by:
        createProviderInstance in class ResteasyProviderFactory
        Type Parameters:
        T - type
        Parameters:
        clazz - class
        Returns:
        provider instance of type T
      • injectedInstance

        public <T> T injectedInstance​(Class<? extends T> clazz)
        Description copied from class: ResteasyProviderFactory
        Property and constructor injection using the InjectorFactory.
        Specified by:
        injectedInstance in class ResteasyProviderFactory
        Type Parameters:
        T - type
        Parameters:
        clazz - class
        Returns:
        instance of type T
      • hasProperty

        public boolean hasProperty​(String name)
        Description copied from interface: Configuration
        Check whether the property with a given name is configured.
        Parameters:
        name - property name.
        Returns:
        false if the property with such name is not configured, true otherwise.