# HG changeset patch # User Sascha L. Teichmann # Date 1252053129 0 # Node ID 13a12b607bafbfb45e1204e25c20fb552b704665 # Parent b1ec257e9d8d043e3ad313731766d37dfd0d73bd Added mechanism to create an share a global context in the artifact database. artifacts/trunk@13 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b1ec257e9d8d -r 13a12b607baf Changelog --- a/Changelog Thu Sep 03 16:13:25 2009 +0000 +++ b/Changelog Fri Sep 04 08:32:09 2009 +0000 @@ -1,3 +1,19 @@ +2009-09-04 Sascha L. Teichmann + + * artifacts/src/main/java/de/intevation/artifacts/ArtifactContextFactory.java: + New. Factory for a global context in the artifact data base. Useful to + create shared ressources for artifacts like caches et al. + + * 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/ArtifactContextFactory.java, + artifacts/src/main/java/de/intevation/artifacts/Artifact.java: Uses the + global context more consistent. + + * artifact-database/doc/schema.sql: Using BINARY instead of BLOB to + avoid external files for each artifact blob. See H2 documentation + for details. + 2009-09-03 Sascha L. Teichmann * artifact-database/doc/schema.sql: Schema to store artifacts diff -r b1ec257e9d8d -r 13a12b607baf artifact-database/doc/schema.sql --- a/artifact-database/doc/schema.sql Thu Sep 03 16:13:25 2009 +0000 +++ b/artifact-database/doc/schema.sql Fri Sep 04 08:32:09 2009 +0000 @@ -10,7 +10,7 @@ creation TIMESTAMP NOT NULL, last_access TIMESTAMP NOT NULL, ttl TIME, -- NULL means eternal - data BLOB + data BINARY ); COMMIT; diff -r b1ec257e9d8d -r 13a12b607baf artifacts/src/main/java/de/intevation/artifacts/Artifact.java --- a/artifacts/src/main/java/de/intevation/artifacts/Artifact.java Thu Sep 03 16:13:25 2009 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/Artifact.java Fri Sep 04 08:32:09 2009 +0000 @@ -15,11 +15,11 @@ * of this artifact. *
  • {@link #hash() hash()}: Returns a hash value over the internal state * of this artifact.
  • - *
  • {@link #describe()}: Returns a description of this artifact.
  • - *
  • {@link #advance(String) advance()}: Advances this artifact + *
  • {@link #describe(Object)}: Returns a description of this artifact.
  • + *
  • {@link #advance(Document, Object) advance()}: Advances this artifact * to the next internal state
  • - *
  • {@link #feed(Document) feed()}: Feed new data into this artifact.
  • - *
  • {@link #out(Document) out()}: Produces output for this artifact.
  • + *
  • {@link #feed(Document, Object) feed()}: Feed new data into this artifact.
  • + *
  • {@link #out(Document, Object) out()}: Produces output for this artifact.
  • * * * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) @@ -42,29 +42,33 @@ /** * A description used to build a interface to interact with this artifact. + * @param context The global context of the runtime system. * @return An XML representation of the current state of the artifact. */ - public Document describe(); + public Document describe(Object context); /** * 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. + * @param target Target of internal state to move to. + * @param context The global context of the runtime system. */ - public Document advance(String target); + public Document advance(Document target, Object context); /** * Feed data into this artifact. * @param data Data to feed artifact with. + * @param context The global context of the runtime system. * @return An XML representation of the success of the feeding. */ - public Document feed(Document data); + public Document feed(Document data, Object context); /** * Produce output from this artifact. * @param format Specifies the format of the output. + * @param context The global context of the runtime system. * @return a byte representation of the output. */ - public byte [] out(Document format); + public byte [] out(Document format, Object context); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: diff -r b1ec257e9d8d -r 13a12b607baf artifacts/src/main/java/de/intevation/artifacts/ArtifactContextFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactContextFactory.java Fri Sep 04 08:32:09 2009 +0000 @@ -0,0 +1,21 @@ +package de.intevation.artifacts; + +import org.w3c.dom.Document; + +/** + * Interface of a factory that produces a global artifact context in the artifact data base. + * + * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) + */ +public interface ArtifactContextFactory +{ + /** + * Creates a global context given a configuration in the artifact data base. + * @param config the configuration. + * @return The global context. + * {@link de.intevation.artifacts.ArtifactFactory#createArtifact(String, Object) createArtifact()} + * {@link de.intevation.artifacts.Artifact Artifact} + */ + Object createArtifactContext(Document config); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: diff -r b1ec257e9d8d -r 13a12b607baf artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java --- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java Thu Sep 03 16:13:25 2009 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java Fri Sep 04 08:32:09 2009 +0000 @@ -21,8 +21,15 @@ /** * Creates new artifact with a certain factory. - * @param factoryName the name of the factory. Name out of {@see #getArtifactFactoryNames() getArtifactFactoryNames()}. + * @param factoryName the name of the factory. Name out of {@link #getArtifactFactoryNames() getArtifactFactoryNames()}. */ Artifact createArtifactWithFactory(String factoryName); + + + /** + * Returns the global artifact runtime context. + * @return the runtime context + */ + Object getArtifactContext(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: diff -r b1ec257e9d8d -r 13a12b607baf artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java --- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java Thu Sep 03 16:13:25 2009 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java Fri Sep 04 08:32:09 2009 +0000 @@ -1,5 +1,7 @@ package de.intevation.artifacts; +import org.w3c.dom.Document; + /** * Interface of an artifact producing factory. * @@ -26,6 +28,12 @@ * @param identifier unique identifer for the new artifact * @return a new {@linkplain de.intevation.artifacts.Artifact Artifact} */ - Artifact createArtifact(Object context, String identifier); + Artifact createArtifact(String identifier, Object context); + + /** + * Setup the factory with a given configuration + * @param config the configuration + */ + void setup(Document config); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: