X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=dom%2Fmdsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fdom%2Fbroker%2FAbstractDOMForwardedCompositeTransaction.java;fp=dom%2Fmdsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fdom%2Fbroker%2FAbstractDOMForwardedCompositeTransaction.java;h=0000000000000000000000000000000000000000;hb=0396080f0391fcf78c3a707d79f03ef69ffc8ce9;hp=83d3d3cd1a7f8060fea6d88c5c6b123e865e6281;hpb=90c8c63d1fdbc54b05a5c2d55cada6787fb9bd2f;p=mdsal.git diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMForwardedCompositeTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMForwardedCompositeTransaction.java deleted file mode 100644 index 83d3d3cd1a..0000000000 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMForwardedCompositeTransaction.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.mdsal.dom.broker; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Objects.requireNonNull; - -import java.util.Collection; -import java.util.Map; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction; - -/** - * Composite DOM Transaction backed by {@link DOMStoreTransaction}. - * - *

- * Abstract base for composite transaction, which provides access only to common - * functionality as retrieval of subtransaction, close method and retrieval of - * identifier. - * - * @param Subtransaction type - */ -abstract class AbstractDOMForwardedCompositeTransaction - implements DOMDataTreeTransaction { - private final Map backingTxs; - private final Object identifier; - - /** - * Creates new composite Transactions. - * - * @param identifier - * Identifier of transaction. - * @param backingTxs - * Key,value map of backing transactions. - */ - protected AbstractDOMForwardedCompositeTransaction(final Object identifier, - final Map backingTxs) { - this.identifier = requireNonNull(identifier, "Identifier should not be null"); - this.backingTxs = requireNonNull(backingTxs, "Backing transactions should not be null"); - } - - /** - * Returns subtransaction associated with supplied key. - * - * @param key is used to retrieve subtransaction object - * @return the subtransaction object - * @throws NullPointerException - * if key is null - * @throws IllegalArgumentException - * if no subtransaction is associated with key. - */ - protected final T getSubtransaction(final LogicalDatastoreType key) { - requireNonNull(key, "key must not be null."); - - final T ret = backingTxs.get(key); - checkArgument(ret != null, "No subtransaction associated with %s", key); - return ret; - } - - /** - * Returns immutable Iterable of all subtransactions. - * - */ - protected Collection getSubtransactions() { - return backingTxs.values(); - } - - @Override - public Object getIdentifier() { - return identifier; - } - - @SuppressWarnings("checkstyle:IllegalCatch") - protected void closeSubtransactions() { - /* - * We share one exception for all failures, which are added - * as supressedExceptions to it. - */ - IllegalStateException failure = null; - for (T subtransaction : backingTxs.values()) { - try { - subtransaction.close(); - } catch (Exception e) { - // If we did not allocate failure we allocate it - if (failure == null) { - failure = new IllegalStateException("Uncaught exception occurred during closing transaction", e); - } else { - // We update it with additional exceptions, which occurred during error. - failure.addSuppressed(e); - } - } - } - // If we have failure, we throw it at after all attempts to close. - if (failure != null) { - throw failure; - } - } -}