blob: 30737acd6c97d0a91b54fa8cf7a654c886d9376d [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
18import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
21import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
23import org.onosproject.codec.CodecService;
24import org.onosproject.openstacktelemetry.api.FlowInfo;
25import org.onosproject.openstacktelemetry.api.StatsInfo;
26import org.onosproject.openstacktelemetry.codec.FlowInfoJsonCodec;
27import org.onosproject.openstacktelemetry.codec.StatsInfoJsonCodec;
28
29import static org.slf4j.LoggerFactory.getLogger;
30
31/**
32 * Implementation of the JSON codec brokering service for OpenstackTelemetry.
33 */
34@Component(immediate = true)
35public class OpenstackTelemetryCodecRegister {
36
37 private final org.slf4j.Logger log = getLogger(getClass());
38
39 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
40 protected CodecService codecService;
41
42 @Activate
43 protected void activate() {
44 codecService.registerCodec(StatsInfo.class, new StatsInfoJsonCodec());
45 codecService.registerCodec(FlowInfo.class, new FlowInfoJsonCodec());
46
47 log.info("Started");
48 }
49
50 @Deactivate
51 protected void deactivate() {
52 codecService.unregisterCodec(StatsInfo.class);
53 codecService.unregisterCodec(FlowInfo.class);
54
55 log.info("Stopped");
56 }
57}