blob: 99f39881e9027870842b3fa0b6aa0b3b401d4a9b [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 Lid1445012017-04-09 02:12:07 +090027import org.onosproject.drivers.lisp.extensions.codec.LispListAddressCodec;
28import org.onosproject.drivers.lisp.extensions.codec.LispMulticastAddressCodec;
Jian Lif2acb662017-04-06 02:06:16 +090029import org.onosproject.mapping.web.MappingCodecRegistrator;
30import org.slf4j.Logger;
31
32import static org.slf4j.LoggerFactory.getLogger;
33
34/**
35 * Implementation of the JSON codec brokering service for
36 * mapping extension primitives.
37 */
38@Component(immediate = true)
39public class LispMappingExtensionCodecRegistrator extends MappingCodecRegistrator {
40
41 private final Logger log = getLogger(getClass());
42 private MappingCodecRegistrator registrator;
43
44 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
45 public CodecService codecService;
46
47 @Activate
48 public void activate() {
49
50 registrator = new MappingCodecRegistrator();
51 registrator.codecService = codecService;
52 registrator.activate();
53
54 codecService.registerCodec(LispAppDataAddress.class, new LispAppDataAddressCodec());
Jian Li944e3a92017-04-07 23:53:36 +090055 codecService.registerCodec(LispAsAddress.class, new LispAsAddressCodec());
Jian Liab053212017-04-08 01:37:04 +090056 codecService.registerCodec(LispGcAddress.class, new LispGcAddressCodec());
Jian Lid1445012017-04-09 02:12:07 +090057 codecService.registerCodec(LispListAddress.class, new LispListAddressCodec());
58 codecService.registerCodec(LispMulticastAddress.class, new LispMulticastAddressCodec());
Jian Lif2acb662017-04-06 02:06:16 +090059
60 log.info("Started");
61 }
62
63 @Deactivate
64 public void deactivate() {
65 codecService.unregisterCodec(LispAppDataAddress.class);
Jian Li944e3a92017-04-07 23:53:36 +090066 codecService.unregisterCodec(LispAsAddress.class);
Jian Liab053212017-04-08 01:37:04 +090067 codecService.unregisterCodec(LispGcAddress.class);
Jian Lid1445012017-04-09 02:12:07 +090068 codecService.unregisterCodec(LispListAddress.class);
69 codecService.unregisterCodec(LispMulticastAddress.class);
Jian Lif2acb662017-04-06 02:06:16 +090070
71 registrator.deactivate();
72 registrator = null;
73
74 log.info("Stopped");
75 }
76}