blob: fb0c48fcf753f903c42810f90b569e414c1cb2ab [file] [log] [blame]
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -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 */
Thomas Vachuskad24aa7f2015-05-14 18:37:54 -070016package org.onosproject.incubator.net.config;
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070017
Thomas Vachuska96d55b12015-05-11 08:52:03 -070018import com.fasterxml.jackson.databind.node.ObjectNode;
Thomas Vachuskae2b7e7e2015-05-20 11:11:31 -070019import com.google.common.annotations.Beta;
20
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070021import java.util.Set;
22
23/**
24 * Service for tracking network configurations which specify how the discovered
Thomas Vachuska96d55b12015-05-11 08:52:03 -070025 * network information should be interpreted and how the core or applications
26 * should act on or configure the network.
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070027 */
Thomas Vachuskae2b7e7e2015-05-20 11:11:31 -070028@Beta
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070029public interface NetworkConfigService {
30
31 /**
Thomas Vachuska96d55b12015-05-11 08:52:03 -070032 * Returns the set of subject classes for which configuration may be
33 * available.
34 *
35 * @return set of subject classes
36 */
37 Set<Class> getSubjectClasses();
38
39 /**
40 * Returns the subject factory with the specified key.
41 *
42 * @param subjectKey subject class key
43 * @return subject class
44 */
45 SubjectFactory getSubjectFactory(String subjectKey);
46
47 /**
48 * Returns the subject factory for the specified class.
49 *
50 * @param subjectClass subject class
51 * @return subject class key
52 */
53 SubjectFactory getSubjectFactory(Class subjectClass);
54
55 /**
56 * Returns the configuration class with the specified key.
57 *
58 * @param configKey subject class name
59 * @return subject class
60 */
61 Class<? extends Config> getConfigClass(String configKey);
62
63 /**
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070064 * Returns the set of subjects for which some configuration is available.
65 *
66 * @param subjectClass subject class
Thomas Vachuska96d55b12015-05-11 08:52:03 -070067 * @param <S> type of subject
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070068 * @return set of configured subjects
69 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070070 <S> Set<S> getSubjects(Class<S> subjectClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070071
72 /**
73 * Returns the set of subjects for which the specified configuration is
74 * available.
75 *
76 * @param subjectClass subject class
77 * @param configClass configuration class
Thomas Vachuska96d55b12015-05-11 08:52:03 -070078 * @param <S> type of subject
79 * @param <C> type of configuration
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070080 * @return set of configured subjects
81 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070082 <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070083
84 /**
85 * Returns all configurations for the specified subject.
86 *
87 * @param subject configuration subject
Thomas Vachuska96d55b12015-05-11 08:52:03 -070088 * @param <S> type of subject
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070089 * @return set of configurations
90 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070091 <S> Set<? extends Config<S>> getConfigs(S subject);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070092
93 /**
94 * Returns the configuration for the specified subject and configuration
95 * class if one is available; null otherwise.
96 *
97 * @param subject configuration subject
98 * @param configClass configuration class
Thomas Vachuska96d55b12015-05-11 08:52:03 -070099 * @param <S> type of subject
100 * @param <C> type of configuration
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700101 * @return configuration or null if one is not available
102 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700103 <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700104
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700105 /**
106 * Creates a new configuration for the specified subject and configuration
107 * class. If one already exists, it is simply returned.
108 *
109 * @param subject configuration subject
110 * @param configClass configuration class
111 * @param <S> type of subject
112 * @param <C> type of configuration
113 * @return configuration or null if one is not available
114 */
115 <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass);
116
117 /**
118 * Applies configuration for the specified subject and configuration
119 * class using the raw JSON object. If configuration already exists, it
120 * will be updated.
121 *
122 * @param subject configuration subject
123 * @param configClass configuration class
124 * @param json raw JSON node containing the configuration data
125 * @param <S> type of subject
126 * @param <C> type of configuration
127 * @return configuration or null if one is not available
128 */
129 <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
130 ObjectNode json);
131
132 /**
133 * Clears any configuration for the specified subject and configuration
134 * class. If one does not exist, this call has no effect.
135 *
136 * @param subject configuration subject
137 * @param configClass configuration class
138 * @param <S> type of subject
139 * @param <C> type of configuration
140 */
141 <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass);
142
143 /**
144 * Adds the specified network config listener.
145 *
146 * @param listener network config listener
147 */
148 void addListener(NetworkConfigListener listener);
149
150 /**
151 * Removes the specified network config listener.
152 *
153 * @param listener network config listener
154 */
155 void removeListener(NetworkConfigListener listener);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700156}