Mercurial > dive4elements > framework
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/AbstractCallContext.java Thu Mar 24 16:16:51 2011 +0000 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2010, 2011 by Intevation GmbH + * + * This program is free software under the LGPL (>=v2.1) + * Read the file LGPL.txt coming with the software for details + * or visit http://www.gnu.org/licenses/ if it does not exist. + */ +package de.intevation.artifactdatabase; + +import java.util.HashMap; + +import de.intevation.artifacts.ArtifactDatabase; +import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.CallMeta; + + +/** + * Abstract class that implements some basic methods of a CallContext. + * + * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public abstract class AbstractCallContext implements CallContext { + + /** + * The ArtifactDatabase instance. + */ + protected ArtifactDatabaseImpl database; + + /** + * The action to be performed after the artifacts or collections calls. + */ + protected int action; + + /** + * The meta information of the concrete call (preferred languages et. al.) + */ + protected CallMeta callMeta; + + /** + * The global context. + */ + protected Object context; + + /** + * Map to act like a clipboard when nesting calls like a proxy artifact. + */ + protected HashMap customValues; + + + /** + * The default constructor of this abstract CallContext. + * + * @param action The action. + * @param callMeta The CallMeta object. + * @param context The global context. + */ + public AbstractCallContext( + ArtifactDatabaseImpl artifactDatabase, + int action, + CallMeta callMeta, + Object context) + { + this.database = artifactDatabase; + this.action = action; + this.callMeta = callMeta; + this.context = context; + } + + + public abstract void postCall(); + + public abstract void afterCall(int action); + + public abstract Long getTimeToLive(); + + public abstract void afterBackground(int action); + + + public Object globalContext() { + return context; + } + + + public ArtifactDatabase getDatabase() { + return database; + } + + + public CallMeta getMeta() { + return callMeta; + } + + + public Object getContextValue(Object key) { + return customValues != null + ? customValues.get(key) + : null; + } + + public Object putContextValue(Object key, Object value) { + if (customValues == null) { + customValues = new HashMap(); + } + return customValues.put(key, value); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :