ONOS-2190 - Move org.onosproject.net.config.* out of the incubator
Change-Id: I57cac27ae370ce1155b4f637646d6c25732844e9
diff --git a/core/api/src/main/java/org/onosproject/net/config/Config.java b/core/api/src/main/java/org/onosproject/net/config/Config.java
new file mode 100644
index 0000000..ee7b584
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/Config.java
@@ -0,0 +1,305 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.annotations.Beta;
+import com.google.common.collect.Lists;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.function.Function;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Base abstraction of a configuration facade for a specific subject. Derived
+ * classes should keep all state in the specified JSON tree as that is the
+ * only state that will be distributed or persisted; this class is merely
+ * a facade for interacting with a particular facet of configuration on a
+ * given subject.
+ *
+ * @param <S> type of subject
+ */
+@Beta
+public abstract class Config<S> {
+
+ protected S subject;
+ protected String key;
+ protected ObjectNode node;
+ protected ObjectMapper mapper;
+ protected ConfigApplyDelegate delegate;
+
+ /**
+ * Initializes the configuration behaviour with necessary context.
+ *
+ * @param subject configuration subject
+ * @param key configuration key
+ * @param node JSON object node where configuration data is stored
+ * @param mapper JSON object mapper
+ * @param delegate delegate context
+ */
+ public void init(S subject, String key, ObjectNode node, ObjectMapper mapper,
+ ConfigApplyDelegate delegate) {
+ this.subject = checkNotNull(subject);
+ this.key = key;
+ this.node = checkNotNull(node);
+ this.mapper = checkNotNull(mapper);
+ this.delegate = checkNotNull(delegate);
+ }
+
+ /**
+ * Returns the specific subject to which this configuration pertains.
+ *
+ * @return configuration subject
+ */
+ public S subject() {
+ return subject;
+ }
+
+ /**
+ * Returns the configuration key. This is primarily aimed for use in
+ * composite JSON trees in external representations and has no bearing on
+ * the internal behaviours.
+ *
+ * @return configuration key
+ */
+ public String key() {
+ return key;
+ }
+
+ /**
+ * Returns the JSON node that contains the configuration data.
+ *
+ * @return JSON node backing the configuration
+ */
+ public ObjectNode node() {
+ return node;
+ }
+
+ /**
+ * Applies any configuration changes made via this configuration.
+ */
+ public void apply() {
+ delegate.onApply(this);
+ }
+
+
+ // Miscellaneous helpers for interacting with JSON
+
+ /**
+ * Gets the specified property as a string.
+ *
+ * @param name property name
+ * @param defaultValue default value if property not set
+ * @return property value or default value
+ */
+ protected String get(String name, String defaultValue) {
+ return node.path(name).asText(defaultValue);
+ }
+
+ /**
+ * Sets the specified property as a string or clears it if null value given.
+ *
+ * @param name property name
+ * @param value new value or null to clear the property
+ * @return self
+ */
+ protected Config<S> setOrClear(String name, String value) {
+ if (value != null) {
+ node.put(name, value);
+ } else {
+ node.remove(name);
+ }
+ return this;
+ }
+
+ /**
+ * Gets the specified property as a boolean.
+ *
+ * @param name property name
+ * @param defaultValue default value if property not set
+ * @return property value or default value
+ */
+ protected boolean get(String name, boolean defaultValue) {
+ return node.path(name).asBoolean(defaultValue);
+ }
+
+ /**
+ * Sets the specified property as a boolean or clears it if null value given.
+ *
+ * @param name property name
+ * @param value new value or null to clear the property
+ * @return self
+ */
+ protected Config<S> setOrClear(String name, Boolean value) {
+ if (value != null) {
+ node.put(name, value.booleanValue());
+ } else {
+ node.remove(name);
+ }
+ return this;
+ }
+
+ /**
+ * Gets the specified property as an integer.
+ *
+ * @param name property name
+ * @param defaultValue default value if property not set
+ * @return property value or default value
+ */
+ protected int get(String name, int defaultValue) {
+ return node.path(name).asInt(defaultValue);
+ }
+
+ /**
+ * Sets the specified property as an integer or clears it if null value given.
+ *
+ * @param name property name
+ * @param value new value or null to clear the property
+ * @return self
+ */
+ protected Config<S> setOrClear(String name, Integer value) {
+ if (value != null) {
+ node.put(name, value.intValue());
+ } else {
+ node.remove(name);
+ }
+ return this;
+ }
+
+ /**
+ * Gets the specified property as a long.
+ *
+ * @param name property name
+ * @param defaultValue default value if property not set
+ * @return property value or default value
+ */
+ protected long get(String name, long defaultValue) {
+ return node.path(name).asLong(defaultValue);
+ }
+
+ /**
+ * Sets the specified property as a long or clears it if null value given.
+ *
+ * @param name property name
+ * @param value new value or null to clear the property
+ * @return self
+ */
+ protected Config<S> setOrClear(String name, Long value) {
+ if (value != null) {
+ node.put(name, value.longValue());
+ } else {
+ node.remove(name);
+ }
+ return this;
+ }
+
+ /**
+ * Gets the specified property as a double.
+ *
+ * @param name property name
+ * @param defaultValue default value if property not set
+ * @return property value or default value
+ */
+ protected double get(String name, double defaultValue) {
+ return node.path(name).asDouble(defaultValue);
+ }
+
+ /**
+ * Sets the specified property as a double or clears it if null value given.
+ *
+ * @param name property name
+ * @param value new value or null to clear the property
+ * @return self
+ */
+ protected Config<S> setOrClear(String name, Double value) {
+ if (value != null) {
+ node.put(name, value.doubleValue());
+ } else {
+ node.remove(name);
+ }
+ return this;
+ }
+
+ /**
+ * Gets the specified property as an enum.
+ *
+ * @param name property name
+ * @param defaultValue default value if property not set
+ * @param enumClass the enum class
+ * @param <E> type of enum
+ * @return property value or default value
+ */
+ protected <E extends Enum<E>> E get(String name, E defaultValue, Class<E> enumClass) {
+ return Enum.valueOf(enumClass, node.path(name).asText(defaultValue.toString()));
+ }
+
+ /**
+ * Sets the specified property as a double or clears it if null value given.
+ *
+ * @param name property name
+ * @param value new value or null to clear the property
+ * @param <E> type of enum
+ * @return self
+ */
+ protected <E extends Enum> Config<S> setOrClear(String name, E value) {
+ if (value != null) {
+ node.put(name, value.toString());
+ } else {
+ node.remove(name);
+ }
+ return this;
+ }
+
+ /**
+ * Gets the specified array property as a list of items.
+ *
+ * @param name property name
+ * @param function mapper from string to item
+ * @param <T> type of item
+ * @return list of items
+ */
+ protected <T> List<T> getList(String name, Function<String, T> function) {
+ List<T> list = Lists.newArrayList();
+ ArrayNode arrayNode = (ArrayNode) node.path(name);
+ arrayNode.forEach(i -> list.add(function.apply(i.asText())));
+ return list;
+ }
+
+ /**
+ * Sets the specified property as an array of items in a given collection or
+ * clears it if null is given.
+ *
+ * @param name propertyName
+ * @param collection collection of items
+ * @param <T> type of items
+ * @return self
+ */
+ protected <T> Config<S> setOrClear(String name, Collection<T> collection) {
+ if (collection == null) {
+ node.remove(name);
+ } else {
+ ArrayNode arrayNode = mapper.createArrayNode();
+ collection.forEach(i -> arrayNode.add(i.toString()));
+ node.set(name, arrayNode);
+ }
+ return this;
+ }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/ConfigApplyDelegate.java b/core/api/src/main/java/org/onosproject/net/config/ConfigApplyDelegate.java
new file mode 100644
index 0000000..1160a09
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/ConfigApplyDelegate.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Delegate for notification when configuration changes have been applied.
+ */
+@Beta
+public interface ConfigApplyDelegate {
+
+ /**
+ * Processes changes applied to the specified configuration.
+ *
+ * @param config changed configuration
+ */
+ void onApply(Config config);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/ConfigFactory.java b/core/api/src/main/java/org/onosproject/net/config/ConfigFactory.java
new file mode 100644
index 0000000..f8b72df
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/ConfigFactory.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Base abstract factory for creating configurations for the specified subject type.
+ *
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ */
+@Beta
+public abstract class ConfigFactory<S, C extends Config<S>> {
+
+ private final SubjectFactory<S> subjectFactory;
+ private final Class<C> configClass;
+ private final String configKey;
+
+ /**
+ * Creates a new configuration factory for the specified class of subjects
+ * capable of generating the configurations of the specified class. The
+ * subject and configuration class keys are used merely as keys for use in
+ * composite JSON trees.
+ *
+ * @param subjectFactory subject factory
+ * @param configClass configuration class
+ * @param configKey configuration class key
+ */
+ protected ConfigFactory(SubjectFactory<S> subjectFactory,
+ Class<C> configClass, String configKey) {
+ this.subjectFactory = subjectFactory;
+ this.configClass = configClass;
+ this.configKey = configKey;
+ }
+
+ /**
+ * Returns the class of the subject to which this factory applies.
+ *
+ * @return subject type
+ */
+ public SubjectFactory<S> subjectFactory() {
+ return subjectFactory;
+ }
+
+ /**
+ * Returns the class of the configuration which this factory generates.
+ *
+ * @return configuration type
+ */
+ public Class<C> configClass() {
+ return configClass;
+ }
+
+ /**
+ * Returns the unique key (within subject class) of this configuration.
+ * This is primarily aimed for use in composite JSON trees in external
+ * representations and has no bearing on the internal behaviours.
+ *
+ * @return configuration key
+ */
+ public String configKey() {
+ return configKey;
+ }
+
+ /**
+ * Creates a new but uninitialized configuration. Framework will initialize
+ * the configuration via {@link Config#init} method.
+ *
+ * @return new uninitialized configuration
+ */
+ public abstract C createConfig();
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/ConfigOperator.java b/core/api/src/main/java/org/onosproject/net/config/ConfigOperator.java
new file mode 100644
index 0000000..505e8b3
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/ConfigOperator.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+/**
+ * An interface signifying a class that implements network configuration
+ * information from multiple sources. There is a natural ordering to the
+ * precedence of information, depending on its source:
+ * <ol>
+ * <li>Intents (from applications), which override</li>
+ * <li>Configs (from the network configuration subsystem), which override</li>
+ * <li>Descriptions (from southbound)</li>
+ * </ol>
+ * i.e., for a field representing the same attribute, the value from a Config
+ * entity will be used over that from the Description.
+ */
+public interface ConfigOperator {
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/NetworkConfigEvent.java b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigEvent.java
new file mode 100644
index 0000000..ee9cead
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigEvent.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Describes network configuration event.
+ */
+public class NetworkConfigEvent extends AbstractEvent<NetworkConfigEvent.Type, Object> {
+
+ private final Class configClass;
+
+ /**
+ * Type of network configuration events.
+ */
+ public enum Type {
+ /**
+ * Signifies that a network configuration was registered.
+ */
+ CONFIG_REGISTERED,
+
+ /**
+ * Signifies that a network configuration was unregistered.
+ */
+ CONFIG_UNREGISTERED,
+
+ /**
+ * Signifies that network configuration was added.
+ */
+ CONFIG_ADDED,
+
+ /**
+ * Signifies that network configuration was updated.
+ */
+ CONFIG_UPDATED,
+
+ /**
+ * Signifies that network configuration was removed.
+ */
+ CONFIG_REMOVED
+ }
+
+ /**
+ * Creates an event of a given type and for the specified subject and the
+ * current time.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param configClass configuration class
+ */
+ public NetworkConfigEvent(Type type, Object subject, Class configClass) {
+ super(type, subject);
+ this.configClass = configClass;
+ }
+
+ /**
+ * Creates an event of a given type and for the specified subject and time.
+ *
+ * @param type device event type
+ * @param subject event subject
+ * @param configClass configuration class
+ * @param time occurrence time
+ */
+ public NetworkConfigEvent(Type type, Object subject, Class configClass, long time) {
+ super(type, subject, time);
+ this.configClass = configClass;
+ }
+
+ /**
+ * Returns the class of configuration that has been changed.
+ *
+ * @return configuration class
+ */
+ public Class configClass() {
+ return configClass;
+ }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/NetworkConfigListener.java b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigListener.java
new file mode 100644
index 0000000..7317775
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Entity capable of receiving network configuration related events.
+ */
+public interface NetworkConfigListener extends EventListener<NetworkConfigEvent> {
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/NetworkConfigRegistry.java b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigRegistry.java
new file mode 100644
index 0000000..b4937d7
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigRegistry.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+import com.google.common.annotations.Beta;
+
+import java.util.Set;
+
+/**
+ * Service for tracking network configuration factories. It is the basis for
+ * extensibility to allow various core subsystems or apps to register their
+ * own configuration factories that permit use to inject additional meta
+ * information about how various parts of the network should be viewed and
+ * treated.
+ */
+@Beta
+public interface NetworkConfigRegistry extends NetworkConfigService {
+
+ /**
+ * Registers the specified configuration factory.
+ *
+ * @param configFactory configuration factory
+ */
+ void registerConfigFactory(ConfigFactory configFactory);
+
+ /**
+ * Unregisters the specified configuration factory.
+ *
+ * @param configFactory configuration factory
+ */
+ void unregisterConfigFactory(ConfigFactory configFactory);
+
+ /**
+ * Returns set of all registered configuration factories.
+ *
+ * @return set of config factories
+ */
+ Set<ConfigFactory> getConfigFactories();
+
+ /**
+ * Returns set of all configuration factories registered for the specified
+ * class of subject.
+ *
+ * @param subjectClass subject class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return set of config factories
+ */
+ <S, C extends Config<S>> Set<ConfigFactory<S, C>> getConfigFactories(Class<S> subjectClass);
+
+ /**
+ * Returns the configuration factory that produces the specified class of
+ * configurations.
+ *
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return config factory
+ */
+ <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java
new file mode 100644
index 0000000..465751b
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.annotations.Beta;
+import org.onosproject.event.ListenerService;
+
+import java.util.Set;
+
+/**
+ * Service for tracking network configurations which specify how the discovered
+ * network information should be interpreted and how the core or applications
+ * should act on or configure the network.
+ */
+@Beta
+public interface NetworkConfigService
+ extends ListenerService<NetworkConfigEvent, NetworkConfigListener> {
+
+ /**
+ * Returns the set of subject classes for which configuration may be
+ * available.
+ *
+ * @return set of subject classes
+ */
+ Set<Class> getSubjectClasses();
+
+ /**
+ * Returns the subject factory with the specified key.
+ *
+ * @param subjectKey subject class key
+ * @return subject class
+ */
+ SubjectFactory getSubjectFactory(String subjectKey);
+
+ /**
+ * Returns the subject factory for the specified class.
+ *
+ * @param subjectClass subject class
+ * @return subject class key
+ */
+ SubjectFactory getSubjectFactory(Class subjectClass);
+
+ /**
+ * Returns the configuration class with the specified key.
+ *
+ * @param subjectKey subject class key
+ * @param configKey subject class name
+ * @return subject class
+ */
+ Class<? extends Config> getConfigClass(String subjectKey, String configKey);
+
+ /**
+ * Returns the set of subjects for which some configuration is available.
+ *
+ * @param subjectClass subject class
+ * @param <S> type of subject
+ * @return set of configured subjects
+ */
+ <S> Set<S> getSubjects(Class<S> subjectClass);
+
+ /**
+ * Returns the set of subjects for which the specified configuration is
+ * available.
+ *
+ * @param subjectClass subject class
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return set of configured subjects
+ */
+ <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass);
+
+ /**
+ * Returns all configurations for the specified subject.
+ *
+ * @param subject configuration subject
+ * @param <S> type of subject
+ * @return set of configurations
+ */
+ <S> Set<? extends Config<S>> getConfigs(S subject);
+
+ /**
+ * Returns the configuration for the specified subject and configuration
+ * class if one is available; null otherwise.
+ *
+ * @param subject configuration subject
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return configuration or null if one is not available
+ */
+ <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass);
+
+ /**
+ * Creates a new configuration for the specified subject and configuration
+ * class. If one already exists, it is simply returned.
+ *
+ * @param subject configuration subject
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return configuration or null if one is not available
+ */
+ <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass);
+
+ /**
+ * Applies configuration for the specified subject and configuration
+ * class using the raw JSON object. If configuration already exists, it
+ * will be updated.
+ *
+ * @param subject configuration subject
+ * @param configClass configuration class
+ * @param json raw JSON node containing the configuration data
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return configuration or null if one is not available
+ */
+ <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
+ ObjectNode json);
+
+ /**
+ * Clears any configuration for the specified subject and configuration
+ * class. If one does not exist, this call has no effect.
+ *
+ * @param subject configuration subject
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ */
+ <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStore.java b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStore.java
new file mode 100644
index 0000000..c06fe6d
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStore.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.store.Store;
+
+import java.util.Set;
+
+/**
+ * Mechanism for distributing and storing network configuration information.
+ */
+public interface NetworkConfigStore extends Store<NetworkConfigEvent, NetworkConfigStoreDelegate> {
+
+ /**
+ * Adds a new configuration factory.
+ *
+ * @param configFactory configuration factory to add
+ */
+ void addConfigFactory(ConfigFactory configFactory);
+
+ /**
+ * Removes a configuration factory.
+ *
+ * @param configFactory configuration factory to remove
+ */
+ void removeConfigFactory(ConfigFactory configFactory);
+
+ /**
+ * Returns the configuration factory for the specified configuration class.
+ *
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return configuration factory or null
+ */
+ <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass);
+
+ /**
+ * Returns set of subjects of the specified class, which have some
+ * network configuration associated with them.
+ *
+ * @param subjectClass subject class
+ * @param <S> type of subject
+ * @return set of subject
+ */
+ <S> Set<S> getSubjects(Class<S> subjectClass);
+
+ /**
+ * Returns set of subjects of the specified class, which have the
+ * specified class of network configuration associated with them.
+ *
+ * @param subjectClass subject class
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return set of subject
+ */
+ <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass);
+
+ /**
+ * Returns set of configuration classes available for the specified subject.
+ *
+ * @param subject configuration subject
+ * @param <S> type of subject
+ * @return set of configuration classes
+ */
+ <S> Set<Class<? extends Config<S>>> getConfigClasses(S subject);
+
+ /**
+ * Get the configuration of the given class and for the specified subject.
+ *
+ * @param subject configuration subject
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return configuration object
+ */
+ <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass);
+
+ /**
+ * Creates a new configuration of the given class for the specified subject.
+ *
+ * @param subject configuration subject
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return configuration object
+ */
+ <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass);
+
+ /**
+ * Applies configuration for the specified subject and configuration
+ * class using the raw JSON object. If configuration already exists, it
+ * will be updated.
+ *
+ * @param subject configuration subject
+ * @param configClass configuration class
+ * @param json raw JSON node containing the configuration data
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ * @return configuration object
+ */
+ <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
+ ObjectNode json);
+
+ /**
+ * Clears the configuration of the given class for the specified subject.
+ *
+ * @param subject configuration subject
+ * @param configClass configuration class
+ * @param <S> type of subject
+ * @param <C> type of configuration
+ */
+ <S, C extends Config<S>> void clearConfig(S subject, Class<C> configClass);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStoreDelegate.java b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStoreDelegate.java
new file mode 100644
index 0000000..15d3d3e
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigStoreDelegate.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * Network configuration store delegate abstraction.
+ */
+public interface NetworkConfigStoreDelegate extends StoreDelegate<NetworkConfigEvent> {
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/SubjectFactory.java b/core/api/src/main/java/org/onosproject/net/config/SubjectFactory.java
new file mode 100644
index 0000000..cd2db34
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/SubjectFactory.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.config;
+
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Base abstract factory for creating configuration subjects from their
+ * string key image.
+ *
+ * @param <S> subject class
+ */
+@Beta
+public abstract class SubjectFactory<S> {
+
+ private final Class<S> subjectClass;
+ private final String subjectKey;
+
+ /**
+ * Creates a new configuration factory for the specified class of subjects
+ * capable of generating the configurations of the specified class. The
+ * subject and configuration class keys are used merely as keys for use in
+ * composite JSON trees.
+ *
+ * @param subjectClass subject class
+ * @param subjectKey subject class key
+ */
+ protected SubjectFactory(Class<S> subjectClass, String subjectKey) {
+ this.subjectClass = subjectClass;
+ this.subjectKey = subjectKey;
+ }
+
+ /**
+ * Returns the class of the subject to which this factory applies.
+ *
+ * @return subject type
+ */
+ public Class<S> subjectClass() {
+ return subjectClass;
+ }
+
+ /**
+ * Returns the unique key of this configuration subject class.
+ * This is primarily aimed for use in composite JSON trees in external
+ * representations and has no bearing on the internal behaviours.
+ *
+ * @return configuration key
+ */
+ public String subjectKey() {
+ return subjectKey;
+ }
+
+ /**
+ * Creates a configuration subject from its key image.
+ *
+ * @param subjectKey subject class key
+ * @return configuration subject
+ */
+ public abstract S createSubject(String subjectKey);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/config/package-info.java b/core/api/src/main/java/org/onosproject/net/config/package-info.java
new file mode 100644
index 0000000..f300717
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Subsystem for tracking network environment configuration.
+ */
+package org.onosproject.net.config;