Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 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.mapping.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; |
Jian Li | ee65a23 | 2017-03-29 14:15:30 +0900 | [diff] [blame^] | 24 | import org.onosproject.mapping.actions.MappingAction; |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 25 | import org.onosproject.mapping.addresses.MappingAddress; |
Jian Li | b54d14b | 2017-03-28 21:34:34 +0900 | [diff] [blame] | 26 | import org.onosproject.mapping.instructions.MappingInstruction; |
Jian Li | ee65a23 | 2017-03-29 14:15:30 +0900 | [diff] [blame^] | 27 | import org.onosproject.mapping.web.codec.MappingActionCodec; |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 28 | import org.onosproject.mapping.web.codec.MappingAddressCodec; |
Jian Li | b54d14b | 2017-03-28 21:34:34 +0900 | [diff] [blame] | 29 | import org.onosproject.mapping.web.codec.MappingInstructionCodec; |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 30 | import org.slf4j.Logger; |
| 31 | |
| 32 | import static org.slf4j.LoggerFactory.getLogger; |
| 33 | |
| 34 | /** |
| 35 | * Implementation of the JSON codec brokering service for mapping primitives. |
| 36 | */ |
| 37 | @Component(immediate = true) |
| 38 | public class MappingCodecRegistrator { |
| 39 | |
| 40 | private final Logger log = getLogger(getClass()); |
| 41 | |
| 42 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 43 | public CodecService codecService; |
| 44 | |
| 45 | @Activate |
| 46 | public void activate() { |
| 47 | codecService.registerCodec(MappingAddress.class, new MappingAddressCodec()); |
Jian Li | b54d14b | 2017-03-28 21:34:34 +0900 | [diff] [blame] | 48 | codecService.registerCodec(MappingInstruction.class, new MappingInstructionCodec()); |
Jian Li | ee65a23 | 2017-03-29 14:15:30 +0900 | [diff] [blame^] | 49 | codecService.registerCodec(MappingAction.class, new MappingActionCodec()); |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 50 | |
| 51 | log.info("Started"); |
| 52 | } |
| 53 | |
| 54 | @Deactivate |
| 55 | public void deactivate() { |
| 56 | codecService.unregisterCodec(MappingAddress.class); |
Jian Li | b54d14b | 2017-03-28 21:34:34 +0900 | [diff] [blame] | 57 | codecService.unregisterCodec(MappingInstruction.class); |
Jian Li | ee65a23 | 2017-03-29 14:15:30 +0900 | [diff] [blame^] | 58 | codecService.unregisterCodec(MappingAction.class); |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 59 | |
| 60 | log.info("Stopped"); |
| 61 | } |
| 62 | } |