Create AbstractPingPongTransactionChain
[mdsal.git] / dom / mdsal-dom-spi / src / main / java / org / opendaylight / mdsal / dom / spi / PingPongTransactionChain.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.mdsal.dom.spi;
9
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import java.util.function.Function;
12 import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
13 import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 /**
18  * An implementation of {@link DOMTransactionChain}, which has a very specific behavior, which some users may find
19  * surprising. If keeps the general intent of the contract, but it makes sure there are never more than two transactions
20  * allocated at any given time: one of them is being committed, and while that is happening, the other one acts as
21  * a scratch pad. Once the committing transaction completes successfully, the scratch transaction is enqueued as soon as
22  * it is ready.
23  *
24  * <p>
25  * This mode of operation means that there is no inherent isolation between the front-end transactions and transactions
26  * cannot be reasonably cancelled.
27  *
28  * <p>
29  * It furthermore means that the transactions returned by {@link #newReadOnlyTransaction()} counts as an outstanding
30  * transaction and the user may not allocate multiple read-only transactions at the same time.
31  */
32 public final class PingPongTransactionChain extends AbstractPingPongTransactionChain {
33     @SuppressFBWarnings(value = "SLF4J_LOGGER_SHOULD_BE_PRIVATE", justification = "API stability")
34     static final Logger LOG = LoggerFactory.getLogger(PingPongTransactionChain.class);
35
36     public PingPongTransactionChain(final Function<DOMTransactionChainListener, DOMTransactionChain> delegateFactory,
37             final DOMTransactionChainListener listener) {
38         super(delegateFactory, listener);
39     }
40 }