public class CommonConfig extends java.lang.Object implements javax.ws.rs.core.FeatureContext, ExtendedConfig
Configuration
implementation for
server and client.Modifier and Type | Class and Description |
---|---|
private static class |
CommonConfig.FeatureRegistration
A single feature registration record.
|
Modifier and Type | Field and Description |
---|---|
private static java.util.function.Function<java.lang.Object,Binder> |
CAST_TO_BINDER |
private ComponentBag |
componentBag
Configured providers, does not include features and binders.
|
private boolean |
disableMetaProviderConfiguration
Flag determining whether the configuration of meta-providers (excl.
|
private java.util.Set<java.lang.Class<? extends javax.ws.rs.core.Feature>> |
enabledFeatureClasses
Collection of enabled feature classes.
|
private java.util.Set<javax.ws.rs.core.Feature> |
enabledFeatures
Collection of enabled feature instances.
|
private java.util.Map<java.lang.String,java.lang.Object> |
immutablePropertiesView |
private java.util.Collection<java.lang.String> |
immutablePropertyNames |
private static java.util.logging.Logger |
LOGGER |
private java.util.List<CommonConfig.FeatureRegistration> |
newFeatureRegistrations
Collection of unprocessed feature registrations.
|
private java.util.Map<java.lang.String,java.lang.Object> |
properties
Configuration properties collection and it's immutable views.
|
private javax.ws.rs.RuntimeType |
type
Configuration runtime type.
|
Constructor and Description |
---|
CommonConfig(CommonConfig config)
Copy constructor.
|
CommonConfig(javax.ws.rs.RuntimeType type,
java.util.function.Predicate<ContractProvider> registrationStrategy)
Create a new
RuntimeConfig instance. |
Modifier and Type | Method and Description |
---|---|
CommonConfig |
addProperties(java.util.Map<java.lang.String,?> properties)
Add properties to
ResourceConfig . |
private java.util.Set<java.lang.Class<?>> |
asNewIdentitySet(java.lang.Class<?>... contracts) |
private void |
checkComponentClassNotNull(java.lang.Class<?> componentClass) |
private void |
checkProviderNotNull(java.lang.Object provider) |
void |
configureAutoDiscoverableProviders(InjectionManager injectionManager,
java.util.Collection<AutoDiscoverable> autoDiscoverables,
boolean forcedOnly)
Configure
auto-discoverables in the injection manager. |
private java.util.Set<Binder> |
configureBinders(InjectionManager injectionManager,
java.util.Set<Binder> configured) |
private void |
configureExternalObjects(InjectionManager injectionManager) |
private void |
configureFeatures(InjectionManager injectionManager,
java.util.Set<CommonConfig.FeatureRegistration> processed,
java.util.List<CommonConfig.FeatureRegistration> unprocessed,
ManagedObjectsFinalizer managedObjectsFinalizer) |
void |
configureMetaProviders(InjectionManager injectionManager,
ManagedObjectsFinalizer finalizer)
Configure binders in the injection manager and enable JAX-RS features.
|
private void |
copy(CommonConfig config,
boolean loadComponentBag)
Copy config properties, providers from given
config to this instance. |
boolean |
equals(java.lang.Object o) |
private java.util.Collection<Binder> |
getBinder(java.util.Set<Binder> configured) |
java.util.Set<java.lang.Class<?>> |
getClasses() |
ComponentBag |
getComponentBag()
Returns a
ComponentBag instance associated with the configuration. |
ExtendedConfig |
getConfiguration() |
java.util.Map<java.lang.Class<?>,java.lang.Integer> |
getContracts(java.lang.Class<?> componentClass) |
java.util.Set<java.lang.Object> |
getInstances() |
protected Inflector<ContractProvider.Builder,ContractProvider> |
getModelEnhancer(java.lang.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.
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties() |
java.lang.Object |
getProperty(java.lang.String name) |
java.util.Collection<java.lang.String> |
getPropertyNames() |
javax.ws.rs.RuntimeType |
getRuntimeType() |
int |
hashCode() |
boolean |
isEnabled(java.lang.Class<? extends javax.ws.rs.core.Feature> featureClass) |
boolean |
isEnabled(javax.ws.rs.core.Feature feature) |
boolean |
isProperty(java.lang.String name)
Get the value of the property with a given name converted to
boolean . |
boolean |
isRegistered(java.lang.Class<?> componentClass) |
boolean |
isRegistered(java.lang.Object component) |
CommonConfig |
loadFrom(javax.ws.rs.core.Configuration config)
Load the internal configuration state from an externally provided configuration state.
|
private void |
processFeatureRegistration(java.lang.Object component,
java.lang.Class<?> componentClass) |
CommonConfig |
property(java.lang.String name,
java.lang.Object value) |
CommonConfig |
register(java.lang.Class<?> componentClass) |
CommonConfig |
register(java.lang.Class<?> componentClass,
java.lang.Class<?>... contracts) |
CommonConfig |
register(java.lang.Class<?> componentClass,
int bindingPriority) |
CommonConfig |
register(java.lang.Class<?> componentClass,
java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts) |
CommonConfig |
register(java.lang.Object component) |
CommonConfig |
register(java.lang.Object component,
java.lang.Class<?>... contracts) |
CommonConfig |
register(java.lang.Object component,
int bindingPriority) |
CommonConfig |
register(java.lang.Object component,
java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts) |
private java.util.List<CommonConfig.FeatureRegistration> |
resetRegistrations() |
CommonConfig |
setProperties(java.util.Map<java.lang.String,?> properties)
Set the configured properties to the provided map of properties.
|
private static final java.util.logging.Logger LOGGER
private static final java.util.function.Function<java.lang.Object,Binder> CAST_TO_BINDER
private final javax.ws.rs.RuntimeType type
private final java.util.Map<java.lang.String,java.lang.Object> properties
private final java.util.Map<java.lang.String,java.lang.Object> immutablePropertiesView
private final java.util.Collection<java.lang.String> immutablePropertyNames
private final ComponentBag componentBag
private final java.util.List<CommonConfig.FeatureRegistration> newFeatureRegistrations
private final java.util.Set<java.lang.Class<? extends javax.ws.rs.core.Feature>> enabledFeatureClasses
private final java.util.Set<javax.ws.rs.core.Feature> enabledFeatures
private boolean disableMetaProviderConfiguration
public CommonConfig(javax.ws.rs.RuntimeType type, java.util.function.Predicate<ContractProvider> registrationStrategy)
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.
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.public CommonConfig(CommonConfig config)
config
- configurable to copy class properties from.private void copy(CommonConfig config, boolean loadComponentBag)
config
to this instance.config
- configurable to copy class properties from.loadComponentBag
- true
if the component bag from config should be copied as well, false
otherwise.public ExtendedConfig getConfiguration()
getConfiguration
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public javax.ws.rs.RuntimeType getRuntimeType()
getRuntimeType
in interface javax.ws.rs.core.Configuration
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
getProperties
in interface javax.ws.rs.core.Configuration
public java.lang.Object getProperty(java.lang.String name)
getProperty
in interface javax.ws.rs.core.Configuration
public boolean isProperty(java.lang.String name)
ExtendedConfig
boolean
.
Returns false
if the value is not convertible.isProperty
in interface ExtendedConfig
name
- property name.boolean
property value or false
if the property is not
convertible.public java.util.Collection<java.lang.String> getPropertyNames()
getPropertyNames
in interface javax.ws.rs.core.Configuration
public boolean isEnabled(java.lang.Class<? extends javax.ws.rs.core.Feature> featureClass)
isEnabled
in interface javax.ws.rs.core.Configuration
public boolean isEnabled(javax.ws.rs.core.Feature feature)
isEnabled
in interface javax.ws.rs.core.Configuration
public boolean isRegistered(java.lang.Object component)
isRegistered
in interface javax.ws.rs.core.Configuration
public boolean isRegistered(java.lang.Class<?> componentClass)
isRegistered
in interface javax.ws.rs.core.Configuration
public java.util.Map<java.lang.Class<?>,java.lang.Integer> getContracts(java.lang.Class<?> componentClass)
getContracts
in interface javax.ws.rs.core.Configuration
public java.util.Set<java.lang.Class<?>> getClasses()
getClasses
in interface javax.ws.rs.core.Configuration
public java.util.Set<java.lang.Object> getInstances()
getInstances
in interface javax.ws.rs.core.Configuration
public final ComponentBag getComponentBag()
ComponentBag
instance associated with the configuration.protected Inflector<ContractProvider.Builder,ContractProvider> getModelEnhancer(java.lang.Class<?> componentClass)
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.
componentClass
- class of the component being registered.public CommonConfig setProperties(java.util.Map<java.lang.String,?> properties)
properties
- new map of properties to be set.public CommonConfig addProperties(java.util.Map<java.lang.String,?> properties)
ResourceConfig
.
If any of the added properties exists already, he values of the existing
properties will be replaced with new values.properties
- properties to add.public CommonConfig property(java.lang.String name, java.lang.Object value)
property
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public CommonConfig register(java.lang.Class<?> componentClass)
register
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public CommonConfig register(java.lang.Class<?> componentClass, int bindingPriority)
register
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public CommonConfig register(java.lang.Class<?> componentClass, java.lang.Class<?>... contracts)
register
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public CommonConfig register(java.lang.Class<?> componentClass, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)
register
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public CommonConfig register(java.lang.Object component)
register
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public CommonConfig register(java.lang.Object component, int bindingPriority)
register
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public CommonConfig register(java.lang.Object component, java.lang.Class<?>... contracts)
register
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
public CommonConfig register(java.lang.Object component, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)
register
in interface javax.ws.rs.core.Configurable<javax.ws.rs.core.FeatureContext>
private void processFeatureRegistration(java.lang.Object component, java.lang.Class<?> componentClass)
public CommonConfig loadFrom(javax.ws.rs.core.Configuration config)
config
- external configuration state to replace the configuration of this configurable instance.private java.util.Set<java.lang.Class<?>> asNewIdentitySet(java.lang.Class<?>... contracts)
private void checkProviderNotNull(java.lang.Object provider)
private void checkComponentClassNotNull(java.lang.Class<?> componentClass)
public void configureAutoDiscoverableProviders(InjectionManager injectionManager, java.util.Collection<AutoDiscoverable> autoDiscoverables, boolean forcedOnly)
auto-discoverables
in the injection manager.injectionManager
- injection manager in which the auto-discoverables should be configured.autoDiscoverables
- list of registered auto discoverable components.forcedOnly
- defines whether all or only forced auto-discoverables should be configured.public void configureMetaProviders(InjectionManager injectionManager, ManagedObjectsFinalizer finalizer)
injectionManager
- injection manager in which the binders and features should be configured.private java.util.Set<Binder> configureBinders(InjectionManager injectionManager, java.util.Set<Binder> configured)
private void configureExternalObjects(InjectionManager injectionManager)
private void configureFeatures(InjectionManager injectionManager, java.util.Set<CommonConfig.FeatureRegistration> processed, java.util.List<CommonConfig.FeatureRegistration> unprocessed, ManagedObjectsFinalizer managedObjectsFinalizer)
private java.util.List<CommonConfig.FeatureRegistration> resetRegistrations()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object