javax.ws.rs.client
Interface Configuration

All Superinterfaces:
Configurable
All Known Implementing Classes:
ClientConfiguration

public interface Configuration
extends Configurable

Represents inheritable configuration of the main client-side JAX-RS components, such as Client, WebTarget, Invocation Builder or Invocation.

Configuration is inherited from a parent component to a child component. When creating new resource targets using a Client instance, the configuration of the Client instance is inherited by the child target instances being created. Similarly, when creating new Invocation.Builder invocation builders or derived resource targets using a parent target instance, the configuration of the parent target is inherited by the child instances being created.

The inherited configuration on a child instance reflects the state of the parent configuration at the time of the child instance creation. Once the child instance is created its configuration is detached from the parent configuration. This means that any subsequent changes in the parent configuration do not affect the configuration of previously created child instances.

Once the child instance is created, it's configuration can be further customized using the provided set of instance configuration mutator methods. A change made in the configuration of a child instance does not affect the configuration of its parent, for example:
 Client client = ClientFactory.newClient();
 client.configuration().setProperty("FOO_PROPERTY", "FOO_VALUE");

 // inherits the configured "FOO_PROPERTY" from the client instance
 WebTarget resourceTarget = client.target("http://examples.jaxrs.com/");

 // does not modify the client instance configuration
 resourceTarget.configuration().register(new BarFeature());
 

For a discussion on registering providers or narrowing down the scope of the contracts registered for each provider, see configurable context documentation.

Since:
2.0
Author:
Marek Potociar

Method Summary
 Configuration register(Class<?> providerClass)
          Register a provider or a feature class to be instantiated and used in the scope of the configured instance.
 Configuration register(Class<?> providerClass, int bindingPriority)
          Register a provider or a feature class to be instantiated and used in the scope of the configured instance.
<T> Configuration
register(Class<T> providerClass, Class<? super T>... contracts)
          Register a provider or a feature class to be instantiated and used in the scope of the configured instance.
<T> Configuration
register(Class<T> providerClass, int bindingPriority, Class<? super T>... contracts)
          Register a provider or a feature class to be instantiated and used in the scope of the configured instance.
 Configuration register(Object provider)
          Register a provider or a feature ("singleton") instance to be used in the scope of the configured instance.
<T> Configuration
register(Object provider, Class<? super T>... contracts)
          Register a provider or a feature ("singleton") instance to be used in the scope of the configured instance.
 Configuration register(Object provider, int bindingPriority)
          Register a provider or a feature ("singleton") instance to be used in the scope of the configured instance.
<T> Configuration
register(Object provider, int bindingPriority, Class<? super T>... contracts)
          Register a provider or a feature ("singleton") instance to be used in the scope of the configured instance.
 Configuration setProperties(Map<String,?> properties)
          Set new configuration properties replacing all previously set properties.
 Configuration setProperty(String name, Object value)
          Set the new configuration property, if already set, the existing value of the property will be updated.
 Configuration updateFrom(Configurable configuration)
          Replace the existing configuration state with the configuration state of the externally provided configuration.
 
Methods inherited from interface javax.ws.rs.core.Configurable
getEnabledFeatures, getFeatureClasses, getFeatureInstances, getProperties, getProperty, getProviderClasses, getProviderInstances
 

Method Detail

setProperties

Configuration setProperties(Map<String,?> properties)
Description copied from interface: Configurable
Set new configuration properties replacing all previously set properties.

Specified by:
setProperties in interface Configurable
Parameters:
properties - new set of configuration properties. The content of the map will replace any existing properties set on the configurable instance.
Returns:
the updated configurable instance.

setProperty

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

updateFrom

Configuration updateFrom(Configurable configuration)
Replace the existing configuration state with the configuration state of the externally provided configuration.

Parameters:
configuration - configuration to be used to update the instance.
Returns:
the updated configuration.

register

Configuration register(Class<?> providerClass)
Description copied from interface: Configurable
Register a provider or a feature class to be instantiated and used in the scope of the configured instance. The registered class is registered as a provider of all the recognized JAX-RS or implementation-specific extension contracts including Feature contract.

As opposed to the instances registered via Configurable.register(Object) method, classes registered using this method are instantiated and properly injected by the JAX-RS implementation provider. In case of a conflict between a registered feature and/or provider instance and instantiated registered class, the registered instance takes precedence and the registered class will not be instantiated in such case.

Specified by:
register in interface Configurable
Parameters:
providerClass - provider class to be instantiated and used in the scope of the configured instance.
Returns:
the updated configurable instance.

register

Configuration register(Class<?> providerClass,
                       int bindingPriority)
Description copied from interface: Configurable
Register a provider or a feature class to be instantiated and used in the scope of the configured instance.

This registration method provides same functionality as Configurable.register(Class) except that any provider binding priority specified on the provider class using @BindingPriority annotation is overridden with the supplied bindingPriority value.

Note that in case the binding priority is not applicable to any particular provider contract registered for the provider class, the supplied bindingPriority value will be ignored for that contract.

Specified by:
register in interface Configurable
Parameters:
providerClass - provider class to be instantiated and used in the scope of the configured instance.
bindingPriority - the overriding binding priority for the registered contract(s).
Returns:
the updated configurable instance.

register

<T> Configuration register(Class<T> providerClass,
                           Class<? super T>... contracts)
Description copied from interface: Configurable
Register a provider or a feature class to be instantiated and used in the scope of the configured instance.

This registration method provides same functionality as Configurable.register(Class) except the provider class is only registered as a provider of the listed contracts. Note that in case the Feature interface is not listed explicitly, the provider class is not recognized as a JAX-RS feature.

Specified by:
register in interface Configurable
Parameters:
providerClass - provider class to be instantiated and used in the scope of the configured instance.
contracts - the specific set of contracts implemented by the provider class for which the provider should be registered. If omitted, the provider class will be registered as a provider of all recognized contracts implemented by the provider class.
Returns:
the updated configurable instance.

register

<T> Configuration register(Class<T> providerClass,
                           int bindingPriority,
                           Class<? super T>... contracts)
Description copied from interface: Configurable
Register a provider or a feature class to be instantiated and used in the scope of the configured instance.

This registration method provides same functionality as Configurable.register(Class, Class[]) except that any provider binding priority specified on the provider class using @BindingPriority annotation is overridden with the supplied bindingPriority value.

Note that in case the binding priority is not applicable to any particular provider contract registered for the provider class, the supplied bindingPriority value will be ignored for that contract.

Specified by:
register in interface Configurable
Parameters:
providerClass - provider class to be instantiated and used in the scope of the configured instance.
bindingPriority - the overriding binding priority for the registered contract(s).
contracts - the specific set of contracts implemented by the provider class for which the provider should be registered. If omitted, the provider class will be registered as a provider of all recognized contracts implemented by the provider class.
Returns:
the updated configurable instance.

register

Configuration register(Object provider)
Description copied from interface: Configurable
Register a provider or a feature ("singleton") instance to be used in the scope of the configured instance. The registered instance is registered as a provider of all the recognized JAX-RS or implementation-specific extension contracts including Feature contract.

As opposed to the instances registered via Configurable.register(Object) method, classes registered using this method used "as is", i.e. are not managed or injected by the JAX-RS implementation provider. In case of a conflict between a registered feature and/or provider instance and instantiated registered class, the registered instance takes precedence and the registered class will not be instantiated in such case.

Specified by:
register in interface Configurable
Parameters:
provider - a provider instance to be registered in the scope of the configured instance.
Returns:
the updated configurable instance.

register

Configuration register(Object provider,
                       int bindingPriority)
Description copied from interface: Configurable
Register a provider or a feature ("singleton") instance to be used in the scope of the configured instance.

This registration method provides same functionality as Configurable.register(Object) except that any provider binding priority specified on the provider using @BindingPriority annotation is overridden with the supplied bindingPriority value.

Note that in case the binding priority is not applicable to any particular provider contract registered for the provider, the supplied bindingPriority value will be ignored for that contract.

Specified by:
register in interface Configurable
Parameters:
provider - provider class to be instantiated and used in the scope of the configured instance.
bindingPriority - the overriding binding priority for the registered contract(s).
Returns:
the updated configurable instance.

register

<T> Configuration register(Object provider,
                           Class<? super T>... contracts)
Description copied from interface: Configurable
Register a provider or a feature ("singleton") instance to be used in the scope of the configured instance.

This registration method provides same functionality as Configurable.register(Object) except the provider is only registered as a provider of the listed contracts. Note that in case the Feature interface is not listed explicitly, the provider is not recognized as a JAX-RS feature.

Specified by:
register in interface Configurable
Parameters:
provider - a provider instance to be registered in the scope of the configured instance.
contracts - the specific set of contracts implemented by the provider class for which the provider should be registered. If omitted, the provider class will be registered as a provider of all recognized contracts implemented by the provider class.
Returns:
the updated configurable instance.

register

<T> Configuration register(Object provider,
                           int bindingPriority,
                           Class<? super T>... contracts)
Description copied from interface: Configurable
Register a provider or a feature ("singleton") instance to be used in the scope of the configured instance.

This registration method provides same functionality as Configurable.register(Object, Class[]) except that any provider binding priority specified on the provider using @BindingPriority annotation is overridden with the supplied bindingPriority value.

Note that in case the binding priority is not applicable to any particular provider contract registered for the provider, the supplied bindingPriority value will be ignored for that contract.

Specified by:
register in interface Configurable
Parameters:
provider - a provider instance to be registered in the scope of the configured instance.
bindingPriority - the overriding binding priority for the registered contract(s).
contracts - the specific set of contracts implemented by the provider class for which the provider should be registered. If omitted, the provider class will be registered as a provider of all recognized contracts implemented by the provider class.
Returns:
the updated configurable instance.


Copyright © 2012. All Rights Reserved.