blob: d41fd0c3d678a62788e0473dc2e94e5ed398ae9a [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 Liab053212017-04-08 01:37:04 +090026import org.onosproject.drivers.lisp.extensions.codec.LispGcAddressCodec;
Jian Lif2acb662017-04-06 02:06:16 +090027import org.onosproject.mapping.web.MappingCodecRegistrator;
28import org.slf4j.Logger;
29
30import static org.slf4j.LoggerFactory.getLogger;
31
32/**
33 * Implementation of the JSON codec brokering service for
34 * mapping extension primitives.
35 */
36@Component(immediate = true)
37public class LispMappingExtensionCodecRegistrator extends MappingCodecRegistrator {
38
39 private final Logger log = getLogger(getClass());
40 private MappingCodecRegistrator registrator;
41
42 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
43 public CodecService codecService;
44
45 @Activate
46 public void activate() {
47
48 registrator = new MappingCodecRegistrator();
49 registrator.codecService = codecService;
50 registrator.activate();
51
52 codecService.registerCodec(LispAppDataAddress.class, new LispAppDataAddressCodec());
Jian Li944e3a92017-04-07 23:53:36 +090053 codecService.registerCodec(LispAsAddress.class, new LispAsAddressCodec());
Jian Liab053212017-04-08 01:37:04 +090054 codecService.registerCodec(LispGcAddress.class, new LispGcAddressCodec());
Jian Lif2acb662017-04-06 02:06:16 +090055
56 log.info("Started");
57 }
58
59 @Deactivate
60 public void deactivate() {
61 codecService.unregisterCodec(LispAppDataAddress.class);
Jian Li944e3a92017-04-07 23:53:36 +090062 codecService.unregisterCodec(LispAsAddress.class);
Jian Liab053212017-04-08 01:37:04 +090063 codecService.unregisterCodec(LispGcAddress.class);
Jian Lif2acb662017-04-06 02:06:16 +090064
65 registrator.deactivate();
66 registrator = null;
67
68 log.info("Stopped");
69 }
70}