sascha@1: package de.intevation.artifacts;
sascha@1:
sascha@1: import org.w3c.dom.Document;
sascha@1:
sascha@1: import java.io.Serializable;
sascha@31: import java.io.OutputStream;
sascha@31: import java.io.IOException;
sascha@1:
sascha@1: /**
sascha@1: * Interface of the core component of the artifact system: The artifact.
sascha@1: *
sascha@1: *
sascha@1: * An artifact is an abstract data type offering the following methods:
sascha@1: *
sascha@1: *
sascha@1: * - {@link #identifier() identifier()}: Returns a gobally unique identfier
sascha@1: * of this artifact.
sascha@2: * - {@link #hash() hash()}: Returns a hash value over the internal state
sascha@1: * of this artifact.
sascha@4: * - {@link #describe(Object)}: Returns a description of this artifact.
sascha@4: * - {@link #advance(Document, Object) advance()}: Advances this artifact
sascha@1: * to the next internal state
sascha@4: * - {@link #feed(Document, Object) feed()}: Feed new data into this artifact.
sascha@4: * - {@link #out(Document, Object) out()}: Produces output for this artifact.
sascha@1: *
sascha@1: *
sascha@10: * There are two more methods involved with the life cycle of the are:
sascha@10: *
sascha@24: * - {@link #setup(String, ArtifactFactory, Object) setup()}: Called after created by the
sascha@10: * factory.
sascha@10: * - {@link #endOfLife(Object) endOfLife()}: Called when the artifact
sascha@10: * is going to be removed from
sascha@10: * system. Useful to clean up.
sascha@10: *
sascha@10: *
sascha@1: * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
sascha@1: */
sascha@1: public interface Artifact
sascha@1: extends Serializable
sascha@1: {
sascha@1: /**
sascha@1: * Identify this artifact.
sascha@1: * @return Returns unique string to identify this artifact globally.
sascha@1: */
sascha@1: public String identifier();
sascha@1:
sascha@1: /**
sascha@1: * Internal hash of this artifact.
sascha@1: * @return Returns hash that should stay the same if the internal
sascha@1: * value has not changed. Useful for caching
sascha@1: */
sascha@1: public String hash();
sascha@1:
sascha@1: /**
sascha@1: * A description used to build a interface to interact with this artifact.
sascha@4: * @param context The global context of the runtime system.
sascha@1: * @return An XML representation of the current state of the artifact.
sascha@1: */
sascha@4: public Document describe(Object context);
sascha@1:
sascha@1: /**
sascha@1: * Change the internal state of the artifact.
sascha@1: * @return An XML representation of the success of the advancing.
sascha@4: * @param target Target of internal state to move to.
sascha@4: * @param context The global context of the runtime system.
sascha@1: */
sascha@4: public Document advance(Document target, Object context);
sascha@1:
sascha@1: /**
sascha@1: * Feed data into this artifact.
sascha@1: * @param data Data to feed artifact with.
sascha@4: * @param context The global context of the runtime system.
sascha@1: * @return An XML representation of the success of the feeding.
sascha@1: */
sascha@4: public Document feed(Document data, Object context);
sascha@1:
sascha@1: /**
sascha@1: * Produce output from this artifact.
sascha@1: * @param format Specifies the format of the output.
sascha@4: * @param context The global context of the runtime system.
sascha@1: */
sascha@31: public void out(
sascha@31: Document format,
sascha@31: OutputStream out,
sascha@31: Object context)
sascha@31: throws IOException;
sascha@9:
sascha@9: /**
sascha@10: * When created by a factory this method is called to
sascha@10: * initialize the artifact.
sascha@10: * @param identifier The identifier from artifact database
sascha@24: * @param factory The factory which created this artifact.
sascha@10: * @param context The global context of the runtime system.
sascha@10: */
sascha@24: public void setup(String identifier, ArtifactFactory factory, Object context);
sascha@10:
sascha@10: /**
sascha@9: * Called from artifact database when an artifact is
sascha@9: * going to be removed from system.
sascha@9: * @param context The global context of the runtime system.
sascha@9: */
sascha@9: public void endOfLife(Object context);
sascha@1: }
sascha@1: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: