Thomas Vachuska | 264d957 | 2016-08-04 11:36:26 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Thomas Vachuska | 264d957 | 2016-08-04 11:36:26 -0700 | [diff] [blame] | 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 | */ |
| 16 | |
| 17 | package org.onosproject.netcfgmonitor; |
| 18 | |
| 19 | import org.apache.felix.scr.annotations.Activate; |
| 20 | import org.apache.felix.scr.annotations.Component; |
| 21 | import org.apache.felix.scr.annotations.Deactivate; |
| 22 | import org.apache.felix.scr.annotations.Reference; |
| 23 | import org.onosproject.net.config.NetworkConfigEvent; |
| 24 | import org.onosproject.net.config.NetworkConfigListener; |
| 25 | import org.onosproject.net.config.NetworkConfigService; |
| 26 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; |
| 28 | |
| 29 | /** |
| 30 | * Network configuration monitor. |
| 31 | */ |
| 32 | @Component(immediate = true) |
| 33 | public class NetCfgEventMonitor { |
| 34 | |
| 35 | private Logger log = LoggerFactory.getLogger(getClass()); |
| 36 | |
| 37 | @Reference |
| 38 | protected NetworkConfigService networkConfigService; |
| 39 | |
| 40 | private final NetworkConfigListener listener = new InternalListener(); |
| 41 | |
| 42 | @Activate |
| 43 | protected void activate() { |
| 44 | networkConfigService.addListener(listener); |
| 45 | } |
| 46 | |
| 47 | @Deactivate |
| 48 | protected void deactivate() { |
| 49 | networkConfigService.removeListener(listener); |
| 50 | } |
| 51 | |
| 52 | private class InternalListener implements NetworkConfigListener { |
| 53 | @Override |
| 54 | public void event(NetworkConfigEvent event) { |
| 55 | log.info("Received event {}", event); |
| 56 | } |
| 57 | } |
| 58 | } |