283f9c15d52bcc1f16e00bb0411bc456b2987872
[openflowplugin.git] / drop-test / src / main / java / org / opendaylight / openflowplugin / droptest / DropTestRpcProvider.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.droptest;
9
10 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
12 import org.opendaylight.yangtools.concepts.Registration;
13 import org.opendaylight.yangtools.yang.binding.NotificationListener;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 @SuppressWarnings("all")
18 public class DropTestRpcProvider implements AutoCloseable {
19     private final static Logger LOG = LoggerFactory.getLogger(DropTestProvider.class);
20
21     private SalFlowService _flowService;
22     private NotificationProviderService _notificationService;
23     private DropTestRpcSender commiter;
24     private Registration<NotificationListener> listenerRegistration;
25
26     public SalFlowService getFlowService() {
27         return this._flowService;
28     }
29
30     public void setFlowService(final SalFlowService flowService) {
31         this._flowService = flowService;
32     }
33
34     public NotificationProviderService getNotificationService() {
35         return this._notificationService;
36     }
37
38     public void setNotificationService(final NotificationProviderService notificationService) {
39         this._notificationService = notificationService;
40     }
41
42     public void start() {
43         this.commiter = new DropTestRpcSender(this, this.getFlowService());;
44         this.listenerRegistration = this.getNotificationService().registerNotificationListener(this.commiter);
45         LOG.debug("DropTestProvider Started.");
46     }
47
48     public void close() {
49         try {
50             LOG.debug("DropTestProvider stopped.");
51             if (this.listenerRegistration != null) {
52                 this.listenerRegistration.close();
53             }
54         } catch (Exception _e) {
55             throw new Error(_e);
56         }
57     }
58 }