Mahesh Poojary Huawei

[ONOS-3113] flow-classifier manager modification

Change-Id: I9e7c8f8f397edb36be0a6a4cc53ee2b2174679c5
...@@ -15,13 +15,14 @@ ...@@ -15,13 +15,14 @@
15 */ 15 */
16 package org.onosproject.vtnrsc.flowclassifier; 16 package org.onosproject.vtnrsc.flowclassifier;
17 17
18 +import org.onosproject.event.ListenerService;
18 import org.onosproject.vtnrsc.FlowClassifier; 19 import org.onosproject.vtnrsc.FlowClassifier;
19 import org.onosproject.vtnrsc.FlowClassifierId; 20 import org.onosproject.vtnrsc.FlowClassifierId;
20 21
21 /** 22 /**
22 * Provides Services for Flow Classifier. 23 * Provides Services for Flow Classifier.
23 */ 24 */
24 -public interface FlowClassifierService { 25 +public interface FlowClassifierService extends ListenerService<FlowClassifierEvent, FlowClassifierListener> {
25 26
26 /** 27 /**
27 * Check whether Flow Classifier is present based on given Flow Classifier 28 * Check whether Flow Classifier is present based on given Flow Classifier
...@@ -79,18 +80,4 @@ public interface FlowClassifierService { ...@@ -79,18 +80,4 @@ public interface FlowClassifierService {
79 * false 80 * false
80 */ 81 */
81 boolean removeFlowClassifier(FlowClassifierId id); 82 boolean removeFlowClassifier(FlowClassifierId id);
82 -
83 - /**
84 - * Adds the specified listener to Flow-Classifier manager.
85 - *
86 - * @param listener Flow-Classifier listener
87 - */
88 - void addListener(FlowClassifierListener listener);
89 -
90 - /**
91 - * Removes the specified listener to Flow-Classifier manager.
92 - *
93 - * @param listener Flow-Classifier listener
94 - */
95 - void removeListener(FlowClassifierListener listener);
96 } 83 }
......
...@@ -25,6 +25,7 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -25,6 +25,7 @@ import org.apache.felix.scr.annotations.Reference;
25 import org.apache.felix.scr.annotations.ReferenceCardinality; 25 import org.apache.felix.scr.annotations.ReferenceCardinality;
26 import org.apache.felix.scr.annotations.Service; 26 import org.apache.felix.scr.annotations.Service;
27 import org.onlab.util.KryoNamespace; 27 import org.onlab.util.KryoNamespace;
28 +import org.onosproject.event.AbstractListenerManager;
28 import org.onosproject.store.serializers.KryoNamespaces; 29 import org.onosproject.store.serializers.KryoNamespaces;
29 import org.onosproject.store.service.EventuallyConsistentMap; 30 import org.onosproject.store.service.EventuallyConsistentMap;
30 import org.onosproject.store.service.MultiValuedTimestamp; 31 import org.onosproject.store.service.MultiValuedTimestamp;
...@@ -32,28 +33,27 @@ import org.onosproject.store.service.StorageService; ...@@ -32,28 +33,27 @@ import org.onosproject.store.service.StorageService;
32 import org.onosproject.store.service.WallClockTimestamp; 33 import org.onosproject.store.service.WallClockTimestamp;
33 import org.onosproject.vtnrsc.FlowClassifierId; 34 import org.onosproject.vtnrsc.FlowClassifierId;
34 import org.onosproject.vtnrsc.FlowClassifier; 35 import org.onosproject.vtnrsc.FlowClassifier;
36 +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierEvent;
35 import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener; 37 import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener;
36 import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; 38 import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
37 import org.slf4j.Logger; 39 import org.slf4j.Logger;
38 40
39 -import java.util.Set;
40 -
41 import com.google.common.collect.ImmutableList; 41 import com.google.common.collect.ImmutableList;
42 -import com.google.common.collect.Sets;
43 42
44 /** 43 /**
45 * Provides implementation of the Flow Classifier Service. 44 * Provides implementation of the Flow Classifier Service.
46 */ 45 */
47 @Component(immediate = true) 46 @Component(immediate = true)
48 @Service 47 @Service
49 -public class FlowClassifierManager implements FlowClassifierService { 48 +public class FlowClassifierManager extends AbstractListenerManager<FlowClassifierEvent, FlowClassifierListener>
49 + implements FlowClassifierService {
50 50
51 private static final String FLOW_CLASSIFIER_NOT_NULL = "Flow Classifier cannot be null"; 51 private static final String FLOW_CLASSIFIER_NOT_NULL = "Flow Classifier cannot be null";
52 private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "Flow Classifier Id cannot be null"; 52 private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "Flow Classifier Id cannot be null";
53 private static final String LISTENER_NOT_NULL = "Listener cannot be null"; 53 private static final String LISTENER_NOT_NULL = "Listener cannot be null";
54 54
55 private final Logger log = getLogger(FlowClassifierManager.class); 55 private final Logger log = getLogger(FlowClassifierManager.class);
56 - private final Set<FlowClassifierListener> listeners = Sets.newCopyOnWriteArraySet(); 56 +
57 private EventuallyConsistentMap<FlowClassifierId, FlowClassifier> flowClassifierStore; 57 private EventuallyConsistentMap<FlowClassifierId, FlowClassifier> flowClassifierStore;
58 58
59 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 59 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
...@@ -75,7 +75,6 @@ public class FlowClassifierManager implements FlowClassifierService { ...@@ -75,7 +75,6 @@ public class FlowClassifierManager implements FlowClassifierService {
75 @Deactivate 75 @Deactivate
76 protected void deactivate() { 76 protected void deactivate() {
77 flowClassifierStore.destroy(); 77 flowClassifierStore.destroy();
78 - listeners.clear();
79 log.info("Flow Classifier service deactivated"); 78 log.info("Flow Classifier service deactivated");
80 } 79 }
81 80
...@@ -145,16 +144,4 @@ public class FlowClassifierManager implements FlowClassifierService { ...@@ -145,16 +144,4 @@ public class FlowClassifierManager implements FlowClassifierService {
145 } 144 }
146 return true; 145 return true;
147 } 146 }
148 -
149 - @Override
150 - public void addListener(FlowClassifierListener listener) {
151 - checkNotNull(listener, LISTENER_NOT_NULL);
152 - listeners.add(listener);
153 - }
154 -
155 - @Override
156 - public void removeListener(FlowClassifierListener listener) {
157 - checkNotNull(listener, LISTENER_NOT_NULL);
158 - listeners.remove(listener);
159 - }
160 } 147 }
......