geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r573690 - in /geronimo/sandbox/gshell/trunk/gshell-core/src: main/java/org/apache/geronimo/gshell/layout/ main/java/org/apache/geronimo/gshell/layout/model/ test/java/org/apache/geronimo/gshell/layout/model/
Date Fri, 07 Sep 2007 20:27:15 GMT
Author: jdillon
Date: Fri Sep  7 13:27:12 2007
New Revision: 573690

URL: http://svn.apache.org/viewvc?rev=573690&view=rev
Log:
Add *Node suffix to bits
Put toXML|fromXML bits into Layout

Added:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/AliasNode.java
  (contents, props changed)
      - copied, changed from r573387, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Alias.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/CommandNode.java
  (contents, props changed)
      - copied, changed from r573388, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Command.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/GroupNode.java
  (contents, props changed)
      - copied, changed from r573387, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Group.java
Removed:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Alias.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Command.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Group.java
Modified:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Layout.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/model/BasicModelValidationTest.java

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java?rev=573690&r1=573689&r2=573690&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java
Fri Sep  7 13:27:12 2007
@@ -25,13 +25,8 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 
-import com.thoughtworks.xstream.XStream;
-import com.thoughtworks.xstream.annotations.Annotations;
-import com.thoughtworks.xstream.io.xml.DomDriver;
 import org.apache.geronimo.gshell.command.ShellInfo;
 import org.apache.geronimo.gshell.command.descriptor.CommandDescriptor;
-import org.apache.geronimo.gshell.layout.model.Alias;
-import org.apache.geronimo.gshell.layout.model.Command;
 import org.apache.geronimo.gshell.layout.model.Layout;
 import org.apache.geronimo.gshell.plugin.PluginCollector;
 import org.codehaus.plexus.component.annotations.Component;
@@ -89,13 +84,9 @@
 
         InputStream input = url.openStream();
 
-        // Setup the XStream marshallar and configure it with the aliases for the model we
are working with
-        XStream xs = new XStream(new DomDriver());
-        Annotations.configureAliases(xs, Layout.class, Command.class, Alias.class);
-
         Layout layout;
         try {
-            layout = (Layout)xs.fromXML(input);
+            layout = Layout.fromXML(input);
             
             assert layout != null;
         }
@@ -105,9 +96,6 @@
 
         log.debug("Loaded layout: {}", layout);
 
-        //
-        // TODO: Do some kind post-parsing validation or someting?
-
         return layout;
     }
 
@@ -133,8 +121,6 @@
         // HACK: For now, assume the path is just the id... should eventually change this
         //
 
-        CommandDescriptor desc = pluginCollector.getCommandDescriptor(path);
-
-        return desc;
+        return pluginCollector.getCommandDescriptor(path);
     }
 }

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/AliasNode.java
(from r573387, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Alias.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/AliasNode.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/AliasNode.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Alias.java&r1=573387&r2=573690&rev=573690&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Alias.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/AliasNode.java
Fri Sep  7 13:27:12 2007
@@ -27,12 +27,12 @@
  * @version $Rev$ $Date$
  */
 @XStreamAlias("alias")
-public class Alias
+public class AliasNode
     extends Node
 {
     protected String command;
 
-    public Alias(final String name, final String command) {
+    public AliasNode(final String name, final String command) {
         super(name);
 
         assert command != null;

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/AliasNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/AliasNode.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/AliasNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/CommandNode.java
(from r573388, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Command.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/CommandNode.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/CommandNode.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Command.java&r1=573388&r2=573690&rev=573690&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Command.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/CommandNode.java
Fri Sep  7 13:27:12 2007
@@ -27,12 +27,12 @@
  * @version $Rev$ $Date$
  */
 @XStreamAlias("command")
-public class Command
+public class CommandNode
     extends Node
 {
     protected String id;
 
-    public Command(final String name, final String id) {
+    public CommandNode(final String name, final String id) {
         super(name);
 
         assert id != null;

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/CommandNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/CommandNode.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/CommandNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/GroupNode.java
(from r573387, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Group.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/GroupNode.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/GroupNode.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Group.java&r1=573387&r2=573690&rev=573690&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Group.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/GroupNode.java
Fri Sep  7 13:27:12 2007
@@ -30,12 +30,12 @@
  * @version $Rev$ $Date$
  */
 @XStreamAlias("group")
-public class Group
+public class GroupNode
     extends Node
 {
     protected List<Node> nodes = new ArrayList<Node>();
 
-    public Group(final String name) {
+    public GroupNode(final String name) {
         super(name);
     }
 

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/GroupNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/GroupNode.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/GroupNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Layout.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Layout.java?rev=573690&r1=573689&r2=573690&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Layout.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/model/Layout.java
Fri Sep  7 13:27:12 2007
@@ -19,7 +19,14 @@
 
 package org.apache.geronimo.gshell.layout.model;
 
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.annotations.Annotations;
 import com.thoughtworks.xstream.annotations.XStreamAlias;
+import com.thoughtworks.xstream.io.xml.DomDriver;
 
 /**
  * The root container for a layout tree.
@@ -28,16 +35,45 @@
  */
 @XStreamAlias("layout")
 public class Layout
-    extends Group
 {
+    protected String name;
+
+    protected List<Node> nodes = new ArrayList<Node>();
+
     public Layout(final String name) {
-        super(name);
+        assert name != null;
+
+        this.name = name;
+    }
+
+    public List<Node> nodes() {
+        return nodes;
+    }
+
+    public String getName() {
+        return name;
     }
 
-    /**
-     * Constructs the root layout.
-     */
-    public Layout() {
-        super("/");
+    //
+    // XML Conversion
+    //
+    
+    private static XStream createXStream() {
+        XStream xs = new XStream(new DomDriver());
+        Annotations.configureAliases(xs, Layout.class, CommandNode.class, AliasNode.class);
+
+        return xs;
+    }
+
+    public static Layout fromXML(final InputStream input) {
+        assert input != null;
+
+        return (Layout) createXStream().fromXML(input);
+    }
+
+    public static String toXML(final Layout layout) {
+        assert layout != null;
+
+        return createXStream().toXML(layout);
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/model/BasicModelValidationTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/model/BasicModelValidationTest.java?rev=573690&r1=573689&r2=573690&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/model/BasicModelValidationTest.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/model/BasicModelValidationTest.java
Fri Sep  7 13:27:12 2007
@@ -32,36 +32,29 @@
 public class BasicModelValidationTest
     extends TestCase
 {
-    private XStream xs;
-
-    protected void setUp() throws Exception {
-        xs = new XStream(new DomDriver());
-        Annotations.configureAliases(xs, Layout.class, Command.class, Alias.class);
-    }
-
     public void testReadLayout1() throws Exception {
-        Layout layout = (Layout) xs.fromXML(getClass().getResourceAsStream("layout1.xml"));
+        Layout layout = Layout.fromXML(getClass().getResourceAsStream("layout1.xml"));
         assertNotNull(layout);
     }
 
     public void testReadLayout2() throws Exception {
-        Layout layout = (Layout) xs.fromXML(getClass().getResourceAsStream("layout2.xml"));
+        Layout layout = Layout.fromXML(getClass().getResourceAsStream("layout2.xml"));
         assertNotNull(layout);
     }
     
     public void testDumpLayout1() throws Exception {
-        Layout layout = new Layout();
+        Layout layout = new Layout("/");
         
-        layout.nodes().add(new Command("foo", "bar"));
-        layout.nodes().add(new Alias("f", "foo"));
+        layout.nodes().add(new CommandNode("foo", "bar"));
+        layout.nodes().add(new AliasNode("f", "foo"));
 
-        Group g = new  Group("test");
-        g.nodes().add(new Command("a", "b"));
-        g.nodes().add(new Command("c", "d"));
+        GroupNode g = new GroupNode("test");
+        g.nodes().add(new CommandNode("a", "b"));
+        g.nodes().add(new CommandNode("c", "d"));
 
         layout.nodes().add(g);
         
-        String xml = xs.toXML(layout);
+        String xml = Layout.toXML(layout);
 
         System.err.println("XML: " + xml);
     }



Mime
View raw message