Update MRI projects for Aluminium
[openflowplugin.git] / samples / learning-switch / src / main / java / org / opendaylight / openflowplugin / learningswitch / FlowCommitWrapperImpl.java
1 /*
2  * Copyright (c) 2014 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.learningswitch;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16
17 public class FlowCommitWrapperImpl implements FlowCommitWrapper {
18
19     private final DataBroker dataBrokerService;
20
21     public FlowCommitWrapperImpl(DataBroker dataBrokerService) {
22         this.dataBrokerService = dataBrokerService;
23     }
24
25     @Override
26     public ListenableFuture<?> writeFlowToConfig(InstanceIdentifier<Flow> flowPath, Flow flowBody) {
27         ReadWriteTransaction addFlowTransaction = dataBrokerService.newReadWriteTransaction();
28         addFlowTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowPath, flowBody);
29         return addFlowTransaction.commit();
30     }
31
32 }