<groupId>org.apache.log4j</groupId>
<artifactId>com.springsource.org.apache.log4j</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>
- com.springsource.org.apache.commons.logging
- </artifactId>
- </dependency>
-
+ <!--
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>com.springsource.slf4j.org.apache.commons.logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>com.springsource.slf4j.jcl</artifactId>
+ </dependency>
+ -->
</dependencies>
</project>
\ No newline at end of file
startApp(config);
// Start OSGi framework
- startEquinox(config);
+ try {
+ startEquinox(config);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
info("Argeo SLC Detached launcher started.");
} catch (Exception e) {
e.printStackTrace();
.getCanonicalFile();
String equinoxConfigurationPath = baseDir.getPath() + File.separator
+ "slc-detached" + File.separator + "equinoxConfiguration";
- String[] equinoxArgs = { "-console", "-noExit", "-clean",
+ String[] equinoxArgs = { "-console", "-noExit", "-clean", "-debug",
"-configuration", equinoxConfigurationPath };
BundleContext context = EclipseStarter.startup(equinoxArgs, null);
private static void startBundle(BundleContext bundleContext,
String symbolicName) throws BundleException {
+ info("Starting bundle " + symbolicName + "...");
Bundle bundle = findBundleBySymbolicName(bundleContext, symbolicName);
if (bundle != null)
bundle.start();
String[] uiArgs = readArgumentsFromLine(config.getProperty(
"slc.detached.appargs", ""));
- if (className == null)
- throw new Exception(
- "A main class has to be defined with the system property slc.detached.appclass");
-
- // Launch main method using reflection
- Class clss = Class.forName(className);
- Class[] mainArgsClasses = new Class[] { uiArgs.getClass() };
- Object[] mainArgs = { uiArgs };
- Method mainMethod = clss.getMethod("main", mainArgsClasses);
- mainMethod.invoke(null, mainArgs);
+ if (className == null) {
+ info("No slc.detached.appclass property define: does not try to launch an app from the standard classpath.");
+ } else {
+ // Launch main method using reflection
+ Class clss = Class.forName(className);
+ Class[] mainArgsClasses = new Class[] { uiArgs.getClass() };
+ Object[] mainArgs = { uiArgs };
+ Method mainMethod = clss.getMethod("main", mainArgsClasses);
+ mainMethod.invoke(null, mainArgs);
+ }
}
/* UTILITIES */
--- /dev/null
+package org.argeo.slc.detached;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Properties;
+import java.util.Vector;
+
+public class AppLauncher {
+ private Properties systemProperties = new Properties();
+ private String mainClass = null;
+ private List arguments = new Vector();
+
+ public void launch() {
+ try {
+ if (mainClass == null)
+ throw new DetachedException(
+ "A main class name muste be specified.");
+
+ System.getProperties().putAll(systemProperties);
+ //Class clss = getClass().getClassLoader().loadClass(mainClass);
+ Class clss = Class.forName(mainClass);
+
+ String[] args = new String[arguments.size()];
+ for (int i = 0; i < arguments.size(); i++) {
+ args[i] = arguments.get(i).toString();
+ }
+
+ Class[] mainArgsClasses = new Class[] { args.getClass() };
+ Object[] mainArgs = { args };
+ Method mainMethod = clss.getMethod("main", mainArgsClasses);
+ mainMethod.invoke(null, mainArgs);
+
+ } catch (Exception e) {
+ throw new DetachedException("Unexpected exception while launching "
+ + mainClass, e);
+ }
+
+ }
+
+ public void setSystemProperties(Properties systemProperties) {
+ this.systemProperties = systemProperties;
+ }
+
+ public void setMainClass(String mainClass) {
+ this.mainClass = mainClass;
+ }
+
+ public void setArguments(List arguments) {
+ this.arguments = arguments;
+ }
+
+}
package org.argeo.slc.detached;
public class DetachedException extends RuntimeException {
- private Exception cause;
+ static final long serialVersionUID = 1l;
public DetachedException(String message) {
super(message);
}
public DetachedException(String message, Exception cause) {
- super(message);
- this.cause = cause;
+ super(message, cause);
}
}
<artifactId>com.springsource.slf4j.org.apache.commons.logging</artifactId>
<version>1.5.3</version>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>com.springsource.slf4j.jcl</artifactId>
+ <version>1.5.3</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.org.apache.log4j</artifactId>
</dependency>
<!-- OSGi -->
- <!--
- <dependency>
- <groupId>org.apache.felix</groupId>
+ <!--
+ <dependency> <groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
- <version>1.2.1</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>
- org.apache.felix.framework
- </artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.2.0</version>
- <scope>provided</scope>
- </dependency>
- -->
+ <version>1.2.1</version> <exclusions> <exclusion>
+ <groupId>org.apache.felix</groupId> <artifactId>
+ org.apache.felix.framework </artifactId> </exclusion> </exclusions>
+ </dependency> <dependency> <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId> <version>1.2.0</version>
+ <scope>provided</scope> </dependency>
+ -->
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>