From 5a916488e73ffb47b2899252b73f6d0a8d1d10e6 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Fri, 22 Sep 2017 10:30:52 +0300 Subject: [PATCH] Adding system property support for starting SCL REST server on startup refs #7374 Change-Id: I4d961a547ccf5101fd36846c4deddda4c20048b9 --- .../src/org/simantics/scl/rest/Activator.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; } -- 2.43.2