blob: 1bd5f96dc6791aa1159cceb7f1e1a1d8771d0fee [file] [log] [blame]
Jian Li45083522017-03-20 18:46:07 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Jian Li45083522017-03-20 18:46:07 +09003 *
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 Li2e818b02017-04-12 19:28:30 +090016package org.onosproject.mapping;
Jian Li45083522017-03-20 18:46:07 +090017
18import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
21import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
23import org.onosproject.codec.CodecService;
Jian Liee65a232017-03-29 14:15:30 +090024import org.onosproject.mapping.actions.MappingAction;
Jian Li45083522017-03-20 18:46:07 +090025import org.onosproject.mapping.addresses.MappingAddress;
Jian Lib5d82212017-04-25 01:45:18 +090026import org.onosproject.mapping.codec.MappingEntryCodec;
Jian Lib54d14b2017-03-28 21:34:34 +090027import org.onosproject.mapping.instructions.MappingInstruction;
Jian Li2e818b02017-04-12 19:28:30 +090028import org.onosproject.mapping.codec.MappingActionCodec;
29import org.onosproject.mapping.codec.MappingAddressCodec;
30import org.onosproject.mapping.codec.MappingInstructionCodec;
31import org.onosproject.mapping.codec.MappingKeyCodec;
32import org.onosproject.mapping.codec.MappingTreatmentCodec;
33import org.onosproject.mapping.codec.MappingValueCodec;
Jian Li45083522017-03-20 18:46:07 +090034import org.slf4j.Logger;
35
36import static org.slf4j.LoggerFactory.getLogger;
37
38/**
39 * Implementation of the JSON codec brokering service for mapping primitives.
40 */
41@Component(immediate = true)
42public 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 Lib54d14b2017-03-28 21:34:34 +090052 codecService.registerCodec(MappingInstruction.class, new MappingInstructionCodec());
Jian Liee65a232017-03-29 14:15:30 +090053 codecService.registerCodec(MappingAction.class, new MappingActionCodec());
Jian Licb42c312017-03-30 16:20:33 +090054 codecService.registerCodec(MappingTreatment.class, new MappingTreatmentCodec());
Jian Li5a577a32017-04-04 12:37:53 +090055 codecService.registerCodec(MappingKey.class, new MappingKeyCodec());
Jian Li2d3a1d12017-04-05 00:56:54 +090056 codecService.registerCodec(MappingValue.class, new MappingValueCodec());
Jian Lib5d82212017-04-25 01:45:18 +090057 codecService.registerCodec(MappingEntry.class, new MappingEntryCodec());
Jian Li45083522017-03-20 18:46:07 +090058
59 log.info("Started");
60 }
61
62 @Deactivate
63 public void deactivate() {
64 codecService.unregisterCodec(MappingAddress.class);
Jian Lib54d14b2017-03-28 21:34:34 +090065 codecService.unregisterCodec(MappingInstruction.class);
Jian Liee65a232017-03-29 14:15:30 +090066 codecService.unregisterCodec(MappingAction.class);
Jian Licb42c312017-03-30 16:20:33 +090067 codecService.unregisterCodec(MappingTreatment.class);
Jian Li5a577a32017-04-04 12:37:53 +090068 codecService.unregisterCodec(MappingKey.class);
Jian Li2d3a1d12017-04-05 00:56:54 +090069 codecService.unregisterCodec(MappingValue.class);
Jian Lib5d82212017-04-25 01:45:18 +090070 codecService.unregisterCodec(MappingEntry.class);
Jian Li45083522017-03-20 18:46:07 +090071
72 log.info("Stopped");
73 }
74}