1 package org
.argeo
.slc
.detached
;
3 import java
.lang
.reflect
.Method
;
5 import java
.util
.Properties
;
6 import java
.util
.Vector
;
8 public class AppLauncher
{
9 private Properties systemProperties
= new Properties();
10 private String mainClass
= null;
11 private List arguments
= new Vector();
13 public void launch() {
15 if (mainClass
== null)
16 throw new DetachedException(
17 "A main class name muste be specified.");
19 System
.getProperties().putAll(systemProperties
);
20 //Class clss = getClass().getClassLoader().loadClass(mainClass);
21 Class clss
= Class
.forName(mainClass
);
23 String
[] args
= new String
[arguments
.size()];
24 for (int i
= 0; i
< arguments
.size(); i
++) {
25 args
[i
] = arguments
.get(i
).toString();
28 Class
[] mainArgsClasses
= new Class
[] { args
.getClass() };
29 Object
[] mainArgs
= { args
};
30 Method mainMethod
= clss
.getMethod("main", mainArgsClasses
);
31 mainMethod
.invoke(null, mainArgs
);
33 } catch (Exception e
) {
34 throw new DetachedException("Unexpected exception while launching "
40 public void setSystemProperties(Properties systemProperties
) {
41 this.systemProperties
= systemProperties
;
44 public void setMainClass(String mainClass
) {
45 this.mainClass
= mainClass
;
48 public void setArguments(List arguments
) {
49 this.arguments
= arguments
;