blob: 9138539b0d3e7f629d3d4c62713601f7dc328d1c [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 Li3defa842019-02-12 00:31:35 +090019import org.onosproject.k8snode.api.K8sApiConfig;
Jian Li49109b52019-01-22 00:17:28 +090020import org.onosproject.k8snode.api.K8sNode;
Jian Li3defa842019-02-12 00:31:35 +090021import org.onosproject.k8snode.codec.K8sApiConfigCodec;
Jian Li49109b52019-01-22 00:17:28 +090022import org.onosproject.k8snode.codec.K8sNodeCodec;
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 K8sNode.
34 */
35@Component(immediate = true)
36public class K8sNodeCodecRegister {
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
46 codecService.registerCodec(K8sNode.class, new K8sNodeCodec());
Jian Li3defa842019-02-12 00:31:35 +090047 codecService.registerCodec(K8sApiConfig.class, new K8sApiConfigCodec());
Jian Li49109b52019-01-22 00:17:28 +090048
49 log.info("Started");
50 }
51
52 @Deactivate
53 protected void deactivate() {
54
55 codecService.unregisterCodec(K8sNode.class);
Jian Li3defa842019-02-12 00:31:35 +090056 codecService.unregisterCodec(K8sApiConfig.class);
Jian Li49109b52019-01-22 00:17:28 +090057
58 log.info("Stopped");
59 }
60}