blob: 98a028f4c47c1b4f3196a6cb3d1559bad0610461 [file] [log] [blame]
Sithara Punnassery9306e6b2017-02-06 15:38:19 -08001/*
2 * Copyright 2016-present 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.config.impl;
17
Sithara Punnassery06208792017-02-10 16:25:29 -080018import com.google.common.annotations.Beta;
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080019import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
24import org.apache.felix.scr.annotations.Service;
25import org.onosproject.config.DynamicConfigEvent;
26import org.onosproject.config.DynamicConfigListener;
27import org.onosproject.config.DynamicConfigService;
28import org.onosproject.config.DynamicConfigStore;
29import org.onosproject.config.DynamicConfigStoreDelegate;
30import org.onosproject.config.FailedException;
31import org.onosproject.config.Filter;
32import org.onosproject.config.RpcCaller;
33import org.onosproject.config.RpcCommand;
34import org.onosproject.config.RpcHandler;
35import org.onosproject.config.RpcInput;
36import org.onosproject.config.RpcOutput;
37import org.onosproject.config.model.DataNode;
38import org.onosproject.config.model.ResourceId;
39import org.onosproject.event.AbstractListenerManager;
40import org.onosproject.event.EventDeliveryService;
41import org.slf4j.Logger;
42
43import static org.slf4j.LoggerFactory.getLogger;
44
45/**
46 * Demo application to use the DynamicConfig Service and DynamicConfigStore.
47 *
48 */
Sithara Punnassery06208792017-02-10 16:25:29 -080049@Beta
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080050@Component(immediate = true)
51@Service
52public class DynamicConfigManager
53 extends AbstractListenerManager<DynamicConfigEvent, DynamicConfigListener>
54 implements DynamicConfigService {
55 private final Logger log = getLogger(getClass());
56 private final DynamicConfigStoreDelegate storeDelegate = new InternalStoreDelegate();
57 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
58 protected EventDeliveryService eventDispatcher;
59 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
60 protected DynamicConfigStore store;
61
62 @Activate
63 public void activate() {
64 store.setDelegate(storeDelegate);
65 log.info("DynamicConfigService Started");
66 }
67
68 @Deactivate
69 public void deactivate() {
70 store.unsetDelegate(storeDelegate);
71 log.info("DynamicConfigService Stopped");
72 }
73
74 @Override
75 public void createNode(ResourceId path, DataNode node) {
76 Boolean stat = false;
77 stat = this.store.addNode(path, node).join();
78 }
79
80 public void createNodeRecursive(ResourceId path, DataNode node) {
81 Boolean stat = false;
82 stat = this.store.addRecursive(path, node).join();
83 }
84
85 public DataNode readNode(ResourceId path, Filter filter) {
86 return store.readNode(path, filter).join();
87 }
88
89 public Integer getNumberOfChildren(ResourceId path, Filter filter) {
90 throw new FailedException("Not yet implemented");
91 }
92
93 public void updateNode(ResourceId path, DataNode node) {
94 throw new FailedException("Not yet implemented");
95 }
96
97 public void deleteNode(ResourceId path) {
98 throw new FailedException("Not yet implemented");
99 }
100
101 public void deleteNodeRecursive(ResourceId path) {
102 throw new FailedException("Not yet implemented");
103 }
104
105 public void updateNodeRecursive(ResourceId path, DataNode node) {
106 throw new FailedException("Not yet implemented");
107 }
108
109 public void replaceNode(ResourceId path, DataNode node) {
110 throw new FailedException("Not yet implemented");
111 }
112
113 public void addConfigListener(ResourceId path, DynamicConfigListener listener) {
114 throw new FailedException("Not yet implemented");
115 }
116
117 public void removeConfigListener(ResourceId path, DynamicConfigListener listener) {
118 throw new FailedException("Not yet implemented");
119 }
120
121 public void registerHandler(RpcHandler handler, RpcCommand command) {
122 throw new FailedException("Not yet implemented");
123 }
124
125 public void unRegisterHandler(RpcHandler handler, RpcCommand command) {
126 //check obj1.getClass().equals(obj2.getClass())
127 throw new FailedException("Not yet implemented");
128 }
129
130 public void invokeRpc(RpcCaller caller, Integer msgId, RpcCommand command, RpcInput input) {
131 throw new FailedException("Not yet implemented");
132 }
133
134 public void rpcResponse(Integer msgId, RpcOutput output) {
135 throw new FailedException("Not yet implemented");
136 }
137 /**
138 * Auxiliary store delegate to receive notification about changes in
139 * the prop configuration store state - by the store itself.
140 */
141 private class InternalStoreDelegate implements DynamicConfigStoreDelegate {
142 public void notify(DynamicConfigEvent event) {
143 // TODO
144 // post(event);
145 }
146 }
147}