annotate artifact-database/src/main/java/org/dive4elements/artifactdatabase/AbstractCallContext.java @ 570:584591f8203c 3.2.x

Upgrade to Log4j 2
author Tom Gottfried <tom@intevation.de>
date Mon, 28 Feb 2022 17:41:14 +0100
parents 415df0fc4fa1
children
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 */
475
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
8 package org.dive4elements.artifactdatabase;
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
570
584591f8203c Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 475
diff changeset
10 import org.apache.logging.log4j.Logger;
584591f8203c Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 475
diff changeset
11 import org.apache.logging.log4j.LogManager;
362
5b6ba54d488a Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 357
diff changeset
12
353
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.ArrayList;
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
14 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
15 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
16 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
17
475
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
18 import org.dive4elements.artifacts.ArtifactDatabase;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
19 import org.dive4elements.artifacts.CallContext;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
20 import org.dive4elements.artifacts.CallMeta;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
21 import org.dive4elements.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
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 /**
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 * 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
26 *
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: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
28 * @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
29 */
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 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
31
570
584591f8203c Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 475
diff changeset
32 Logger logger = LogManager.getLogger(AbstractCallContext.class);
362
5b6ba54d488a Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 357
diff changeset
33
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 /**
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 * 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
36 */
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 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
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 /**
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 * 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
41 */
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 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
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 /**
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 * 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
46 */
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 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
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 /**
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 * 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
51 */
366
1f51f3c46efe AbstractCallContext: Instance vars are now Maps instead of Hashmaps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 362
diff changeset
52 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
53
353
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
54 /**
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
55 * 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
56 */
366
1f51f3c46efe AbstractCallContext: Instance vars are now Maps instead of Hashmaps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 362
diff changeset
57 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
58
219
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 /**
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 * 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
62 *
400
f367be55dd35 Doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 366
diff changeset
63 * @param artifactDatabase The artifact database.
219
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 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
65 * @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
66 */
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 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
68 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
69 int action,
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
70 CallMeta callMeta
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
71 ) {
219
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.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
73 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
74 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
75
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
76 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
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
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
80 public void postCall() {
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
81 database.closeCallContext(this);
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 219
diff changeset
82 }
219
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 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
85
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 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
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 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
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
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 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
92 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
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
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 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
97 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
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
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 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
102 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
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
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 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
107 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
108 ? 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
109 : null;
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
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 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
113 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
114 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
115 }
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 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
117 }
353
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 /**
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
120 * 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
121 * @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
122 */
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
123 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
124 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
125 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
126 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
127 ? list
5b6ba54d488a Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 357
diff changeset
128 : 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
129 }
5b6ba54d488a Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 357
diff changeset
130 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
131 }
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
132
362
5b6ba54d488a Never return null from a function which is documented to do so.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 357
diff changeset
133
353
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 * 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
136 * 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
137 */
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
138 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
139 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
140 if (dataProviders == null) {
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
141 dataProviders = new HashMap();
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
142 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
143 providers.add(value);
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
144 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
145 }
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
146 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
147
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
148 if (providers == null) {
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
149 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
150 }
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
151 providers.add(value);
33d7a6da1a05 Extended CallContext to also act as a blackboard/service broker.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 246
diff changeset
152 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
153 }
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 }
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org