Package org.onosproject.net.config
Class NetworkConfigServiceAdapter
- java.lang.Object
-
- org.onosproject.net.config.NetworkConfigServiceAdapter
-
- All Implemented Interfaces:
ListenerService<NetworkConfigEvent,NetworkConfigListener>
,NetworkConfigService
- Direct Known Subclasses:
NetworkConfigRegistryAdapter
public class NetworkConfigServiceAdapter extends java.lang.Object implements NetworkConfigService
Test adapter for network configuration service.
-
-
Constructor Summary
Constructors Constructor Description NetworkConfigServiceAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S,C extends Config<S>>
CaddConfig(S subject, java.lang.Class<C> configClass)
Creates a new configuration for the specified subject and configuration class.void
addListener(NetworkConfigListener listener)
Adds the specified listener.<S,C extends Config<S>>
CapplyConfig(java.lang.String subjectClassKey, S subject, java.lang.String configKey, com.fasterxml.jackson.databind.JsonNode json)
Applies configuration for the specified subject and configuration key using the raw JSON object.<S,C extends Config<S>>
CapplyConfig(S subject, java.lang.Class<C> configClass, com.fasterxml.jackson.databind.JsonNode json)
Applies configuration for the specified subject and configuration class using the raw JSON node.<S,C extends Config<S>>
CgetConfig(S subject, java.lang.Class<C> configClass)
Returns the configuration for the specified subject and configuration class if one is available; null otherwise.java.lang.Class<? extends Config>
getConfigClass(java.lang.String subjectClassKey, java.lang.String configKey)
Returns the configuration class with the specified key.<S> java.util.Set<? extends Config<S>>
getConfigs(S subject)
Returns all configurations for the specified subject.java.util.Set<java.lang.Class>
getSubjectClasses()
Returns the set of subject classes for which configuration may be available.SubjectFactory
getSubjectFactory(java.lang.Class subjectClass)
Returns the subject factory for the specified class.SubjectFactory
getSubjectFactory(java.lang.String subjectClassKey)
Returns the subject factory with the specified key.<S> java.util.Set<S>
getSubjects(java.lang.Class<S> subjectClass)
Returns the set of subjects for which some configuration is available.<S,C extends Config<S>>
java.util.Set<S>getSubjects(java.lang.Class<S> subjectClass, java.lang.Class<C> configClass)
Returns the set of subjects for which the specified configuration is available.<S> void
removeConfig()
Clears the complete configuration including queued.<S> void
removeConfig(java.lang.String subjectClassKey, S subject, java.lang.String configKey)
Clears any configuration for the specified subject and configuration key.<S> void
removeConfig(S subject)
Clears the configuration including queued based on the subject.<S,C extends Config<S>>
voidremoveConfig(S subject, java.lang.Class<C> configClass)
Clears any configuration for the specified subject and configuration class.void
removeListener(NetworkConfigListener listener)
Removes the specified listener.
-
-
-
Method Detail
-
getSubjectClasses
public java.util.Set<java.lang.Class> getSubjectClasses()
Description copied from interface:NetworkConfigService
Returns the set of subject classes for which configuration may be available.- Specified by:
getSubjectClasses
in interfaceNetworkConfigService
- Returns:
- set of subject classes
-
getSubjectFactory
public SubjectFactory getSubjectFactory(java.lang.String subjectClassKey)
Description copied from interface:NetworkConfigService
Returns the subject factory with the specified key.- Specified by:
getSubjectFactory
in interfaceNetworkConfigService
- Parameters:
subjectClassKey
- subject class key- Returns:
- subject class
-
getSubjectFactory
public SubjectFactory getSubjectFactory(java.lang.Class subjectClass)
Description copied from interface:NetworkConfigService
Returns the subject factory for the specified class.- Specified by:
getSubjectFactory
in interfaceNetworkConfigService
- Parameters:
subjectClass
- subject class- Returns:
- subject class factory
-
getConfigClass
public java.lang.Class<? extends Config> getConfigClass(java.lang.String subjectClassKey, java.lang.String configKey)
Description copied from interface:NetworkConfigService
Returns the configuration class with the specified key.- Specified by:
getConfigClass
in interfaceNetworkConfigService
- Parameters:
subjectClassKey
- subject class keyconfigKey
- subject class name- Returns:
- subject class
-
getSubjects
public <S> java.util.Set<S> getSubjects(java.lang.Class<S> subjectClass)
Description copied from interface:NetworkConfigService
Returns the set of subjects for which some configuration is available.- Specified by:
getSubjects
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subject- Parameters:
subjectClass
- subject class- Returns:
- set of configured subjects
-
getSubjects
public <S,C extends Config<S>> java.util.Set<S> getSubjects(java.lang.Class<S> subjectClass, java.lang.Class<C> configClass)
Description copied from interface:NetworkConfigService
Returns the set of subjects for which the specified configuration is available.- Specified by:
getSubjects
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subjectC
- type of configuration- Parameters:
subjectClass
- subject classconfigClass
- configuration class- Returns:
- set of configured subjects
-
getConfigs
public <S> java.util.Set<? extends Config<S>> getConfigs(S subject)
Description copied from interface:NetworkConfigService
Returns all configurations for the specified subject.- Specified by:
getConfigs
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subject- Parameters:
subject
- configuration subject- Returns:
- set of configurations
-
getConfig
public <S,C extends Config<S>> C getConfig(S subject, java.lang.Class<C> configClass)
Description copied from interface:NetworkConfigService
Returns the configuration for the specified subject and configuration class if one is available; null otherwise.- Specified by:
getConfig
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subjectC
- type of configuration- Parameters:
subject
- configuration subjectconfigClass
- configuration class- Returns:
- configuration or null if one is not available
-
addConfig
public <S,C extends Config<S>> C addConfig(S subject, java.lang.Class<C> configClass)
Description copied from interface:NetworkConfigService
Creates a new configuration for the specified subject and configuration class. If one already exists, it is simply returned.- Specified by:
addConfig
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subjectC
- type of configuration- Parameters:
subject
- configuration subjectconfigClass
- configuration class- Returns:
- configuration or null if one is not available
-
applyConfig
public <S,C extends Config<S>> C applyConfig(S subject, java.lang.Class<C> configClass, com.fasterxml.jackson.databind.JsonNode json)
Description copied from interface:NetworkConfigService
Applies configuration for the specified subject and configuration class using the raw JSON node. If configuration already exists, it will be updated.- Specified by:
applyConfig
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subjectC
- type of configuration- Parameters:
subject
- configuration subjectconfigClass
- configuration classjson
- raw JSON node containing the configuration data- Returns:
- configuration or null if one is not available
-
applyConfig
public <S,C extends Config<S>> C applyConfig(java.lang.String subjectClassKey, S subject, java.lang.String configKey, com.fasterxml.jackson.databind.JsonNode json)
Description copied from interface:NetworkConfigService
Applies configuration for the specified subject and configuration key using the raw JSON object. If configuration already exists, it will be updated. If the specified configuration key does not yet have a registered class associated with it, the configuration will be pending and null value will be returned. Once the backing configuration class is registered, the configuration will be validated and accepted.- Specified by:
applyConfig
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subjectC
- type of configuration- Parameters:
subjectClassKey
- subject class keysubject
- configuration subjectconfigKey
- configuration class keyjson
- raw JSON node containing the configuration data- Returns:
- configuration object or null if configuration key does not have a registered class yet
-
removeConfig
public <S,C extends Config<S>> void removeConfig(S subject, java.lang.Class<C> configClass)
Description copied from interface:NetworkConfigService
Clears any configuration for the specified subject and configuration class. If one does not exist, this call has no effect.- Specified by:
removeConfig
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subjectC
- type of configuration- Parameters:
subject
- configuration subjectconfigClass
- configuration class
-
removeConfig
public <S> void removeConfig(java.lang.String subjectClassKey, S subject, java.lang.String configKey)
Description copied from interface:NetworkConfigService
Clears any configuration for the specified subject and configuration key. If one does not exist, this call has no effect.- Specified by:
removeConfig
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subject- Parameters:
subjectClassKey
- subject class keysubject
- configuration subjectconfigKey
- configuration key
-
addListener
public void addListener(NetworkConfigListener listener)
Description copied from interface:ListenerService
Adds the specified listener.- Specified by:
addListener
in interfaceListenerService<NetworkConfigEvent,NetworkConfigListener>
- Parameters:
listener
- listener to be added
-
removeListener
public void removeListener(NetworkConfigListener listener)
Description copied from interface:ListenerService
Removes the specified listener.- Specified by:
removeListener
in interfaceListenerService<NetworkConfigEvent,NetworkConfigListener>
- Parameters:
listener
- listener to be removed
-
removeConfig
public <S> void removeConfig(S subject)
Description copied from interface:NetworkConfigService
Clears the configuration including queued based on the subject. If does not exists this call has no effect.- Specified by:
removeConfig
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subject- Parameters:
subject
- configuration subject
-
removeConfig
public <S> void removeConfig()
Description copied from interface:NetworkConfigService
Clears the complete configuration including queued. If does not exists this call has no effect.- Specified by:
removeConfig
in interfaceNetworkConfigService
- Type Parameters:
S
- type of subject
-
-