blob: f9e1f3fedfa1400f973c92609d5dad5fb340015a [file] [log] [blame]
Hyunsun Moone5a1fc32016-09-02 16:01:01 -07001/*
2 * Copyright 2016-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.opencord.cordvtn.codec;
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;
Hyunsun Moonfd5a24e2016-10-19 19:15:48 -070024import org.opencord.cordvtn.api.net.ServiceNetwork;
25import org.opencord.cordvtn.api.net.ServicePort;
Hyunsun Moone5a1fc32016-09-02 16:01:01 -070026import org.slf4j.Logger;
27
28import static org.slf4j.LoggerFactory.getLogger;
29
30/**
31 * Implementation of the JSON codec brokering service for VTN.
32 */
33@Component(immediate = true)
34public class CodecRegistrator {
35 private final Logger log = getLogger(getClass());
36
37 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
38 protected CodecService codecService;
39
40 @Activate
41 public void activate() {
42 codecService.registerCodec(ServiceNetwork.class, new ServiceNetworkCodec());
43 codecService.registerCodec(ServicePort.class, new ServicePortCodec());
44 log.info("Started");
45 }
46
47 @Deactivate
48 public void deactivate() {
49 codecService.unregisterCodec(ServiceNetwork.class);
50 codecService.unregisterCodec(ServicePort.class);
51 log.info("Stopped");
52 }
53}