+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.controller.sal.rest.impl;
import java.util.Collection;
import org.opendaylight.controller.sal.core.api.Provider;
import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
+import org.opendaylight.controller.sal.core.api.mount.MountService;
import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
+import org.opendaylight.controller.sal.streams.websockets.WebSocketServer;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class RestconfProvider implements BundleActivator, Provider, ServiceTrackerCustomizer<Broker, Broker> {
public final static String NOT_INITALIZED_MSG = "Restconf is not initialized yet. Please try again later";
-
+
private ListenerRegistration<SchemaServiceListener> listenerRegistration;
private ServiceTracker<Broker, Broker> brokerServiceTrancker;
private BundleContext bundleContext;
- private ProviderSession session;
+ private Thread webSocketServerThread;
@Override
public void onSessionInitiated(ProviderSession session) {
SchemaService schemaService = session.getService(SchemaService.class);
listenerRegistration = schemaService.registerSchemaServiceListener(ControllerContext.getInstance());
ControllerContext.getInstance().setSchemas(schemaService.getGlobalContext());
+ ControllerContext.getInstance().setMountService(session.getService(MountService.class));
}
@Override
bundleContext = context;
brokerServiceTrancker = new ServiceTracker<>(context, Broker.class, this);
brokerServiceTrancker.open();
+ webSocketServerThread = new Thread(new WebSocketServer());
+ webSocketServerThread.setName("Web socket server");
+ webSocketServerThread.start();
}
@Override
e.printStackTrace();
}
}
- session.close();
+ webSocketServerThread.interrupt();
brokerServiceTrancker.close();
}