Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -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 | */ |
Thomas Vachuska | c97aa61 | 2015-06-23 16:00:18 -0700 | [diff] [blame] | 16 | package org.onosproject.store.trivial; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 17 | |
| 18 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; |
| 21 | import org.apache.felix.scr.annotations.Service; |
| 22 | import org.onosproject.cfg.ComponentConfigEvent; |
| 23 | import org.onosproject.cfg.ComponentConfigStore; |
| 24 | import org.onosproject.cfg.ComponentConfigStoreDelegate; |
| 25 | import org.onosproject.store.AbstractStore; |
| 26 | import org.slf4j.Logger; |
| 27 | |
| 28 | import static org.onosproject.cfg.ComponentConfigEvent.Type.PROPERTY_SET; |
| 29 | import static org.onosproject.cfg.ComponentConfigEvent.Type.PROPERTY_UNSET; |
| 30 | import static org.slf4j.LoggerFactory.getLogger; |
| 31 | |
| 32 | /** |
| 33 | * Manages inventory of component configuration properties. |
| 34 | */ |
| 35 | @Component(immediate = true) |
| 36 | @Service |
| 37 | public class SimpleComponentConfigStore |
| 38 | extends AbstractStore<ComponentConfigEvent, ComponentConfigStoreDelegate> |
| 39 | implements ComponentConfigStore { |
| 40 | |
| 41 | private final Logger log = getLogger(getClass()); |
| 42 | |
| 43 | @Activate |
| 44 | public void activate() { |
| 45 | log.info("Started"); |
| 46 | } |
| 47 | |
| 48 | @Deactivate |
| 49 | public void deactivate() { |
| 50 | log.info("Stopped"); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public void setProperty(String componentName, String name, String value) { |
| 55 | delegate.notify(new ComponentConfigEvent(PROPERTY_SET, componentName, name, value)); |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public void unsetProperty(String componentName, String name) { |
| 60 | delegate.notify(new ComponentConfigEvent(PROPERTY_UNSET, componentName, name, null)); |
| 61 | } |
| 62 | } |