blob: e482d52afbe0e7764c51a43ff43facf066584fe4 [file] [log] [blame]
Jian Lia80b1582019-01-25 12:47:42 +09001/*
2 * Copyright 2019-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.k8snetworking.web;
17
18import org.onosproject.codec.CodecService;
19import org.onosproject.k8snetworking.api.K8sIpam;
20import org.onosproject.k8snetworking.api.K8sNetwork;
21import org.onosproject.k8snetworking.api.K8sPort;
22import org.onosproject.k8snetworking.codec.K8sIpamCodec;
23import org.onosproject.k8snetworking.codec.K8sNetworkCodec;
24import org.onosproject.k8snetworking.codec.K8sPortCodec;
25import org.osgi.service.component.annotations.Activate;
26import org.osgi.service.component.annotations.Component;
27import org.osgi.service.component.annotations.Deactivate;
28import org.osgi.service.component.annotations.Reference;
29import org.osgi.service.component.annotations.ReferenceCardinality;
30import org.slf4j.Logger;
31
32import static org.slf4j.LoggerFactory.getLogger;
33
34/**
35 * Implementation of the JSON codec brokering service for K8sNetworking.
36 */
37@Component(immediate = true)
38public class K8sNetworkingCodecRegister {
39
40 private final Logger log = getLogger(getClass());
41
42 @Reference(cardinality = ReferenceCardinality.MANDATORY)
43 protected CodecService codecService;
44
45 @Activate
46 protected void activate() {
47
48 codecService.registerCodec(K8sIpam.class, new K8sIpamCodec());
49 codecService.registerCodec(K8sNetwork.class, new K8sNetworkCodec());
50 codecService.registerCodec(K8sPort.class, new K8sPortCodec());
51
52 log.info("Started");
53 }
54
55 @Deactivate
56 protected void deactivate() {
57
58 codecService.unregisterCodec(K8sIpam.class);
59 codecService.unregisterCodec(K8sNetwork.class);
60 codecService.unregisterCodec(K8sPort.class);
61
62 log.info("Stopped");
63 }
64}