From 670599a6d8f4973ed32be513d3de9269b08c9b21 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Thu, 25 Sep 2008 17:14:04 +0000 Subject: [PATCH] Start using Spring git-svn-id: https://svn.argeo.org/slc/trunk@1636 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- org.argeo.slc.autoui.launcher/pom.xml | 16 +++++++++ .../org/argeo/slc/autoui/launcher/Main.java | 33 ++++++++++++++++--- .../slc/autoui/launcher/felix.properties | 7 +++- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/org.argeo.slc.autoui.launcher/pom.xml b/org.argeo.slc.autoui.launcher/pom.xml index f49c9168d..76d65cc15 100644 --- a/org.argeo.slc.autoui.launcher/pom.xml +++ b/org.argeo.slc.autoui.launcher/pom.xml @@ -41,5 +41,21 @@ org.apache.felix org.apache.felix.main + + + org.springframework + spring-core + 2.0.8 + + + org.springframework + spring-context + 2.0.8 + + + org.springframework + spring-beans + 2.0.8 + \ No newline at end of file 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 cf5ec3790..987a675e6 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,6 +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.util.ArrayList; import java.util.Enumeration; import java.util.List; @@ -15,8 +16,13 @@ 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 { @@ -26,12 +32,28 @@ public class Main { 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); // Automate automateUi(felix.getBundleContext()); - + felix.stop(); } catch (Exception e) { e.printStackTrace(); @@ -104,11 +126,14 @@ public class Main { classReference.startApplication(uiArgs); } - protected static void automateUi(BundleContext context) throws Exception { + protected static void automateUi(BundleContext bundleContext) + throws Exception { // Retrieve service and execute it - ServiceReference ref = context + ServiceReference ref = bundleContext .getServiceReference("org.argeo.slc.autoui.AutoUiApplication"); - Object service = context.getService(ref); + Object service = bundleContext.getService(ref); + + // Object service = applicationContext.getBean("jemmyTest"); AutoUiActivator.stdOut("service.class=" + service.getClass()); AutoUiApplication app = (AutoUiApplication) service; app.execute(null); diff --git a/org.argeo.slc.autoui.launcher/src/main/resources/org/argeo/slc/autoui/launcher/felix.properties b/org.argeo.slc.autoui.launcher/src/main/resources/org/argeo/slc/autoui/launcher/felix.properties index e89217cad..d3b022065 100644 --- a/org.argeo.slc.autoui.launcher/src/main/resources/org/argeo/slc/autoui/launcher/felix.properties +++ b/org.argeo.slc.autoui.launcher/src/main/resources/org/argeo/slc/autoui/launcher/felix.properties @@ -14,7 +14,12 @@ org.osgi.framework.system.packages=org.osgi.framework; version=1.4.0, \ org.osgi.service.url; version=1.0.0, \ org.osgi.util.tracker; version=1.3.3, \ org.argeo.slc.autoui; version=0.10.3.SNAPSHOT, \ - org.argeo.slc.testui \ + org.argeo.slc.testui, \ + org.springframework.beans.factory.support,\ + org.springframework.beans.factory.xml,\ + org.springframework.context,\ + org.springframework.context.support,\ + org.springframework.core.io \ ${jre-${java.specification.version}} #org.osgi.framework.bootdelegation=sun.*,com.sun.* -- 2.39.2