changeset 24:d5dc2900392f

* Added callback parameter to Artifact.setup() * New namespace context for artifacts. artifacts/trunk@58 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 10 Sep 2009 08:57:09 +0000
parents 00596a591a2f
children ccc6aae25585
files Changelog artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/FactoriesResource.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java artifacts/src/main/java/de/intevation/artifacts/Artifact.java artifacts/src/main/java/de/intevation/artifacts/ArtifactNamespaceContext.java
diffstat 8 files changed, 91 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/Changelog	Thu Sep 10 08:14:03 2009 +0000
+++ b/Changelog	Thu Sep 10 08:57:09 2009 +0000
@@ -1,3 +1,27 @@
+2009-09-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifacts/src/main/java/de/intevation/artifacts/Artifact.java(setup): Added
+	callback parameter in form of the creating factory.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java,
+	artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java:
+	Adjusted to match new Artifact interface.
+	
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java:
+	Call artifact.setup() with this.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java:
+	Removed namespace stuff.
+
+	* artifacts/src/main/java/de/intevation/artifacts/ArtifactNamespaceContext.java:
+	Created namespace stuff, need for XPath for e.g.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/rest/FactoriesResource.java:
+	Use new namespace stuff.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java: 
+	Added author.
+
 2009-09-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/XMLUtils.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Sep 10 08:14:03 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Sep 10 08:57:09 2009 +0000
@@ -123,8 +123,8 @@
             }
         }
 
-        public void setup(String identifier, Object context) {
-            original.setup(identifier, context);
+        public void setup(String identifier, ArtifactFactory factory, Object context) {
+            original.setup(identifier, factory, context);
         }
 
         public void endOfLife(Object context) {
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java	Thu Sep 10 08:14:03 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java	Thu Sep 10 08:57:09 2009 +0000
@@ -6,6 +6,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.ArtifactFactory;
 
 import org.apache.log4j.Logger;
 
@@ -17,16 +18,6 @@
 {
     private static Logger logger = Logger.getLogger(DefaultArtifact.class);
     
-    /**
-     * The URI of the Namespace of the Artifacts
-     */
-    public final static String NAMESPACE_URI = "http://www.intevation.de/2009/artifacts";
-    
-    /**
-     * The XML-Prefix for the Artifacts-Namespae
-     */
-    public final static String NAMESPACE_PREFIX = "art";
-
     protected String identifier;
 
     public DefaultArtifact() {
@@ -69,7 +60,7 @@
         return new byte[0];
     }
 
-    public void setup(String identifier, Object context) {
+    public void setup(String identifier, ArtifactFactory factory, Object context) {
         this.identifier = identifier;
     }
 
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java	Thu Sep 10 08:14:03 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java	Thu Sep 10 08:57:09 2009 +0000
@@ -53,7 +53,7 @@
             Artifact artifact =
                 (Artifact)artifactClass.newInstance();
 
-            artifact.setup(identifier, context);
+            artifact.setup(identifier, this, context);
 
             return artifact;
         }
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/FactoriesResource.java	Thu Sep 10 08:14:03 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/FactoriesResource.java	Thu Sep 10 08:57:09 2009 +0000
@@ -1,6 +1,7 @@
 package de.intevation.artifactdatabase.rest;
 
 import de.intevation.artifacts.ArtifactDatabase;
+import de.intevation.artifacts.ArtifactNamespaceContext;
 
 import org.restlet.data.MediaType;
 
@@ -38,8 +39,8 @@
 
         ElementCreator ec = new ElementCreator(
             document,
-            DefaultArtifact.NAMESPACE_URI,
-            DefaultArtifact.NAMESPACE_PREFIX);
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
 
         ArtifactDatabase db = (ArtifactDatabase)getContext()
             .getAttributes().get("database");
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java	Thu Sep 10 08:14:03 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java	Thu Sep 10 08:57:09 2009 +0000
@@ -12,6 +12,9 @@
 
 import org.apache.log4j.Logger;
 
+/**
+ * @author Sascha L. Teichmann (sascha.teichmann@intevation)
+ */
 public class Standalone
 {
     private static Logger logger = Logger.getLogger(Standalone.class);
--- a/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Thu Sep 10 08:14:03 2009 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Thu Sep 10 08:57:09 2009 +0000
@@ -24,7 +24,7 @@
  *
  * There are two more methods involved with the life cycle of the are:
  * <ol>
- *   <li>{@link #setup(String, Object) setup()}: Called after created by the 
+ *   <li>{@link #setup(String, ArtifactFactory, Object) setup()}: Called after created by the 
  *                                               factory.</li>
  *   <li>{@link #endOfLife(Object) endOfLife()}: Called when the artifact
  *                                               is going to be removed from
@@ -84,9 +84,10 @@
      * When created by a factory this method is called to
      * initialize the artifact.
      * @param identifier The identifier from artifact database
+     * @param factory    The factory which created this artifact.
      * @param context    The global context of the runtime system.
      */
-    public void setup(String identifier, Object context);
+    public void setup(String identifier, ArtifactFactory factory, Object context);
 
     /**
      * Called from artifact database when an artifact is
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactNamespaceContext.java	Thu Sep 10 08:57:09 2009 +0000
@@ -0,0 +1,53 @@
+package de.intevation.artifacts;
+
+import javax.xml.XMLConstants;
+
+import javax.xml.namespace.NamespaceContext;
+
+import java.util.Iterator;
+
+/**
+ * @author Sascha L. Teichmann (sascha.teichmann@intevation)
+ */
+public class ArtifactNamespaceContext
+implements   NamespaceContext
+{
+    /**
+     * The URI of the namespace of the artifacts.
+     */
+    public final static String NAMESPACE_URI = "http://www.intevation.de/2009/artifacts";
+    
+    /**
+     * The XML prefix for the artifacts namespace.
+     */
+    public final static String NAMESPACE_PREFIX = "art";
+
+    public ArtifactNamespaceContext() {
+    }
+
+    public String getNamespaceURI(String prefix) {
+
+        if (prefix == null) {
+            throw new NullPointerException("Null prefix");
+        }
+
+        if (NAMESPACE_PREFIX.equals(prefix)) {
+            return NAMESPACE_URI;
+        }
+
+        if ("xml".equals(prefix)) {
+            return XMLConstants.XML_NS_URI;
+        }
+
+        return XMLConstants.NULL_NS_URI;
+    }
+
+    public String getPrefix(String uri) {
+        throw new UnsupportedOperationException();
+    }
+
+    public Iterator getPrefixes(String uri) {
+        throw new UnsupportedOperationException();
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org