Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Scope |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 1999-2001,2004 The Apache Software Foundation. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | package org.apache.commons.workflow; | |
18 | ||
19 | ||
20 | import java.util.Map; | |
21 | ||
22 | ||
23 | /** | |
24 | * <p>A <strong>Scope</strong> is a collection of arbitrary Java objects, | |
25 | * keyed by String-valued names. Specialized workflow implementations | |
26 | * will register their own <code>Scope</code> implementations to connect | |
27 | * the workflow engine processing to their own execution environments. | |
28 | * For example, a web layer implementation would most likely adapt | |
29 | * Scopes to the request attributes, session attributes, and servlet | |
30 | * context attributes provided by the Servlet API.</p> | |
31 | * | |
32 | * <p>A Scope implements the API contracts of <code>java.util.Map</code> | |
33 | * with the following additional rules:</p> | |
34 | * <ul> | |
35 | * <li>Keys must be of the <code>java.lang.String</code></li> | |
36 | * <li>Null keys are not allowed</li> | |
37 | * <li>Null beans are not allowed</li> | |
38 | * </ul> | |
39 | * | |
40 | * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $ | |
41 | * @author Craig R. McClanahan | |
42 | */ | |
43 | ||
44 | public interface Scope extends Map { | |
45 | ||
46 | ||
47 | // ------------------------------------------------------------ Map Methods | |
48 | ||
49 | ||
50 | /** | |
51 | * Remove all beans from this Map and call <code>scopeCleared() on | |
52 | * all registered <code>ScopeListeners</code>. | |
53 | */ | |
54 | public void clear(); | |
55 | ||
56 | ||
57 | /** | |
58 | * Add the specified bean, associated with the specified key, to this | |
59 | * scope and replace any previous bean associated with this key. If | |
60 | * the bean was added, call <code>beanAdded()</code> on all registered | |
61 | * listeners after the add is done. If an old bean was replaced, | |
62 | * call <code>beanReplaced()</code> (passing the old value in the event) | |
63 | * on all registered <code>ScopeListeners</code> after the removal | |
64 | * is done. If a bean was replaced, the old value is also returned; | |
65 | * otherwise <code>null</code> is returned. | |
66 | * | |
67 | * @param key Key with which the new value should be associated | |
68 | * (cannot be null) | |
69 | * @param bean Bean to be associated with this key (cannot be null) | |
70 | * | |
71 | * @exception IllegalArgumentException if <code>key</code> or | |
72 | * <code>bean</code> is null | |
73 | */ | |
74 | public Object put(String key, Object bean); | |
75 | ||
76 | ||
77 | /** | |
78 | * Remove the bean associated with the specified key (if any). If such | |
79 | * a bean is found and removed, call <code>beanRemoved()</code> on all | |
80 | * registered <code>ScopeListeners</code> after the removal is done. | |
81 | * Return the old value (if any); otherwise return <code>null</code>. | |
82 | * | |
83 | * @param key Key of the bean to remove (cannot be null) | |
84 | * | |
85 | * @exception IllegalArgumentException if <code>key</code> is null | |
86 | */ | |
87 | public Object remove(String key); | |
88 | ||
89 | ||
90 | // ------------------------------------------------- Event Listener Methods | |
91 | ||
92 | ||
93 | /** | |
94 | * Add a listener that is notified each time beans are added, | |
95 | * replaced, or removed in this scope. | |
96 | * | |
97 | * @param listener The ScopeListener to be added | |
98 | */ | |
99 | public void addScopeListener(ScopeListener listener); | |
100 | ||
101 | ||
102 | /** | |
103 | * Remove a listener that is notified each time beans are added, | |
104 | * replaced, or removed in this scope. | |
105 | * | |
106 | * @param listener The ScopeListener to be removed | |
107 | */ | |
108 | public void removeScopeListener(ScopeListener listener); | |
109 | ||
110 | ||
111 | } |