blob: d4d91d2bdfea6636b7195dba5e9bae884184fb30 [file] [log] [blame]
Jian Li45083522017-03-20 18:46:07 +09001/*
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 */
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 Lib54d14b2017-03-28 21:34:34 +090026import org.onosproject.mapping.instructions.MappingInstruction;
Jian Li2e818b02017-04-12 19:28:30 +090027import org.onosproject.mapping.codec.MappingActionCodec;
28import org.onosproject.mapping.codec.MappingAddressCodec;
29import org.onosproject.mapping.codec.MappingInstructionCodec;
30import org.onosproject.mapping.codec.MappingKeyCodec;
31import org.onosproject.mapping.codec.MappingTreatmentCodec;
32import org.onosproject.mapping.codec.MappingValueCodec;
Jian Li45083522017-03-20 18:46:07 +090033import org.slf4j.Logger;
34
35import static org.slf4j.LoggerFactory.getLogger;
36
37/**
38 * Implementation of the JSON codec brokering service for mapping primitives.
39 */
40@Component(immediate = true)
41public class MappingCodecRegistrator {
42
43 private final Logger log = getLogger(getClass());
44
45 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
46 public CodecService codecService;
47
48 @Activate
49 public void activate() {
50 codecService.registerCodec(MappingAddress.class, new MappingAddressCodec());
Jian Lib54d14b2017-03-28 21:34:34 +090051 codecService.registerCodec(MappingInstruction.class, new MappingInstructionCodec());
Jian Liee65a232017-03-29 14:15:30 +090052 codecService.registerCodec(MappingAction.class, new MappingActionCodec());
Jian Licb42c312017-03-30 16:20:33 +090053 codecService.registerCodec(MappingTreatment.class, new MappingTreatmentCodec());
Jian Li5a577a32017-04-04 12:37:53 +090054 codecService.registerCodec(MappingKey.class, new MappingKeyCodec());
Jian Li2d3a1d12017-04-05 00:56:54 +090055 codecService.registerCodec(MappingValue.class, new MappingValueCodec());
Jian Li45083522017-03-20 18:46:07 +090056
57 log.info("Started");
58 }
59
60 @Deactivate
61 public void deactivate() {
62 codecService.unregisterCodec(MappingAddress.class);
Jian Lib54d14b2017-03-28 21:34:34 +090063 codecService.unregisterCodec(MappingInstruction.class);
Jian Liee65a232017-03-29 14:15:30 +090064 codecService.unregisterCodec(MappingAction.class);
Jian Licb42c312017-03-30 16:20:33 +090065 codecService.unregisterCodec(MappingTreatment.class);
Jian Li5a577a32017-04-04 12:37:53 +090066 codecService.unregisterCodec(MappingKey.class);
Jian Li2d3a1d12017-04-05 00:56:54 +090067 codecService.unregisterCodec(MappingValue.class);
Jian Li45083522017-03-20 18:46:07 +090068
69 log.info("Stopped");
70 }
71}