blob: 420e87a5bf3ec0089811c2b21d9baf109ebf0075 [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;
24import org.onosproject.openstacknode.api.OpenstackNode;
Jian Lie6312162018-03-21 21:41:00 +090025import org.onosproject.openstacknode.api.OpenstackPhyInterface;
Jian Li23c8be22018-02-13 11:34:15 +090026import org.onosproject.openstacknode.codec.OpenstackNodeCodec;
Jian Lie6312162018-03-21 21:41:00 +090027import org.onosproject.openstacknode.codec.OpenstackPhyInterfaceCodec;
Jian Li23c8be22018-02-13 11:34:15 +090028
29import static org.slf4j.LoggerFactory.getLogger;
30
31/**
32 * Implementation of the JSON codec brokering service for OpenstackNode.
33 */
34@Component(immediate = true)
35public class OpenstackNodeCodecRegister {
36
37 private final org.slf4j.Logger log = getLogger(getClass());
38
39 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
40 protected CodecService codecService;
41
42 @Activate
Jian Li5afbea42018-02-28 10:37:03 +090043 protected void activate() {
Jian Li23c8be22018-02-13 11:34:15 +090044 codecService.registerCodec(OpenstackNode.class, new OpenstackNodeCodec());
Jian Lie6312162018-03-21 21:41:00 +090045 codecService.registerCodec(OpenstackPhyInterface.class, new OpenstackPhyInterfaceCodec());
Jian Li23c8be22018-02-13 11:34:15 +090046
47 log.info("Started");
48 }
49
50 @Deactivate
Jian Li5afbea42018-02-28 10:37:03 +090051 protected void deactivate() {
Jian Li23c8be22018-02-13 11:34:15 +090052 codecService.unregisterCodec(OpenstackNode.class);
Jian Lie6312162018-03-21 21:41:00 +090053 codecService.unregisterCodec(OpenstackPhyInterface.class);
Jian Li23c8be22018-02-13 11:34:15 +090054
55 log.info("Stopped");
56 }
57}