1 package org.apache.fulcrum.yaafi.framework.tls;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 /**
23 * Provides a service which can temporarily store
24 * thread-local data. This is useful in a multithreaded
25 * environment, such as a servlet or Tapestry application.
26 * ThreadLocalStorage acts like a map around thread local data.
27 *
28 * The code was pasted from the Hivemind container written by
29 * Howard Lewis Ship.
30 *
31 * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
32 */
33
34 public interface ThreadLocalStorage
35 {
36 /**
37 * Returns the thread-local object for the given key, or null
38 * if no such object exists.
39 *
40 * @param key the key for the lookup
41 * @return the object
42 */
43 public Object get(String key);
44
45 /**
46 * Stores the value object at the given key, overwriting
47 * any prior value that may have been stored at that key.
48 * Care should be taken in selecting keys to avoid
49 * naming conflicts; in general, prefixing a key with
50 * a module id is a good idea.
51 *
52 * @param key the key of the object to store
53 * @param value the value of the object to store
54 */
55 public void put(String key, Object value);
56
57 /**
58 * Checks if the thread-local object for the given key exists
59 *
60 * @param key the key for the lookup
61 * @return true the object exists
62 */
63 public boolean containsKey(String key);
64
65 /**
66 * Clears all keys.
67 */
68 public void clear();
69 }