geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r658593 - in /geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model: common/Dependency.java marshal/Marshaller.java marshal/MarshallerSupport.java
Date Wed, 21 May 2008 08:26:29 GMT
Author: jdillon
Date: Wed May 21 01:26:29 2008
New Revision: 658593

URL: http://svn.apache.org/viewvc?rev=658593&view=rev
Log:
Make Dependency.getType() default to 'jar'
Add more type support for input/output muck for marshallers

Modified:
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/Dependency.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/common/Dependency.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/Dependency.java?rev=658593&r1=658592&r2=658593&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/Dependency.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/Dependency.java
Wed May 21 01:26:29 2008
@@ -30,6 +30,8 @@
 public class Dependency
     extends DependencySupport
 {
+    public static final String DEFAULT_TYPE = "jar";
+
     private transient DependencyGroup dependencyGroup;
 
     public DependencyGroup getDependencyGroup() {
@@ -79,6 +81,10 @@
             tmp = dependencyGroup.getType();
         }
 
+        if (tmp == null) {
+            tmp = DEFAULT_TYPE;
+        }
+
         return tmp;
     }
 

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=658593&r1=658592&r2=658593&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
Wed May 21 01:26:29 2008
@@ -20,6 +20,9 @@
 package org.apache.geronimo.gshell.model.marshal;
 
 import java.io.InputStream;
+import java.io.Reader;
+import java.io.OutputStream;
+import java.io.Writer;
 
 /**
  * Model marshaller interface.
@@ -28,7 +31,15 @@
  */
 public interface Marshaller<T>
 {
+    void marshal(T root, OutputStream output);
+
+    void marshal(T root, Writer writer);
+
     String marshal(T root);
 
     T unmarshal(InputStream input);
+
+    T unmarshal(Reader reader);
+
+    T unmarshal(String xml);
 }
\ No newline at end of file

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=658593&r1=658592&r2=658593&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
Wed May 21 01:26:29 2008
@@ -26,6 +26,9 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.Reader;
+import java.io.StringReader;
+import java.io.OutputStream;
+import java.io.Writer;
 import java.net.URL;
 
 /**
@@ -33,7 +36,7 @@
  *
  * @version $Rev$ $Date$
  */
-public abstract class MarshallerSupport<T>
+public class MarshallerSupport<T>
     implements Marshaller<T>
 {
     private Class rootType;
@@ -61,6 +64,20 @@
         return xs;
     }
 
+    public void marshal(final T root, final OutputStream output) {
+        assert root != null;
+        assert output != null;
+
+        createXStream().toXML(root, output);
+    }
+
+    public void marshal(final T root, final Writer writer) {
+        assert root != null;
+        assert writer != null;
+
+        createXStream().toXML(root, writer);
+    }
+
     public String marshal(final T root) {
         assert root != null;
 
@@ -80,10 +97,12 @@
         //noinspection unchecked
         return (T)createXStream().fromXML(reader);
     }
-    
-    //
-    // Helpers
-    //
+
+    public T unmarshal(final String xml) {
+        assert xml != null;
+
+        return unmarshal(new StringReader(xml));
+    }
     
     public T unmarshal(final URL url) throws IOException {
         assert url != null;



Mime
View raw message