From: Mathieu Baudier Date: Fri, 26 Sep 2008 18:05:57 +0000 (+0000) Subject: Start introducing the interfaces X-Git-Tag: argeo-slc-2.1.7~2548 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=60e78665964756bdcf403fd5c85631396f1d4690;p=gpl%2Fargeo-slc.git Start introducing the interfaces git-svn-id: https://svn.argeo.org/slc/trunk@1643 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/org.argeo.slc.autoui/.classpath b/org.argeo.slc.autoui/.classpath index c3624f87c..1aa73cdbf 100644 --- a/org.argeo.slc.autoui/.classpath +++ b/org.argeo.slc.autoui/.classpath @@ -1,6 +1,7 @@ + diff --git a/org.argeo.slc.autoui/pom.xml b/org.argeo.slc.autoui/pom.xml index 4bf435492..c47610cc3 100644 --- a/org.argeo.slc.autoui/pom.xml +++ b/org.argeo.slc.autoui/pom.xml @@ -49,28 +49,6 @@ - - - org.eclipse osgi @@ -83,6 +61,9 @@ 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/AbstractAutoActivator.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractAutoActivator.java deleted file mode 100644 index 59c9746e3..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractAutoActivator.java +++ /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 index 000000000..7f18d50a4 --- /dev/null +++ b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java @@ -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 index cca0006c5..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiApplication.java +++ /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 index 523d58cde..000000000 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiStep.java +++ /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 index 000000000..5c4b2a6cb --- /dev/null +++ b/org.argeo.slc.autoui/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.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 index 000000000..93676b414 --- /dev/null +++ b/org.argeo.slc.autoui/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.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 index 000000000..cd20bb3ab --- /dev/null +++ b/org.argeo.slc.autoui/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.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 index 000000000..9d3edd11b --- /dev/null +++ b/org.argeo.slc.autoui/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.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 index 000000000..9c61afc83 --- /dev/null +++ b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/DetachedStepRequest.java @@ -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; +}