X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frest%2Fimpl%2FRestconfProvider.java;h=2abd4b6a3ab5b9a08c56e782257a262db80fbfe2;hp=53b401e4a2c55856dc215c4fc5b62987ebaa71f0;hb=510561642a3d699673140da8879d4eb5bc88534e;hpb=1d86c5cf27410934076c10eaa74f4bab4418215c diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java index 53b401e4a2..2abd4b6a3a 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java @@ -1,3 +1,10 @@ +/* + * 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; @@ -8,10 +15,12 @@ import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; 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; @@ -20,12 +29,12 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; public class RestconfProvider implements BundleActivator, Provider, ServiceTrackerCustomizer { - public final static String NOT_INITALIZED_MSG = "Restcof is not initialized yet. Please try again later"; - + public final static String NOT_INITALIZED_MSG = "Restconf is not initialized yet. Please try again later"; + private ListenerRegistration listenerRegistration; private ServiceTracker brokerServiceTrancker; private BundleContext bundleContext; - private ProviderSession session; + private Thread webSocketServerThread; @Override public void onSessionInitiated(ProviderSession session) { @@ -37,6 +46,7 @@ public class RestconfProvider implements BundleActivator, Provider, ServiceTrack SchemaService schemaService = session.getService(SchemaService.class); listenerRegistration = schemaService.registerSchemaServiceListener(ControllerContext.getInstance()); ControllerContext.getInstance().setSchemas(schemaService.getGlobalContext()); + ControllerContext.getInstance().setMountService(session.getService(MountService.class)); } @Override @@ -44,6 +54,9 @@ public class RestconfProvider implements BundleActivator, Provider, ServiceTrack bundleContext = context; brokerServiceTrancker = new ServiceTracker<>(context, Broker.class, this); brokerServiceTrancker.open(); + webSocketServerThread = new Thread(new WebSocketServer()); + webSocketServerThread.setName("Web socket server"); + webSocketServerThread.start(); } @Override @@ -55,7 +68,7 @@ public class RestconfProvider implements BundleActivator, Provider, ServiceTrack e.printStackTrace(); } } - session.close(); + webSocketServerThread.interrupt(); brokerServiceTrancker.close(); }