]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Centralize Spring initialization
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 26 Sep 2008 14:41:00 +0000 (14:41 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 26 Sep 2008 14:41:00 +0000 (14:41 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1641 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.autoui.launcher/pom.xml
org.argeo.slc.autoui.launcher/src/main/java/org/argeo/slc/autoui/launcher/Main.java

index 8810f92d1c910a99d0458cb9ddae137b4a7964ee..1785af18744987dc97da894dd2165fa5dcc4cf59 100644 (file)
                        <artifactId>org.argeo.slc.autoui</artifactId>
                        <version>${project.version}</version>
                </dependency>
-               <dependency>
-                       <groupId>org.argeo.dep.jemmy</groupId>
-                       <artifactId>org.argeo.dep.jemmy.nb61</artifactId>
-               </dependency>
                <dependency>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>org.apache.felix.main</artifactId>
index 987a675e66c0a3135b58f7fc63e6a5d16edd29e2..e7bba09c881843bfa26d7dbf76513879ae8d43c2 100644 (file)
@@ -3,7 +3,7 @@ package org.argeo.slc.autoui.launcher;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
@@ -15,42 +15,22 @@ 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.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.GenericApplicationContext;
-import org.springframework.core.io.UrlResource;
 
 public class Main {
 
        public static void main(String[] args) {
                try {
-                       // Start OSGi system
+                       // Load properties
                        Properties config = prepareConfig();
-                       Felix felix = startSystem(config);
-
-                       // GenericApplicationContext context = new
-                       // GenericApplicationContext();
-                       // XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
-                       // context);
-                       // Bundle[] bundles = felix.getBundleContext().getBundles();
-                       // for (int i = 0; i < bundles.length; i++) {
-                       // Bundle bundle = bundles[i];
-                       // URL url = bundle
-                       // .getResource("META-INF/slc/conf/applicationContext.xml");
-                       // if (url != null) {
-                       // System.out.println("Loads application context from bundle "
-                       // + bundle.getSymbolicName());
-                       // xmlReader.loadBeanDefinitions(new UrlResource(url));
-                       // }
-                       // }
-
+                       
                        // Start UI (in main class loader)
                        startUi(config);
 
+                       // Start OSGi system
+                       Felix felix = startSystem(config);
+
                        // Automate
                        automateUi(felix.getBundleContext());
 
@@ -122,8 +102,17 @@ public class Main {
                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 };
+               // mainArgs[0] = Class.forName("[Ljava.lang.String;");
+               Method mainMethod = clss.getMethod("main", mainArgsClasses);
+               mainMethod.invoke(null, mainArgs);
+
+               // ClassReference classReference = new ClassReference(className);
+               // classReference.startApplication(uiArgs);
        }
 
        protected static void automateUi(BundleContext bundleContext)