Jian Li | 23c8be2 | 2018-02-13 11:34:15 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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.openstacknode.web; |
| 17 | |
| 18 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; |
| 21 | import org.apache.felix.scr.annotations.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 23 | import org.onosproject.codec.CodecService; |
| 24 | import org.onosproject.openstacknode.api.OpenstackNode; |
Jian Li | e631216 | 2018-03-21 21:41:00 +0900 | [diff] [blame] | 25 | import org.onosproject.openstacknode.api.OpenstackPhyInterface; |
Jian Li | 23c8be2 | 2018-02-13 11:34:15 +0900 | [diff] [blame] | 26 | import org.onosproject.openstacknode.codec.OpenstackNodeCodec; |
Jian Li | e631216 | 2018-03-21 21:41:00 +0900 | [diff] [blame] | 27 | import org.onosproject.openstacknode.codec.OpenstackPhyInterfaceCodec; |
Jian Li | 23c8be2 | 2018-02-13 11:34:15 +0900 | [diff] [blame] | 28 | |
| 29 | import static org.slf4j.LoggerFactory.getLogger; |
| 30 | |
| 31 | /** |
| 32 | * Implementation of the JSON codec brokering service for OpenstackNode. |
| 33 | */ |
| 34 | @Component(immediate = true) |
| 35 | public class OpenstackNodeCodecRegister { |
| 36 | |
| 37 | private final org.slf4j.Logger log = getLogger(getClass()); |
| 38 | |
| 39 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 40 | protected CodecService codecService; |
| 41 | |
| 42 | @Activate |
Jian Li | 5afbea4 | 2018-02-28 10:37:03 +0900 | [diff] [blame] | 43 | protected void activate() { |
Jian Li | 23c8be2 | 2018-02-13 11:34:15 +0900 | [diff] [blame] | 44 | codecService.registerCodec(OpenstackNode.class, new OpenstackNodeCodec()); |
Jian Li | e631216 | 2018-03-21 21:41:00 +0900 | [diff] [blame] | 45 | codecService.registerCodec(OpenstackPhyInterface.class, new OpenstackPhyInterfaceCodec()); |
Jian Li | 23c8be2 | 2018-02-13 11:34:15 +0900 | [diff] [blame] | 46 | |
| 47 | log.info("Started"); |
| 48 | } |
| 49 | |
| 50 | @Deactivate |
Jian Li | 5afbea4 | 2018-02-28 10:37:03 +0900 | [diff] [blame] | 51 | protected void deactivate() { |
Jian Li | 23c8be2 | 2018-02-13 11:34:15 +0900 | [diff] [blame] | 52 | codecService.unregisterCodec(OpenstackNode.class); |
Jian Li | e631216 | 2018-03-21 21:41:00 +0900 | [diff] [blame] | 53 | codecService.unregisterCodec(OpenstackPhyInterface.class); |
Jian Li | 23c8be2 | 2018-02-13 11:34:15 +0900 | [diff] [blame] | 54 | |
| 55 | log.info("Stopped"); |
| 56 | } |
| 57 | } |