blob: 3fa316f173856aef9002e33fb9781e165569731b [file] [log] [blame]
Jian Lif2acb662017-04-06 02:06:16 +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.drivers.lisp.extensions;
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;
24import org.onosproject.drivers.lisp.extensions.codec.LispAppDataAddressCodec;
Jian Li944e3a92017-04-07 23:53:36 +090025import org.onosproject.drivers.lisp.extensions.codec.LispAsAddressCodec;
Jian Lif2acb662017-04-06 02:06:16 +090026import org.onosproject.mapping.web.MappingCodecRegistrator;
27import org.slf4j.Logger;
28
29import static org.slf4j.LoggerFactory.getLogger;
30
31/**
32 * Implementation of the JSON codec brokering service for
33 * mapping extension primitives.
34 */
35@Component(immediate = true)
36public class LispMappingExtensionCodecRegistrator extends MappingCodecRegistrator {
37
38 private final Logger log = getLogger(getClass());
39 private MappingCodecRegistrator registrator;
40
41 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
42 public CodecService codecService;
43
44 @Activate
45 public void activate() {
46
47 registrator = new MappingCodecRegistrator();
48 registrator.codecService = codecService;
49 registrator.activate();
50
51 codecService.registerCodec(LispAppDataAddress.class, new LispAppDataAddressCodec());
Jian Li944e3a92017-04-07 23:53:36 +090052 codecService.registerCodec(LispAsAddress.class, new LispAsAddressCodec());
Jian Lif2acb662017-04-06 02:06:16 +090053
54 log.info("Started");
55 }
56
57 @Deactivate
58 public void deactivate() {
59 codecService.unregisterCodec(LispAppDataAddress.class);
Jian Li944e3a92017-04-07 23:53:36 +090060 codecService.unregisterCodec(LispAsAddress.class);
Jian Lif2acb662017-04-06 02:06:16 +090061
62 registrator.deactivate();
63 registrator = null;
64
65 log.info("Stopped");
66 }
67}