Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/AbstractCallContext.java @ 389:ea263ee87563
Added new helper class DateUtils.
artifacts/trunk@4436 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 May 2012 09:08:03 +0000 |
parents | 1f51f3c46efe |
children | f367be55dd35 |
rev | line source |
---|---|
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 /* |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 * Copyright (c) 2010, 2011 by Intevation GmbH |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 * |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 */ |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.artifactdatabase; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
362
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
10 import org.apache.log4j.Logger; |
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
11 |
353
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
12 import java.util.ArrayList; |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
13 import java.util.List; |
362
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
14 import java.util.Map; |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import java.util.HashMap; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.ArtifactDatabase; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.CallContext; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifacts.CallMeta; |
353
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
20 import de.intevation.artifacts.DataProvider; |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 /** |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * Abstract class that implements some basic methods of a CallContext. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 */ |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 public abstract class AbstractCallContext implements CallContext { |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
362
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
31 Logger logger = Logger.getLogger(AbstractCallContext.class); |
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
32 |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 /** |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 * The ArtifactDatabase instance. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 */ |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 protected ArtifactDatabaseImpl database; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 /** |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 * The action to be performed after the artifacts or collections calls. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 */ |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 protected int action; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 /** |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 * The meta information of the concrete call (preferred languages et. al.) |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 */ |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 protected CallMeta callMeta; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 /** |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 * Map to act like a clipboard when nesting calls like a proxy artifact. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 */ |
366
1f51f3c46efe
AbstractCallContext: Instance vars are now Maps instead of Hashmaps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
362
diff
changeset
|
51 protected Map customValues; |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
353
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
53 /** |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
54 * Map to act like a clipboard when nesting calls like a proxy artifact. |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
55 */ |
366
1f51f3c46efe
AbstractCallContext: Instance vars are now Maps instead of Hashmaps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
362
diff
changeset
|
56 protected Map<Object, List<DataProvider>> dataProviders; |
353
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
57 |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 /** |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 * The default constructor of this abstract CallContext. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 * |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 * @param action The action. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 * @param callMeta The CallMeta object. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 * @param context The global context. |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 */ |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 public AbstractCallContext( |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 ArtifactDatabaseImpl artifactDatabase, |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 int action, |
246
a8a06bbe306c
Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
219
diff
changeset
|
69 CallMeta callMeta |
a8a06bbe306c
Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
219
diff
changeset
|
70 ) { |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 this.database = artifactDatabase; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 this.action = action; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 this.callMeta = callMeta; |
246
a8a06bbe306c
Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
219
diff
changeset
|
74 |
a8a06bbe306c
Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
219
diff
changeset
|
75 database.initCallContext(this); |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 } |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
246
a8a06bbe306c
Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
219
diff
changeset
|
79 public void postCall() { |
a8a06bbe306c
Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
219
diff
changeset
|
80 database.closeCallContext(this); |
a8a06bbe306c
Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
219
diff
changeset
|
81 } |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 public abstract void afterCall(int action); |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 public abstract Long getTimeToLive(); |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 public abstract void afterBackground(int action); |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 public Object globalContext() { |
246
a8a06bbe306c
Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
219
diff
changeset
|
91 return database.context; |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 } |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 public ArtifactDatabase getDatabase() { |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 return database; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 } |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 public CallMeta getMeta() { |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 return callMeta; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 } |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 public Object getContextValue(Object key) { |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 return customValues != null |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 ? customValues.get(key) |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 : null; |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 } |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 public Object putContextValue(Object key, Object value) { |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 if (customValues == null) { |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 customValues = new HashMap(); |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 } |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 return customValues.put(key, value); |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 } |
353
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
117 |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
118 /** |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
119 * Get list of DataProviders that registered for given key. |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
120 * @return list (empty list if none found, never null). |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
121 */ |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
122 public List<DataProvider> getDataProvider(Object key) { |
362
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
123 if (dataProviders != null) { |
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
124 List<DataProvider> list = dataProviders.get(key); |
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
125 return list != null |
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
126 ? list |
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
127 : java.util.Collections.<DataProvider>emptyList(); |
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
128 } |
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
129 return java.util.Collections.<DataProvider>emptyList(); |
353
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
130 } |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
131 |
362
5b6ba54d488a
Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
357
diff
changeset
|
132 |
353
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
133 /** |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
134 * Let a DataProvider register itself with given key. |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
135 * Multiple DataProvider can register under the same key. |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
136 */ |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
137 public Object registerDataProvider(Object key, DataProvider value) { |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
138 List<DataProvider> providers = null; |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
139 if (dataProviders == null) { |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
140 dataProviders = new HashMap(); |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
141 providers = new ArrayList<DataProvider>(); |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
142 providers.add(value); |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
143 return dataProviders.put(key, providers); |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
144 } |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
145 providers = dataProviders.get(key); |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
146 |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
147 if (providers == null) { |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
148 providers = new ArrayList<DataProvider>(); |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
149 } |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
150 providers.add(value); |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
151 return dataProviders.put(key, providers); |
33d7a6da1a05
Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
246
diff
changeset
|
152 } |
219
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 } |
cabe4c02ab64
Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |