diff options
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier')
4 files changed, 102 insertions, 7 deletions
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierEvent.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierEvent.java new file mode 100644 index 00000000..d81ab48a --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierEvent.java @@ -0,0 +1,63 @@ +/* + * 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.vtnrsc.flowclassifier; + +import org.onosproject.event.AbstractEvent; +import org.onosproject.vtnrsc.FlowClassifier; + +/** + * Describes network Flow-Classifier event. + */ +public class FlowClassifierEvent extends AbstractEvent<FlowClassifierEvent.Type, FlowClassifier> { + /** + * Type of flow-classifier events. + */ + public enum Type { + /** + * Signifies that flow-classifier has been created. + */ + FLOW_CLASSIFIER_PUT, + /** + * Signifies that flow-classifier has been deleted. + */ + FLOW_CLASSIFIER_DELETE, + /** + * Signifies that flow-classifier has been updated. + */ + FLOW_CLASSIFIER_UPDATE + } + + /** + * Creates an event of a given type and for the specified Flow-Classifier. + * + * @param type Flow-Classifier event type + * @param flowClassifier Flow-Classifier subject + */ + public FlowClassifierEvent(Type type, FlowClassifier flowClassifier) { + super(type, flowClassifier); + } + + /** + * Creates an event of a given type and for the specified Flow-Classifier. + * + * @param type Flow-Classifier event type + * @param flowClassifier Flow-Classifier subject + * @param time occurrence time + */ + public FlowClassifierEvent(Type type, FlowClassifier flowClassifier, long time) { + super(type, flowClassifier, time); + } +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierListener.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierListener.java new file mode 100644 index 00000000..3c0409ad --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierListener.java @@ -0,0 +1,25 @@ +/* + * 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.vtnrsc.flowclassifier; + +import org.onosproject.event.EventListener; + +/** + * Entity capable of Flow-Classifier related events. + */ +public interface FlowClassifierListener extends EventListener<FlowClassifierEvent> { + +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java index c5911ff2..48438846 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java @@ -15,13 +15,14 @@ */ package org.onosproject.vtnrsc.flowclassifier; +import org.onosproject.event.ListenerService; import org.onosproject.vtnrsc.FlowClassifier; import org.onosproject.vtnrsc.FlowClassifierId; /** * Provides Services for Flow Classifier. */ -public interface FlowClassifierService { +public interface FlowClassifierService extends ListenerService<FlowClassifierEvent, FlowClassifierListener> { /** * Check whether Flow Classifier is present based on given Flow Classifier diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java index 4a60cd34..18f63b30 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java @@ -15,6 +15,9 @@ */ package org.onosproject.vtnrsc.flowclassifier.impl; +import static org.slf4j.LoggerFactory.getLogger; +import static com.google.common.base.Preconditions.checkNotNull; + import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -22,6 +25,7 @@ import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.Service; import org.onlab.util.KryoNamespace; +import org.onosproject.event.AbstractListenerManager; import org.onosproject.store.serializers.KryoNamespaces; import org.onosproject.store.service.EventuallyConsistentMap; import org.onosproject.store.service.MultiValuedTimestamp; @@ -29,12 +33,11 @@ import org.onosproject.store.service.StorageService; import org.onosproject.store.service.WallClockTimestamp; import org.onosproject.vtnrsc.FlowClassifierId; import org.onosproject.vtnrsc.FlowClassifier; +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierEvent; +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener; import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; import org.slf4j.Logger; -import static org.slf4j.LoggerFactory.getLogger; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.collect.ImmutableList; /** @@ -42,14 +45,17 @@ import com.google.common.collect.ImmutableList; */ @Component(immediate = true) @Service -public class FlowClassifierManager implements FlowClassifierService { - - private final Logger log = getLogger(FlowClassifierManager.class); +public class FlowClassifierManager extends AbstractListenerManager<FlowClassifierEvent, FlowClassifierListener> + implements FlowClassifierService { private static final String FLOW_CLASSIFIER_NOT_NULL = "Flow Classifier cannot be null"; private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "Flow Classifier Id cannot be null"; + private static final String LISTENER_NOT_NULL = "Listener cannot be null"; + + private final Logger log = getLogger(FlowClassifierManager.class); private EventuallyConsistentMap<FlowClassifierId, FlowClassifier> flowClassifierStore; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected StorageService storageService; |