blob: 4bca46e216d040ed09356c821fc7224b2b3622a8 [file] [log] [blame]
Jian Li49109b52019-01-22 00:17:28 +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.k8snode.web;
17
18import org.onosproject.codec.CodecService;
Jian Lie2a04ce2020-07-01 19:07:02 +090019import org.onosproject.k8snode.api.HostNodesInfo;
Jian Li3defa842019-02-12 00:31:35 +090020import org.onosproject.k8snode.api.K8sApiConfig;
Jian Lie2a04ce2020-07-01 19:07:02 +090021import org.onosproject.k8snode.api.K8sHost;
Jian Li49109b52019-01-22 00:17:28 +090022import org.onosproject.k8snode.api.K8sNode;
Jian Lie2a04ce2020-07-01 19:07:02 +090023import org.onosproject.k8snode.codec.HostNodesInfoCodec;
Jian Li3defa842019-02-12 00:31:35 +090024import org.onosproject.k8snode.codec.K8sApiConfigCodec;
Jian Lie2a04ce2020-07-01 19:07:02 +090025import org.onosproject.k8snode.codec.K8sHostCodec;
Jian Li49109b52019-01-22 00:17:28 +090026import org.onosproject.k8snode.codec.K8sNodeCodec;
27import 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;
32import org.slf4j.Logger;
33
34import static org.slf4j.LoggerFactory.getLogger;
35
36/**
37 * Implementation of the JSON codec brokering service for K8sNode.
38 */
39@Component(immediate = true)
40public class K8sNodeCodecRegister {
41
42 private final Logger log = getLogger(getClass());
43
44 @Reference(cardinality = ReferenceCardinality.MANDATORY)
45 protected CodecService codecService;
46
47 @Activate
48 protected void activate() {
49
50 codecService.registerCodec(K8sNode.class, new K8sNodeCodec());
Jian Li3defa842019-02-12 00:31:35 +090051 codecService.registerCodec(K8sApiConfig.class, new K8sApiConfigCodec());
Jian Lie2a04ce2020-07-01 19:07:02 +090052 codecService.registerCodec(HostNodesInfo.class, new HostNodesInfoCodec());
53 codecService.registerCodec(K8sHost.class, new K8sHostCodec());
Jian Li49109b52019-01-22 00:17:28 +090054
55 log.info("Started");
56 }
57
58 @Deactivate
59 protected void deactivate() {
60
61 codecService.unregisterCodec(K8sNode.class);
Jian Li3defa842019-02-12 00:31:35 +090062 codecService.unregisterCodec(K8sApiConfig.class);
Jian Lie2a04ce2020-07-01 19:07:02 +090063 codecService.unregisterCodec(HostNodesInfo.class);
64 codecService.unregisterCodec(K8sHost.class);
Jian Li49109b52019-01-22 00:17:28 +090065
66 log.info("Stopped");
67 }
68}