1 package org.simantics.scl.rest;
3 import org.osgi.framework.BundleActivator;
4 import org.osgi.framework.BundleContext;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
8 public class Activator implements BundleActivator {
10 public static final String START_SERVER = "org.simantics.scl.rest.startServer";
12 private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
14 private static BundleContext context;
16 static BundleContext getContext() {
24 * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
26 public void start(BundleContext bundleContext) throws Exception {
27 String onStartup = System.getProperty(START_SERVER);
28 if (onStartup != null && !onStartup.isEmpty()) {
30 String[] tokenAndPort = onStartup.split("::");
31 SCLRESTServer.start(tokenAndPort[0], Integer.parseInt(tokenAndPort[1]));
32 } catch (Exception e) {
33 LOGGER.error("Could not start server with value {}. It should be in the form of <secret-token>::<port-number>", onStartup, e);
36 Activator.context = bundleContext;
43 * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
45 public void stop(BundleContext bundleContext) throws Exception {
47 Activator.context = null;