Jian Li | 49109b5 | 2019-01-22 00:17:28 +0900 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.k8snode.web; |
| 17 | |
| 18 | import org.onosproject.codec.CodecService; |
Jian Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 19 | import org.onosproject.k8snode.api.HostNodesInfo; |
Jian Li | 3defa84 | 2019-02-12 00:31:35 +0900 | [diff] [blame] | 20 | import org.onosproject.k8snode.api.K8sApiConfig; |
Jian Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 21 | import org.onosproject.k8snode.api.K8sHost; |
Jian Li | 49109b5 | 2019-01-22 00:17:28 +0900 | [diff] [blame] | 22 | import org.onosproject.k8snode.api.K8sNode; |
Jian Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 23 | import org.onosproject.k8snode.codec.HostNodesInfoCodec; |
Jian Li | 3defa84 | 2019-02-12 00:31:35 +0900 | [diff] [blame] | 24 | import org.onosproject.k8snode.codec.K8sApiConfigCodec; |
Jian Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 25 | import org.onosproject.k8snode.codec.K8sHostCodec; |
Jian Li | 49109b5 | 2019-01-22 00:17:28 +0900 | [diff] [blame] | 26 | import org.onosproject.k8snode.codec.K8sNodeCodec; |
| 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 K8sNode. |
| 38 | */ |
| 39 | @Component(immediate = true) |
| 40 | public class K8sNodeCodecRegister { |
| 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 | |
| 50 | codecService.registerCodec(K8sNode.class, new K8sNodeCodec()); |
Jian Li | 3defa84 | 2019-02-12 00:31:35 +0900 | [diff] [blame] | 51 | codecService.registerCodec(K8sApiConfig.class, new K8sApiConfigCodec()); |
Jian Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 52 | codecService.registerCodec(HostNodesInfo.class, new HostNodesInfoCodec()); |
| 53 | codecService.registerCodec(K8sHost.class, new K8sHostCodec()); |
Jian Li | 49109b5 | 2019-01-22 00:17:28 +0900 | [diff] [blame] | 54 | |
| 55 | log.info("Started"); |
| 56 | } |
| 57 | |
| 58 | @Deactivate |
| 59 | protected void deactivate() { |
| 60 | |
| 61 | codecService.unregisterCodec(K8sNode.class); |
Jian Li | 3defa84 | 2019-02-12 00:31:35 +0900 | [diff] [blame] | 62 | codecService.unregisterCodec(K8sApiConfig.class); |
Jian Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 63 | codecService.unregisterCodec(HostNodesInfo.class); |
| 64 | codecService.unregisterCodec(K8sHost.class); |
Jian Li | 49109b5 | 2019-01-22 00:17:28 +0900 | [diff] [blame] | 65 | |
| 66 | log.info("Stopped"); |
| 67 | } |
| 68 | } |