Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java @ 59:8cd770330f1b
Added path to chart template and added a method to retrieve its configuration.
artifacts/trunk@361 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 23 Nov 2009 16:56:47 +0000 |
parents | 39fec7d714dc |
children | 85d996328c8a |
line wrap: on
line source
package de.intevation.artifactdatabase; import org.w3c.dom.Document; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.ArtifactFactory; import org.apache.log4j.Logger; import java.io.IOException; import java.io.OutputStream; /** * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) */ public class ProxyArtifact extends DefaultArtifact { public static final Object REPLACE_PROXY = new Object(); private static Logger logger = Logger.getLogger(ProxyArtifact.class); protected Artifact proxied; public ProxyArtifact() { } public ProxyArtifact(Artifact proxied) { this.proxied = proxied; } public Artifact getProxied() { return proxied; } public void setProxied(Artifact proxied) { this.proxied = proxied; } protected void checkReplacement(CallContext callContext) { Object replacement = callContext.getContextValue(REPLACE_PROXY); if (replacement instanceof Artifact) { setProxied((Artifact)replacement); } } public String hash() { return proxied != null ? proxied.hash() : super.hash(); } public Document describe(Document data, CallContext context) { try { return proxied != null ? proxied.describe(data, context) : super.describe(data, context); } finally { checkReplacement(context); } } public Document advance(Document target, CallContext context) { try { return proxied != null ? proxied.advance(target, context) : super.advance(target, context); } finally { checkReplacement(context); } } public Document feed(Document target, CallContext context) { try { return proxied != null ? proxied.feed(target, context) : super.feed(target, context); } finally { checkReplacement(context); } } public void out( Document format, OutputStream out, CallContext context ) throws IOException { try { if (proxied != null) { proxied.out(format, out, context); } else { super.out(format, out, context); } } finally { checkReplacement(context); } } public void endOfLife(Object context) { if (proxied != null) { proxied.endOfLife(context); } else { super.endOfLife(context); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: