blob: 55d740f54fff11d9793e93b2c3f5307704da8ac3 [file] [log] [blame]
Jian Li171582e2020-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;
Jian Lic4604302020-12-25 02:24:16 +090019import org.onosproject.kubevirtnode.api.KubevirtApiConfig;
Jian Li171582e2020-12-21 01:44:05 +090020import org.onosproject.kubevirtnode.api.KubevirtNode;
21import org.onosproject.kubevirtnode.api.KubevirtPhyInterface;
Jian Lic4604302020-12-25 02:24:16 +090022import org.onosproject.kubevirtnode.codec.KubevirtApiConfigCodec;
Jian Li171582e2020-12-21 01:44:05 +090023import org.onosproject.kubevirtnode.codec.KubevirtNodeCodec;
24import org.onosproject.kubevirtnode.codec.KubevirtPhyInterfaceCodec;
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 KubevirtNode.
36 */
37@Component(immediate = true)
38public class KubevirtNodeCodecRegister {
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 codecService.registerCodec(KubevirtNode.class, new KubevirtNodeCodec());
48 codecService.registerCodec(KubevirtPhyInterface.class, new KubevirtPhyInterfaceCodec());
Jian Lic4604302020-12-25 02:24:16 +090049 codecService.registerCodec(KubevirtApiConfig.class, new KubevirtApiConfigCodec());
Jian Li171582e2020-12-21 01:44:05 +090050
51 log.info("Started");
52 }
53
54 @Deactivate
55 protected void deactivate() {
56 codecService.unregisterCodec(KubevirtNode.class);
57 codecService.unregisterCodec(KubevirtPhyInterface.class);
Jian Lic4604302020-12-25 02:24:16 +090058 codecService.unregisterCodec(KubevirtApiConfig.class);
Jian Li171582e2020-12-21 01:44:05 +090059
60 log.info("Stopped");
61 }
62}