blob: 6bd8636f934b4b7f725729e4b031b7155a77b6a9 [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
Jian Li7fe7eaf2018-12-31 17:00:33 +090018import org.onosproject.codec.CodecService;
19import org.onosproject.openstacktelemetry.api.FlowInfo;
20import org.onosproject.openstacktelemetry.api.StatsFlowRule;
21import org.onosproject.openstacktelemetry.api.StatsInfo;
22import org.onosproject.openstacktelemetry.api.config.TelemetryConfig;
23import org.onosproject.openstacktelemetry.codec.rest.FlowInfoJsonCodec;
24import org.onosproject.openstacktelemetry.codec.rest.StatsFlowRuleJsonCodec;
25import org.onosproject.openstacktelemetry.codec.rest.StatsInfoJsonCodec;
26import org.onosproject.openstacktelemetry.codec.rest.TelemetryConfigJsonCodec;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070027import org.osgi.service.component.annotations.Activate;
28import org.osgi.service.component.annotations.Component;
29import org.osgi.service.component.annotations.Deactivate;
30import org.osgi.service.component.annotations.Reference;
31import org.osgi.service.component.annotations.ReferenceCardinality;
Jian Li4a3fffa2018-06-10 23:12:40 +090032
33import static org.slf4j.LoggerFactory.getLogger;
34
35/**
36 * Implementation of the JSON codec brokering service for OpenstackTelemetry.
37 */
38@Component(immediate = true)
39public class OpenstackTelemetryCodecRegister {
40
41 private final org.slf4j.Logger log = getLogger(getClass());
42
Ray Milkeyd84f89b2018-08-17 14:54:17 -070043 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Jian Li4a3fffa2018-06-10 23:12:40 +090044 protected CodecService codecService;
45
46 @Activate
47 protected void activate() {
48 codecService.registerCodec(StatsInfo.class, new StatsInfoJsonCodec());
49 codecService.registerCodec(FlowInfo.class, new FlowInfoJsonCodec());
Boyoung Jeong9e8faec2018-06-17 21:19:23 +090050 codecService.registerCodec(StatsFlowRule.class, new StatsFlowRuleJsonCodec());
Jian Li7fe7eaf2018-12-31 17:00:33 +090051 codecService.registerCodec(TelemetryConfig.class, new TelemetryConfigJsonCodec());
Jian Li4a3fffa2018-06-10 23:12:40 +090052
53 log.info("Started");
54 }
55
56 @Deactivate
57 protected void deactivate() {
58 codecService.unregisterCodec(StatsInfo.class);
59 codecService.unregisterCodec(FlowInfo.class);
Boyoung Jeong9e8faec2018-06-17 21:19:23 +090060 codecService.unregisterCodec(StatsFlowRule.class);
Jian Li7fe7eaf2018-12-31 17:00:33 +090061 codecService.unregisterCodec(TelemetryConfig.class);
Jian Li4a3fffa2018-06-10 23:12:40 +090062
63 log.info("Stopped");
64 }
65}