sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [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.provider.ospf.cfg.impl; |
| 18 | |
| 19 | import com.fasterxml.jackson.databind.JsonNode; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 20 | import org.osgi.service.component.annotations.Reference; |
| 21 | import org.osgi.service.component.annotations.ReferenceCardinality; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 22 | import org.onlab.osgi.DefaultServiceDirectory; |
| 23 | import org.onosproject.core.ApplicationId; |
| 24 | import org.onosproject.net.config.Config; |
| 25 | import org.onosproject.ospf.controller.OspfController; |
| 26 | |
| 27 | /** |
| 28 | * Configuration object for OSPF. |
| 29 | */ |
| 30 | public class OspfAppConfig extends Config<ApplicationId> { |
| 31 | public static final String METHOD = "method"; |
| 32 | public static final String ATTRIBUTE = "attribute"; |
| 33 | public static final String PROCESSES = "processes"; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 34 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 35 | private OspfController ospfController; |
| 36 | |
| 37 | /** |
| 38 | * Returns the configuration method, add, delete etc. |
| 39 | * |
| 40 | * @return the configuration method, add, delete etc |
| 41 | */ |
| 42 | public String method() { |
| 43 | return get(METHOD, null); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns the configuration attribute, area, process etc. |
| 48 | * |
| 49 | * @return the configuration attribute, area, process etc |
| 50 | */ |
| 51 | public String attribute() { |
| 52 | return get(ATTRIBUTE, null); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns the configured processes. |
| 57 | * |
| 58 | * @return the configured processes |
| 59 | */ |
| 60 | public JsonNode processes() { |
| 61 | JsonNode jsonNodes = object.get(PROCESSES); |
| 62 | |
| 63 | return jsonNodes; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public boolean isValid() { |
| 68 | this.ospfController = DefaultServiceDirectory.getService(OspfController.class); |
| 69 | |
| 70 | return true; |
| 71 | } |
| 72 | } |