Class BindingDOMDataBrokerAdapter
- java.lang.Object
-
- org.opendaylight.mdsal.binding.dom.adapter.BindingDOMDataBrokerAdapter
-
- All Implemented Interfaces:
BindingService
,DataBroker
,DataTreeChangeService
,TransactionFactory
,Delegator<DOMDataBroker>
public class BindingDOMDataBrokerAdapter extends Object implements DataBroker, DataTreeChangeService
The DataBrokerImpl simply defers to the DOMDataBroker for all its operations. All transactions and listener registrations are wrapped by the DataBrokerImpl to allow binding aware components to use the DataBroker transparently.Besides this the DataBrokerImpl and it's collaborators also cache data that is already transformed from the binding independent to binding aware format.
-
-
Constructor Summary
Constructors Constructor Description BindingDOMDataBrokerAdapter(AdapterContext adapterContext, DOMDataBroker domDataBroker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AdapterContext
adapterContext()
TransactionChain
createMergingTransactionChain(TransactionChainListener listener)
Create a new transaction chain.TransactionChain
createTransactionChain(TransactionChainListener listener)
Create a new transaction chain.protected CurrentAdapterSerializer
currentSerializer()
T
getDelegate()
ReadTransaction
newReadOnlyTransaction()
Allocates a new read-only transaction which provides an immutable snapshot of the data tree.ReadWriteTransaction
newReadWriteTransaction()
Allocates new read-write transaction which provides a mutable view of the data tree.WriteTransaction
newWriteOnlyTransaction()
Allocates new write-only transaction based on latest state of data tree.<T extends DataObject,L extends DataTreeChangeListener<T>>
ListenerRegistration<L>registerDataTreeChangeListener(DataTreeIdentifier<T> treeId, L listener)
Registers aDataTreeChangeListener
to receive notifications when data changes under a given path in the conceptual data tree.
-
-
-
Constructor Detail
-
BindingDOMDataBrokerAdapter
public BindingDOMDataBrokerAdapter(AdapterContext adapterContext, DOMDataBroker domDataBroker)
-
-
Method Detail
-
newReadOnlyTransaction
public ReadTransaction newReadOnlyTransaction()
Description copied from interface:TransactionFactory
Allocates a new read-only transaction which provides an immutable snapshot of the data tree. The view of data tree is an immutable snapshot of current data tree state when transaction was allocated.- Specified by:
newReadOnlyTransaction
in interfaceTransactionFactory
- Returns:
- A new read-only transaction
-
newWriteOnlyTransaction
public WriteTransaction newWriteOnlyTransaction()
Description copied from interface:TransactionFactory
Allocates new write-only transaction based on latest state of data tree.Preconditions for mutation of data tree are captured from the snapshot of data tree state, when the transaction is allocated. If data was changed during transaction in an incompatible way then the commit of this transaction will fail. See
WriteTransaction.commit()
for more details about conflicting and not-conflicting changes and failure scenarios.Since this transaction does not provide a view of the data it SHOULD BE used only by callers who are exclusive writers (exporters of data) to the subtree they modify. This prevents optimistic lock failures as described in
WriteTransaction.commit()
.Exclusivity of writers to particular subtree SHOULD BE enforced by external locking mechanism.
- Specified by:
newWriteOnlyTransaction
in interfaceTransactionFactory
- Returns:
- new write-only transaction
-
newReadWriteTransaction
public ReadWriteTransaction newReadWriteTransaction()
Description copied from interface:TransactionFactory
Allocates new read-write transaction which provides a mutable view of the data tree.Preconditions for mutation of data tree are captured from the snapshot of data tree state, when the transaction is allocated. If data was changed during transaction in an incompatible way then the commit of this transaction will fail. See
WriteTransaction.commit()
for more details about conflicting and non-conflicting changes and failure scenarios.- Specified by:
newReadWriteTransaction
in interfaceTransactionFactory
- Returns:
- new read-write transaction
-
createTransactionChain
public TransactionChain createTransactionChain(TransactionChainListener listener)
Description copied from interface:DataBroker
Create a new transaction chain. The chain will be initialized to read from its backing datastore, with no outstanding transaction. Listener will be registered to handle chain-level events.- Specified by:
createTransactionChain
in interfaceDataBroker
- Parameters:
listener
- Transaction chain event listener- Returns:
- A new transaction chain.
-
createMergingTransactionChain
public TransactionChain createMergingTransactionChain(TransactionChainListener listener)
Description copied from interface:DataBroker
Create a new transaction chain. The chain will be initialized to read from its backing datastore, with no outstanding transaction. Listener will be registered to handle chain-level events.Unlike
DataBroker.createTransactionChain(TransactionChainListener)
, the transaction chain returned by this method is allowed to merge individual transactions into larger chunks. When transactions are merged, the results must be indistinguishable from the result of all operations having been performed on a single transaction.When transactions are merged,
TransactionChain.newReadOnlyTransaction()
may actually be backed by a read-write transaction, hence an additional restriction on API use is that multiple read-only transactions may not be open at the same time.- Specified by:
createMergingTransactionChain
in interfaceDataBroker
- Parameters:
listener
- Transaction chain event listener- Returns:
- A new transaction chain.
-
registerDataTreeChangeListener
public <T extends DataObject,L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener(DataTreeIdentifier<T> treeId, L listener)
Description copied from interface:DataTreeChangeService
Registers aDataTreeChangeListener
to receive notifications when data changes under a given path in the conceptual data tree.You are able to register for notifications for any node or subtree which can be represented using
DataTreeIdentifier
.You are able to register for data change notifications for a subtree or leaf even if it does not exist. You will receive notification once that node is created.
If there is any pre-existing data in the data tree for the path for which you are registering, you will receive an initial data change event, which will contain all pre-existing data, marked as created.
This method returns a
ListenerRegistration
object. To "unregister" your listener for changes call theListenerRegistration.close()
method on the returned object.You MUST explicitly unregister your listener when you no longer want to receive notifications. This is especially true in OSGi environments, where failure to do so during bundle shutdown can lead to stale listeners being still registered.
- Specified by:
registerDataTreeChangeListener
in interfaceDataTreeChangeService
- Parameters:
treeId
- Data tree identifier of the subtree which should be watched for changes.listener
- Listener instance which is being registered- Returns:
- Listener registration object, which may be used to unregister
your listener using
ListenerRegistration.close()
to stop delivery of change events.
-
getDelegate
public final T getDelegate()
- Specified by:
getDelegate
in interfaceDelegator<T>
-
adapterContext
protected final AdapterContext adapterContext()
-
currentSerializer
protected final CurrentAdapterSerializer currentSerializer()
-
-