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