1 package org.opendaylight.controller.sal.restconf.impl
3 import org.opendaylight.controller.md.sal.common.api.data.DataReader
4 import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession
5 import org.opendaylight.controller.sal.core.api.data.DataBrokerService
6 import org.opendaylight.yangtools.yang.common.QName
7 import org.opendaylight.yangtools.yang.common.RpcResult
8 import org.opendaylight.yangtools.yang.data.api.CompositeNode
9 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
10 import static org.opendaylight.controller.sal.restconf.impl.BrokerFacade.*
12 class BrokerFacade implements DataReader<InstanceIdentifier, CompositeNode> {
14 val static BrokerFacade INSTANCE = new BrokerFacade
17 private ConsumerSession context;
20 private DataBrokerService dataService;
23 if (INSTANCE != null) {
24 throw new IllegalStateException("Already instantiated");
28 def static BrokerFacade getInstance() {
32 override readConfigurationData(InstanceIdentifier path) {
33 return dataService.readConfigurationData(path);
36 override readOperationalData(InstanceIdentifier path) {
37 return dataService.readOperationalData(path);
40 def RpcResult<CompositeNode> invokeRpc(QName type, CompositeNode payload) {
41 val future = context.rpc(type, payload);
45 def commitConfigurationDataPut(InstanceIdentifier path, CompositeNode payload) {
46 val transaction = dataService.beginTransaction;
47 transaction.putConfigurationData(path, payload);
48 return transaction.commit()
51 def commitOperationalDataPut(InstanceIdentifier path, CompositeNode payload) {
52 val transaction = dataService.beginTransaction;
53 transaction.putOperationalData(path, payload);
54 return transaction.commit()