changeset 351:eb1136134d09

Prepare inter-facet pre-rendering communication ('blackboard') phase. artifacts/trunk@3329 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 30 Nov 2011 08:13:48 +0000
parents ab743e750ac6
children 9c8d91708d28
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java
diffstat 3 files changed, 83 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Nov 23 17:17:39 2011 +0000
+++ b/ChangeLog	Wed Nov 30 08:13:48 2011 +0000
@@ -1,3 +1,17 @@
+2011-11-30	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Prepare inter-facet pre-rendering communication ('blackboard') phase.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java
+	  (getDataProviderKeys,provideBlackboardData): Extended interface to
+	  allow easy integration of blackboard mechanism (inter-facet
+	  pre-rendering communication).
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java
+	  (getDataProviderKeys,provideBlackboardData): Trivial implementation.
+	  The DefaultFacet will not talk to other facets during inter-facet
+	  pre-rendering ("blackboard") phase. Cosmetics, docs.
+
 2011-11-21  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/XMLUtils.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java	Wed Nov 23 17:17:39 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java	Wed Nov 30 08:13:48 2011 +0000
@@ -1,5 +1,7 @@
 package de.intevation.artifactdatabase.state;
 
+import java.util.List;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -18,18 +20,21 @@
  */
 public class DefaultFacet implements Facet {
 
-    /** The index of this facet.*/
+    /** The index of this facet. */
     protected int index;
 
-    /** The name of this facet.*/
+    /** The name of this facet. */
     protected String name;
 
-    /** The description of this facet.*/
+    /** The description of this facet. */
     protected String description;
 
+
+    /** Trivial, empty constructor. */
     public DefaultFacet() {
     }
 
+
     /**
      * The default constructor to create new Facet objects.
      *
@@ -54,12 +59,17 @@
         this.description = description;
     }
 
+
+    /**
+     * Copies name, index and description of other facet.
+     */
     public void set(Facet other) {
         index       = other.getIndex();
         name        = other.getName();
         description = other.getDescription();
     }
 
+
     public Facet deepCopy() {
         DefaultFacet copy = new DefaultFacet();
         copy.set(this);
@@ -82,10 +92,38 @@
     }
 
 
+    /**
+     * @return null
+     */
     public Object getData(Artifact artifact, CallContext context) {
         return null;
     }
 
+
+    /**
+     * (Do not) provide data.
+     * Override to allow other facets to access your data.
+     * @return always null.
+     */
+    public Object provideBlackboardData(
+        Artifact artifact,
+        Object key,
+        Object param,
+        CallContext context
+    ) {
+        return null;
+    }
+
+
+    /**
+     * Return list of keys (objects) for which this facet can provide data
+     * ("external parameterization"), for other facets, via blackboard.
+     */
+    public List getDataProviderKeys() {
+        return null;
+    }
+
+
     public String toString() {
         return new StringBuilder("name = '")
             .append(name).append("', index = ")
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java	Wed Nov 23 17:17:39 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java	Wed Nov 30 08:13:48 2011 +0000
@@ -1,5 +1,7 @@
 package de.intevation.artifactdatabase.state;
 
+import java.util.List;
+
 import java.io.Serializable;
 
 import org.w3c.dom.Document;
@@ -49,6 +51,32 @@
 
 
     /**
+     * Get keys for which this Facet can provide data (for other facets, not
+     * for plot).
+     *
+     * @return list of keys
+     */
+    List getDataProviderKeys();
+
+
+    /**
+     * Provide data to other facet.
+     *
+     * @param art  The artifact that this facet belongs to.
+     * @param key  the key of the requested service.
+     * @param prm  optional parameters.
+     * @param ctxt the callcontext.
+     *
+     * @return the data
+     */
+    Object provideBlackboardData(
+        Artifact art,
+        Object key,
+        Object prm,
+        CallContext ctxt);
+
+
+    /**
      * Write the internal representation of a facet to a node.
      *
      * @param doc A Document.

http://dive4elements.wald.intevation.org