From: Mathieu Baudier Date: Sun, 28 Sep 2008 13:05:37 +0000 (+0000) Subject: Rename SLC AutoUI in SLC Detached X-Git-Tag: argeo-slc-2.1.7~2537 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=6437f24e421a02ab9da1c3b11d711f022c3b4c87;p=gpl%2Fargeo-slc.git Rename SLC AutoUI in SLC Detached git-svn-id: https://svn.argeo.org/slc/trunk@1654 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/org.argeo.slc.autoui/.classpath b/org.argeo.slc.autoui/.classpath deleted file mode 100644 index 1aa73cdbf..000000000 --- a/org.argeo.slc.autoui/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/org.argeo.slc.autoui/.project b/org.argeo.slc.autoui/.project deleted file mode 100644 index 7e385953d..000000000 --- a/org.argeo.slc.autoui/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - org.argeo.slc.autoui - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - 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 index 6d67bdee8..000000000 --- a/org.argeo.slc.autoui/.settings/org.eclipse.jdt.core.prefs +++ /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 index 78b8c9f89..000000000 --- a/org.argeo.slc.autoui/.settings/org.maven.ide.eclipse.prefs +++ /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 index 4c526a48e..000000000 --- a/org.argeo.slc.autoui/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - 4.0.0 - - org.argeo.slc - argeo-slc - 0.11.1-SNAPSHOT - ../org.argeo.slc - - org.argeo.slc.autoui - SLC Auto UI - bundle - - - - - org.apache.felix - maven-bundle-plugin - 1.4.3 - true - - src/main/resources/META-INF - - - ${pom.artifactId} - - - org.argeo.slc.autoui.AutoUiActivator - - - org.argeo.slc.autoui.* - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.3 - 1.3 - - - - org.apache.maven.plugins - maven-source-plugin - - - - - - junit - junit - - - org.eclipse - osgi - 3.3.0-v20070530 - - - - org.springframework - spring-context - 2.0.8 - - - - org.codehaus.castor - castor - - - \ 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 index 877d8b674..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java +++ /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 index 21c7d49cd..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java +++ /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 index 6afeca770..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedClient.java +++ /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 index 5c4b2a6cb..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContext.java +++ /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 index 93676b414..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java +++ /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 index b97361087..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedDriver.java +++ /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 index f6ba5d168..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedException.java +++ /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 index 637eab8dd..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServer.java +++ /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 index 5cd4419f5..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java +++ /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 index cd20bb3ab..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStep.java +++ /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 index 9d3edd11b..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java +++ /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 index 65fda8836..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java +++ /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 index 5f6ae560e..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java +++ /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 index 8fb757f36..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/SpringStaticRefProvider.java +++ /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 index d0f2b07c5..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/StaticRefProvider.java +++ /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 index 263f63397..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/drivers/FileDriver.java +++ /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 index 00c27ba5c..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiContext.java +++ /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 index a776b4021..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServer.java +++ /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 index a3a7e7a26..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java +++ /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 index 2e3d1dab9..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/rmi/AutoUiTask.java +++ /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 index 765729687..000000000 --- a/org.argeo.slc.autoui/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,28 +0,0 @@ -Manifest-Version: 1.0 -Export-Package: org.argeo.slc.autoui.rmi,org.argeo.slc.autoui;uses:="o - 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 -Bundle-Version: 0.11.1.SNAPSHOT -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.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.detached/.classpath b/org.argeo.slc.detached/.classpath new file mode 100644 index 000000000..1aa73cdbf --- /dev/null +++ b/org.argeo.slc.detached/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.argeo.slc.detached/.project b/org.argeo.slc.detached/.project new file mode 100644 index 000000000..7e385953d --- /dev/null +++ b/org.argeo.slc.detached/.project @@ -0,0 +1,23 @@ + + + org.argeo.slc.autoui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + 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 index 000000000..6d67bdee8 --- /dev/null +++ b/org.argeo.slc.detached/.settings/org.eclipse.jdt.core.prefs @@ -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 index 000000000..78b8c9f89 --- /dev/null +++ b/org.argeo.slc.detached/.settings/org.maven.ide.eclipse.prefs @@ -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 index 000000000..4c526a48e --- /dev/null +++ b/org.argeo.slc.detached/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + + org.argeo.slc + argeo-slc + 0.11.1-SNAPSHOT + ../org.argeo.slc + + org.argeo.slc.autoui + SLC Auto UI + bundle + + + + + org.apache.felix + maven-bundle-plugin + 1.4.3 + true + + src/main/resources/META-INF + + + ${pom.artifactId} + + + org.argeo.slc.autoui.AutoUiActivator + + + org.argeo.slc.autoui.* + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.3 + 1.3 + + + + org.apache.maven.plugins + maven-source-plugin + + + + + + junit + junit + + + org.eclipse + osgi + 3.3.0-v20070530 + + + + org.springframework + spring-context + 2.0.8 + + + + org.codehaus.castor + castor + + + \ 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 index 000000000..877d8b674 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java @@ -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 index 000000000..21c7d49cd --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java @@ -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 index 000000000..6afeca770 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedClient.java @@ -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 index 000000000..5c4b2a6cb --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedContext.java @@ -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 index 000000000..93676b414 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java @@ -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 index 000000000..b97361087 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedDriver.java @@ -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 index 000000000..f6ba5d168 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedException.java @@ -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 index 000000000..637eab8dd --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedExecutionServer.java @@ -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 index 000000000..5cd4419f5 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedExecutionServerImpl.java @@ -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 index 000000000..cd20bb3ab --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStep.java @@ -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 index 000000000..9d3edd11b --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java @@ -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 index 000000000..65fda8836 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java @@ -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 index 000000000..5f6ae560e --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/SimpleDetachedActivator.java @@ -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 index 000000000..8fb757f36 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/SpringStaticRefProvider.java @@ -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 index 000000000..d0f2b07c5 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/StaticRefProvider.java @@ -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 index 000000000..263f63397 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/drivers/FileDriver.java @@ -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 index 000000000..00c27ba5c --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiContext.java @@ -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 index 000000000..a776b4021 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServer.java @@ -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 index 000000000..a3a7e7a26 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiServerImpl.java @@ -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 index 000000000..2e3d1dab9 --- /dev/null +++ b/org.argeo.slc.detached/src/main/java/org/argeo/slc/autoui/rmi/AutoUiTask.java @@ -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 index 000000000..765729687 --- /dev/null +++ b/org.argeo.slc.detached/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,28 @@ +Manifest-Version: 1.0 +Export-Package: org.argeo.slc.autoui.rmi,org.argeo.slc.autoui;uses:="o + 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 +Bundle-Version: 0.11.1.SNAPSHOT +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.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 +