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 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 18 | import org.onosproject.cfg.ComponentConfigEvent; |
| 19 | import org.onosproject.cfg.ComponentConfigStore; |
| 20 | import org.onosproject.cfg.ComponentConfigStoreDelegate; |
| 21 | import org.onosproject.store.AbstractStore; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 22 | import org.osgi.service.component.annotations.Activate; |
| 23 | import org.osgi.service.component.annotations.Component; |
| 24 | import org.osgi.service.component.annotations.Deactivate; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 25 | import org.slf4j.Logger; |
| 26 | |
| 27 | import static org.onosproject.cfg.ComponentConfigEvent.Type.PROPERTY_SET; |
| 28 | import static org.onosproject.cfg.ComponentConfigEvent.Type.PROPERTY_UNSET; |
| 29 | import static org.slf4j.LoggerFactory.getLogger; |
| 30 | |
| 31 | /** |
| 32 | * Manages inventory of component configuration properties. |
| 33 | */ |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 34 | @Component(immediate = true, service = ComponentConfigStore.class) |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 35 | public class SimpleComponentConfigStore |
| 36 | extends AbstractStore<ComponentConfigEvent, ComponentConfigStoreDelegate> |
| 37 | implements ComponentConfigStore { |
| 38 | |
| 39 | private final Logger log = getLogger(getClass()); |
| 40 | |
| 41 | @Activate |
| 42 | public void activate() { |
| 43 | log.info("Started"); |
| 44 | } |
| 45 | |
| 46 | @Deactivate |
| 47 | public void deactivate() { |
| 48 | log.info("Stopped"); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public void setProperty(String componentName, String name, String value) { |
| 53 | delegate.notify(new ComponentConfigEvent(PROPERTY_SET, componentName, name, value)); |
| 54 | } |
| 55 | |
| 56 | @Override |
Charles Chan | 8b488de | 2019-04-10 17:12:20 -0700 | [diff] [blame] | 57 | public void setProperty(String componentName, String name, String value, boolean override) { |
| 58 | setProperty(componentName, name, value); |
| 59 | } |
| 60 | |
| 61 | @Override |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 62 | public void unsetProperty(String componentName, String name) { |
| 63 | delegate.notify(new ComponentConfigEvent(PROPERTY_UNSET, componentName, name, null)); |
| 64 | } |
| 65 | } |