geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r707634 - in /geronimo/gshell/trunk: gshell-assembly/src/main/underlay/etc/ gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/ gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshel...
Date Fri, 24 Oct 2008 13:53:57 GMT
Author: jdillon
Date: Fri Oct 24 06:53:56 2008
New Revision: 707634

URL: http://svn.apache.org/viewvc?rev=707634&view=rev
Log:
Add a resolver to handle decoding the gshell.group muck

Added:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupDirectoryResolver.java
  (with props)
Modified:
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/gshell/components.xml

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml?rev=707634&r1=707633&r2=707634&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml Fri Oct 24
06:53:56 2008
@@ -47,9 +47,9 @@
                 </bean>
                 
                 <!--
-                <bean class="org.apache.geronimo.gshell.application.model.Artifact">
-                    <property name="groupId" value="org.apache.geronimo.gshell.support"/>
-                    <property name="artifactId" value="gshell-vfs-truezip"/>
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.support"/>
+                    <property name="artifact" value="gshell-vfs-truezip"/>
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
                 -->
@@ -64,43 +64,43 @@
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
 
-                <!--
-                <bean class="org.apache.geronimo.gshell.application.model.Artifact">
-                    <property name="groupId" value="org.apache.geronimo.gshell.commands"/>
-                    <property name="artifactId" value="gshell-vfs"/>
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.commands"/>
+                    <property name="artifact" value="gshell-vfs"/>
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.application.model.Artifact">
-                    <property name="groupId" value="org.apache.geronimo.gshell.commands"/>
-                    <property name="artifactId" value="gshell-admin"/>
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.commands"/>
+                    <property name="artifact" value="gshell-admin"/>
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.application.model.Artifact">
-                    <property name="groupId" value="org.apache.geronimo.gshell.commands"/>
-                    <property name="artifactId" value="gshell-optional"/>
+                <!--
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.commands"/>
+                    <property name="artifact" value="gshell-optional"/>
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.application.model.Artifact">
-                    <property name="groupId" value="org.apache.geronimo.gshell.commands"/>
-                    <property name="artifactId" value="gshell-log4j"/>
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.commands"/>
+                    <property name="artifact" value="gshell-log4j"/>
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.application.model.Artifact">
-                    <property name="groupId" value="org.apache.geronimo.gshell.commands"/>
-                    <property name="artifactId" value="gshell-bsf"/>
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.commands"/>
+                    <property name="artifact" value="gshell-bsf"/>
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
+                -->
 
-                <bean class="org.apache.geronimo.gshell.application.model.Artifact">
-                    <property name="groupId" value="org.apache.geronimo.gshell.commands"/>
-                    <property name="artifactId" value="gshell-remote"/>
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.commands"/>
+                    <property name="artifact" value="gshell-remote"/>
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
-                -->
             </list>
         </property>
     </bean>

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java?rev=707634&r1=707633&r2=707634&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java
Fri Oct 24 06:53:56 2008
@@ -29,7 +29,6 @@
 import org.apache.geronimo.gshell.event.EventListener;
 import org.apache.geronimo.gshell.event.EventManager;
 import org.apache.geronimo.gshell.registry.CommandRegistry;
-import org.apache.geronimo.gshell.vfs.FileSystemAccess;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegisteredEvent;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRemovedEvent;
 import org.apache.geronimo.gshell.wisdom.registry.CommandRegisteredEvent;
@@ -100,11 +99,11 @@
                 }
                 else if (event instanceof MetaDataRegisteredEvent) {
                     MetaDataRegisteredEvent targetEvent = (MetaDataRegisteredEvent)event;
-                    log.debug("{}", targetEvent.getName());
+                    log.debug("+ {}", targetEvent.getName());
                 }
                 else if (event instanceof MetaDataRemovedEvent) {
                     MetaDataRemovedEvent targetEvent = (MetaDataRemovedEvent)event;
-                    log.debug("{}", targetEvent.getName());
+                    log.debug("- {}", targetEvent.getName());
                 }
             }
         });

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java?rev=707634&r1=707633&r2=707634&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
Fri Oct 24 06:53:56 2008
@@ -26,6 +26,7 @@
 import org.apache.geronimo.gshell.event.EventListener;
 import org.apache.geronimo.gshell.event.EventManager;
 import org.apache.geronimo.gshell.registry.AliasRegistry;
+import org.apache.geronimo.gshell.registry.CommandResolver;
 import org.apache.geronimo.gshell.vfs.provider.meta.MetaFileNameParser;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
@@ -82,7 +83,7 @@
 
     private FileName createName(final String name) throws FileSystemException {
         assert name != null;
-        return nameParser.parseUri("/aliases/" + name);
+        return nameParser.parseUri(CommandResolver.ALIASES_ROOT + "/" + name);
     }
 
     private void add(final String name, final String alias) throws Exception {

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java?rev=707634&r1=707633&r2=707634&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
Fri Oct 24 06:53:56 2008
@@ -27,6 +27,7 @@
 import org.apache.geronimo.gshell.event.EventListener;
 import org.apache.geronimo.gshell.event.EventManager;
 import org.apache.geronimo.gshell.registry.CommandRegistry;
+import org.apache.geronimo.gshell.registry.CommandResolver;
 import org.apache.geronimo.gshell.vfs.provider.meta.MetaFileNameParser;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
@@ -83,7 +84,7 @@
 
     private FileName createName(final String name) throws FileSystemException {
         assert name != null;
-        return nameParser.parseUri("/commands/" + name);
+        return nameParser.parseUri(CommandResolver.COMMANDS_ROOT + "/" + name);
     }
 
     private void add(final String name, final Command command) throws Exception {

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java?rev=707634&r1=707633&r2=707634&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java
Fri Oct 24 06:53:56 2008
@@ -53,6 +53,8 @@
 
     private final FileSystemAccess fileSystemAccess;
 
+    private final GroupDirectoryResolver groupDirResolver;
+
     //
     // TODO: Consider using FileSystemManager.createVirtualFileSystem() to chroot for resolving?
     //
@@ -63,9 +65,12 @@
 
     private BeanContainer container;
 
-    public CommandResolverImpl(final FileSystemAccess fileSystemAccess) {
+    public CommandResolverImpl(final FileSystemAccess fileSystemAccess, final GroupDirectoryResolver
groupDirResolver) {
         assert fileSystemAccess != null;
         this.fileSystemAccess = fileSystemAccess;
+
+        assert groupDirResolver != null;
+        this.groupDirResolver = groupDirResolver;
     }
 
     public void setBeanContainer(final BeanContainer container) {
@@ -159,14 +164,14 @@
             return getCommandsDirectory();
         }
         else if (name.equals(".")) {
-            return getGroupDirectory(variables);
+            return groupDirResolver.getGroupDirectory(variables);
         }
         
         Collection<String> searchPath = getSearchPath(variables);
 
         log.trace("Search path: {}", searchPath);
 
-        FileObject groupDir = getGroupDirectory(variables);
+        FileObject groupDir = groupDirResolver.getGroupDirectory(variables);
 
         log.trace("Group dir: {}", groupDir);
 
@@ -300,37 +305,6 @@
         return aliasesDirectory;
     }
 
-    private FileObject getGroupDirectory(final Variables vars) throws FileSystemException
{
-        assert vars != null;
-
-        FileObject dir;
-
-        Object tmp = vars.get(GROUP);
-
-        if (tmp == null) {
-            dir = getCommandsDirectory();
-        }
-        else if (tmp instanceof String) {
-            log.trace("Resolving group directory from string: {}", tmp);
-            dir = fileSystemAccess.resolveFile(null, (String)tmp);
-        }
-        else if (tmp instanceof FileObject) {
-            dir = (FileObject)tmp;
-        }
-        else {
-            // Complain, then use the default so commands still work
-            log.error("Invalid type for variable '" + GROUP + "'; expected String or FileObject;
found: " + tmp.getClass());
-            dir = getCommandsDirectory();
-        }
-
-        if (!isMetaFile(dir)) {
-            log.error("Command group did not resolve to a meta-file: {}", dir);
-            dir = getCommandsDirectory();
-        }
-
-        return dir;
-    }
-
     private Command createCommand(final FileObject file) throws FileSystemException, CommandException
{
         assert file != null;
 

Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupDirectoryResolver.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupDirectoryResolver.java?rev=707634&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupDirectoryResolver.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupDirectoryResolver.java
Fri Oct 24 06:53:56 2008
@@ -0,0 +1,99 @@
+/*
+ * 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.wisdom.registry;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.registry.CommandResolver;
+import org.apache.geronimo.gshell.vfs.FileSystemAccess;
+import org.apache.geronimo.gshell.vfs.provider.meta.MetaFileName;
+import org.apache.geronimo.gshell.shell.ShellContextHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Resolves to location of <tt>gshell.group</tt>.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GroupDirectoryResolver
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final FileSystemAccess fileSystemAccess;
+
+    private FileObject commandsDirectory;
+
+    public GroupDirectoryResolver(final FileSystemAccess fileSystemAccess) {
+        assert fileSystemAccess != null;
+        this.fileSystemAccess = fileSystemAccess;
+    }
+
+    public FileObject getGroupDirectory(final Variables vars) throws FileSystemException
{
+        assert vars != null;
+
+        FileObject dir;
+
+        Object tmp = vars.get(CommandResolver.GROUP);
+
+        if (tmp == null) {
+            dir = getCommandsDirectory();
+        }
+        else if (tmp instanceof String) {
+            log.trace("Resolving group directory from string: {}", tmp);
+            dir = fileSystemAccess.resolveFile(null, (String)tmp);
+        }
+        else if (tmp instanceof FileObject) {
+            dir = (FileObject)tmp;
+        }
+        else {
+            // Complain, then use the default so commands still work
+            log.error("Invalid type for variable '" + CommandResolver.GROUP + "'; expected
String or FileObject; found: " + tmp.getClass());
+            dir = getCommandsDirectory();
+        }
+
+        if (!isMetaFile(dir)) {
+            log.error("Command group did not resolve to a meta-file: {}", dir);
+            dir = getCommandsDirectory();
+        }
+
+        return dir;
+    }
+
+    public FileObject getGroupDirectory() throws FileSystemException {
+        return getGroupDirectory(ShellContextHolder.get().getVariables());
+    }
+
+    private boolean isMetaFile(final FileObject file) {
+        assert file != null;
+
+        return MetaFileName.SCHEME.equals(file.getName().getScheme());
+    }
+
+    private FileObject getCommandsDirectory() throws FileSystemException {
+        if (commandsDirectory == null) {
+            commandsDirectory = fileSystemAccess.resolveFile(null, CommandResolver.COMMANDS_ROOT);
+        }
+
+        return commandsDirectory;
+    }
+
+}
\ No newline at end of file

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

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

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

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/gshell/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/gshell/components.xml?rev=707634&r1=707633&r2=707634&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/gshell/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/gshell/components.xml
Fri Oct 24 06:53:56 2008
@@ -189,8 +189,13 @@
         <constructor-arg ref="commandRegistry"/>
     </bean>
 
+    <bean id="groupDirResolver" class="org.apache.geronimo.gshell.wisdom.registry.GroupDirectoryResolver">
+        <constructor-arg ref="fileSystemAccess"/>
+    </bean>
+
     <bean id="commandResolver" class="org.apache.geronimo.gshell.wisdom.registry.CommandResolverImpl">
         <constructor-arg ref="fileSystemAccess"/>
+        <constructor-arg ref="groupDirResolver"/>
     </bean>
 
     <bean class="org.apache.geronimo.gshell.wisdom.command.AliasCommand" scope="prototype">



Mime
View raw message