annotate artifact-database/src/main/java/de/intevation/artifactdatabase/AbstractCallContext.java @ 353:33d7a6da1a05

Extended CallContext to also act as a blackboard/service broker. artifacts/trunk@3331 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 30 Nov 2011 08:24:55 +0000
parents a8a06bbe306c
children 1d11a0531242
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
353
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
10 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
11 import java.util.List;
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 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
13
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 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
15 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
16 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
17 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
18
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 /**
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 * 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
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 * @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
24 * @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
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 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
27
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 * 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
30 */
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 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
32
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 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
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 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
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 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
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 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
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 * 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
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 HashMap customValues;
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
353
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
48 /**
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
49 * 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
50 */
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
51 protected HashMap<Object, List<DataProvider>> dataProviders;
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
52
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 /**
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 * 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
56 *
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 * @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
58 * @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
59 * @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
60 */
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 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
62 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
63 int action,
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
64 CallMeta callMeta
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
65 ) {
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 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
67 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
68 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
69
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
70 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
71 }
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
74 public void postCall() {
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
75 database.closeCallContext(this);
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
76 }
219
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 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
79
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 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
81
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 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
83
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 Object globalContext() {
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
86 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
87 }
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 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
91 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
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 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
96 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
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 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
101 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
102 ? 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
103 : null;
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
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 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
107 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
108 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
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 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
111 }
353
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
112
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
113 /**
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
114 * 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
115 * @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
116 */
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
117 public List<DataProvider> getDataProvider(Object key) {
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
118 return dataProviders != null
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
119 ? dataProviders.get(key)
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
120 : null;//java.util.Collections.emptyList();
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
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
123 /**
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
124 * 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
125 * 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
126 */
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
127 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
128 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
129 if (dataProviders == null) {
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
130 dataProviders = new HashMap();
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
131 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
132 providers.add(value);
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
133 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
134 }
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
135 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
136
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
137 if (providers == null) {
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
138 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
139 }
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
140 providers.add(value);
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
141 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
142 }
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 }
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org