blob: 9354cd8d4e4c846d472e0e828d913870081ff582 [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 */
16package org.onosproject.mapping.web;
17
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 Liee65a232017-03-29 14:15:30 +090027import org.onosproject.mapping.web.codec.MappingActionCodec;
Jian Li45083522017-03-20 18:46:07 +090028import org.onosproject.mapping.web.codec.MappingAddressCodec;
Jian Lib54d14b2017-03-28 21:34:34 +090029import org.onosproject.mapping.web.codec.MappingInstructionCodec;
Jian Li45083522017-03-20 18:46:07 +090030import org.slf4j.Logger;
31
32import static org.slf4j.LoggerFactory.getLogger;
33
34/**
35 * Implementation of the JSON codec brokering service for mapping primitives.
36 */
37@Component(immediate = true)
38public 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 Lib54d14b2017-03-28 21:34:34 +090048 codecService.registerCodec(MappingInstruction.class, new MappingInstructionCodec());
Jian Liee65a232017-03-29 14:15:30 +090049 codecService.registerCodec(MappingAction.class, new MappingActionCodec());
Jian Li45083522017-03-20 18:46:07 +090050
51 log.info("Started");
52 }
53
54 @Deactivate
55 public void deactivate() {
56 codecService.unregisterCodec(MappingAddress.class);
Jian Lib54d14b2017-03-28 21:34:34 +090057 codecService.unregisterCodec(MappingInstruction.class);
Jian Liee65a232017-03-29 14:15:30 +090058 codecService.unregisterCodec(MappingAction.class);
Jian Li45083522017-03-20 18:46:07 +090059
60 log.info("Stopped");
61 }
62}