blob: 9002237b249c456ba473b7902bb25fa782810be1 [file] [log] [blame]
Jian Li23c8be22018-02-13 11:34:15 +09001/*
2 * Copyright 2018-present Open Networking Foundation
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.openstacknode.web;
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;
Jian Li789fadb2018-07-10 13:59:47 +090024import org.onosproject.net.behaviour.ControllerInfo;
Jian Li27841662018-04-14 01:59:47 +090025import org.onosproject.openstacknode.api.OpenstackAuth;
Jian Li23c8be22018-02-13 11:34:15 +090026import org.onosproject.openstacknode.api.OpenstackNode;
Jian Lie6312162018-03-21 21:41:00 +090027import org.onosproject.openstacknode.api.OpenstackPhyInterface;
Jian Li27841662018-04-14 01:59:47 +090028import org.onosproject.openstacknode.codec.OpenstackAuthCodec;
Jian Li789fadb2018-07-10 13:59:47 +090029import org.onosproject.openstacknode.codec.OpenstackControllerCodec;
Jian Li23c8be22018-02-13 11:34:15 +090030import org.onosproject.openstacknode.codec.OpenstackNodeCodec;
Jian Lie6312162018-03-21 21:41:00 +090031import org.onosproject.openstacknode.codec.OpenstackPhyInterfaceCodec;
Jian Li23c8be22018-02-13 11:34:15 +090032
33import static org.slf4j.LoggerFactory.getLogger;
34
35/**
36 * Implementation of the JSON codec brokering service for OpenstackNode.
37 */
38@Component(immediate = true)
39public class OpenstackNodeCodecRegister {
40
41 private final org.slf4j.Logger log = getLogger(getClass());
42
43 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
44 protected CodecService codecService;
45
46 @Activate
Jian Li5afbea42018-02-28 10:37:03 +090047 protected void activate() {
Jian Li23c8be22018-02-13 11:34:15 +090048 codecService.registerCodec(OpenstackNode.class, new OpenstackNodeCodec());
Jian Li27841662018-04-14 01:59:47 +090049 codecService.registerCodec(OpenstackAuth.class, new OpenstackAuthCodec());
Jian Lie6312162018-03-21 21:41:00 +090050 codecService.registerCodec(OpenstackPhyInterface.class, new OpenstackPhyInterfaceCodec());
Jian Li789fadb2018-07-10 13:59:47 +090051 codecService.registerCodec(ControllerInfo.class, new OpenstackControllerCodec());
Jian Li23c8be22018-02-13 11:34:15 +090052
53 log.info("Started");
54 }
55
56 @Deactivate
Jian Li5afbea42018-02-28 10:37:03 +090057 protected void deactivate() {
Jian Li23c8be22018-02-13 11:34:15 +090058 codecService.unregisterCodec(OpenstackNode.class);
Jian Li27841662018-04-14 01:59:47 +090059 codecService.unregisterCodec(OpenstackAuth.class);
Jian Lie6312162018-03-21 21:41:00 +090060 codecService.unregisterCodec(OpenstackPhyInterface.class);
Jian Li789fadb2018-07-10 13:59:47 +090061 codecService.unregisterCodec(ControllerInfo.class);
Jian Li23c8be22018-02-13 11:34:15 +090062
63 log.info("Stopped");
64 }
65}