blob: cd9e229fcee4ea5886b2466170d53ead03292355 [file] [log] [blame]
Thomas Vachuska96d55b12015-05-11 08:52:03 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.incubator.net.config;
17
18import com.fasterxml.jackson.databind.node.ObjectNode;
19import org.onosproject.store.Store;
20
21import java.util.Set;
22
23/**
24 * Mechanism for distributing and storing network configuration information.
25 */
26public interface NetworkConfigStore extends Store<NetworkConfigEvent, NetworkConfigStoreDelegate> {
27
28 /**
29 * Adds a new configuration factory.
30 *
31 * @param configFactory configuration factory to add
32 */
33 void addConfigFactory(ConfigFactory configFactory);
34
35 /**
36 * Removes a configuration factory.
37 *
38 * @param configFactory configuration factory to remove
39 */
40 void removeConfigFactory(ConfigFactory configFactory);
41
42 /**
43 * Returns the configuration factory for the specified configuration class.
44 *
45 * @param configClass configuration class
46 * @param <S> type of subject
47 * @param <C> type of configuration
48 * @return configuration factory or null
49 */
50 <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass);
51
52 /**
53 * Returns set of subjects of the specified class, which have some
54 * network configuration associated with them.
55 *
56 * @param subjectClass subject class
57 * @param <S> type of subject
58 * @return set of subject
59 */
60 <S> Set<S> getSubjects(Class<S> subjectClass);
61
62 /**
63 * Returns set of subjects of the specified class, which have the
64 * specified class of network configuration associated with them.
65 *
66 * @param subjectClass subject class
67 * @param configClass configuration class
68 * @param <S> type of subject
69 * @param <C> type of configuration
70 * @return set of subject
71 */
72 <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass);
73
74 /**
75 * Returns set of configuration classes available for the specified subject.
76 *
77 * @param subject configuration subject
78 * @param <S> type of subject
79 * @return set of configuration classes
80 */
81 <S> Set<Class<? extends Config<S>>> getConfigClasses(S subject);
82
83 /**
84 * Get the configuration of the given class and for the specified subject.
85 *
86 * @param subject configuration subject
87 * @param configClass configuration class
88 * @param <S> type of subject
89 * @param <C> type of configuration
90 * @return configuration object
91 */
92 <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass);
93
94 /**
95 * Creates a new configuration of the given class for the specified subject.
96 *
97 * @param subject configuration subject
98 * @param configClass configuration class
99 * @param <S> type of subject
100 * @param <C> type of configuration
101 * @return configuration object
102 */
103 <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass);
104
105 /**
106 * Applies configuration for the specified subject and configuration
107 * class using the raw JSON object. If configuration already exists, it
108 * will be updated.
109 *
110 * @param subject configuration subject
111 * @param configClass configuration class
112 * @param json raw JSON node containing the configuration data
113 * @param <S> type of subject
114 * @param <C> type of configuration
115 */
116 <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
117 ObjectNode json);
118
119 /**
120 * Clears the configuration of the given class for the specified subject.
121 *
122 * @param subject configuration subject
123 * @param configClass configuration class
124 * @param <S> type of subject
125 * @param <C> type of configuration
126 */
127 <S, C extends Config<S>> void clearConfig(S subject, Class<C> configClass);
128
129}