Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 16 | package protocols.gnmi.ctl.java.org.onosproject.gnmi.ctl; |
| 17 | |
| 18 | import io.grpc.ManagedChannel; |
| 19 | import org.apache.felix.scr.annotations.Activate; |
| 20 | import org.apache.felix.scr.annotations.Component; |
| 21 | import org.apache.felix.scr.annotations.Deactivate; |
| 22 | import org.apache.felix.scr.annotations.Service; |
| 23 | import org.onosproject.gnmi.api.GnmiEvent; |
| 24 | import org.onosproject.gnmi.api.GnmiEventListener; |
| 25 | import org.onosproject.grpc.ctl.AbstractGrpcClientController; |
| 26 | import org.onosproject.gnmi.api.GnmiClient; |
| 27 | import org.onosproject.gnmi.api.GnmiClientKey; |
| 28 | import org.onosproject.gnmi.api.GnmiController; |
| 29 | import org.slf4j.Logger; |
| 30 | |
| 31 | import static org.slf4j.LoggerFactory.getLogger; |
| 32 | |
| 33 | /** |
| 34 | * Implementation of gNMI controller. |
| 35 | */ |
| 36 | @Component(immediate = true) |
| 37 | @Service |
| 38 | public 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 | } |