Jian Li | 4a3fffa | 2018-06-10 23:12:40 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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 | package org.onosproject.openstacktelemetry.web; |
| 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.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 23 | import org.onosproject.codec.CodecService; |
| 24 | import org.onosproject.openstacktelemetry.api.FlowInfo; |
Boyoung Jeong | 9e8faec | 2018-06-17 21:19:23 +0900 | [diff] [blame] | 25 | import org.onosproject.openstacktelemetry.api.StatsFlowRule; |
Jian Li | 4a3fffa | 2018-06-10 23:12:40 +0900 | [diff] [blame] | 26 | import org.onosproject.openstacktelemetry.api.StatsInfo; |
| 27 | import org.onosproject.openstacktelemetry.codec.FlowInfoJsonCodec; |
Boyoung Jeong | 9e8faec | 2018-06-17 21:19:23 +0900 | [diff] [blame] | 28 | import org.onosproject.openstacktelemetry.codec.StatsFlowRuleJsonCodec; |
Jian Li | 4a3fffa | 2018-06-10 23:12:40 +0900 | [diff] [blame] | 29 | import org.onosproject.openstacktelemetry.codec.StatsInfoJsonCodec; |
| 30 | |
| 31 | import static org.slf4j.LoggerFactory.getLogger; |
| 32 | |
| 33 | /** |
| 34 | * Implementation of the JSON codec brokering service for OpenstackTelemetry. |
| 35 | */ |
| 36 | @Component(immediate = true) |
| 37 | public class OpenstackTelemetryCodecRegister { |
| 38 | |
| 39 | private final org.slf4j.Logger log = getLogger(getClass()); |
| 40 | |
| 41 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 42 | protected CodecService codecService; |
| 43 | |
| 44 | @Activate |
| 45 | protected void activate() { |
| 46 | codecService.registerCodec(StatsInfo.class, new StatsInfoJsonCodec()); |
| 47 | codecService.registerCodec(FlowInfo.class, new FlowInfoJsonCodec()); |
Boyoung Jeong | 9e8faec | 2018-06-17 21:19:23 +0900 | [diff] [blame] | 48 | codecService.registerCodec(StatsFlowRule.class, new StatsFlowRuleJsonCodec()); |
Jian Li | 4a3fffa | 2018-06-10 23:12:40 +0900 | [diff] [blame] | 49 | |
| 50 | log.info("Started"); |
| 51 | } |
| 52 | |
| 53 | @Deactivate |
| 54 | protected void deactivate() { |
| 55 | codecService.unregisterCodec(StatsInfo.class); |
| 56 | codecService.unregisterCodec(FlowInfo.class); |
Boyoung Jeong | 9e8faec | 2018-06-17 21:19:23 +0900 | [diff] [blame] | 57 | codecService.unregisterCodec(StatsFlowRule.class); |
Jian Li | 4a3fffa | 2018-06-10 23:12:40 +0900 | [diff] [blame] | 58 | |
| 59 | log.info("Stopped"); |
| 60 | } |
| 61 | } |