bug 3126 - shift to new notification service
[openflowplugin.git] / drop-test-karaf / src / main / java / org / opendaylight / openflowplugin / droptestkaraf / DropTestProviderImpl.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.openflowplugin.droptestkaraf;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
14 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
15 import org.opendaylight.openflowplugin.testcommon.DropTestDsProvider;
16 import org.opendaylight.openflowplugin.testcommon.DropTestRpcProvider;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * Created by Martin Bobak <mbobak@cisco.com> on 26.4.2015.
23  */
24 public class DropTestProviderImpl implements AutoCloseable {
25
26     private static Logger LOG = LoggerFactory.getLogger(DropTestProviderImpl.class);
27
28     private static DropTestDsProvider dropDsProvider = new DropTestDsProvider();
29
30     private static DropTestRpcProvider dropRpcProvider = new DropTestRpcProvider();
31
32     public DropTestProviderImpl(final DataBroker dataBroker,
33                                 final NotificationService notificationService,
34                                 final SalFlowService salFlowService) {
35         Preconditions.checkNotNull(dataBroker, "Data broker can't be empty");
36         Preconditions.checkNotNull(notificationService, "NotificationProviderService can't be empty");
37         Preconditions.checkNotNull(salFlowService, "SalFlowService can't be empty");
38
39         LOG.debug("Activator DropAllPack INIT");
40
41         dropDsProvider.setDataService(dataBroker);
42         dropDsProvider.setNotificationService(notificationService);
43
44         dropRpcProvider.setNotificationService(notificationService);
45         dropRpcProvider.setFlowService(salFlowService);
46
47         LOG.debug("Activator DropAllPack END");
48     }
49
50     public static DropTestDsProvider getDropDsProvider() {
51         return dropDsProvider;
52     }
53
54     public static DropTestRpcProvider getDropRpcProvider() {
55         return dropRpcProvider;
56     }
57
58     @Override
59     public void close() throws Exception {
60         dropDsProvider.close();
61         dropRpcProvider.close();
62     }
63 }