From: jsimomaa Date: Fri, 22 Sep 2017 07:30:52 +0000 (+0300) Subject: Adding system property support for starting SCL REST server on startup X-Git-Tag: v1.31.0~174 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=5a916488e73ffb47b2899252b73f6d0a8d1d10e6;p=simantics%2Fplatform.git Adding system property support for starting SCL REST server on startup refs #7374 Change-Id: I4d961a547ccf5101fd36846c4deddda4c20048b9 --- diff --git a/bundles/org.simantics.scl.rest/src/org/simantics/scl/rest/Activator.java b/bundles/org.simantics.scl.rest/src/org/simantics/scl/rest/Activator.java index 4f90e6900..b7cf31689 100644 --- a/bundles/org.simantics.scl.rest/src/org/simantics/scl/rest/Activator.java +++ b/bundles/org.simantics.scl.rest/src/org/simantics/scl/rest/Activator.java @@ -2,9 +2,15 @@ package org.simantics.scl.rest; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Activator implements BundleActivator { + public static final String START_SERVER = "org.simantics.scl.rest.startServer"; + + private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class); + private static BundleContext context; static BundleContext getContext() { @@ -18,6 +24,15 @@ public class Activator implements BundleActivator { * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ public void start(BundleContext bundleContext) throws Exception { + String onStartup = System.getProperty(START_SERVER); + if (onStartup != null && !onStartup.isEmpty()) { + try { + String[] tokenAndPort = onStartup.split("::"); + SCLRESTServer.start(tokenAndPort[0], Integer.parseInt(tokenAndPort[1])); + } catch (Exception e) { + LOGGER.error("Could not start server with value {}. It should be in the form of ::", onStartup, e); + } + } Activator.context = bundleContext; }