blob: c8bfeb5d3ebc866f0a68a9bd01a822fcfe5ce81b [file] [log] [blame]
Jian Li4a3fffa2018-06-10 23:12:40 +09001/*
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 */
16package org.onosproject.openstacktelemetry.web;
17
Ray Milkeyd84f89b2018-08-17 14:54:17 -070018import org.osgi.service.component.annotations.Activate;
19import org.osgi.service.component.annotations.Component;
20import org.osgi.service.component.annotations.Deactivate;
21import org.osgi.service.component.annotations.Reference;
22import org.osgi.service.component.annotations.ReferenceCardinality;
Jian Li4a3fffa2018-06-10 23:12:40 +090023import org.onosproject.codec.CodecService;
24import org.onosproject.openstacktelemetry.api.FlowInfo;
Boyoung Jeong9e8faec2018-06-17 21:19:23 +090025import org.onosproject.openstacktelemetry.api.StatsFlowRule;
Jian Li4a3fffa2018-06-10 23:12:40 +090026import org.onosproject.openstacktelemetry.api.StatsInfo;
27import org.onosproject.openstacktelemetry.codec.FlowInfoJsonCodec;
Boyoung Jeong9e8faec2018-06-17 21:19:23 +090028import org.onosproject.openstacktelemetry.codec.StatsFlowRuleJsonCodec;
Jian Li4a3fffa2018-06-10 23:12:40 +090029import org.onosproject.openstacktelemetry.codec.StatsInfoJsonCodec;
30
31import static org.slf4j.LoggerFactory.getLogger;
32
33/**
34 * Implementation of the JSON codec brokering service for OpenstackTelemetry.
35 */
36@Component(immediate = true)
37public class OpenstackTelemetryCodecRegister {
38
39 private final org.slf4j.Logger log = getLogger(getClass());
40
Ray Milkeyd84f89b2018-08-17 14:54:17 -070041 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Jian Li4a3fffa2018-06-10 23:12:40 +090042 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 Jeong9e8faec2018-06-17 21:19:23 +090048 codecService.registerCodec(StatsFlowRule.class, new StatsFlowRuleJsonCodec());
Jian Li4a3fffa2018-06-10 23:12:40 +090049
50 log.info("Started");
51 }
52
53 @Deactivate
54 protected void deactivate() {
55 codecService.unregisterCodec(StatsInfo.class);
56 codecService.unregisterCodec(FlowInfo.class);
Boyoung Jeong9e8faec2018-06-17 21:19:23 +090057 codecService.unregisterCodec(StatsFlowRule.class);
Jian Li4a3fffa2018-06-10 23:12:40 +090058
59 log.info("Stopped");
60 }
61}