Jian Li | cc01e45 | 2020-12-21 01:44:05 +0900 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.kubevirtnode.web; |
| 17 | |
| 18 | import org.onosproject.codec.CodecService; |
Daniel Park | 5ff76b7 | 2022-09-26 22:58:53 +0900 | [diff] [blame] | 19 | import org.onosproject.kubevirtnode.api.KubernetesExternalLbInterface; |
Jian Li | f248307 | 2020-12-25 02:24:16 +0900 | [diff] [blame] | 20 | import org.onosproject.kubevirtnode.api.KubevirtApiConfig; |
Jian Li | cc01e45 | 2020-12-21 01:44:05 +0900 | [diff] [blame] | 21 | import org.onosproject.kubevirtnode.api.KubevirtNode; |
| 22 | import org.onosproject.kubevirtnode.api.KubevirtPhyInterface; |
Daniel Park | 5ff76b7 | 2022-09-26 22:58:53 +0900 | [diff] [blame] | 23 | import org.onosproject.kubevirtnode.codec.KubernetesExternalLbInterfaceCodec; |
Jian Li | f248307 | 2020-12-25 02:24:16 +0900 | [diff] [blame] | 24 | import org.onosproject.kubevirtnode.codec.KubevirtApiConfigCodec; |
Jian Li | cc01e45 | 2020-12-21 01:44:05 +0900 | [diff] [blame] | 25 | import org.onosproject.kubevirtnode.codec.KubevirtNodeCodec; |
| 26 | import org.onosproject.kubevirtnode.codec.KubevirtPhyInterfaceCodec; |
| 27 | import org.osgi.service.component.annotations.Activate; |
| 28 | import org.osgi.service.component.annotations.Component; |
| 29 | import org.osgi.service.component.annotations.Deactivate; |
| 30 | import org.osgi.service.component.annotations.Reference; |
| 31 | import org.osgi.service.component.annotations.ReferenceCardinality; |
| 32 | import org.slf4j.Logger; |
| 33 | |
| 34 | import static org.slf4j.LoggerFactory.getLogger; |
| 35 | |
| 36 | /** |
| 37 | * Implementation of the JSON codec brokering service for KubevirtNode. |
| 38 | */ |
| 39 | @Component(immediate = true) |
| 40 | public 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 Li | f248307 | 2020-12-25 02:24:16 +0900 | [diff] [blame] | 51 | codecService.registerCodec(KubevirtApiConfig.class, new KubevirtApiConfigCodec()); |
Daniel Park | 5ff76b7 | 2022-09-26 22:58:53 +0900 | [diff] [blame] | 52 | codecService.registerCodec(KubernetesExternalLbInterface.class, new KubernetesExternalLbInterfaceCodec()); |
Jian Li | cc01e45 | 2020-12-21 01:44:05 +0900 | [diff] [blame] | 53 | |
| 54 | log.info("Started"); |
| 55 | } |
| 56 | |
| 57 | @Deactivate |
| 58 | protected void deactivate() { |
| 59 | codecService.unregisterCodec(KubevirtNode.class); |
| 60 | codecService.unregisterCodec(KubevirtPhyInterface.class); |
Jian Li | f248307 | 2020-12-25 02:24:16 +0900 | [diff] [blame] | 61 | codecService.unregisterCodec(KubevirtApiConfig.class); |
Daniel Park | 5ff76b7 | 2022-09-26 22:58:53 +0900 | [diff] [blame] | 62 | codecService.unregisterCodec(KubernetesExternalLbInterface.class); |
Jian Li | cc01e45 | 2020-12-21 01:44:05 +0900 | [diff] [blame] | 63 | |
| 64 | log.info("Stopped"); |
| 65 | } |
| 66 | } |