From 139eece2b8574f2d6a834692ac6c664fcba7cb97 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Fri, 26 Sep 2008 14:41:00 +0000 Subject: [PATCH] Centralize Spring initialization git-svn-id: https://svn.argeo.org/slc/trunk@1641 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- org.argeo.slc.autoui.launcher/pom.xml | 4 -- .../org/argeo/slc/autoui/launcher/Main.java | 45 +++++++------------ 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/org.argeo.slc.autoui.launcher/pom.xml b/org.argeo.slc.autoui.launcher/pom.xml index 8810f92d1..1785af187 100644 --- a/org.argeo.slc.autoui.launcher/pom.xml +++ b/org.argeo.slc.autoui.launcher/pom.xml @@ -33,10 +33,6 @@ org.argeo.slc.autoui ${project.version} - - org.argeo.dep.jemmy - org.argeo.dep.jemmy.nb61 - org.apache.felix org.apache.felix.main diff --git a/org.argeo.slc.autoui.launcher/src/main/java/org/argeo/slc/autoui/launcher/Main.java b/org.argeo.slc.autoui.launcher/src/main/java/org/argeo/slc/autoui/launcher/Main.java index 987a675e6..e7bba09c8 100644 --- a/org.argeo.slc.autoui.launcher/src/main/java/org/argeo/slc/autoui/launcher/Main.java +++ b/org.argeo.slc.autoui.launcher/src/main/java/org/argeo/slc/autoui/launcher/Main.java @@ -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) -- 2.39.5