+/*
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ *
+ * 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;
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);
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);