changeset 1:11c82d3f125e

Checked in the central interfaces of the artifact system. artifacts/trunk@6 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 02 Sep 2009 14:03:48 +0000
parents 458bffbf57c0
children 141457e0d7b1
files Changelog artifacts/pom.xml artifacts/src/main/java/de/intevation/artifacts/Artifact.java artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java artifacts/src/main/java/de/intevation/artifacts/package.html
diffstat 6 files changed, 162 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Changelog	Tue Sep 01 15:25:41 2009 +0000
+++ b/Changelog	Wed Sep 02 14:03:48 2009 +0000
@@ -1,3 +1,16 @@
+2009-09-02	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifacts/src/main/java/de/intevation/artifacts/Artifact.java:
+	Interface of the central component of the system.
+
+	* artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java:
+	Central place to store artifacts in.
+
+	* artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java:
+	Factory to build artifacts. Works together with ArtifactDatabase.
+
+	* artifacts/pom.xml: Simple maven file to compile the project.
+
 2009-09-01	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* README, Changelog, Changes, NEWS, TODO: New. Initial setup
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/pom.xml	Wed Sep 02 14:03:48 2009 +0000
@@ -0,0 +1,12 @@
+<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>
+  <groupId>de.intevation.bsh</groupId>
+  <artifactId>artifacts</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>artifacts</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+  </dependencies>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Wed Sep 02 14:03:48 2009 +0000
@@ -0,0 +1,70 @@
+package de.intevation.artifacts;
+
+import org.w3c.dom.Document;
+
+import java.io.Serializable;
+
+/**
+ * Interface of the core component of the artifact system: <strong>The artifact</strong>.
+ * <br>
+ *
+ * An artifact is an abstract data type offering the following methods:
+ *
+ * <ol>
+ *   <li>{@link #identifier() identifier()}: Returns a gobally unique identfier
+ *        of this artifact.</li>
+ *   <li>{@link #hash() hash()}: Returns a hash value over the internal state 
+ *        of this artifact.</li>
+ *   <li>{@link #describe()}: Returns a description of this artifact.</li>
+ *   <li>{@link #advance(String) advance()}: Advances this artifact 
+ *       to the next internal state</li>
+ *   <li>{@link #feed(Document) feed()}: Feed new data into this artifact.</li>
+ *   <li>{@link #out(Document) out()}: Produces output for this artifact.</li>
+ * </ol>
+ *
+ * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
+ */
+public interface Artifact
+extends          Serializable
+{
+    /**
+     * Identify this artifact.
+     * @return Returns unique string to identify this artifact globally.
+     */
+    public String identifier();
+
+    /**
+     * Internal hash of this artifact.
+     * @return Returns hash that should stay the same if the internal
+     *         value has not changed. Useful for caching
+     */
+    public String hash();
+
+    /**
+     * A description used to build a interface to interact with this artifact.
+     * @return An XML representation of the current state of the artifact.
+     */
+    public Document describe();
+
+    /**
+     * Change the internal state of the artifact.
+     * @param target Target of internal state to move to.
+     * @return An XML representation of the success of the advancing.
+     */
+    public Document advance(String target);
+
+    /**
+     * Feed data into this artifact.
+     * @param data Data to feed artifact with.
+     * @return An XML representation of the success of the feeding.
+     */
+    public Document feed(Document data);
+
+    /**
+     * Produce output from this artifact.
+     * @param format Specifies the format of the output.
+     * @return a byte representation of the output.
+     */
+    public byte [] out(Document format);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java	Wed Sep 02 14:03:48 2009 +0000
@@ -0,0 +1,28 @@
+package de.intevation.artifacts;
+
+/**
+ * Interface of an artifact managing database.
+ *
+ * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
+ */
+public interface ArtifactDatabase
+{
+    /**
+     * List of artifact factories names accessible through the database.
+     * @return names of the factories.
+     */
+    String [] getArtifactFactoryNames();
+
+    /**
+     * Look up an artifact by its identifier.
+     * @return the artifact. null if the artifact is not found.
+     */
+    Artifact getArtifact(String identifier);
+
+    /**
+     * Creates new artifact with a certain factory.
+     * @param factoryName the name of the factory. Name out of {@see #getArtifactFactoryNames() getArtifactFactoryNames()}.
+     */
+    Artifact createArtifactWithFactory(String factoryName);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java	Wed Sep 02 14:03:48 2009 +0000
@@ -0,0 +1,31 @@
+package de.intevation.artifacts;
+
+/**
+ * Interface of an artifact producing factory.
+ *
+ * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
+ */
+public interface ArtifactFactory
+{
+    /**
+     * The short name of this factory.
+     * @return the name of this factory.
+     */
+    String getName();
+
+    /**
+     * Description of this factory.
+     * @return description of the factory.
+     */
+    String getDescription();
+
+    /**
+     * Create a new artifact of certain type, given a general purpose context and
+     * an identifier.
+     * @param context a context from the ArtifactDatabase.
+     * @param identifier unique identifer for the new artifact
+     * @return a new {@linkplain de.intevation.artifacts.Artifact Artifact}
+     */
+    Artifact createArtifact(Object context, String identifier);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/package.html	Wed Sep 02 14:03:48 2009 +0000
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body>
+The abstract interfaces and base classes of the artifact system.
+</body>
+</html>

http://dive4elements.wald.intevation.org