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.controller.sal.compatibility.topology
10 import java.util.Collections
12 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction
13 import org.opendaylight.controller.md.sal.common.api.data.DataModification
14 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
15 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
16 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate
17 import org.opendaylight.yangtools.yang.binding.DataObject
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
19 import org.opendaylight.yangtools.yang.common.RpcResult
20 import org.slf4j.LoggerFactory
22 class TopologyTransaction implements DataCommitTransaction<InstanceIdentifier<?extends DataObject>, DataObject> {
23 static val LOG = LoggerFactory.getLogger(TopologyTransaction);
25 val DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
28 IPluginOutTopologyService topologyPublisher;
31 DataProviderService dataService;
33 List<TopoEdgeUpdate> edgeUpdates;
35 new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,IPluginOutTopologyService topologyPublisher,
36 DataProviderService dataService,List<TopoEdgeUpdate> edgeUpdates) {
37 _modification = modification;
38 _topologyPublisher = topologyPublisher
39 _dataService = dataService
40 _edgeUpdates = edgeUpdates
42 override finish() throws IllegalStateException {
44 if(topologyPublisher != null && _edgeUpdates != null && !edgeUpdates.empty) {
45 topologyPublisher.edgeUpdate(edgeUpdates)
48 return new RpcResultTo()
51 override getModification() {
55 override rollback() throws IllegalStateException {
59 class RpcResultTo implements RpcResult<Void> {
61 override getErrors() {
62 return Collections.emptySet
65 override getResult() {
69 override isSuccessful() {