]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Start introducing the interfaces
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 26 Sep 2008 18:05:57 +0000 (18:05 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 26 Sep 2008 18:05:57 +0000 (18:05 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1643 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.autoui/.classpath
org.argeo.slc.autoui/pom.xml
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractAutoActivator.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiApplication.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiStep.java [deleted file]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContext.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStep.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java [new file with mode: 0644]

index c3624f87cec710f92cfac0f17204466abf8b1bbf..1aa73cdbf084050c2f4611c2f74041009d5307dc 100644 (file)
@@ -1,6 +1,7 @@
 <?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"/>
index 4bf4354928a42d7180af1ff8b9988f0e27a5f4b1..c47610cc36dd63d2784352c1e5cc372278252f22 100644 (file)
                </plugins>
        </build>
        <dependencies>
-               <!-- 
-                       <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       </dependency>
-                       <dependency>
-                       <groupId>commons-logging</groupId>
-                       <artifactId>commons-logging</artifactId>
-                       </dependency>
-                       <dependency>
-                       <groupId>log4j</groupId>
-                       <artifactId>log4j</artifactId>
-                       </dependency>
-               -->
-
-               <!-- OSGi 
-                       <dependency>
-                       <groupId>org.apache.felix</groupId>
-                       <artifactId>org.osgi.core</artifactId>
-                       <version>1.0.0</version>
-                       </dependency>
-               -->
                <dependency>
                        <groupId>org.eclipse</groupId>
                        <artifactId>osgi</artifactId>
@@ -83,6 +61,9 @@
                        <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/AbstractAutoActivator.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractAutoActivator.java
deleted file mode 100644 (file)
index 59c9746..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.argeo.slc.autoui;
-
-import java.net.URL;
-
-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 AbstractAutoActivator implements BundleActivator {
-       private AbstractApplicationContext applicationContext;
-
-       public final void start(BundleContext context) throws Exception {
-               ClassLoader classLoader = getClass().getClassLoader();
-
-               Thread cur = Thread.currentThread();
-               ClassLoader save = cur.getContextClassLoader();
-               cur.setContextClassLoader(classLoader);
-
-               try {
-                       // applicationContext = new ClassPathXmlApplicationContext(
-                       // "/slc/conf/applicationContext.xml");
-
-                       applicationContext = new GenericApplicationContext();
-                       XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
-                                       (BeanDefinitionRegistry) applicationContext);
-                       Bundle bundle = context.getBundle();
-
-                       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));
-                       }
-
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       throw new Exception("Could not initialize application context");
-               } finally {
-                       cur.setContextClassLoader(save);
-               }
-
-               startAutoBundle(context);
-       }
-
-       /** Does nothing by default. */
-       protected void startAutoBundle(BundleContext context) throws Exception {
-
-       }
-
-       public final void stop(BundleContext context) throws Exception {
-               stopAutoBundle(context);
-
-               if (applicationContext != null) {
-                       applicationContext.close();
-               }
-
-       }
-
-       /** Does nothing by default. */
-       protected void stopAutoBundle(BundleContext context) throws Exception {
-
-       }
-
-       public Object getStaticRef(String id) {
-               return applicationContext.getBean(id);
-       }
-
-}
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
new file mode 100644 (file)
index 0000000..7f18d50
--- /dev/null
@@ -0,0 +1,74 @@
+package org.argeo.slc.autoui;
+
+import java.net.URL;
+
+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 AbstractApplicationContext applicationContext;
+
+       public final void start(BundleContext context) throws Exception {
+               ClassLoader classLoader = getClass().getClassLoader();
+
+               Thread cur = Thread.currentThread();
+               ClassLoader save = cur.getContextClassLoader();
+               cur.setContextClassLoader(classLoader);
+
+               try {
+                       // applicationContext = new ClassPathXmlApplicationContext(
+                       // "/slc/conf/applicationContext.xml");
+
+                       applicationContext = new GenericApplicationContext();
+                       XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
+                                       (BeanDefinitionRegistry) applicationContext);
+                       Bundle bundle = context.getBundle();
+
+                       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));
+                       }
+
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw new Exception("Could not initialize application context");
+               } finally {
+                       cur.setContextClassLoader(save);
+               }
+
+               startAutoBundle(context);
+       }
+
+       /** Does nothing by default. */
+       protected void startAutoBundle(BundleContext context) throws Exception {
+
+       }
+
+       public final void stop(BundleContext context) throws Exception {
+               stopAutoBundle(context);
+
+               if (applicationContext != null) {
+                       applicationContext.close();
+               }
+
+       }
+
+       /** Does nothing by default. */
+       protected void stopAutoBundle(BundleContext context) throws Exception {
+
+       }
+
+       public Object getStaticRef(String id) {
+               return applicationContext.getBean(id);
+       }
+
+}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiApplication.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiApplication.java
deleted file mode 100644 (file)
index cca0006..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.autoui;
-
-public interface AutoUiApplication {
-       public Object execute(Object object) throws Exception;
-}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiStep.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiStep.java
deleted file mode 100644 (file)
index 523d58c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.argeo.slc.autoui;
-
-public interface AutoUiStep {
-       /** Runs synchronously. */
-       public void run();
-
-       /** Closes and releases the associated resources. */
-       public void close();
-
-       /**
-        * Sets an input parameter. Value can be various Java type and implementors
-        * are supposed to document which data types are supported.
-        */
-       public void setInputParameter(Object key, Object value);
-
-       /**
-        * Gets an output parameter. Implementors are supposed to convert the
-        * returned value to the appropriate data type.
-        */
-       public Object getOutputParameter(Object key);
-
-}
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
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.autoui/src/main/java/org/argeo/slc/autoui/DetachedContextImpl.java b/org.argeo.slc.autoui/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.autoui/src/main/java/org/argeo/slc/autoui/DetachedStep.java b/org.argeo.slc.autoui/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.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepAnswer.java b/org.argeo.slc.autoui/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.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java
new file mode 100644 (file)
index 0000000..9c61afc
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.autoui;
+
+import java.util.Properties;
+
+public class DetachedStepRequest {
+       private Properties inputParameters;
+       private String stepRef;
+       private String path;
+}