2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.openflowplugin.learningswitch;
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;
17 public class FlowCommitWrapperImpl implements FlowCommitWrapper {
19 private final DataBroker dataBrokerService;
21 public FlowCommitWrapperImpl(DataBroker dataBrokerService) {
22 this.dataBrokerService = dataBrokerService;
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();