comparison artifact-database/src/main/java/de/intevation/artifactdatabase/AbstractCallContext.java @ 219:cabe4c02ab64

Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now. artifacts/trunk@1559 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 24 Mar 2011 16:16:51 +0000
parents
children a8a06bbe306c
comparison
equal deleted inserted replaced
218:70cbbe144931 219:cabe4c02ab64
1 /*
2 * Copyright (c) 2010, 2011 by Intevation GmbH
3 *
4 * This program is free software under the LGPL (>=v2.1)
5 * Read the file LGPL.txt coming with the software for details
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
7 */
8 package de.intevation.artifactdatabase;
9
10 import java.util.HashMap;
11
12 import de.intevation.artifacts.ArtifactDatabase;
13 import de.intevation.artifacts.CallContext;
14 import de.intevation.artifacts.CallMeta;
15
16
17 /**
18 * Abstract class that implements some basic methods of a CallContext.
19 *
20 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
21 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
22 */
23 public abstract class AbstractCallContext implements CallContext {
24
25 /**
26 * The ArtifactDatabase instance.
27 */
28 protected ArtifactDatabaseImpl database;
29
30 /**
31 * The action to be performed after the artifacts or collections calls.
32 */
33 protected int action;
34
35 /**
36 * The meta information of the concrete call (preferred languages et. al.)
37 */
38 protected CallMeta callMeta;
39
40 /**
41 * The global context.
42 */
43 protected Object context;
44
45 /**
46 * Map to act like a clipboard when nesting calls like a proxy artifact.
47 */
48 protected HashMap customValues;
49
50
51 /**
52 * The default constructor of this abstract CallContext.
53 *
54 * @param action The action.
55 * @param callMeta The CallMeta object.
56 * @param context The global context.
57 */
58 public AbstractCallContext(
59 ArtifactDatabaseImpl artifactDatabase,
60 int action,
61 CallMeta callMeta,
62 Object context)
63 {
64 this.database = artifactDatabase;
65 this.action = action;
66 this.callMeta = callMeta;
67 this.context = context;
68 }
69
70
71 public abstract void postCall();
72
73 public abstract void afterCall(int action);
74
75 public abstract Long getTimeToLive();
76
77 public abstract void afterBackground(int action);
78
79
80 public Object globalContext() {
81 return context;
82 }
83
84
85 public ArtifactDatabase getDatabase() {
86 return database;
87 }
88
89
90 public CallMeta getMeta() {
91 return callMeta;
92 }
93
94
95 public Object getContextValue(Object key) {
96 return customValues != null
97 ? customValues.get(key)
98 : null;
99 }
100
101 public Object putContextValue(Object key, Object value) {
102 if (customValues == null) {
103 customValues = new HashMap();
104 }
105 return customValues.put(key, value);
106 }
107 }
108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org