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%2Frest%2Fimpl%2FRestconfProvider.java;h=1f1d0eb83147533d1171a4e81a36a73d7f72acd0;hb=refs%2Fchanges%2F27%2F8927%2F3;hp=242f18d240122597bea4d1dac29a4f1a31ea9e31;hpb=887cfd8dac6eb58f8c43a64ea5e84b77ab4d7917;p=controller.git 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 242f18d240..1f1d0eb831 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,17 +1,25 @@ +/* + * 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 java.util.Collections; - import org.opendaylight.controller.sal.core.api.Broker; 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; @@ -21,11 +29,11 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; public class RestconfProvider implements BundleActivator, Provider, ServiceTrackerCustomizer { 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,11 +45,18 @@ 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 public void start(BundleContext context) throws Exception { + String websocketPortStr = context.getProperty(WebSocketServer.WEBSOCKET_SERVER_CONFIG_PROPERTY); + int websocketPort = (websocketPortStr != null && !"".equals(websocketPortStr)) ? Integer + .parseInt(websocketPortStr) : WebSocketServer.DEFAULT_PORT; bundleContext = context; + webSocketServerThread = new Thread(WebSocketServer.createInstance(websocketPort)); + webSocketServerThread.setName("Web socket server"); + webSocketServerThread.start(); brokerServiceTrancker = new ServiceTracker<>(context, Broker.class, this); brokerServiceTrancker.open(); } @@ -55,7 +70,7 @@ public class RestconfProvider implements BundleActivator, Provider, ServiceTrack e.printStackTrace(); } } - session.close(); + webSocketServerThread.interrupt(); brokerServiceTrancker.close(); }