From 494aaacdfe1ac2e28fb3eaebb7952ecb1e274a5e Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sun, 28 Sep 2008 12:41:53 +0000 Subject: [PATCH] Use SLC Detached (aka. SLC AutoUI) as a bundle. Move servers config to end bundle. git-svn-id: https://svn.argeo.org/slc/trunk@1651 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../slc/autoui/AbstractDetachedActivator.java | 35 +++++++++++-------- .../org/argeo/slc/autoui/AutoUiActivator.java | 27 -------------- .../DetachedExecutionServerImpl.java | 12 ++----- .../slc/autoui/SimpleDetachedActivator.java | 28 +++++++++++++++ .../slc/autoui/rmi/AutoUiServerImpl.java | 2 -- .../src/main/resources/META-INF/MANIFEST.MF | 26 +++++++------- .../META-INF/slc/conf/applicationContext.xml | 15 -------- .../org/argeo/slc/detached/DetachedTest.java | 6 ++-- 8 files changed, 67 insertions(+), 84 deletions(-) rename org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/{internal => }/DetachedExecutionServerImpl.java (81%) create mode 100644 org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java delete mode 100644 org.argeo.slc.autoui/src/main/resources/META-INF/slc/conf/applicationContext.xml diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java index b1fe56922..877d8b674 100644 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java +++ b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java @@ -3,6 +3,8 @@ package org.argeo.slc.autoui; import java.net.URL; import java.util.Properties; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -13,24 +15,24 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.UrlResource; public class AbstractDetachedActivator implements BundleActivator { + private final Log log = LogFactory.getLog(getClass()); + private SpringStaticRefProvider staticRefProvider; public final void start(BundleContext context) throws Exception { - ClassLoader classLoader = getClass().getClassLoader(); - // Creates application context + Bundle bundle = context.getBundle(); + + // Creates application context with this class class loader + ClassLoader classLoader = getClass().getClassLoader(); Thread cur = Thread.currentThread(); ClassLoader save = cur.getContextClassLoader(); cur.setContextClassLoader(classLoader); try { - // applicationContext = new ClassPathXmlApplicationContext( - // "/slc/conf/applicationContext.xml"); - AbstractApplicationContext applicationContext = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader( (BeanDefinitionRegistry) applicationContext); - Bundle bundle = context.getBundle(); URL url = bundle .getResource("META-INF/slc/conf/applicationContext.xml"); @@ -38,15 +40,17 @@ public class AbstractDetachedActivator implements BundleActivator { System.out.println("Loads application context from bundle " + bundle.getSymbolicName() + " (url=" + url + ")"); xmlReader.loadBeanDefinitions(new UrlResource(url)); - } - // Register static ref provider - staticRefProvider = new SpringStaticRefProvider(applicationContext); - Properties properties = new Properties(); - properties.setProperty("slc.detached.bundle", bundle - .getSymbolicName()); - context.registerService(StaticRefProvider.class.getName(), - staticRefProvider, properties); + // Register static ref provider + staticRefProvider = new SpringStaticRefProvider( + applicationContext); + Properties properties = new Properties(); + properties.setProperty("slc.detached.bundle", bundle + .getSymbolicName()); + context.registerService(StaticRefProvider.class.getName(), + staticRefProvider, properties); + + } } catch (Exception e) { e.printStackTrace(); @@ -56,6 +60,9 @@ public class AbstractDetachedActivator implements BundleActivator { } startAutoBundle(context); + + log.info("SLC Detached bundle " + bundle.getSymbolicName() + " (" + + bundle.getBundleId() + ") started"); } /** Does nothing by default. */ diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java index 01b249253..21c7d49cd 100644 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java +++ b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java @@ -1,32 +1,5 @@ package org.argeo.slc.autoui; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.autoui.internal.DetachedExecutionServerImpl; -import org.osgi.framework.BundleContext; public class AutoUiActivator extends AbstractDetachedActivator { - private final Log log = LogFactory.getLog(getClass()); - - private DetachedExecutionServerImpl executionServer; - - public void startAutoBundle(BundleContext context) throws Exception { - Object obj = getStaticRefProvider().getStaticRef("executionServer"); - if (obj != null) - executionServer = (DetachedExecutionServerImpl) obj; - else - throw new DetachedException("Could not find execution server."); - - executionServer.init(context); - - context.registerService(DetachedExecutionServer.class.getName(), - executionServer, new Properties()); - log.info("AutoUi started"); - } - - public void stopAutoBundle(BundleContext context) throws Exception { - log.info("AutoUi stopped"); - } } diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/internal/DetachedExecutionServerImpl.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java similarity index 81% rename from org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/internal/DetachedExecutionServerImpl.java rename to org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java index cc6c97a3f..27fe50a39 100644 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/internal/DetachedExecutionServerImpl.java +++ b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java @@ -1,13 +1,5 @@ -package org.argeo.slc.autoui.internal; - -import org.argeo.slc.autoui.DetachedContextImpl; -import org.argeo.slc.autoui.DetachedDriver; -import org.argeo.slc.autoui.DetachedException; -import org.argeo.slc.autoui.DetachedExecutionServer; -import org.argeo.slc.autoui.DetachedStep; -import org.argeo.slc.autoui.DetachedStepAnswer; -import org.argeo.slc.autoui.DetachedStepRequest; -import org.argeo.slc.autoui.StaticRefProvider; +package org.argeo.slc.autoui; + import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java new file mode 100644 index 000000000..4a7f3e41b --- /dev/null +++ b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java @@ -0,0 +1,28 @@ +package org.argeo.slc.autoui; + +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; + +public class SimpleDetachedActivator extends AbstractDetachedActivator { + private final Log log = LogFactory.getLog(getClass()); + + private DetachedExecutionServerImpl executionServer; + + protected void startAutoBundle(BundleContext context) throws Exception { + Object obj = getStaticRefProvider().getStaticRef("executionServer"); + if (obj != null) + executionServer = (DetachedExecutionServerImpl) obj; + else + throw new DetachedException("Could not find execution server."); + + executionServer.init(context); + + context.registerService(DetachedExecutionServer.class.getName(), + executionServer, new Properties()); + log.info("SimpleDetachedActivator started"); + } + +} diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java index ef078aea2..a3a7e7a26 100644 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java +++ b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java @@ -2,8 +2,6 @@ package org.argeo.slc.autoui.rmi; import java.rmi.Naming; import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import java.util.Map; import java.util.TreeMap; diff --git a/org.argeo.slc.autoui/src/main/resources/META-INF/MANIFEST.MF b/org.argeo.slc.autoui/src/main/resources/META-INF/MANIFEST.MF index 112e547b1..765729687 100644 --- a/org.argeo.slc.autoui/src/main/resources/META-INF/MANIFEST.MF +++ b/org.argeo.slc.autoui/src/main/resources/META-INF/MANIFEST.MF @@ -1,29 +1,27 @@ Manifest-Version: 1.0 Export-Package: org.argeo.slc.autoui.rmi,org.argeo.slc.autoui;uses:="o - rg.apache.commons.logging,org.springframework.context.support,org.spr - ingframework.core.io,org.springframework.context,org.springframework. - beans.factory.xml,org.argeo.slc.autoui.internal,org.springframework.b - eans.factory.support,org.osgi.framework,org.springframework.beans.fac - tory",org.argeo.slc.autoui.internal;uses:="org.argeo.slc.autoui,org.o - sgi.framework",org.argeo.slc.autoui.drivers;uses:="org.argeo.slc.auto - ui" + rg.springframework.beans.factory.support,org.apache.commons.logging,o + rg.springframework.context.support,org.springframework.core.io,org.os + gi.framework,org.springframework.beans.factory.xml,org.springframewor + k.context,org.springframework.beans.factory",org.argeo.slc.autoui.dri + vers;uses:="org.argeo.slc.autoui" Built-By: mbaudier Tool: Bnd-0.0.255 Bundle-Name: SLC Auto UI Created-By: Apache Maven Bundle Plugin Bundle-Vendor: Argeo -Build-Jdk: 1.6.0_0 +Build-Jdk: 1.6.0 Bundle-Version: 0.11.1.SNAPSHOT -Bnd-LastModified: 1222532180778 +Bnd-LastModified: 1222605231968 Bundle-ManifestVersion: 2 Bundle-Activator: org.argeo.slc.autoui.AutoUiActivator Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Import-Package: org.apache.commons.logging,org.argeo.slc.autoui,org.ar - geo.slc.autoui.drivers,org.argeo.slc.autoui.internal,org.argeo.slc.au - toui.rmi,org.osgi.framework;version="1.4",org.springframework.beans.f - actory,org.springframework.beans.factory.support,org.springframework. - beans.factory.xml,org.springframework.context,org.springframework.con - text.support,org.springframework.core.io + geo.slc.autoui.drivers,org.argeo.slc.autoui.rmi,org.osgi.framework;ve + rsion="1.4",org.springframework.beans.factory,org.springframework.bea + ns.factory.support,org.springframework.beans.factory.xml,org.springfr + amework.context,org.springframework.context.support,org.springframewo + rk.core.io Bundle-SymbolicName: org.argeo.slc.autoui Bundle-DocURL: http://www.argeo.org Originally-Created-By: Apache Maven Bundle Plugin diff --git a/org.argeo.slc.autoui/src/main/resources/META-INF/slc/conf/applicationContext.xml b/org.argeo.slc.autoui/src/main/resources/META-INF/slc/conf/applicationContext.xml deleted file mode 100644 index 2deaa4dee..000000000 --- a/org.argeo.slc.autoui/src/main/resources/META-INF/slc/conf/applicationContext.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/org.argeo.slc.autoui/src/test/java/org/argeo/slc/detached/DetachedTest.java b/org.argeo.slc.autoui/src/test/java/org/argeo/slc/detached/DetachedTest.java index 09d7bba97..be8bc8c65 100644 --- a/org.argeo.slc.autoui/src/test/java/org/argeo/slc/detached/DetachedTest.java +++ b/org.argeo.slc.autoui/src/test/java/org/argeo/slc/detached/DetachedTest.java @@ -11,8 +11,10 @@ import org.argeo.slc.autoui.drivers.FileDriver; public class DetachedTest extends TestCase { public void testSendRequest() throws Exception { FileDriver client = new FileDriver(); - client.setRequestDir(new File( - "/home/mbaudier/dev/test/SLC/detachedRequests")); + File requestDir = new File( + "/home/mbaudier/dev/test/SLC/detachedRequests"); + requestDir.mkdirs(); + client.setRequestDir(requestDir); DetachedStepRequest request = new DetachedStepRequest(); request.setUuid(UUID.randomUUID().toString()); -- 2.39.2