Class ClientConfiguration

java.lang.Object
org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration
All Implemented Interfaces:
Configurable<ClientConfiguration>, Configuration, Providers, HeaderValueProcessor

public class ClientConfiguration extends Object implements Configuration, Configurable<ClientConfiguration>, Providers, HeaderValueProcessor
Version:
$Revision: 1 $
Author:
Bill Burke
  • Field Details

  • Constructor Details

  • Method Details

    • setProperties

      public void setProperties(Map<String,Object> newProps)
    • getProviderFactory

      protected ResteasyProviderFactory getProviderFactory()
    • getMutableProperties

      public Map<String,Object> getMutableProperties()
    • toHeaderString

      public String toHeaderString(Object object)
      Convert an object to a header string. First try StringConverter, then HeaderDelegate, then object.toString()
      Specified by:
      toHeaderString in interface HeaderValueProcessor
      Parameters:
      object - header object
      Returns:
      header string
    • 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.
      Specified by:
      getMessageBodyWriter in interface Providers
      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.
    • 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.
      Specified by:
      getMessageBodyReader in interface Providers
      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.
    • getWriterInterceptors

      public WriterInterceptor[] getWriterInterceptors(Class declaring, AccessibleObject target)
    • getReaderInterceptors

      public ReaderInterceptor[] getReaderInterceptors(Class declaring, AccessibleObject target)
    • getRequestFilters

      public ClientRequestFilter[] getRequestFilters(Class declaring, AccessibleObject target)
    • getResponseFilters

      public ClientResponseFilter[] getResponseFilters(Class declaring, AccessibleObject target)
    • getDynamicFeatures

      public Set<DynamicFeature> getDynamicFeatures()
    • getParamConverter

      public ParamConverter getParamConverter(Class<?> clazz, Type genericType, Annotation[] annotations)
    • toString

      public String toString(Object object)
    • toString

      public String toString(Object object, Type type, Annotation[] annotations)
    • getExceptionMapper

      public <T extends Throwable> ExceptionMapper<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.
      Specified by:
      getExceptionMapper in interface Providers
      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.
      Specified by:
      getContextResolver in interface Providers
      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.
    • getProperties

      public Map<String,Object> getProperties()
      Description copied from interface: Configuration
      Get the immutable bag of configuration properties.
      Specified by:
      getProperties in interface Configuration
      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.
      Specified by:
      getProperty in interface Configuration
      Parameters:
      name - property name.
      Returns:
      the property value for the specified property name or null if the property with such name is not configured.
    • 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.

      Specified by:
      getClasses in interface Configuration
      Returns:
      the immutable set of registered JAX-RS component classes. The returned value may be empty but will never be null.
      See Also:
    • 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.

      Specified by:
      getInstances in interface Configuration
      Returns:
      the immutable set of registered JAX-RS component instances. The returned value may be empty but will never be null.
      See Also:
    • register

      public ClientConfiguration register(Class<?> providerClass)
      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.

      Specified by:
      register in interface Configurable<ClientConfiguration>
      Parameters:
      providerClass - JAX-RS component class to be configured in the scope of this configurable context.
      Returns:
      the updated configurable context.
    • register

      public ClientConfiguration register(Object provider)
      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.

      Specified by:
      register in interface Configurable<ClientConfiguration>
      Parameters:
      provider - JAX-RS component instance to be configured in the scope of this configurable context.
      Returns:
      the updated configurable context.
    • register

      public ClientConfiguration register(Class<?> providerClass, 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.

      Specified by:
      register in interface Configurable<ClientConfiguration>
      Parameters:
      providerClass - 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 ClientConfiguration register(Object provider, 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.

      Specified by:
      register in interface Configurable<ClientConfiguration>
      Parameters:
      provider - 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.
    • property

      public ClientConfiguration 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.
      Specified by:
      property in interface Configurable<ClientConfiguration>
      Parameters:
      name - property name.
      value - (new) property value. null value removes the property with the given name.
      Returns:
      the updated configurable instance.
    • 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.

      Specified by:
      getConfiguration in interface Configurable<ClientConfiguration>
      Returns:
      configuration live view of the internal configuration state.
    • register

      public ClientConfiguration 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).

      Specified by:
      register in interface Configurable<ClientConfiguration>
      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 ClientConfiguration 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.

      Specified by:
      register in interface Configurable<ClientConfiguration>
      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 ClientConfiguration 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).

      Specified by:
      register in interface Configurable<ClientConfiguration>
      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 ClientConfiguration 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.

      Specified by:
      register in interface Configurable<ClientConfiguration>
      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.
      Specified by:
      getRuntimeType in interface Configuration
      Returns:
      configuration context runtime type.
    • getPropertyNames

      public Collection<String> getPropertyNames()
      Description copied from interface: Configuration
      Returns an immutable collection containing the property names available within the context of the current configuration instance.

      Use the Configuration.getProperty(java.lang.String) method with a property name to get the value of a property.

      Specified by:
      getPropertyNames in interface Configuration
      Returns:
      an immutable collection of property names.
      See Also:
    • 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.

      Specified by:
      isEnabled in interface Configuration
      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.

      Specified by:
      isEnabled in interface Configuration
      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.

      Specified by:
      isRegistered in interface Configuration
      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:
    • 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.

      Specified by:
      isRegistered in interface Configuration
      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:
    • 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.
      Specified by:
      getContracts in interface Configuration
      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.
    • getRxInvokerProvider

      public <I extends RxInvoker<?>> RxInvokerProvider<I> getRxInvokerProvider(Class<I> clazz)
    • getRxInvokerProviderFromReactiveClass

      public RxInvokerProvider<?> getRxInvokerProviderFromReactiveClass(Class<?> clazz)
    • isReactive

      public boolean isReactive(Class<?> clazz)
    • addHeaderDelegate

      public void addHeaderDelegate(Class<?> clazz, RuntimeDelegate.HeaderDelegate header)