annotate artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java @ 68:541814404822

Added interfaces for XML processing services. TODO: Implement them! artifacts/trunk@593 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 22 Jan 2010 09:48:18 +0000
parents 85d996328c8a
children 48d1a9a082c2
rev   line source
58
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.artifactdatabase;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import org.w3c.dom.Document;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import de.intevation.artifacts.Artifact;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 import de.intevation.artifacts.CallContext;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 import org.apache.log4j.Logger;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 import java.io.IOException;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import java.io.OutputStream;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 /**
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 */
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 public class ProxyArtifact
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 extends DefaultArtifact
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 public static final Object REPLACE_PROXY = new Object();
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 private static Logger logger = Logger.getLogger(ProxyArtifact.class);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 protected Artifact proxied;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 public ProxyArtifact() {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public ProxyArtifact(Artifact proxied) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 this.proxied = proxied;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 public Artifact getProxied() {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 return proxied;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public void setProxied(Artifact proxied) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 this.proxied = proxied;
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 protected void checkReplacement(CallContext callContext) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 Object replacement = callContext.getContextValue(REPLACE_PROXY);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 if (replacement instanceof Artifact) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 setProxied((Artifact)replacement);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 public String hash() {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 return proxied != null
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 ? proxied.hash()
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 : super.hash();
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 public Document describe(Document data, CallContext context) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 try {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 return proxied != null
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 ? proxied.describe(data, context)
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 : super.describe(data, context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 finally {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 checkReplacement(context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 public Document advance(Document target, CallContext context) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 try {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 return proxied != null
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 ? proxied.advance(target, context)
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 : super.advance(target, context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 finally {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 checkReplacement(context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 public Document feed(Document target, CallContext context) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 try {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 return proxied != null
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 ? proxied.feed(target, context)
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 : super.feed(target, context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 finally {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 checkReplacement(context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 public void out(
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 Document format,
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 OutputStream out,
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 CallContext context
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 )
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 throws IOException
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 try {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 if (proxied != null) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 proxied.out(format, out, context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 else {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 super.out(format, out, context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 finally {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 checkReplacement(context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 public void endOfLife(Object context) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 if (proxied != null) {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 proxied.endOfLife(context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 else {
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 super.endOfLife(context);
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 }
39fec7d714dc Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org