You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/06/11 20:53:12 UTC

svn commit: r666783 - in /geronimo/gshell/trunk: ./ gshell-commands/gshell-builtins/ gshell-core/ gshell-core/src/main/java/org/apache/geronimo/gshell/ gshell-core/src/main/java/org/apache/geronimo/gshell/layout/ gshell-layout/ gshell-layout/src/ gshel...

Author: jdillon
Date: Wed Jun 11 11:53:12 2008
New Revision: 666783

URL: http://svn.apache.org/viewvc?rev=666783&view=rev
Log:
Move the layout bits to gshell-layout

Added:
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultLayoutManager.java   (with props)
    geronimo/gshell/trunk/gshell-layout/
    geronimo/gshell/trunk/gshell-layout/pom.xml   (with props)
    geronimo/gshell/trunk/gshell-layout/src/
    geronimo/gshell/trunk/gshell-layout/src/main/
    geronimo/gshell/trunk/gshell-layout/src/main/java/
    geronimo/gshell/trunk/gshell-layout/src/main/java/org/
    geronimo/gshell/trunk/gshell-layout/src/main/java/org/apache/
    geronimo/gshell/trunk/gshell-layout/src/main/java/org/apache/geronimo/
    geronimo/gshell/trunk/gshell-layout/src/main/java/org/apache/geronimo/gshell/
    geronimo/gshell/trunk/gshell-layout/src/main/java/org/apache/geronimo/gshell/layout/
      - copied from r666664, geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/
Removed:
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/
    geronimo/gshell/trunk/gshell-layout/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/pom.xml
    geronimo/gshell/trunk/gshell-core/pom.xml
    geronimo/gshell/trunk/pom.xml
    geronimo/gshell/trunk/src/uml/GShell.mdxml

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/pom.xml?rev=666783&r1=666782&r2=666783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/pom.xml Wed Jun 11 11:53:12 2008
@@ -52,15 +52,10 @@
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-plugin</artifactId>
         </dependency>
-        
-        <!--
-        FIXME: This is currently needed for the 'help' command implementation, and should be removed once the
-               command has been refactored as well as the Layout API sorted/moved out of core.
-        -->
 
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
-            <artifactId>gshell-core</artifactId>
+            <artifactId>gshell-layout</artifactId>
         </dependency>
     </dependencies>
 

Modified: geronimo/gshell/trunk/gshell-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/pom.xml?rev=666783&r1=666782&r2=666783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-core/pom.xml Wed Jun 11 11:53:12 2008
@@ -69,6 +69,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-layout</artifactId>
+        </dependency>
+        
+        <dependency>
             <groupId>org.codehaus.plexus</groupId>
             <artifactId>plexus-interpolation</artifactId>
         </dependency>

Added: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultLayoutManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultLayoutManager.java?rev=666783&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultLayoutManager.java (added)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultLayoutManager.java Wed Jun 11 11:53:12 2008
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell;
+
+import org.apache.geronimo.gshell.application.ApplicationManager;
+import org.apache.geronimo.gshell.model.layout.GroupNode;
+import org.apache.geronimo.gshell.model.layout.Layout;
+import org.apache.geronimo.gshell.model.layout.Node;
+import org.apache.geronimo.gshell.layout.LayoutManager;
+import org.apache.geronimo.gshell.layout.NotFoundException;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The default implementation of the {@link LayoutManager} component.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role= LayoutManager.class)
+public class DefaultLayoutManager
+    implements LayoutManager
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Requirement
+    private ApplicationManager applicationManager;
+    
+    private Layout layout;
+
+    public DefaultLayoutManager() {}
+    
+    public DefaultLayoutManager(final ApplicationManager applicationManager) {
+        assert applicationManager != null;
+
+        this.applicationManager = applicationManager;
+    }
+
+    private Layout lookupLayout() {
+        assert applicationManager != null;
+
+        Layout layout = applicationManager.getContext().getApplication().getLayout();
+
+        if (layout == null) {
+            throw new IllegalStateException("Layout has not been configured for application");
+        }
+
+        return layout;
+    }
+
+    public Layout getLayout() {
+        if (layout == null) {
+            layout = lookupLayout();
+
+            log.debug("Using layout: {}", layout);
+        }
+        
+        return layout;
+    }
+
+    public Node findNode(final String path) throws NotFoundException {
+        return findNode(path, null);
+    }
+
+    public Node findNode(final String path, final String searchPath) throws NotFoundException {
+        assert path != null;
+
+        // Make sure we have initialized the layout
+        getLayout();
+
+        Node start;
+
+        if (path.startsWith(FILE_SEPARATOR)) {
+            start = layout;
+            return findNode(start, path);
+        }
+        else if (searchPath != null) {
+            String[] pathList = searchPath.split(SEARCH_PATH_SEPARATOR);
+            Node foundNode = null;
+            
+            for (String commandPath : pathList) {
+                try {
+                    Node pathNode = findNode(commandPath);
+                    foundNode = findNode(pathNode, path);
+                    
+                    if (foundNode != null) {
+                        break;
+                    }
+                }
+                catch (NotFoundException e) {
+                    // Ignore this for now.  We might still have paths to check
+                }
+            }
+            
+            if (foundNode == null) {
+                foundNode = findNode(layout, path);
+            }
+            
+            return foundNode;
+        }
+        else {
+            assert applicationManager != null;
+            
+            start = (Node) applicationManager.getContext().getEnvironment().getVariables().get(CURRENT_NODE);
+
+            if (start == null) {
+                start = layout;
+            }
+            
+            return findNode(start, path);
+        }
+    }
+
+    public Node findNode(final Node start, final String path) throws NotFoundException {
+        assert start != null;
+        assert path != null;
+
+        Node current = start;
+
+        String[] elements = path.split(FILE_SEPARATOR);
+        
+        for (String element : elements) {
+            if (current instanceof GroupNode) {
+                Node node = ((GroupNode)current).find(element);
+
+                if (node == null) {
+                    throw new NotFoundException(path);
+                }
+
+                current = node;
+            }
+            else {
+                throw new NotFoundException(path);
+            }
+        }
+
+        return current;
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultLayoutManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: geronimo/gshell/trunk/gshell-layout/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-layout/pom.xml?rev=666783&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-layout/pom.xml (added)
+++ geronimo/gshell/trunk/gshell-layout/pom.xml Wed Jun 11 11:53:12 2008
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+     http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.geronimo.gshell</groupId>
+        <artifactId>gshell</artifactId>
+        <version>1.0-alpha-2-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>gshell-layout</artifactId>
+    <name>GShell Layout</name>
+
+    <description>
+        Provides access to command layout configuration details.
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-model</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

Propchange: geronimo/gshell/trunk/gshell-layout/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-layout/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-layout/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/pom.xml?rev=666783&r1=666782&r2=666783&view=diff
==============================================================================
--- geronimo/gshell/trunk/pom.xml (original)
+++ geronimo/gshell/trunk/pom.xml Wed Jun 11 11:53:12 2008
@@ -395,6 +395,12 @@
             </dependency>
 
             <dependency>
+                <groupId>org.apache.geronimo.gshell</groupId>
+                <artifactId>gshell-layout</artifactId>
+                <version>1.0-alpha-2-SNAPSHOT</version>
+            </dependency>
+            
+            <dependency>
                 <groupId>org.apache.geronimo.gshell.remote</groupId>
                 <artifactId>gshell-whisper</artifactId>
                 <version>1.0-alpha-2-SNAPSHOT</version>
@@ -484,6 +490,7 @@
         <module>gshell-model</module>
         <module>gshell-plugin</module>
         <module>gshell-parser</module>
+        <module>gshell-layout</module>
         <module>gshell-core</module>
         <module>gshell-cli</module>
         <module>gshell-commands</module>

Modified: geronimo/gshell/trunk/src/uml/GShell.mdxml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/src/uml/GShell.mdxml?rev=666783&r1=666782&r2=666783&view=diff
==============================================================================
--- geronimo/gshell/trunk/src/uml/GShell.mdxml (original)
+++ geronimo/gshell/trunk/src/uml/GShell.mdxml Wed Jun 11 11:53:12 2008
@@ -1621,6 +1621,22 @@
 							<linkConveyedAID xmi:idref='_15_1_640021c_1213207328445_846925_6961'/>
 							<linkConveyedBID xmi:idref='_15_1_640021c_1213207328445_276076_6963'/>
 						</mdElement>
+						<mdElement elementClass='Note' xmi:id='_15_1_640021c_1213207616728_128440_6965'>
+							<elementID xmi:idref='_15_1_640021c_1213183422570_237805_1323'/>
+							<geometry>378, 910, 100, 73</geometry>
+							<text>These are really container implementation specific</text>
+							<active xmi:idref='_15_1_640021c_1213207630605_262912_6976'/>
+						</mdElement>
+						<mdElement elementClass='NoteAnchor' xmi:id='_15_1_640021c_1213207630605_262912_6976'>
+							<linkFirstEndID xmi:idref='_15_1_640021c_1213183422570_628704_1324'/>
+							<linkSecondEndID xmi:idref='_15_1_640021c_1213207616728_128440_6965'/>
+							<geometry>273, 943; 378, 945; </geometry>
+						</mdElement>
+						<mdElement elementClass='NoteAnchor' xmi:id='_15_1_640021c_1213207633491_530735_6977'>
+							<linkFirstEndID xmi:idref='_15_1_640021c_1213183493139_853602_1384'/>
+							<linkSecondEndID xmi:idref='_15_1_640021c_1213207616728_128440_6965'/>
+							<geometry>262, 833; 378, 912; </geometry>
+						</mdElement>
 					</mdOwnedViews>
 				</mdElement>
 			</mdElement>
@@ -4635,7 +4651,7 @@
 						<mdElement elementClass='StringProperty'>
 							<propertyID>INFO_PROPERTY</propertyID>
 							<propertyDescriptionID>INFO_PROPERTY_DESCRIPTION</propertyDescriptionID>
-							<value>f 1d 39 42 6a 2a 59 57 35 51 56 a9 62 b8 1b eb f5 71 27 f3 d3 f1 81 ed d4 da 55 e7 ce 8 b5 c0 29 26 f 8b 6e 37 74 28 fa c9 c7 79 26 df 3f d0 4e 4 41 7c 29 e7 fa 2 f1 ec c2 d1 3d 11 8 4e e0 27 0 fd 3b 5b d8 9d de 92 2a e0 ed c0 b 95 ba 9a 43 74 1c 2f d1 81 f ca 16 3f 34 4d 97 c6 28 91 47 ff ec 28 ab 61 39 ed </value>
+							<value>f 1d 39 42 6a 2a 59 57 35 51 56 a9 62 b8 1b eb f5 71 27 f3 d3 f1 81 ed d4 da 57 e7 cc a b5 c0 29 26 f 8b 6e 37 74 28 fa c9 c7 79 26 df 3f d0 4e 4 41 7c 29 e7 fa 2 f1 ec c2 d1 3d 11 8 4e e0 27 0 fd 3b 5b d8 9d de 92 2a e0 ed c0 b 95 ba 9a 43 74 1c 2f d1 81 f ca 16 3f 34 4d 97 c6 28 91 47 ff ec 28 ab 61 39 ed </value>
 							<multiline xmi:value='false'/>
 						</mdElement>
 						<mdElement elementClass='LIST_PROPERTY'>