X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.osgiboot%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fosgiboot%2FLauncher.java;h=96a21cc0d369c8f2b6488b5c00b11f0534b969be;hb=78328cee88413039b5af7bc9f256b640c09c1c26;hp=8116b71f34b9165a0d8e868dff216574ff352eb0;hpb=8eb028e332cb2be50ed311a0501f7efce5849d44;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/Launcher.java b/runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/Launcher.java index 8116b71f3..96a21cc0d 100644 --- a/runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/Launcher.java +++ b/runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/Launcher.java @@ -1,5 +1,23 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.osgiboot; +import java.io.FileInputStream; +import java.io.IOException; import java.lang.reflect.Method; import java.util.List; import java.util.Properties; @@ -11,8 +29,32 @@ import org.osgi.framework.BundleContext; public class Launcher { public static void main(String[] args) { + // Try to load system properties + String systemPropertiesFilePath = System + .getProperty(OsgiBoot.PROP_SLC_OSGIBOOT_SYSTEM_PROPERTIES_FILE); + if (systemPropertiesFilePath != null) { + FileInputStream in; + try { + in = new FileInputStream(systemPropertiesFilePath); + System.getProperties().load(in); + } catch (IOException e1) { + throw new RuntimeException( + "Cannot load system properties from " + + systemPropertiesFilePath, e1); + } + if (in != null) { + try { + in.close(); + } catch (Exception e) { + // silent + } + } + } + + // Start main class startMainClass(); + // Start Equinox BundleContext bundleContext = null; try { bundleContext = EclipseStarter.startup(args, null); @@ -20,35 +62,19 @@ public class Launcher { throw new RuntimeException("Cannot start Equinox.", e); } + // OSGi bootstrap OsgiBoot osgiBoot = new OsgiBoot(bundleContext); osgiBoot.bootstrap(); } -// -// protected static void startEquinox(Properties config) throws Exception { -// info("java.home=" + System.getProperty("java.home")); -// info("java.class.path=" + System.getProperty("java.class.path")); -// -// File baseDir = new File(System.getProperty("user.dir")) -// .getCanonicalFile(); -// String equinoxConfigurationPath = baseDir.getPath() + File.separator -// + "slc-detached" + File.separator + "equinoxConfiguration"; -// -// String equinoxArgsLineDefault = "-console -noExit -clean -debug -configuration " -// + equinoxConfigurationPath; -// String equinoxArgsLine = config.getProperty(PROP_SLC_OSGI_EQUINOX_ARGS, -// equinoxArgsLineDefault); -// // String[] equinoxArgs = { "-console", "-noExit", "-clean", "-debug", -// // "-configuration", equinoxConfigurationPath }; -// String[] equinoxArgs = equinoxArgsLine.split(" "); -// -// BundleContext context = EclipseStarter.startup(equinoxArgs, null); -// } protected static void startMainClass() { Properties config = System.getProperties(); - String className = config.getProperty("slc.detached.appclass"); + String className = config.getProperty("slc.osgiboot.appclass"); + if (className == null) + return; + String[] uiArgs = readArgumentsFromLine(config.getProperty( - "slc.detached.appargs", "")); + "slc.osgiboot.appargs", "")); try { // Launch main method using reflection Class clss = Class.forName(className);