]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Rename SLC AutoUI in SLC Detached
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 28 Sep 2008 13:05:37 +0000 (13:05 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 28 Sep 2008 13:05:37 +0000 (13:05 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1654 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

52 files changed:
org.argeo.slc.autoui/.classpath [deleted file]
org.argeo.slc.autoui/.project [deleted file]
org.argeo.slc.autoui/.settings/org.eclipse.jdt.core.prefs [deleted file]
org.argeo.slc.autoui/.settings/org.maven.ide.eclipse.prefs [deleted file]
org.argeo.slc.autoui/pom.xml [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedClient.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContext.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedDriver.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedException.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServer.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStep.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SpringStaticRefProvider.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/StaticRefProvider.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/drivers/FileDriver.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiContext.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServer.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiTask.java [deleted file]
org.argeo.slc.autoui/src/main/resources/META-INF/MANIFEST.MF [deleted file]
org.argeo.slc.detached/.classpath [new file with mode: 0644]
org.argeo.slc.detached/.project [new file with mode: 0644]
org.argeo.slc.detached/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.argeo.slc.detached/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
org.argeo.slc.detached/pom.xml [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedClient.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedContext.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedDriver.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedException.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedExecutionServer.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStep.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/SpringStaticRefProvider.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/StaticRefProvider.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/drivers/FileDriver.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiContext.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServer.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiTask.java [new file with mode: 0644]
org.argeo.slc.detached/src/main/resources/META-INF/MANIFEST.MF [new file with mode: 0644]

diff --git a/org.argeo.slc.autoui/.classpath b/org.argeo.slc.autoui/.classpath
deleted file mode 100644 (file)
index 1aa73cd..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src/main/java"/>
-       <classpathentry kind="src" path="src/main/resources"/>
-       <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.argeo.slc.autoui/.project b/org.argeo.slc.autoui/.project
deleted file mode 100644 (file)
index 7e38595..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.autoui</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.maven.ide.eclipse.maven2Builder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-               <nature>org.maven.ide.eclipse.maven2Nature</nature>
-       </natures>
-</projectDescription>
diff --git a/org.argeo.slc.autoui/.settings/org.eclipse.jdt.core.prefs b/org.argeo.slc.autoui/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index 6d67bde..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#Wed Sep 24 19:16:18 CEST 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
diff --git a/org.argeo.slc.autoui/.settings/org.maven.ide.eclipse.prefs b/org.argeo.slc.autoui/.settings/org.maven.ide.eclipse.prefs
deleted file mode 100644 (file)
index 78b8c9f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#Thu Sep 18 18:28:43 CEST 2008
-activeProfiles=
-eclipse.preferences.version=1
-filterResources=false
-includeModules=false
-resolveWorkspaceProjects=true
-resourceFilterGoals=process-resources resources\:testResources
-useMavenFolders=false
-version=1
diff --git a/org.argeo.slc.autoui/pom.xml b/org.argeo.slc.autoui/pom.xml
deleted file mode 100644 (file)
index 4c526a4..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc</artifactId>
-               <version>0.11.1-SNAPSHOT</version>
-               <relativePath>../org.argeo.slc</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.autoui</artifactId>
-       <name>SLC Auto UI</name>
-       <packaging>bundle</packaging>
-       <description />
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.felix</groupId>
-                               <artifactId>maven-bundle-plugin</artifactId>
-                               <version>1.4.3</version>
-                               <extensions>true</extensions>
-                               <configuration>
-                                       <manifestLocation>src/main/resources/META-INF</manifestLocation>
-                                       <instructions>
-                                               <Bundle-SymbolicName>
-                                                       ${pom.artifactId}
-                                               </Bundle-SymbolicName>
-                                               <Bundle-Activator>
-                                                       org.argeo.slc.autoui.AutoUiActivator
-                                               </Bundle-Activator>
-                                               <Export-Package>
-                                                       org.argeo.slc.autoui.*
-                                               </Export-Package>
-                                       </instructions>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                               <configuration>
-                                       <source>1.3</source>
-                                       <target>1.3</target>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-source-plugin</artifactId>
-                       </plugin>
-               </plugins>
-       </build>
-       <dependencies>
-               <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.eclipse</groupId>
-                       <artifactId>osgi</artifactId>
-                       <version>3.3.0-v20070530</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>org.springframework</groupId>
-                       <artifactId>spring-context</artifactId>
-                       <version>2.0.8</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>org.codehaus.castor</groupId>
-                       <artifactId>castor</artifactId>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
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
deleted file mode 100644 (file)
index 877d8b6..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-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;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.support.AbstractApplicationContext;
-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 {
-
-               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 {
-                       AbstractApplicationContext applicationContext = new GenericApplicationContext();
-                       XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
-                                       (BeanDefinitionRegistry) applicationContext);
-
-                       URL url = bundle
-                                       .getResource("META-INF/slc/conf/applicationContext.xml");
-                       if (url != null) {
-                               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);
-
-                       }
-
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       throw new Exception("Could not initialize application context");
-               } finally {
-                       cur.setContextClassLoader(save);
-               }
-
-               startAutoBundle(context);
-
-               log.info("SLC Detached bundle " + bundle.getSymbolicName() + " ("
-                               + bundle.getBundleId() + ") started");
-       }
-
-       /** Does nothing by default. */
-       protected void startAutoBundle(BundleContext context) throws Exception {
-
-       }
-
-       public final void stop(BundleContext context) throws Exception {
-               stopAutoBundle(context);
-
-               if (staticRefProvider != null) {
-                       staticRefProvider.close();
-               }
-
-       }
-
-       /** Does nothing by default. */
-       protected void stopAutoBundle(BundleContext context) throws Exception {
-
-       }
-
-       protected StaticRefProvider getStaticRefProvider() {
-               return staticRefProvider;
-       }
-}
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
deleted file mode 100644 (file)
index 21c7d49..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.autoui;
-
-
-public class AutoUiActivator extends AbstractDetachedActivator {
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedClient.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedClient.java
deleted file mode 100644 (file)
index 6afeca7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.autoui;
-
-public interface DetachedClient {
-       public void sendRequest(DetachedStepRequest request) throws Exception;
-
-       /** Blocks until next answer. */
-       public DetachedStepAnswer receiveAnswer() throws Exception;
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContext.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContext.java
deleted file mode 100644 (file)
index 5c4b2a6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.argeo.slc.autoui;
-
-import java.util.List;
-
-public interface DetachedContext {
-       public Object getDynamicRef(String ref);
-
-       public void setDynamicRef(String ref, Object obj);
-
-       public String getCurrentPath();
-
-       public List getExecutedPaths();
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java
deleted file mode 100644 (file)
index 93676b4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.argeo.slc.autoui;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.Vector;
-
-public class DetachedContextImpl implements DetachedContext {
-       private List executedPaths = new Vector();
-       private String currentPath;
-       private Map dynamicRefs = new TreeMap();
-
-       public String getCurrentPath() {
-               return currentPath;
-       }
-
-       public void setDynamicRef(String ref, Object obj) {
-               dynamicRefs.put(ref, obj);
-       }
-
-       public Object getDynamicRef(String ref) {
-               if (dynamicRefs.containsKey(ref))
-                       return dynamicRefs.get(ref);
-               else
-                       return null;
-       }
-
-       public List getExecutedPaths() {
-               return new ArrayList(executedPaths);
-       }
-
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedDriver.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedDriver.java
deleted file mode 100644 (file)
index b973610..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.autoui;
-
-public interface DetachedDriver {
-       /** Blocks until it receives a request. */
-       public DetachedStepRequest receiveRequest() throws Exception;
-       public void sendAnswer(DetachedStepAnswer answer) throws Exception;
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedException.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedException.java
deleted file mode 100644 (file)
index f6ba5d1..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.argeo.slc.autoui;
-
-public class DetachedException extends RuntimeException {
-       private Exception cause;
-
-       public DetachedException(String message) {
-               super(message);
-       }
-
-       public DetachedException(String message, Exception cause) {
-               super(message);
-               this.cause = cause;
-       }
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServer.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServer.java
deleted file mode 100644 (file)
index 637eab8..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.autoui;
-
-public interface DetachedExecutionServer {
-       public DetachedStepAnswer executeStep(DetachedStepRequest request);
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java
deleted file mode 100644 (file)
index 5cd4419..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.argeo.slc.autoui;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-public class DetachedExecutionServerImpl implements DetachedExecutionServer {
-       private final DetachedContextImpl detachedContext;
-
-       private BundleContext bundleContext;
-       private DetachedDriver driver;
-
-       private boolean active = false;
-
-       public void setDriver(DetachedDriver driver) {
-               this.driver = driver;
-       }
-
-       public DetachedExecutionServerImpl() {
-               detachedContext = new DetachedContextImpl();
-       }
-
-       public DetachedStepAnswer executeStep(DetachedStepRequest request) {
-               try {
-                       DetachedStep step = null;
-
-                       // Find step
-                       ServiceReference[] refs = bundleContext.getAllServiceReferences(
-                                       StaticRefProvider.class.getName(), null);
-                       for (int i = 0; i < refs.length; i++) {
-                               StaticRefProvider provider = (StaticRefProvider) bundleContext
-                                               .getService(refs[i]);
-                               Object obj = provider.getStaticRef(request.getStepRef());
-                               if (obj != null) {
-                                       step = (DetachedStep) obj;
-                                       break;
-                               }
-                       }
-
-                       if (step == null)
-                               throw new DetachedException("Could not find step with ref "
-                                               + request.getStepRef());
-
-                       return step.execute(detachedContext, request);
-               } catch (DetachedException e) {
-                       throw e;
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       throw new DetachedException(
-                                       "Unexpected exception while executing request " + request,
-                                       e);
-               }
-       }
-
-       public void init(BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-               Thread driverThread = new Thread(new Runnable() {
-
-                       public void run() {
-                               while (active) {
-                                       try {
-                                               DetachedStepRequest request = driver.receiveRequest();
-                                               executeStep(request);
-                                       } catch (Exception e) {
-                                               if (e instanceof RuntimeException)
-                                                       throw (RuntimeException) e;
-                                               else
-                                                       e.printStackTrace();
-                                       }
-                               }
-
-                       }
-               }, "driverThread");
-
-               active = true;
-
-               driverThread.start();
-       }
-
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStep.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStep.java
deleted file mode 100644 (file)
index cd20bb3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.autoui;
-
-
-public interface DetachedStep {
-       public DetachedStepAnswer execute(DetachedContext detachedContext,
-                       DetachedStepRequest detachedStepRequest);
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java
deleted file mode 100644 (file)
index 9d3edd1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.argeo.slc.autoui;
-
-import java.util.Properties;
-
-public class DetachedStepAnswer {
-       public static int PROCESSED = 0;
-       public static int ERROR = 1;
-       public static int SKIPPED = 2;
-
-       private Properties outputParameters;
-       private int outputStatus;
-       private String log;
-
-       public Properties getOutputParameters() {
-               return outputParameters;
-       }
-
-       public void setOutputParameters(Properties outputParameters) {
-               this.outputParameters = outputParameters;
-       }
-
-       public int getOutputStatus() {
-               return outputStatus;
-       }
-
-       public void setOutputStatus(int outputStatus) {
-               this.outputStatus = outputStatus;
-       }
-
-       public String getLog() {
-               return log;
-       }
-
-       public void setLog(String log) {
-               this.log = log;
-       }
-
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java
deleted file mode 100644 (file)
index 65fda88..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.argeo.slc.autoui;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-public class DetachedStepRequest implements Serializable {
-       private String uuid;
-       private Properties inputParameters;
-       private String stepRef;
-       private String path;
-
-       public Properties getInputParameters() {
-               return inputParameters;
-       }
-
-       public void setInputParameters(Properties inputParameters) {
-               this.inputParameters = inputParameters;
-       }
-
-       public String getStepRef() {
-               return stepRef;
-       }
-
-       public void setStepRef(String stepRef) {
-               this.stepRef = stepRef;
-       }
-
-       public String getPath() {
-               return path;
-       }
-
-       public void setPath(String path) {
-               this.path = path;
-       }
-
-       public String getUuid() {
-               return uuid;
-       }
-
-       public void setUuid(String uuid) {
-               this.uuid = uuid;
-       }
-}
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
deleted file mode 100644 (file)
index 5f6ae56..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.argeo.slc.autoui;
-
-import java.util.Properties;
-
-import org.osgi.framework.BundleContext;
-
-public class SimpleDetachedActivator extends AbstractDetachedActivator {
-       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());
-       }
-
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SpringStaticRefProvider.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SpringStaticRefProvider.java
deleted file mode 100644 (file)
index 8fb757f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.argeo.slc.autoui;
-
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public class SpringStaticRefProvider implements StaticRefProvider {
-       private final ConfigurableApplicationContext applicationContext;
-
-       public SpringStaticRefProvider(
-                       ConfigurableApplicationContext applicationContext) {
-               this.applicationContext = applicationContext;
-       }
-
-       public Object getStaticRef(String id) {
-               try {
-                       return applicationContext.getBean(id);
-               } catch (NoSuchBeanDefinitionException e) {
-                       // silent
-                       return null;
-               }
-       }
-
-       public void close(){
-               applicationContext.close();
-       }
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/StaticRefProvider.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/StaticRefProvider.java
deleted file mode 100644 (file)
index d0f2b07..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.argeo.slc.autoui;
-
-public interface StaticRefProvider {
-       /** Returns null if no such ref. */
-       public Object getStaticRef(String id);
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/drivers/FileDriver.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/drivers/FileDriver.java
deleted file mode 100644 (file)
index 263f633..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.argeo.slc.autoui.drivers;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import org.argeo.slc.autoui.DetachedClient;
-import org.argeo.slc.autoui.DetachedDriver;
-import org.argeo.slc.autoui.DetachedException;
-import org.argeo.slc.autoui.DetachedStepAnswer;
-import org.argeo.slc.autoui.DetachedStepRequest;
-
-public class FileDriver implements DetachedDriver, DetachedClient {
-       private File requestDir;
-       private File answerDir;
-
-       public synchronized DetachedStepRequest receiveRequest() throws Exception {
-               if (!requestDir.exists())
-                       throw new DetachedException("Request dir "
-                                       + requestDir.getCanonicalPath() + " does not exist.");
-
-               File file = null;
-               while (file == null) {
-                       File[] files = requestDir.listFiles();
-                       if (files.length > 0)
-                               file = files[0];
-                       else
-                               Thread.sleep(1000);
-               }
-
-               ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
-               DetachedStepRequest request = (DetachedStepRequest) in.readObject();
-               in.close();
-
-               file.delete();// move it to a processed dir instead?
-               return request;
-       }
-
-       public void sendAnswer(DetachedStepAnswer answer) throws Exception {
-               // TODO Auto-generated method stub
-
-       }
-
-       public DetachedStepAnswer receiveAnswer() throws Exception {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public void sendRequest(DetachedStepRequest request) throws Exception {
-               File file = new File(requestDir.getPath() + File.separator
-                               + request.getUuid());
-               ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(
-                               file));
-               out.writeObject(request);
-               out.close();
-       }
-
-       public void setRequestDir(File requestDir) {
-               this.requestDir = requestDir;
-       }
-
-       public void setAnswerDir(File answerDir) {
-               this.answerDir = answerDir;
-       }
-
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiContext.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiContext.java
deleted file mode 100644 (file)
index 00c27ba..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.autoui.rmi;
-
-public interface AutoUiContext {
-       public Object getLocalRef(String key);
-
-       public void setLocalRef(String key, Object ref);
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServer.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServer.java
deleted file mode 100644 (file)
index a776b40..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.autoui.rmi;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-public interface AutoUiServer extends Remote {
-       public Object executeTask(AutoUiTask task) throws RemoteException;
-}
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
deleted file mode 100644 (file)
index a3a7e7a..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.argeo.slc.autoui.rmi;
-
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class AutoUiServerImpl extends UnicastRemoteObject implements
-               AutoUiServer, AutoUiContext {
-       private Map map = new TreeMap();
-
-       public AutoUiServerImpl() throws RemoteException {
-               super();
-       }
-
-       public Object executeTask(AutoUiTask task) throws RemoteException {
-               try {
-                       return task.execute(this);
-               } catch (Exception e) {
-                       throw new RemoteException("Coul not execute task.", e);
-               }
-       }
-
-       public Object getLocalRef(String key) {
-               return map.get(key);
-       }
-
-       public void setLocalRef(String key, Object ref) {
-               map.put(key, ref);
-       }
-
-       public static void main(String[] args) {
-               if (System.getSecurityManager() == null) {
-                       System.setSecurityManager(new SecurityManager());
-               }
-               try {
-                       String name = "AutoUiServer";
-                       AutoUiServer engine = new AutoUiServerImpl();
-                       // AutoUiServer stub = (AutoUiServer) UnicastRemoteObject
-                       // .exportObject(engine, 0);
-                       // Registry registry = LocateRegistry.getRegistry();
-                       // registry.rebind(name, stub);
-                       Naming.rebind(name, engine);
-                       System.out.println("AutoUiServer bound");
-
-               } catch (Exception e) {
-                       System.err.println("AutoUiServer exception:");
-                       e.printStackTrace();
-               }
-
-       }
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiTask.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiTask.java
deleted file mode 100644 (file)
index 2e3d1da..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.autoui.rmi;
-
-import java.io.Serializable;
-
-public interface AutoUiTask extends Serializable {
-       public Object execute(AutoUiContext context) throws Exception;
-}
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
deleted file mode 100644 (file)
index 7657296..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-Manifest-Version: 1.0\r
-Export-Package: org.argeo.slc.autoui.rmi,org.argeo.slc.autoui;uses:="o\r
- rg.springframework.beans.factory.support,org.apache.commons.logging,o\r
- rg.springframework.context.support,org.springframework.core.io,org.os\r
- gi.framework,org.springframework.beans.factory.xml,org.springframewor\r
- k.context,org.springframework.beans.factory",org.argeo.slc.autoui.dri\r
- vers;uses:="org.argeo.slc.autoui"\r
-Built-By: mbaudier\r
-Tool: Bnd-0.0.255\r
-Bundle-Name: SLC Auto UI\r
-Created-By: Apache Maven Bundle Plugin\r
-Bundle-Vendor: Argeo\r
-Build-Jdk: 1.6.0\r
-Bundle-Version: 0.11.1.SNAPSHOT\r
-Bnd-LastModified: 1222605231968\r
-Bundle-ManifestVersion: 2\r
-Bundle-Activator: org.argeo.slc.autoui.AutoUiActivator\r
-Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt\r
-Import-Package: org.apache.commons.logging,org.argeo.slc.autoui,org.ar\r
- geo.slc.autoui.drivers,org.argeo.slc.autoui.rmi,org.osgi.framework;ve\r
- rsion="1.4",org.springframework.beans.factory,org.springframework.bea\r
- ns.factory.support,org.springframework.beans.factory.xml,org.springfr\r
- amework.context,org.springframework.context.support,org.springframewo\r
- rk.core.io\r
-Bundle-SymbolicName: org.argeo.slc.autoui\r
-Bundle-DocURL: http://www.argeo.org\r
-Originally-Created-By: Apache Maven Bundle Plugin\r
-\r
diff --git a/org.argeo.slc.detached/.classpath b/org.argeo.slc.detached/.classpath
new file mode 100644 (file)
index 0000000..1aa73cd
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src/main/java"/>
+       <classpathentry kind="src" path="src/main/resources"/>
+       <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.detached/.project b/org.argeo.slc.detached/.project
new file mode 100644 (file)
index 0000000..7e38595
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.autoui</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.maven.ide.eclipse.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.maven.ide.eclipse.maven2Nature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.argeo.slc.detached/.settings/org.eclipse.jdt.core.prefs b/org.argeo.slc.detached/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..6d67bde
--- /dev/null
@@ -0,0 +1,12 @@
+#Wed Sep 24 19:16:18 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/org.argeo.slc.detached/.settings/org.maven.ide.eclipse.prefs b/org.argeo.slc.detached/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..78b8c9f
--- /dev/null
@@ -0,0 +1,9 @@
+#Thu Sep 18 18:28:43 CEST 2008
+activeProfiles=
+eclipse.preferences.version=1
+filterResources=false
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+useMavenFolders=false
+version=1
diff --git a/org.argeo.slc.detached/pom.xml b/org.argeo.slc.detached/pom.xml
new file mode 100644 (file)
index 0000000..4c526a4
--- /dev/null
@@ -0,0 +1,73 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>0.11.1-SNAPSHOT</version>
+               <relativePath>../org.argeo.slc</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.autoui</artifactId>
+       <name>SLC Auto UI</name>
+       <packaging>bundle</packaging>
+       <description />
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>1.4.3</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <manifestLocation>src/main/resources/META-INF</manifestLocation>
+                                       <instructions>
+                                               <Bundle-SymbolicName>
+                                                       ${pom.artifactId}
+                                               </Bundle-SymbolicName>
+                                               <Bundle-Activator>
+                                                       org.argeo.slc.autoui.AutoUiActivator
+                                               </Bundle-Activator>
+                                               <Export-Package>
+                                                       org.argeo.slc.autoui.*
+                                               </Export-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <configuration>
+                                       <source>1.3</source>
+                                       <target>1.3</target>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-source-plugin</artifactId>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.eclipse</groupId>
+                       <artifactId>osgi</artifactId>
+                       <version>3.3.0-v20070530</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-context</artifactId>
+                       <version>2.0.8</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.codehaus.castor</groupId>
+                       <artifactId>castor</artifactId>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java
new file mode 100644 (file)
index 0000000..877d8b6
--- /dev/null
@@ -0,0 +1,90 @@
+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;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.AbstractApplicationContext;
+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 {
+
+               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 {
+                       AbstractApplicationContext applicationContext = new GenericApplicationContext();
+                       XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
+                                       (BeanDefinitionRegistry) applicationContext);
+
+                       URL url = bundle
+                                       .getResource("META-INF/slc/conf/applicationContext.xml");
+                       if (url != null) {
+                               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);
+
+                       }
+
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw new Exception("Could not initialize application context");
+               } finally {
+                       cur.setContextClassLoader(save);
+               }
+
+               startAutoBundle(context);
+
+               log.info("SLC Detached bundle " + bundle.getSymbolicName() + " ("
+                               + bundle.getBundleId() + ") started");
+       }
+
+       /** Does nothing by default. */
+       protected void startAutoBundle(BundleContext context) throws Exception {
+
+       }
+
+       public final void stop(BundleContext context) throws Exception {
+               stopAutoBundle(context);
+
+               if (staticRefProvider != null) {
+                       staticRefProvider.close();
+               }
+
+       }
+
+       /** Does nothing by default. */
+       protected void stopAutoBundle(BundleContext context) throws Exception {
+
+       }
+
+       protected StaticRefProvider getStaticRefProvider() {
+               return staticRefProvider;
+       }
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java
new file mode 100644 (file)
index 0000000..21c7d49
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.autoui;
+
+
+public class AutoUiActivator extends AbstractDetachedActivator {
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedClient.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedClient.java
new file mode 100644 (file)
index 0000000..6afeca7
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc.autoui;
+
+public interface DetachedClient {
+       public void sendRequest(DetachedStepRequest request) throws Exception;
+
+       /** Blocks until next answer. */
+       public DetachedStepAnswer receiveAnswer() throws Exception;
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedContext.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedContext.java
new file mode 100644 (file)
index 0000000..5c4b2a6
--- /dev/null
@@ -0,0 +1,13 @@
+package org.argeo.slc.autoui;
+
+import java.util.List;
+
+public interface DetachedContext {
+       public Object getDynamicRef(String ref);
+
+       public void setDynamicRef(String ref, Object obj);
+
+       public String getCurrentPath();
+
+       public List getExecutedPaths();
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java
new file mode 100644 (file)
index 0000000..93676b4
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.slc.autoui;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.Vector;
+
+public class DetachedContextImpl implements DetachedContext {
+       private List executedPaths = new Vector();
+       private String currentPath;
+       private Map dynamicRefs = new TreeMap();
+
+       public String getCurrentPath() {
+               return currentPath;
+       }
+
+       public void setDynamicRef(String ref, Object obj) {
+               dynamicRefs.put(ref, obj);
+       }
+
+       public Object getDynamicRef(String ref) {
+               if (dynamicRefs.containsKey(ref))
+                       return dynamicRefs.get(ref);
+               else
+                       return null;
+       }
+
+       public List getExecutedPaths() {
+               return new ArrayList(executedPaths);
+       }
+
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedDriver.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedDriver.java
new file mode 100644 (file)
index 0000000..b973610
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.autoui;
+
+public interface DetachedDriver {
+       /** Blocks until it receives a request. */
+       public DetachedStepRequest receiveRequest() throws Exception;
+       public void sendAnswer(DetachedStepAnswer answer) throws Exception;
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedException.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedException.java
new file mode 100644 (file)
index 0000000..f6ba5d1
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.autoui;
+
+public class DetachedException extends RuntimeException {
+       private Exception cause;
+
+       public DetachedException(String message) {
+               super(message);
+       }
+
+       public DetachedException(String message, Exception cause) {
+               super(message);
+               this.cause = cause;
+       }
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedExecutionServer.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedExecutionServer.java
new file mode 100644 (file)
index 0000000..637eab8
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.autoui;
+
+public interface DetachedExecutionServer {
+       public DetachedStepAnswer executeStep(DetachedStepRequest request);
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java
new file mode 100644 (file)
index 0000000..5cd4419
--- /dev/null
@@ -0,0 +1,79 @@
+package org.argeo.slc.autoui;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public class DetachedExecutionServerImpl implements DetachedExecutionServer {
+       private final DetachedContextImpl detachedContext;
+
+       private BundleContext bundleContext;
+       private DetachedDriver driver;
+
+       private boolean active = false;
+
+       public void setDriver(DetachedDriver driver) {
+               this.driver = driver;
+       }
+
+       public DetachedExecutionServerImpl() {
+               detachedContext = new DetachedContextImpl();
+       }
+
+       public DetachedStepAnswer executeStep(DetachedStepRequest request) {
+               try {
+                       DetachedStep step = null;
+
+                       // Find step
+                       ServiceReference[] refs = bundleContext.getAllServiceReferences(
+                                       StaticRefProvider.class.getName(), null);
+                       for (int i = 0; i < refs.length; i++) {
+                               StaticRefProvider provider = (StaticRefProvider) bundleContext
+                                               .getService(refs[i]);
+                               Object obj = provider.getStaticRef(request.getStepRef());
+                               if (obj != null) {
+                                       step = (DetachedStep) obj;
+                                       break;
+                               }
+                       }
+
+                       if (step == null)
+                               throw new DetachedException("Could not find step with ref "
+                                               + request.getStepRef());
+
+                       return step.execute(detachedContext, request);
+               } catch (DetachedException e) {
+                       throw e;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw new DetachedException(
+                                       "Unexpected exception while executing request " + request,
+                                       e);
+               }
+       }
+
+       public void init(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+               Thread driverThread = new Thread(new Runnable() {
+
+                       public void run() {
+                               while (active) {
+                                       try {
+                                               DetachedStepRequest request = driver.receiveRequest();
+                                               executeStep(request);
+                                       } catch (Exception e) {
+                                               if (e instanceof RuntimeException)
+                                                       throw (RuntimeException) e;
+                                               else
+                                                       e.printStackTrace();
+                                       }
+                               }
+
+                       }
+               }, "driverThread");
+
+               active = true;
+
+               driverThread.start();
+       }
+
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStep.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStep.java
new file mode 100644 (file)
index 0000000..cd20bb3
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.autoui;
+
+
+public interface DetachedStep {
+       public DetachedStepAnswer execute(DetachedContext detachedContext,
+                       DetachedStepRequest detachedStepRequest);
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java
new file mode 100644 (file)
index 0000000..9d3edd1
--- /dev/null
@@ -0,0 +1,38 @@
+package org.argeo.slc.autoui;
+
+import java.util.Properties;
+
+public class DetachedStepAnswer {
+       public static int PROCESSED = 0;
+       public static int ERROR = 1;
+       public static int SKIPPED = 2;
+
+       private Properties outputParameters;
+       private int outputStatus;
+       private String log;
+
+       public Properties getOutputParameters() {
+               return outputParameters;
+       }
+
+       public void setOutputParameters(Properties outputParameters) {
+               this.outputParameters = outputParameters;
+       }
+
+       public int getOutputStatus() {
+               return outputStatus;
+       }
+
+       public void setOutputStatus(int outputStatus) {
+               this.outputStatus = outputStatus;
+       }
+
+       public String getLog() {
+               return log;
+       }
+
+       public void setLog(String log) {
+               this.log = log;
+       }
+
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java
new file mode 100644 (file)
index 0000000..65fda88
--- /dev/null
@@ -0,0 +1,43 @@
+package org.argeo.slc.autoui;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+public class DetachedStepRequest implements Serializable {
+       private String uuid;
+       private Properties inputParameters;
+       private String stepRef;
+       private String path;
+
+       public Properties getInputParameters() {
+               return inputParameters;
+       }
+
+       public void setInputParameters(Properties inputParameters) {
+               this.inputParameters = inputParameters;
+       }
+
+       public String getStepRef() {
+               return stepRef;
+       }
+
+       public void setStepRef(String stepRef) {
+               this.stepRef = stepRef;
+       }
+
+       public String getPath() {
+               return path;
+       }
+
+       public void setPath(String path) {
+               this.path = path;
+       }
+
+       public String getUuid() {
+               return uuid;
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java
new file mode 100644 (file)
index 0000000..5f6ae56
--- /dev/null
@@ -0,0 +1,23 @@
+package org.argeo.slc.autoui;
+
+import java.util.Properties;
+
+import org.osgi.framework.BundleContext;
+
+public class SimpleDetachedActivator extends AbstractDetachedActivator {
+       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());
+       }
+
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/SpringStaticRefProvider.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/SpringStaticRefProvider.java
new file mode 100644 (file)
index 0000000..8fb757f
--- /dev/null
@@ -0,0 +1,26 @@
+package org.argeo.slc.autoui;
+
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.ConfigurableApplicationContext;
+
+public class SpringStaticRefProvider implements StaticRefProvider {
+       private final ConfigurableApplicationContext applicationContext;
+
+       public SpringStaticRefProvider(
+                       ConfigurableApplicationContext applicationContext) {
+               this.applicationContext = applicationContext;
+       }
+
+       public Object getStaticRef(String id) {
+               try {
+                       return applicationContext.getBean(id);
+               } catch (NoSuchBeanDefinitionException e) {
+                       // silent
+                       return null;
+               }
+       }
+
+       public void close(){
+               applicationContext.close();
+       }
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/StaticRefProvider.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/StaticRefProvider.java
new file mode 100644 (file)
index 0000000..d0f2b07
--- /dev/null
@@ -0,0 +1,6 @@
+package org.argeo.slc.autoui;
+
+public interface StaticRefProvider {
+       /** Returns null if no such ref. */
+       public Object getStaticRef(String id);
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/drivers/FileDriver.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/drivers/FileDriver.java
new file mode 100644 (file)
index 0000000..263f633
--- /dev/null
@@ -0,0 +1,68 @@
+package org.argeo.slc.autoui.drivers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.argeo.slc.autoui.DetachedClient;
+import org.argeo.slc.autoui.DetachedDriver;
+import org.argeo.slc.autoui.DetachedException;
+import org.argeo.slc.autoui.DetachedStepAnswer;
+import org.argeo.slc.autoui.DetachedStepRequest;
+
+public class FileDriver implements DetachedDriver, DetachedClient {
+       private File requestDir;
+       private File answerDir;
+
+       public synchronized DetachedStepRequest receiveRequest() throws Exception {
+               if (!requestDir.exists())
+                       throw new DetachedException("Request dir "
+                                       + requestDir.getCanonicalPath() + " does not exist.");
+
+               File file = null;
+               while (file == null) {
+                       File[] files = requestDir.listFiles();
+                       if (files.length > 0)
+                               file = files[0];
+                       else
+                               Thread.sleep(1000);
+               }
+
+               ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
+               DetachedStepRequest request = (DetachedStepRequest) in.readObject();
+               in.close();
+
+               file.delete();// move it to a processed dir instead?
+               return request;
+       }
+
+       public void sendAnswer(DetachedStepAnswer answer) throws Exception {
+               // TODO Auto-generated method stub
+
+       }
+
+       public DetachedStepAnswer receiveAnswer() throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public void sendRequest(DetachedStepRequest request) throws Exception {
+               File file = new File(requestDir.getPath() + File.separator
+                               + request.getUuid());
+               ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(
+                               file));
+               out.writeObject(request);
+               out.close();
+       }
+
+       public void setRequestDir(File requestDir) {
+               this.requestDir = requestDir;
+       }
+
+       public void setAnswerDir(File answerDir) {
+               this.answerDir = answerDir;
+       }
+
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiContext.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiContext.java
new file mode 100644 (file)
index 0000000..00c27ba
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.autoui.rmi;
+
+public interface AutoUiContext {
+       public Object getLocalRef(String key);
+
+       public void setLocalRef(String key, Object ref);
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServer.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServer.java
new file mode 100644 (file)
index 0000000..a776b40
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc.autoui.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface AutoUiServer extends Remote {
+       public Object executeTask(AutoUiTask task) throws RemoteException;
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java
new file mode 100644 (file)
index 0000000..a3a7e7a
--- /dev/null
@@ -0,0 +1,53 @@
+package org.argeo.slc.autoui.rmi;
+
+import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class AutoUiServerImpl extends UnicastRemoteObject implements
+               AutoUiServer, AutoUiContext {
+       private Map map = new TreeMap();
+
+       public AutoUiServerImpl() throws RemoteException {
+               super();
+       }
+
+       public Object executeTask(AutoUiTask task) throws RemoteException {
+               try {
+                       return task.execute(this);
+               } catch (Exception e) {
+                       throw new RemoteException("Coul not execute task.", e);
+               }
+       }
+
+       public Object getLocalRef(String key) {
+               return map.get(key);
+       }
+
+       public void setLocalRef(String key, Object ref) {
+               map.put(key, ref);
+       }
+
+       public static void main(String[] args) {
+               if (System.getSecurityManager() == null) {
+                       System.setSecurityManager(new SecurityManager());
+               }
+               try {
+                       String name = "AutoUiServer";
+                       AutoUiServer engine = new AutoUiServerImpl();
+                       // AutoUiServer stub = (AutoUiServer) UnicastRemoteObject
+                       // .exportObject(engine, 0);
+                       // Registry registry = LocateRegistry.getRegistry();
+                       // registry.rebind(name, stub);
+                       Naming.rebind(name, engine);
+                       System.out.println("AutoUiServer bound");
+
+               } catch (Exception e) {
+                       System.err.println("AutoUiServer exception:");
+                       e.printStackTrace();
+               }
+
+       }
+}
diff --git a/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiTask.java b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiTask.java
new file mode 100644 (file)
index 0000000..2e3d1da
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.autoui.rmi;
+
+import java.io.Serializable;
+
+public interface AutoUiTask extends Serializable {
+       public Object execute(AutoUiContext context) throws Exception;
+}
diff --git a/org.argeo.slc.detached/src/main/resources/META-INF/MANIFEST.MF b/org.argeo.slc.detached/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..7657296
--- /dev/null
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0\r
+Export-Package: org.argeo.slc.autoui.rmi,org.argeo.slc.autoui;uses:="o\r
+ rg.springframework.beans.factory.support,org.apache.commons.logging,o\r
+ rg.springframework.context.support,org.springframework.core.io,org.os\r
+ gi.framework,org.springframework.beans.factory.xml,org.springframewor\r
+ k.context,org.springframework.beans.factory",org.argeo.slc.autoui.dri\r
+ vers;uses:="org.argeo.slc.autoui"\r
+Built-By: mbaudier\r
+Tool: Bnd-0.0.255\r
+Bundle-Name: SLC Auto UI\r
+Created-By: Apache Maven Bundle Plugin\r
+Bundle-Vendor: Argeo\r
+Build-Jdk: 1.6.0\r
+Bundle-Version: 0.11.1.SNAPSHOT\r
+Bnd-LastModified: 1222605231968\r
+Bundle-ManifestVersion: 2\r
+Bundle-Activator: org.argeo.slc.autoui.AutoUiActivator\r
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt\r
+Import-Package: org.apache.commons.logging,org.argeo.slc.autoui,org.ar\r
+ geo.slc.autoui.drivers,org.argeo.slc.autoui.rmi,org.osgi.framework;ve\r
+ rsion="1.4",org.springframework.beans.factory,org.springframework.bea\r
+ ns.factory.support,org.springframework.beans.factory.xml,org.springfr\r
+ amework.context,org.springframework.context.support,org.springframewo\r
+ rk.core.io\r
+Bundle-SymbolicName: org.argeo.slc.autoui\r
+Bundle-DocURL: http://www.argeo.org\r
+Originally-Created-By: Apache Maven Bundle Plugin\r
+\r