comparison artifacts/src/main/java/org/dive4elements/artifacts/CallContext.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/CallContext.java@410a1bfb9590
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.util.LinkedList;
12 import java.util.List;
13
14 import org.w3c.dom.Document;
15 import org.w3c.dom.Node;
16
17 /**
18 * Instances of this interface are given to feed(), advance(), describe()
19 * and out() to enable the artifact to communicate with the runtime system.
20 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
21 */
22 public interface CallContext
23 {
24 interface Listener {
25 void setup(Document config, Node listenerNode);
26 void init(CallContext callContext);
27 void close(CallContext callContext);
28 }
29
30 /**
31 * Constant to signal that nothing should be done
32 * with the artifact after method return.
33 */
34 int NOTHING = 0;
35 /**
36 * Constant to signal that the database timestamp
37 * should be updated after method return.
38 */
39 int TOUCH = 1;
40 /**
41 * Constant to signal that the artifact should be stored
42 * after method return.
43 */
44 int STORE = 2;
45 /**
46 * Constant to signal that the artifact fork a backgroud thread
47 * and should be hold in memory till it signals that it has
48 * finished its operation.
49 */
50 int BACKGROUND = 3;
51 // int DELETE = 4;
52 // int FOREVER = 5;
53
54 /**
55 * This method may be called from feed(), describe(), advance()
56 * and out to signal what should happend with artefact after
57 * the current method call returns.
58 * @param action Valid values are NOTHING, TOUCH, STORE, BACKGROUND.
59 */
60 void afterCall(int action);
61
62 /**
63 * When send to background with a afterCall(BACKGROUND) this
64 * method is to be called from the background thread to signal
65 * that the background operation has ended.
66 * @param action Same semantics as in afterCall.
67 */
68 void afterBackground(int action);
69
70 /**
71 * Returns true, if the object forked a background thread and has not
72 * finished it yet.
73 */
74 boolean isInBackground();
75
76 /**
77 * Adds a background message for the current Artifact or Collection.
78 *
79 * @param msg The message.
80 */
81 void addBackgroundMessage(Message msg);
82
83 /**
84 * Returns the background messages of the current Artifact or Collection.
85 *
86 * @return the list of background messages.
87 */
88 LinkedList<Message> getBackgroundMessages();
89
90 /**
91 * Access to the global context of the runtime system.
92 * @return The global context.
93 */
94 Object globalContext();
95
96 /**
97 * Access to the artifact database itself.
98 * @return The database.
99 */
100 ArtifactDatabase getDatabase();
101
102 /**
103 * The meta data of the current call. Used to transport
104 * language preferences of the callee e.g.
105 * @return The meta information of this call.
106 */
107 CallMeta getMeta();
108
109 /**
110 * Each call context has a clipboard.
111 * getContextValue is used to fetch data from this board.
112 * @param key Key of the requested item.
113 * @return The value stored for the specified value, null if
114 * no item with this key exists.
115 */
116 Object getContextValue(Object key);
117
118 /**
119 * Each call context has a clipboard.
120 * putContextValue is used to store a key/value pair onto this board.
121 * @param key The key of the pair
122 * @param value The value of the pair.
123 * @return The formerly stored value under the given key.
124 */
125 Object putContextValue(Object key, Object value);
126
127 /**
128 * Returns the time to live of the current artifact.
129 * @return The time to live of the current artifact.
130 */
131 Long getTimeToLive();
132
133 /**
134 * Get a list of DataProvider that get provide 'key' type of data to
135 * other facets.
136 */
137 public List<DataProvider> getDataProvider(Object key);
138
139 /**
140 * Register a DataProvider that can provide 'key' type of data to
141 * other facets.
142 */
143 public Object registerDataProvider(Object key, DataProvider provider);
144 }
145 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org