geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r661656 - in /geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model: command/CommandSet.java common/ModelRoot.java marshal/Marshaller.java marshal/MarshallerSupport.java
Date Fri, 30 May 2008 11:33:14 GMT
Author: jdillon
Date: Fri May 30 04:33:14 2008
New Revision: 661656

URL: http://svn.apache.org/viewvc?rev=661656&view=rev
Log:
Attach the marshaller to the model root element when unmarshalling

Modified:
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/command/CommandSet.java
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/ModelRoot.java
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/Marshaller.java
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/MarshallerSupport.java

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/command/CommandSet.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/command/CommandSet.java?rev=661656&r1=661655&r2=661656&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/command/CommandSet.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/command/CommandSet.java
Fri May 30 04:33:14 2008
@@ -22,6 +22,7 @@
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
 import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.geronimo.gshell.model.common.ModelRoot;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -34,6 +35,7 @@
 // FIXME: Use consistent case for XML tags
 @XStreamAlias("command-set")
 public class CommandSet
+    extends ModelRoot
 {
     private String id;
 

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/ModelRoot.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/ModelRoot.java?rev=661656&r1=661655&r2=661656&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/ModelRoot.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/ModelRoot.java
Fri May 30 04:33:14 2008
@@ -20,6 +20,7 @@
 package org.apache.geronimo.gshell.model.common;
 
 import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
+import org.apache.geronimo.gshell.model.marshal.Marshaller;
 
 /**
  * Base class for root model elements.
@@ -29,9 +30,19 @@
 public abstract class ModelRoot
     extends ModelElement
 {
+    private transient Marshaller marshaller;
+
     @XStreamAsAttribute
     private String modelVersion;
 
+    public Marshaller getMarshaller() {
+        return marshaller;
+    }
+
+    public void setMarshaller(final Marshaller marshaller) {
+        this.marshaller = marshaller;
+    }
+
     public String getModelVersion() {
         return modelVersion;
     }

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/Marshaller.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/Marshaller.java?rev=661656&r1=661655&r2=661656&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/Marshaller.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/Marshaller.java
Fri May 30 04:33:14 2008
@@ -19,6 +19,8 @@
 
 package org.apache.geronimo.gshell.model.marshal;
 
+import org.apache.geronimo.gshell.model.common.ModelRoot;
+
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.OutputStream;
@@ -29,7 +31,7 @@
  *
  * @version $Rev$ $Date$
  */
-public interface Marshaller<T>
+public interface Marshaller<T extends ModelRoot>
 {
     void marshal(T root, OutputStream output);
 

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/MarshallerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/MarshallerSupport.java?rev=661656&r1=661655&r2=661656&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/MarshallerSupport.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/marshal/MarshallerSupport.java
Fri May 30 04:33:14 2008
@@ -31,12 +31,14 @@
 import java.io.Writer;
 import java.net.URL;
 
+import org.apache.geronimo.gshell.model.common.ModelRoot;
+
 /**
  * Support for model {@link Marshaller} implementations.
  *
  * @version $Rev$ $Date$
  */
-public class MarshallerSupport<T>
+public class MarshallerSupport<T extends ModelRoot>
     implements Marshaller<T>
 {
     private final Class rootType;
@@ -100,14 +102,22 @@
     public T unmarshal(final InputStream input) {
         assert input != null;
 
-        return (T)createXStream().fromXML(input);
+        T model = (T)createXStream().fromXML(input);
+
+        model.setMarshaller(this);
+
+        return model;
     }
 
     @SuppressWarnings({"unchecked"})
     public T unmarshal(final Reader reader) {
         assert reader != null;
 
-        return (T)createXStream().fromXML(reader);
+        T model = (T)createXStream().fromXML(reader);
+
+        model.setMarshaller(this);
+        
+        return model;
     }
 
     public T unmarshal(final String xml) {



Mime
View raw message