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