2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.core.compat;
10 import com.google.common.collect.ForwardingObject;
11 import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
12 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
13 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
14 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
15 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
16 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher;
17 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
18 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
19 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 public abstract class DOMStoreAdapter<T extends org.opendaylight.mdsal.dom.spi.store.DOMStore
23 & org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher> extends ForwardingObject
24 implements DOMStore, DOMStoreTreeChangePublisher {
26 protected abstract T delegate();
29 public DOMStoreReadTransaction newReadOnlyTransaction() {
30 return new DOMStoreReadTransactionAdapter<>(delegate().newReadOnlyTransaction());
34 public DOMStoreReadWriteTransaction newReadWriteTransaction() {
35 return new DOMStoreReadWriteTransactionAdapter(delegate().newReadWriteTransaction());
39 public DOMStoreWriteTransaction newWriteOnlyTransaction() {
40 return new DOMStoreWriteTransactionAdapter(delegate().newWriteOnlyTransaction());
44 public DOMStoreTransactionChain createTransactionChain() {
45 return new DOMStoreTransactionChainAdapter(delegate().createTransactionChain());
49 public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
50 final YangInstanceIdentifier treeId, final L listener) {
51 final ListenerRegistration<?> reg = delegate().registerTreeChangeListener(treeId, listener::onDataTreeChanged);
52 return new AbstractListenerRegistration<L>(listener) {
54 protected void removeRegistration() {