import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import java.util.Vector;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.felix.framework.Felix;
import org.apache.felix.framework.cache.BundleCache;
import org.apache.felix.main.AutoActivator;
import org.argeo.slc.autoui.AutoUiActivator;
-import org.argeo.slc.autoui.AutoUiApplication;
-import org.netbeans.jemmy.ClassReference;
+import org.argeo.slc.autoui.DetachedExecutionServer;
+import org.argeo.slc.autoui.DetachedStep;
+import org.argeo.slc.autoui.DetachedStepRequest;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class Main {
+ private final static Log log = LogFactory.getLog(Main.class);
public static void main(String[] args) {
try {
- // Start OSGi system
+ // Load properties
Properties config = prepareConfig();
- Felix felix = startSystem(config);
// Start UI (in main class loader)
startUi(config);
+ //Thread.sleep(10000);
+
+ // Start OSGi system
+ Felix felix = startSystem(config);
// Automate
- automateUi(felix.getBundleContext());
-
- felix.stop();
+ //automateUi(felix.getBundleContext());
+
+ // felix.stop();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
// Add activator to process auto-start/install properties.
list.add(new AutoActivator(config));
// Add our own activator.
- list.add(new AutoUiActivator());
+ //list.add(new AutoUiActivator());
// Now create an instance of the framework.
Felix felix = new Felix(config, list);
String className = config.getProperty("argeo.scl.autoui.uiclass");
String[] uiArgs = readArgumentsFromLine(config.getProperty(
"argeo.slc.autoui.uiargs", ""));
- ClassReference classReference = new ClassReference(className);
- classReference.startApplication(uiArgs);
+
+ // 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);
}
- protected static void automateUi(BundleContext context) throws Exception {
+ protected static void automateUi(BundleContext bundleContext)
+ throws Exception {
// Retrieve service and execute it
- ServiceReference ref = context
- .getServiceReference("org.argeo.slc.autoui.AutoUiApplication");
- Object service = context.getService(ref);
- AutoUiActivator.stdOut("service.class=" + service.getClass());
- AutoUiApplication app = (AutoUiApplication) service;
- app.execute(null);
+ ServiceReference ref = bundleContext
+ .getServiceReference(DetachedExecutionServer.class.getName());
+ Object service = bundleContext.getService(ref);
+
+ log.debug("service.class=" + service.getClass());
+ DetachedExecutionServer app = (DetachedExecutionServer) service;
+ DetachedStepRequest request = new DetachedStepRequest();
+ request.setStepRef("jemmyTest");
+ app.executeStep(request);
}
/* UTILITIES */