Mercurial > dive4elements > framework
comparison artifacts/src/main/java/org/dive4elements/artifacts/Artifact.java @ 471:1a87cb24a446
Moved directories to org.dive4elements
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 10:50:31 +0200 |
parents | artifacts/src/main/java/de/intevation/artifacts/Artifact.java@3447fa62f007 |
children | 415df0fc4fa1 |
comparison
equal
deleted
inserted
replaced
470:19cb9729bd17 | 471:1a87cb24a446 |
---|---|
1 /* | |
2 * Copyright (c) 2010 by Intevation GmbH | |
3 * | |
4 * This program is free software under the LGPL (>=v2.1) | |
5 * Read the file LGPL.txt coming with the software for details | |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | |
7 */ | |
8 | |
9 package de.intevation.artifacts; | |
10 | |
11 import java.io.IOException; | |
12 import java.io.OutputStream; | |
13 import java.io.Serializable; | |
14 | |
15 import org.w3c.dom.Document; | |
16 | |
17 /** | |
18 * Interface of the core component of the artifact system: <strong>The artifact</strong>. | |
19 * <br> | |
20 * | |
21 * An artifact is an abstract data type offering the following methods: | |
22 * | |
23 * <ol> | |
24 * <li>{@link #identifier() identifier()}: Returns a gobally unique identfier | |
25 * of this artifact.</li> | |
26 * <li>{@link #hash() hash()}: Returns a hash value over the internal state | |
27 * of this artifact.</li> | |
28 * <li>{@link #describe(Document, CallContext)}: Returns a description of this artifact.</li> | |
29 * <li>{@link #advance(Document, CallContext) advance()}: Advances this artifact | |
30 * to the next internal state</li> | |
31 * <li>{@link #feed(Document, CallContext) feed()}: Feed new data into this artifact.</li> | |
32 * <li>{@link #out(Document, OutputStream, CallContext) out()}: Produces output for this artifact.</li> | |
33 * </ol> | |
34 * | |
35 * There are two more methods involved with the life cycle of the are: | |
36 * <ol> | |
37 * <li>{@link #setup(String, ArtifactFactory, Object, CallMeta, Document) setup()}: | |
38 * Called after created by the factory.</li> | |
39 * <li>{@link #endOfLife(Object) endOfLife()}: Called when the artifact | |
40 * is going to be removed from | |
41 * system. Useful to clean up.</li> | |
42 * </ol> | |
43 * | |
44 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | |
45 */ | |
46 public interface Artifact | |
47 extends Serializable | |
48 { | |
49 | |
50 /** | |
51 * Set a new identifier for this artifact. | |
52 * @param identifier New identifier for this artifact. | |
53 */ | |
54 public void setIdentifier(String identifier); | |
55 | |
56 /** | |
57 * Identify this artifact. | |
58 * @return Returns unique string to identify this artifact globally. | |
59 */ | |
60 String identifier(); | |
61 | |
62 /** | |
63 * Internal hash of this artifact. | |
64 * @return Returns hash that should stay the same if the internal | |
65 * value has not changed. Useful for caching | |
66 */ | |
67 String hash(); | |
68 | |
69 /** | |
70 * A description used to build a interface to interact with this artifact. | |
71 * @param data General input data. Useful to produces specific descriptions. | |
72 * @param context The global context of the runtime system. | |
73 * @return An XML representation of the current state of the artifact. | |
74 */ | |
75 Document describe(Document data, CallContext context); | |
76 | |
77 /** | |
78 * Change the internal state of the artifact. | |
79 * @return An XML representation of the success of the advancing. | |
80 * @param target Target of internal state to move to. | |
81 * @param context The global context of the runtime system. | |
82 */ | |
83 Document advance(Document target, CallContext context); | |
84 | |
85 /** | |
86 * Feed data into this artifact. | |
87 * @param data Data to feed artifact with. | |
88 * @param context The global context of the runtime system. | |
89 * @return An XML representation of the success of the feeding. | |
90 */ | |
91 Document feed(Document data, CallContext context); | |
92 | |
93 /** | |
94 * Produce output for this artifact. | |
95 * @param format Specifies the format of the output. | |
96 * @param out Stream to write the result data to. | |
97 * @param context The global context of the runtime system. | |
98 * @throws IOException Thrown if an I/O occurs. | |
99 */ | |
100 void out( | |
101 Document format, | |
102 OutputStream out, | |
103 CallContext context) | |
104 throws IOException; | |
105 | |
106 /** | |
107 * Produce output for this artifact. | |
108 * @param type Specifies the type of the output. | |
109 * @param format Specifies the format of the output. | |
110 * @param out Stream to write the result data to. | |
111 * @param context The global context of the runtime system. | |
112 * @throws IOException Thrown if an I/O occurs. | |
113 */ | |
114 void out( | |
115 String type, | |
116 Document format, | |
117 OutputStream out, | |
118 CallContext context) | |
119 throws IOException; | |
120 | |
121 /** | |
122 * When created by a factory this method is called to | |
123 * initialize the artifact. | |
124 * | |
125 * @param identifier The identifier from artifact database | |
126 * @param factory The factory which created this artifact. | |
127 * @param context The global context of the runtime system. | |
128 * @param data The data which can be use to setup an artifact with | |
129 * more details. | |
130 */ | |
131 public void setup( | |
132 String identifier, | |
133 ArtifactFactory factory, | |
134 Object context, | |
135 CallMeta callMeta, | |
136 Document data); | |
137 | |
138 /** | |
139 * Called from artifact database when an artifact is | |
140 * going to be removed from system. | |
141 * @param context The global context of the runtime system. | |
142 */ | |
143 public void endOfLife(Object context); | |
144 | |
145 | |
146 /** | |
147 * Called from artifact database before an artifact is | |
148 * going to be exported as xml document. | |
149 * @param context The global context of the runtime system. | |
150 */ | |
151 public void cleanup(Object context); | |
152 } | |
153 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |