org.glassfish.jersey.model.internal
Class CommonConfig

java.lang.Object
  extended by org.glassfish.jersey.model.internal.CommonConfig
All Implemented Interfaces:
Configurable<FeatureContext>, Configuration, FeatureContext, ExtendedConfig
Direct Known Subclasses:
ImmutableCommonConfig

public class CommonConfig
extends Object
implements FeatureContext, ExtendedConfig

Common immutable Configuration implementation for server and client.

Author:
Michal Gajdos (michal.gajdos at oracle.com), Marek Potociar (marek.potociar at oracle.com)

Constructor Summary
CommonConfig(CommonConfig config)
          Copy constructor.
CommonConfig(RuntimeType type, com.google.common.base.Predicate<ContractProvider> registrationStrategy)
          Create a new RuntimeConfig instance.
 
Method Summary
 CommonConfig addProperties(Map<String,?> properties)
          Add properties to ResourceConfig.
 void configureMetaProviders(ServiceLocator locator)
          Configure HK2 binders in the HK2 service locator and enable JAX-RS features.
 boolean equals(Object o)
           
 Set<Class<?>> getClasses()
           
 ComponentBag getComponentBag()
          Returns a ComponentBag instance associated with the configuration.
 ExtendedConfig getConfiguration()
           
 Map<Class<?>,Integer> getContracts(Class<?> componentClass)
           
 Set<Object> getInstances()
           
protected  Inflector<ContractProvider.Builder,ContractProvider> getModelEnhancer(Class<?> componentClass)
          An extension point that provides a way how to define a custom enhancement/update operation of a contract provider model registration being produced for a given component class.
 Map<String,Object> getProperties()
           
 Object getProperty(String name)
           
 Collection<String> getPropertyNames()
           
 RuntimeType getRuntimeType()
           
 int hashCode()
           
 boolean isEnabled(Class<? extends Feature> featureClass)
           
 boolean isEnabled(Feature feature)
           
 boolean isProperty(String name)
          Get the value of the property with a given name converted to boolean.
 boolean isRegistered(Class<?> componentClass)
           
 boolean isRegistered(Object component)
           
 CommonConfig register(Class<?> componentClass)
           
 CommonConfig register(Class<?> componentClass, Class<?>... contracts)
           
 CommonConfig register(Class<?> componentClass, int bindingPriority)
           
 CommonConfig register(Class<?> componentClass, Map<Class<?>,Integer> contracts)
           
 CommonConfig register(Object component)
           
 CommonConfig register(Object component, Class<?>... contracts)
           
 CommonConfig register(Object component, int bindingPriority)
           
 CommonConfig register(Object component, Map<Class<?>,Integer> contracts)
           
 CommonConfig replaceWith(Configuration config)
           
 CommonConfig setProperties(Map<String,?> properties)
          Set the configured properties to the provided map of properties.
 CommonConfig setProperty(String name, Object value)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonConfig

public CommonConfig(RuntimeType type,
                    com.google.common.base.Predicate<ContractProvider> registrationStrategy)
Create a new RuntimeConfig instance.

The constructor provides a way for defining a contract provider model registration strategy. Once a registration model is built for a newly registered contract, the provided registration strategy filter is consulted whether the model should be registered or not.

Clients can use the method to cancel any contract provider model registration that does not meet the criteria of a given configuration context, such as a model that does not have any recognized contracts associated with it.

Parameters:
type - configuration runtime type.
registrationStrategy - function driving the decision (based on the introspected contract provider model) whether or not should the component class registration continue towards a successful completion.

CommonConfig

public CommonConfig(CommonConfig config)
Copy constructor.

Parameters:
config - configurable to copy class properties from.
Method Detail

getConfiguration

public ExtendedConfig getConfiguration()
Specified by:
getConfiguration in interface Configurable<FeatureContext>

getRuntimeType

public RuntimeType getRuntimeType()
Specified by:
getRuntimeType in interface Configuration

getProperties

public Map<String,Object> getProperties()
Specified by:
getProperties in interface Configuration

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface Configuration

isProperty

public boolean isProperty(String name)
Description copied from interface: ExtendedConfig
Get the value of the property with a given name converted to boolean. Returns false if the value is not convertible.

Specified by:
isProperty in interface ExtendedConfig
Parameters:
name - property name.
Returns:
boolean property value or false if the property is not convertible.

getPropertyNames

public Collection<String> getPropertyNames()
Specified by:
getPropertyNames in interface Configuration

isEnabled

public boolean isEnabled(Class<? extends Feature> featureClass)
Specified by:
isEnabled in interface Configuration

isEnabled

public boolean isEnabled(Feature feature)
Specified by:
isEnabled in interface Configuration

isRegistered

public boolean isRegistered(Object component)
Specified by:
isRegistered in interface Configuration

isRegistered

public boolean isRegistered(Class<?> componentClass)
Specified by:
isRegistered in interface Configuration

getContracts

public Map<Class<?>,Integer> getContracts(Class<?> componentClass)
Specified by:
getContracts in interface Configuration

getClasses

public Set<Class<?>> getClasses()
Specified by:
getClasses in interface Configuration

getInstances

public Set<Object> getInstances()
Specified by:
getInstances in interface Configuration

getComponentBag

public final ComponentBag getComponentBag()
Returns a ComponentBag instance associated with the configuration.

Returns:
a non-null component bag instance.

getModelEnhancer

protected Inflector<ContractProvider.Builder,ContractProvider> getModelEnhancer(Class<?> componentClass)
An extension point that provides a way how to define a custom enhancement/update operation of a contract provider model registration being produced for a given component class. Default implementation return an enhancer just builds the model.

Derived implementations may use this method to e.g. filter out all contracts not applicable in the given configuration context or change the model scope. The returned set of filtered contracts is then used for the actual provider registration.

Parameters:
componentClass - class of the component being registered.
Returns:
filter for the contracts that being registered for a given component class.

setProperties

public CommonConfig setProperties(Map<String,?> properties)
Set the configured properties to the provided map of properties.

Parameters:
properties - new map of properties to be set.
Returns:
updated configuration instance.

addProperties

public CommonConfig addProperties(Map<String,?> properties)
Add properties to ResourceConfig. If any of the added properties exists already, he values of the existing properties will be replaced with new values.

Parameters:
properties - properties to add.
Returns:
updated configuration instance.

setProperty

public CommonConfig setProperty(String name,
                                Object value)
Specified by:
setProperty in interface Configurable<FeatureContext>

register

public CommonConfig register(Class<?> componentClass)
Specified by:
register in interface Configurable<FeatureContext>

register

public CommonConfig register(Class<?> componentClass,
                             int bindingPriority)
Specified by:
register in interface Configurable<FeatureContext>

register

public CommonConfig register(Class<?> componentClass,
                             Class<?>... contracts)
Specified by:
register in interface Configurable<FeatureContext>

register

public CommonConfig register(Class<?> componentClass,
                             Map<Class<?>,Integer> contracts)
Specified by:
register in interface Configurable<FeatureContext>

register

public CommonConfig register(Object component)
Specified by:
register in interface Configurable<FeatureContext>

register

public CommonConfig register(Object component,
                             int bindingPriority)
Specified by:
register in interface Configurable<FeatureContext>

register

public CommonConfig register(Object component,
                             Class<?>... contracts)
Specified by:
register in interface Configurable<FeatureContext>

register

public CommonConfig register(Object component,
                             Map<Class<?>,Integer> contracts)
Specified by:
register in interface Configurable<FeatureContext>

replaceWith

public CommonConfig replaceWith(Configuration config)
Specified by:
replaceWith in interface Configurable<FeatureContext>

configureMetaProviders

public void configureMetaProviders(ServiceLocator locator)
Configure HK2 binders in the HK2 service locator and enable JAX-RS features.

Parameters:
locator - locator in which the binders and features should be configured.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.