blob: 8392c4a0be044f9cc18734e65bee0f8f1e46b50e [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;
Yi Tseng890dc3f2018-11-01 13:23:11 -070019import org.onosproject.gnmi.api.GnmiClient;
20import org.onosproject.gnmi.api.GnmiClientKey;
21import org.onosproject.gnmi.api.GnmiController;
Ray Milkey5739b2c2018-11-06 14:04:51 -080022import org.onosproject.gnmi.api.GnmiEvent;
23import org.onosproject.gnmi.api.GnmiEventListener;
24import org.onosproject.grpc.ctl.AbstractGrpcClientController;
25import org.osgi.service.component.annotations.Activate;
26import org.osgi.service.component.annotations.Component;
27import org.osgi.service.component.annotations.Deactivate;
Yi Tseng890dc3f2018-11-01 13:23:11 -070028import org.slf4j.Logger;
29
30import static org.slf4j.LoggerFactory.getLogger;
31
32/**
33 * Implementation of gNMI controller.
34 */
Ray Milkey5739b2c2018-11-06 14:04:51 -080035@Component(immediate = true, service = GnmiController.class)
Yi Tseng890dc3f2018-11-01 13:23:11 -070036public class GnmiControllerImpl
37 extends AbstractGrpcClientController<GnmiClientKey, GnmiClient, GnmiEvent, GnmiEventListener>
38 implements GnmiController {
39 private final Logger log = getLogger(getClass());
40
41 @Activate
42 public void activate() {
43 super.activate();
44 log.info("Started");
45 }
46
47 @Deactivate
48 public void deactivate() {
49 super.deactivate();
50 log.info("Stopped");
51 }
52
53 @Override
54 protected GnmiClient createClientInstance(GnmiClientKey clientKey, ManagedChannel channel) {
55 return new GnmiClientImpl(clientKey, channel);
56 }
57}