blob: 961f4b118802dfa5a9af472c54148f4072d62dfb [file] [log] [blame]
Jian Li80c12702016-02-20 08:58:19 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Jian Li80c12702016-02-20 08:58:19 +09003 *
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.cpman.rest;
17
Ray Milkeyd84f89b2018-08-17 14:54:17 -070018import org.osgi.service.component.annotations.Activate;
19import org.osgi.service.component.annotations.Component;
20import org.osgi.service.component.annotations.Deactivate;
21import org.osgi.service.component.annotations.Reference;
22import org.osgi.service.component.annotations.ReferenceCardinality;
Jian Li80c12702016-02-20 08:58:19 +090023import org.onosproject.codec.CodecService;
Jian Li67e1e152016-04-18 17:52:58 -070024import org.onosproject.cpman.ControlLoadSnapshot;
25import org.onosproject.cpman.codec.ControlLoadSnapshotCodec;
Jian Li80c12702016-02-20 08:58:19 +090026import org.slf4j.Logger;
27
28import static org.slf4j.LoggerFactory.getLogger;
29
30/**
31 * Implementation of the JSON codec brokering service for CPMan app.
32 */
33@Component(immediate = true)
34public class CPManCodecRegistrator {
35
36 private final Logger log = getLogger(getClass());
37
Ray Milkeyd84f89b2018-08-17 14:54:17 -070038 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Jian Li80c12702016-02-20 08:58:19 +090039 protected CodecService codecService;
40
41 @Activate
42 public void activate() {
Jian Li67e1e152016-04-18 17:52:58 -070043 codecService.registerCodec(ControlLoadSnapshot.class, new ControlLoadSnapshotCodec());
Jian Li80c12702016-02-20 08:58:19 +090044
45 log.info("Started");
46 }
47
48 @Deactivate
49 public void deactivate() {
Jian Li67e1e152016-04-18 17:52:58 -070050 codecService.unregisterCodec(ControlLoadSnapshot.class);
Jian Lib6df66b2016-04-13 11:25:13 -070051
Jian Li80c12702016-02-20 08:58:19 +090052 log.info("Stopped");
53 }
54}