Use BrokerFacade non-statically
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / restconf / impl / RestconfProviderImpl.java
index 4afc5f8a6810716343653963f666648d5ded60e2..5870c5d5a787a0c3d4af4f74636d1545cf3fbb32 100644 (file)
@@ -10,13 +10,6 @@ package org.opendaylight.netconf.sal.restconf.impl;
 import com.google.common.base.Preconditions;
 import java.math.BigInteger;
 import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
 import org.opendaylight.netconf.sal.rest.api.RestConnector;
 import org.opendaylight.netconf.sal.restconf.impl.jmx.Config;
 import org.opendaylight.netconf.sal.restconf.impl.jmx.Delete;
@@ -29,51 +22,21 @@ import org.opendaylight.netconf.sal.restconf.impl.jmx.Rpcs;
 import org.opendaylight.netconf.sal.streams.websockets.WebSocketServer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 
 public class RestconfProviderImpl extends AbstractMXBean
         implements AutoCloseable, RestConnector, RestConnectorRuntimeMXBean {
-    private final DOMDataBroker domDataBroker;
-    private final SchemaService schemaService;
-    private final DOMRpcService rpcService;
-    private final DOMNotificationService notificationService;
-    private final DOMMountPointService mountPointService;
     private final IpAddress websocketAddress;
     private final PortNumber websocketPort;
     private final StatisticsRestconfServiceWrapper stats = StatisticsRestconfServiceWrapper.getInstance();
-    private final DOMSchemaService domSchemaService;
-    private ListenerRegistration<SchemaContextListener> listenerRegistration;
     private Thread webSocketServerThread;
 
-    public RestconfProviderImpl(DOMDataBroker domDataBroker, SchemaService schemaService, DOMRpcService rpcService,
-            DOMNotificationService notificationService, DOMMountPointService mountPointService,
-            DOMSchemaService domSchemaService, IpAddress websocketAddress, PortNumber websocketPort) {
+    public RestconfProviderImpl(IpAddress websocketAddress, PortNumber websocketPort) {
         super("Draft02ProviderStatistics", "restconf-connector", null);
-        this.domDataBroker = Preconditions.checkNotNull(domDataBroker);
-        this.schemaService = Preconditions.checkNotNull(schemaService);
-        this.rpcService = Preconditions.checkNotNull(rpcService);
-        this.notificationService = Preconditions.checkNotNull(notificationService);
-        this.mountPointService = Preconditions.checkNotNull(mountPointService);
         this.websocketAddress = Preconditions.checkNotNull(websocketAddress);
         this.websocketPort = Preconditions.checkNotNull(websocketPort);
-        this.domSchemaService = Preconditions.checkNotNull(domSchemaService);
     }
 
     public void start() {
-        this.listenerRegistration = schemaService.registerSchemaContextListener(ControllerContext.getInstance());
-
-        BrokerFacade.getInstance().setDomDataBroker(domDataBroker);
-        BrokerFacade.getInstance().setRpcService(rpcService);
-        BrokerFacade.getInstance().setDomNotificationService(notificationService);
-
-        ControllerContext.getInstance().setSchemas(schemaService.getGlobalContext());
-        ControllerContext.getInstance().setMountService(mountPointService);
-        final DOMYangTextSourceProvider domSchemaServiceExtension =
-                (DOMYangTextSourceProvider) domSchemaService.getSupportedExtensions()
-                        .get(DOMYangTextSourceProvider.class);
-        ControllerContext.getInstance().setYangTextSourceProvider(domSchemaServiceExtension);
-
         this.webSocketServerThread = new Thread(WebSocketServer.createInstance(
                 new String(websocketAddress.getValue()), websocketPort.getValue()));
         this.webSocketServerThread.setName("Web socket server on port " + websocketPort);
@@ -84,12 +47,6 @@ public class RestconfProviderImpl extends AbstractMXBean
 
     @Override
     public void close() {
-        BrokerFacade.getInstance().setDomDataBroker(null);
-
-        if (this.listenerRegistration != null) {
-            this.listenerRegistration.close();
-        }
-
         WebSocketServer.destroyInstance();
         if (this.webSocketServerThread != null) {
             this.webSocketServerThread.interrupt();