# HG changeset patch # User Sascha L. Teichmann # Date 1251900228 0 # Node ID 11c82d3f125e33703db3c4ce02f8c42e242c6d0e # Parent 458bffbf57c075becd062203c73a3b1d07c0e00d Checked in the central interfaces of the artifact system. artifacts/trunk@6 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 458bffbf57c0 -r 11c82d3f125e Changelog --- 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 + + * 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 * README, Changelog, Changes, NEWS, TODO: New. Initial setup diff -r 458bffbf57c0 -r 11c82d3f125e artifacts/pom.xml --- /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 @@ + + 4.0.0 + de.intevation.bsh + artifacts + jar + 1.0-SNAPSHOT + artifacts + http://maven.apache.org + + + diff -r 458bffbf57c0 -r 11c82d3f125e artifacts/src/main/java/de/intevation/artifacts/Artifact.java --- /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: The artifact. + *
+ * + * An artifact is an abstract data type offering the following methods: + * + *
    + *
  1. {@link #identifier() identifier()}: Returns a gobally unique identfier + * of this artifact.
  2. + *
  3. {@link #hash() hash()}: Returns a hash value over the internal state + * of this artifact.
  4. + *
  5. {@link #describe()}: Returns a description of this artifact.
  6. + *
  7. {@link #advance(String) advance()}: Advances this artifact + * to the next internal state
  8. + *
  9. {@link #feed(Document) feed()}: Feed new data into this artifact.
  10. + *
  11. {@link #out(Document) out()}: Produces output for this artifact.
  12. + *
+ * + * @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: diff -r 458bffbf57c0 -r 11c82d3f125e artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java --- /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: diff -r 458bffbf57c0 -r 11c82d3f125e artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java --- /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: diff -r 458bffbf57c0 -r 11c82d3f125e artifacts/src/main/java/de/intevation/artifacts/package.html --- /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 @@ + + + + + +The abstract interfaces and base classes of the artifact system. + +