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