blob: 7ddc3f07b766d4e8a8c44ff01253f1bdf195b539 [file] [log] [blame]
Yi Tseng890dc3f2018-11-01 13:23:11 -07001/*
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 protocols.gnmi.ctl.java.org.onosproject.gnmi.ctl;
17
18import io.grpc.ManagedChannel;
19import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Service;
23import org.onosproject.gnmi.api.GnmiEvent;
24import org.onosproject.gnmi.api.GnmiEventListener;
25import org.onosproject.grpc.ctl.AbstractGrpcClientController;
26import org.onosproject.gnmi.api.GnmiClient;
27import org.onosproject.gnmi.api.GnmiClientKey;
28import org.onosproject.gnmi.api.GnmiController;
29import org.slf4j.Logger;
30
31import static org.slf4j.LoggerFactory.getLogger;
32
33/**
34 * Implementation of gNMI controller.
35 */
36@Component(immediate = true)
37@Service
38public class GnmiControllerImpl
39 extends AbstractGrpcClientController<GnmiClientKey, GnmiClient, GnmiEvent, GnmiEventListener>
40 implements GnmiController {
41 private final Logger log = getLogger(getClass());
42
43 @Activate
44 public void activate() {
45 super.activate();
46 log.info("Started");
47 }
48
49 @Deactivate
50 public void deactivate() {
51 super.deactivate();
52 log.info("Stopped");
53 }
54
55 @Override
56 protected GnmiClient createClientInstance(GnmiClientKey clientKey, ManagedChannel channel) {
57 return new GnmiClientImpl(clientKey, channel);
58 }
59}