X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FBrokerFacade.xtend;h=8e18661db6ecdfcc65d822dff5bf1e4c115c0b96;hb=b5daa3678322a764f9b0e2483f82781f4d39d263;hp=4c6eb3b10658c61b5b0c4de6e423cfad33ed0643;hpb=ce23509536c00cb2649c36b4b64ac261946445a1;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend index 4c6eb3b106..8e18661db6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend @@ -1,65 +1,57 @@ package org.opendaylight.controller.sal.restconf.impl import org.opendaylight.controller.md.sal.common.api.data.DataReader -import java.net.URI -import org.opendaylight.yangtools.yang.data.api.CompositeNode -import org.opendaylight.controller.sal.core.api.data.DataBrokerService -import org.opendaylight.controller.sal.core.api.model.SchemaService -import static com.google.common.base.Preconditions.*; import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession +import org.opendaylight.controller.sal.core.api.data.DataBrokerService +import org.opendaylight.yangtools.yang.common.QName import org.opendaylight.yangtools.yang.common.RpcResult -import org.opendaylight.controller.md.sal.common.api.data.DataModificationTransactionFactory +import org.opendaylight.yangtools.yang.data.api.CompositeNode +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier +import static org.opendaylight.controller.sal.restconf.impl.BrokerFacade.* + +class BrokerFacade implements DataReader { -class BrokerFacade implements DataReader { + val static BrokerFacade INSTANCE = new BrokerFacade @Property private ConsumerSession context; - + @Property private DataBrokerService dataService; - @Property - private SchemaService schemaService; - - @Property - private extension ControllerContext schemaContext; - - - def void init() { - checkState(dataService !== null) - checkState(schemaService !== null) - schemaContext = new ControllerContext(); - schemaContext.schemas = schemaService.globalContext; + private new() { + if (INSTANCE != null) { + throw new IllegalStateException("Already instantiated"); + } + } + + def static BrokerFacade getInstance() { + return INSTANCE } - override readConfigurationData(String path) { - val processedPath = path.removePrefixes(); - return dataService.readConfigurationData(processedPath.toInstanceIdentifier); + override readConfigurationData(InstanceIdentifier path) { + return dataService.readConfigurationData(path); } - override readOperationalData(String path) { - val processedPath = path.removePrefixes(); - return dataService.readOperationalData(processedPath.toInstanceIdentifier); + override readOperationalData(InstanceIdentifier path) { + return dataService.readOperationalData(path); } - - def RpcResult invokeRpc(String type,CompositeNode payload) { - val future = context.rpc(type.toRpcQName(),payload); + + def RpcResult invokeRpc(QName type, CompositeNode payload) { + val future = context.rpc(type, payload); return future.get; } - - def commitConfigurationDataUpdate(String path, CompositeNode payload) { + + def commitConfigurationDataUpdate(InstanceIdentifier path, CompositeNode payload) { val transaction = dataService.beginTransaction; - transaction.putConfigurationData(path.toInstanceIdentifier,payload); + transaction.putConfigurationData(path, payload); return transaction.commit() } - - def commitConfigurationDataCreate(String path, CompositeNode payload) { + + def commitConfigurationDataCreate(InstanceIdentifier path, CompositeNode payload) { val transaction = dataService.beginTransaction; - transaction.putConfigurationData(path.toInstanceIdentifier,payload); + transaction.putConfigurationData(path, payload); return transaction.commit() } - private def String removePrefixes(String path) { - return path; - } }