blob: 00a1007d783efe6ac6b0aa01e2c6cc3cd1884345 [file] [log] [blame]
Jian Licc01e452020-12-21 01:44:05 +09001/*
2 * Copyright 2020-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.kubevirtnode.web;
17
18import org.onosproject.codec.CodecService;
Daniel Park5ff76b72022-09-26 22:58:53 +090019import org.onosproject.kubevirtnode.api.KubernetesExternalLbInterface;
Jian Lif2483072020-12-25 02:24:16 +090020import org.onosproject.kubevirtnode.api.KubevirtApiConfig;
Jian Licc01e452020-12-21 01:44:05 +090021import org.onosproject.kubevirtnode.api.KubevirtNode;
22import org.onosproject.kubevirtnode.api.KubevirtPhyInterface;
Daniel Park5ff76b72022-09-26 22:58:53 +090023import org.onosproject.kubevirtnode.codec.KubernetesExternalLbInterfaceCodec;
Jian Lif2483072020-12-25 02:24:16 +090024import org.onosproject.kubevirtnode.codec.KubevirtApiConfigCodec;
Jian Licc01e452020-12-21 01:44:05 +090025import org.onosproject.kubevirtnode.codec.KubevirtNodeCodec;
26import org.onosproject.kubevirtnode.codec.KubevirtPhyInterfaceCodec;
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 KubevirtNode.
38 */
39@Component(immediate = true)
40public class KubevirtNodeCodecRegister {
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 codecService.registerCodec(KubevirtNode.class, new KubevirtNodeCodec());
50 codecService.registerCodec(KubevirtPhyInterface.class, new KubevirtPhyInterfaceCodec());
Jian Lif2483072020-12-25 02:24:16 +090051 codecService.registerCodec(KubevirtApiConfig.class, new KubevirtApiConfigCodec());
Daniel Park5ff76b72022-09-26 22:58:53 +090052 codecService.registerCodec(KubernetesExternalLbInterface.class, new KubernetesExternalLbInterfaceCodec());
Jian Licc01e452020-12-21 01:44:05 +090053
54 log.info("Started");
55 }
56
57 @Deactivate
58 protected void deactivate() {
59 codecService.unregisterCodec(KubevirtNode.class);
60 codecService.unregisterCodec(KubevirtPhyInterface.class);
Jian Lif2483072020-12-25 02:24:16 +090061 codecService.unregisterCodec(KubevirtApiConfig.class);
Daniel Park5ff76b72022-09-26 22:58:53 +090062 codecService.unregisterCodec(KubernetesExternalLbInterface.class);
Jian Licc01e452020-12-21 01:44:05 +090063
64 log.info("Stopped");
65 }
66}