Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Jian Li | 4508352 | 2017-03-20 18:46:07 +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 | */ |
Jian Li | 2e818b0 | 2017-04-12 19:28:30 +0900 | [diff] [blame] | 16 | package org.onosproject.mapping; |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 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 | b5d8221 | 2017-04-25 01:45:18 +0900 | [diff] [blame] | 26 | import org.onosproject.mapping.codec.MappingEntryCodec; |
Jian Li | b54d14b | 2017-03-28 21:34:34 +0900 | [diff] [blame] | 27 | import org.onosproject.mapping.instructions.MappingInstruction; |
Jian Li | 2e818b0 | 2017-04-12 19:28:30 +0900 | [diff] [blame] | 28 | import org.onosproject.mapping.codec.MappingActionCodec; |
| 29 | import org.onosproject.mapping.codec.MappingAddressCodec; |
| 30 | import org.onosproject.mapping.codec.MappingInstructionCodec; |
| 31 | import org.onosproject.mapping.codec.MappingKeyCodec; |
| 32 | import org.onosproject.mapping.codec.MappingTreatmentCodec; |
| 33 | import org.onosproject.mapping.codec.MappingValueCodec; |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 34 | import org.slf4j.Logger; |
| 35 | |
| 36 | import static org.slf4j.LoggerFactory.getLogger; |
| 37 | |
| 38 | /** |
| 39 | * Implementation of the JSON codec brokering service for mapping primitives. |
| 40 | */ |
| 41 | @Component(immediate = true) |
| 42 | public class MappingCodecRegistrator { |
| 43 | |
| 44 | private final Logger log = getLogger(getClass()); |
| 45 | |
| 46 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 47 | public CodecService codecService; |
| 48 | |
| 49 | @Activate |
| 50 | public void activate() { |
| 51 | codecService.registerCodec(MappingAddress.class, new MappingAddressCodec()); |
Jian Li | b54d14b | 2017-03-28 21:34:34 +0900 | [diff] [blame] | 52 | codecService.registerCodec(MappingInstruction.class, new MappingInstructionCodec()); |
Jian Li | ee65a23 | 2017-03-29 14:15:30 +0900 | [diff] [blame] | 53 | codecService.registerCodec(MappingAction.class, new MappingActionCodec()); |
Jian Li | cb42c31 | 2017-03-30 16:20:33 +0900 | [diff] [blame] | 54 | codecService.registerCodec(MappingTreatment.class, new MappingTreatmentCodec()); |
Jian Li | 5a577a3 | 2017-04-04 12:37:53 +0900 | [diff] [blame] | 55 | codecService.registerCodec(MappingKey.class, new MappingKeyCodec()); |
Jian Li | 2d3a1d1 | 2017-04-05 00:56:54 +0900 | [diff] [blame] | 56 | codecService.registerCodec(MappingValue.class, new MappingValueCodec()); |
Jian Li | b5d8221 | 2017-04-25 01:45:18 +0900 | [diff] [blame] | 57 | codecService.registerCodec(MappingEntry.class, new MappingEntryCodec()); |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 58 | |
| 59 | log.info("Started"); |
| 60 | } |
| 61 | |
| 62 | @Deactivate |
| 63 | public void deactivate() { |
| 64 | codecService.unregisterCodec(MappingAddress.class); |
Jian Li | b54d14b | 2017-03-28 21:34:34 +0900 | [diff] [blame] | 65 | codecService.unregisterCodec(MappingInstruction.class); |
Jian Li | ee65a23 | 2017-03-29 14:15:30 +0900 | [diff] [blame] | 66 | codecService.unregisterCodec(MappingAction.class); |
Jian Li | cb42c31 | 2017-03-30 16:20:33 +0900 | [diff] [blame] | 67 | codecService.unregisterCodec(MappingTreatment.class); |
Jian Li | 5a577a3 | 2017-04-04 12:37:53 +0900 | [diff] [blame] | 68 | codecService.unregisterCodec(MappingKey.class); |
Jian Li | 2d3a1d1 | 2017-04-05 00:56:54 +0900 | [diff] [blame] | 69 | codecService.unregisterCodec(MappingValue.class); |
Jian Li | b5d8221 | 2017-04-25 01:45:18 +0900 | [diff] [blame] | 70 | codecService.unregisterCodec(MappingEntry.class); |
Jian Li | 4508352 | 2017-03-20 18:46:07 +0900 | [diff] [blame] | 71 | |
| 72 | log.info("Stopped"); |
| 73 | } |
| 74 | } |