ControllerContext.dataNodeChildByQName method refactoring
[controller.git] / opendaylight / md-sal / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / netconf / sal / NetconfDeviceDataBroker.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
9 package org.opendaylight.controller.sal.connect.netconf.sal;
10
11 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
12 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
13 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
14 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
15 import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
16 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
17 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
18 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
19 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
20 import org.opendaylight.controller.sal.connect.netconf.listener.NetconfSessionCapabilities;
21 import org.opendaylight.controller.sal.connect.netconf.sal.tx.NetconfDeviceReadOnlyTx;
22 import org.opendaylight.controller.sal.connect.netconf.sal.tx.NetconfDeviceReadWriteTx;
23 import org.opendaylight.controller.sal.connect.netconf.sal.tx.NetconfDeviceWriteOnlyTx;
24 import org.opendaylight.controller.sal.connect.util.RemoteDeviceId;
25 import org.opendaylight.controller.sal.core.api.RpcImplementation;
26 import org.opendaylight.yangtools.concepts.ListenerRegistration;
27 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
28 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
29
30 final class NetconfDeviceDataBroker implements DOMDataBroker {
31     private final RemoteDeviceId id;
32     private final RpcImplementation rpc;
33     private final NetconfSessionCapabilities netconfSessionPreferences;
34     private final DataNormalizer normalizer;
35
36     public NetconfDeviceDataBroker(final RemoteDeviceId id, final RpcImplementation rpc, final SchemaContext schemaContext, NetconfSessionCapabilities netconfSessionPreferences) {
37         this.id = id;
38         this.rpc = rpc;
39         this.netconfSessionPreferences = netconfSessionPreferences;
40         normalizer = new DataNormalizer(schemaContext);
41     }
42
43     @Override
44     public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
45         return new NetconfDeviceReadOnlyTx(rpc, normalizer);
46     }
47
48     @Override
49     public DOMDataReadWriteTransaction newReadWriteTransaction() {
50         return new NetconfDeviceReadWriteTx(newReadOnlyTransaction(), newWriteOnlyTransaction());
51     }
52
53     @Override
54     public DOMDataWriteTransaction newWriteOnlyTransaction() {
55         // FIXME detect if candidate is supported, true is hardcoded
56         return new NetconfDeviceWriteOnlyTx(id, rpc, normalizer, true, netconfSessionPreferences.isRollbackSupported());
57     }
58
59     @Override
60     public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store, final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {
61         throw new UnsupportedOperationException("Data change listeners not supported for netconf mount point");
62     }
63
64     @Override
65     public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
66         // TODO implement
67         throw new UnsupportedOperationException("Transaction chains not supported for netconf mount point");
68     }
69 }