Jian Li | 2c63bd2 | 2018-07-15 23:35:34 +0900 | [diff] [blame] | 1 | /* |
Jian Li | 086ad70 | 2018-07-30 10:50:02 +0900 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Jian Li | 2c63bd2 | 2018-07-15 23:35:34 +0900 | [diff] [blame] | 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.openstacknetworking.web; |
| 17 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 18 | import org.osgi.service.component.annotations.Activate; |
| 19 | import org.osgi.service.component.annotations.Component; |
| 20 | import org.osgi.service.component.annotations.Deactivate; |
| 21 | import org.osgi.service.component.annotations.Reference; |
| 22 | import org.osgi.service.component.annotations.ReferenceCardinality; |
Jian Li | 2c63bd2 | 2018-07-15 23:35:34 +0900 | [diff] [blame] | 23 | import org.onosproject.codec.CodecService; |
| 24 | import org.onosproject.openstacknetworking.api.InstancePort; |
| 25 | import org.onosproject.openstacknetworking.codec.InstancePortCodec; |
| 26 | import org.slf4j.Logger; |
| 27 | |
| 28 | import static org.slf4j.LoggerFactory.getLogger; |
| 29 | |
| 30 | /** |
| 31 | * Implementation of the JSON codec brokering service for OpenstackNetworking. |
| 32 | */ |
| 33 | @Component(immediate = true) |
| 34 | public class OpenstackNetworkingCodecRegister { |
| 35 | |
| 36 | private final Logger log = getLogger(getClass()); |
| 37 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 38 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Jian Li | 2c63bd2 | 2018-07-15 23:35:34 +0900 | [diff] [blame] | 39 | protected CodecService codecService; |
| 40 | |
| 41 | @Activate |
| 42 | protected void activate() { |
| 43 | |
| 44 | codecService.registerCodec(InstancePort.class, new InstancePortCodec()); |
| 45 | |
| 46 | log.info("Started"); |
| 47 | |
| 48 | } |
| 49 | |
| 50 | @Deactivate |
| 51 | protected void deactivate() { |
| 52 | |
| 53 | codecService.unregisterCodec(InstancePort.class); |
| 54 | |
| 55 | log.info("Stopped"); |
| 56 | } |
| 57 | } |