geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r707612 - in /geronimo/gshell/trunk: gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/ gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/ gshell-support/gshell-vfs-meta/src/mai...
Date Fri, 24 Oct 2008 12:29:22 GMT
Author: jdillon
Date: Fri Oct 24 05:29:21 2008
New Revision: 707612

URL: http://svn.apache.org/viewvc?rev=707612&view=rev
Log:
command and alias meta mappers now handle remove
Drop the meta configurer

Removed:
    geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataRegistryConfigurer.java
Modified:
    geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
    geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java
    geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java
    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/plugin/PluginMetaMapper.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/resources/META-INF/gshell/components.xml

Modified: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java?rev=707612&r1=707611&r2=707612&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
(original)
+++ geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
Fri Oct 24 05:29:21 2008
@@ -44,6 +44,10 @@
 
     private static final String DEFAULT_LOG4J_CONF = "org/apache/geronimo/gshell/bootstrap/default-log4j.xml";
 
+    //
+    // TODO: Support loading an optional properties file to merge into system for persistent
customized configuration
+    //
+
     private File homeDir;
 
     private String programName;

Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java?rev=707612&r1=707611&r2=707612&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java
Fri Oct 24 05:29:21 2008
@@ -112,6 +112,10 @@
         return attributes;
     }
 
+    //
+    // TODO: Allow enums for keys?
+    //
+    
     public void addAttribute(final String name, final Object value) {
         assert name != null;
         // value could be null

Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java?rev=707612&r1=707611&r2=707612&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java
Fri Oct 24 05:29:21 2008
@@ -19,6 +19,7 @@
 
 package org.apache.geronimo.gshell.vfs.provider.meta.data.support;
 
+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.MetaDataContent;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
@@ -34,6 +35,8 @@
 {
     private final MetaDataRegistry metaRegistry;
 
+    private final MetaFileNameParser nameParser = new MetaFileNameParser();
+
     private Map<String,MetaDataContent> contentNodes;
 
     public MetaDataInstaller(final MetaDataRegistry metaRegistry) {
@@ -47,17 +50,11 @@
 
     // @PostConstruct
     public void init() throws Exception {
-        assert metaRegistry != null;
-        MetaDataRegistryConfigurer metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
-
         if (contentNodes != null && !contentNodes.isEmpty()) {
             for (Map.Entry<String,MetaDataContent> entry : contentNodes.entrySet())
{
-                metaConfig.addContent(entry.getKey(), entry.getValue());
+                MetaData data = new MetaData(nameParser.parseUri(entry.getKey()), entry.getValue());
+                metaRegistry.registerData(data.getName(), data);
             }
         }
     }
-
-    //
-    // TODO: Merge this guy with MetaDataRegistryConfigurer, allow for spring+direct usage.
-    //
 }
\ No newline at end of file

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=707612&r1=707611&r2=707612&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 05:29:21 2008
@@ -30,8 +30,12 @@
 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;
 import org.apache.geronimo.gshell.wisdom.registry.CommandRemovedEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -49,25 +53,22 @@
 public class CommandsCompleter
     implements Completor
 {
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
     private final EventManager eventManager;
 
     private final CommandRegistry commandRegistry;
 
-    private final FileSystemAccess fileSystemAccess;
-
     private final Map<String,Completor> completors = new HashMap<String,Completor>();
 
     private final AggregateCompleter delegate = new AggregateCompleter();
 
-    public CommandsCompleter(final EventManager eventManager, final CommandRegistry commandRegistry,
final FileSystemAccess fileSystemAccess) {
+    public CommandsCompleter(final EventManager eventManager, final CommandRegistry commandRegistry)
{
         assert eventManager != null;
         this.eventManager = eventManager;
 
         assert commandRegistry != null;
         this.commandRegistry = commandRegistry;
-
-        assert fileSystemAccess != null;
-        this.fileSystemAccess = fileSystemAccess;
     }
 
     //
@@ -97,6 +98,14 @@
                     CommandRemovedEvent targetEvent = (CommandRemovedEvent)event;
                     removeCompleter(targetEvent.getName());
                 }
+                else if (event instanceof MetaDataRegisteredEvent) {
+                    MetaDataRegisteredEvent targetEvent = (MetaDataRegisteredEvent)event;
+                    log.debug("{}", targetEvent.getName());
+                }
+                else if (event instanceof MetaDataRemovedEvent) {
+                    MetaDataRemovedEvent targetEvent = (MetaDataRemovedEvent)event;
+                    log.debug("{}", targetEvent.getName());
+                }
             }
         });
     }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java?rev=707612&r1=707611&r2=707612&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java
Fri Oct 24 05:29:21 2008
@@ -19,12 +19,16 @@
 
 package org.apache.geronimo.gshell.wisdom.plugin;
 
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+import org.apache.geronimo.gshell.application.plugin.Plugin;
 import org.apache.geronimo.gshell.event.Event;
 import org.apache.geronimo.gshell.event.EventListener;
 import org.apache.geronimo.gshell.event.EventManager;
+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;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.support.MetaDataRegistryConfigurer;
 
 /**
  * Handles mapping of plugins under <tt>meta:/plugins</tt>.
@@ -38,34 +42,54 @@
 
     private final MetaDataRegistry metaRegistry;
 
-    private MetaDataRegistryConfigurer metaConfig;
+    private final MetaFileNameParser nameParser = new MetaFileNameParser();
 
     public PluginMetaMapper(final EventManager eventManager, final MetaDataRegistry metaRegistry)
{
         assert eventManager != null;
         this.eventManager = eventManager;
+
         assert metaRegistry != null;
         this.metaRegistry = metaRegistry;
     }
     
     // @PostConstruct
-    public void init() {
-        assert metaRegistry != null;
-        metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
-
-        assert eventManager != null;
+    public synchronized void init() {
+        // TODO: add any existing plugins which may have been configured before we loaded
+        
         eventManager.addListener(this);
     }
 
-    public void onEvent(final Event event) throws Exception {
+    public synchronized void onEvent(final Event event) throws Exception {
         assert event != null;
 
         if (event instanceof PluginLoadedEvent) {
             PluginLoadedEvent targetEvent = (PluginLoadedEvent)event;
-
-            MetaData data = metaConfig.addFile("/plugins/" + targetEvent.getPlugin().getName());
-            data.addAttribute("PLUGIN", targetEvent.getPlugin());
+            add(targetEvent.getPlugin());
         }
 
         // TODO: Handle removing meta:/plugins/<name>
     }
+
+    private FileName createName(final String name) throws FileSystemException {
+        assert name != null;
+        return nameParser.parseUri("/plugins/" + name);
+    }
+
+    private void add(final Plugin plugin) throws Exception {
+        assert plugin != null;
+
+        FileName fileName = createName(plugin.getName());
+        MetaData data = new MetaData(fileName, FileType.FILE);
+        data.addAttribute("PLUGIN", plugin);
+
+        metaRegistry.registerData(fileName, data);
+    }
+
+    private void remove(final String name) throws Exception {
+        assert name != null;
+
+        FileName fileName = createName(name);
+
+        metaRegistry.removeData(fileName);
+    }
 }
\ No newline at end of file

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=707612&r1=707611&r2=707612&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 05:29:21 2008
@@ -19,13 +19,16 @@
 
 package org.apache.geronimo.gshell.wisdom.registry;
 
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 import org.apache.geronimo.gshell.event.Event;
 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.vfs.provider.meta.MetaFileNameParser;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.support.MetaDataRegistryConfigurer;
 
 /**
  * Handles mapping of aliases under <tt>meta:/aliases</tt>.
@@ -41,30 +44,27 @@
 
     private final AliasRegistry aliasRegistry;
 
-    private MetaDataRegistryConfigurer metaConfig;
+    private final MetaFileNameParser nameParser = new MetaFileNameParser();
 
     public AliasMetaMapper(final EventManager eventManager, final MetaDataRegistry metaRegistry,
final AliasRegistry aliasRegistry) {
         assert eventManager != null;
         this.eventManager = eventManager;
+
         assert metaRegistry != null;
         this.metaRegistry = metaRegistry;
+
         assert aliasRegistry != null;
         this.aliasRegistry = aliasRegistry;
     }
 
     // @PostConstruct
     public synchronized void init() throws Exception {
-        assert metaRegistry != null;
-        metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
-
-        assert eventManager != null;
-        eventManager.addListener(this);
-
         // Add existing aliases in case some have already been registered
         for (String name : aliasRegistry.getAliasNames()) {
-            MetaData data = metaConfig.addFile("/aliases/" + name);
-            data.addAttribute("ALIAS", aliasRegistry.getAlias(name));
+            add(name, aliasRegistry.getAlias(name));
         }
+
+        eventManager.addListener(this);
     }
 
     public synchronized void onEvent(final Event event) throws Exception {
@@ -72,14 +72,35 @@
 
         if (event instanceof AliasRegisteredEvent) {
             AliasRegisteredEvent targetEvent = (AliasRegisteredEvent)event;
-
-            MetaData data = metaConfig.addFile("/aliases/" + targetEvent.getName());
-            data.addAttribute("ALIAS", targetEvent.getAlias());
+            add(targetEvent.getName(), targetEvent.getAlias());
         }
         else if (event instanceof AliasRemovedEvent) {
             AliasRemovedEvent targetEvent = (AliasRemovedEvent)event;
-
-            // TODO: Remove meta:/aliases/<name>
+            remove(targetEvent.getName());
         }
     }
+
+    private FileName createName(final String name) throws FileSystemException {
+        assert name != null;
+        return nameParser.parseUri("/aliases/" + name);
+    }
+
+    private void add(final String name, final String alias) throws Exception {
+        assert name != null;
+        assert alias != null;
+
+        FileName fileName = createName(name);
+        MetaData data = new MetaData(fileName, FileType.FILE);
+        data.addAttribute("ALIAS", alias);
+
+        metaRegistry.registerData(fileName, data);
+    }
+
+    private void remove(final String name) throws Exception {
+        assert name != null;
+
+        FileName fileName = createName(name);
+
+        metaRegistry.removeData(fileName);
+    }
 }
\ No newline at end of file

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=707612&r1=707611&r2=707612&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 05:29:21 2008
@@ -19,13 +19,17 @@
 
 package org.apache.geronimo.gshell.wisdom.registry;
 
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.event.Event;
 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.provider.meta.MetaFileNameParser;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.support.MetaDataRegistryConfigurer;
 
 /**
  * Handles mapping of commands under <tt>meta:/commands</tt>.
@@ -41,30 +45,27 @@
 
     private final CommandRegistry commandRegistry;
 
-    private MetaDataRegistryConfigurer metaConfig;
+    private final MetaFileNameParser nameParser = new MetaFileNameParser();
 
     public CommandMetaMapper(final EventManager eventManager, final MetaDataRegistry metaRegistry,
final CommandRegistry commandRegistry) {
         assert eventManager != null;
         this.eventManager = eventManager;
+
         assert metaRegistry != null;
         this.metaRegistry = metaRegistry;
+
         assert commandRegistry != null;
         this.commandRegistry = commandRegistry;
     }
 
     // @PostConstruct
     public synchronized void init() throws Exception {
-        assert metaRegistry != null;
-        metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
-
-        assert eventManager != null;
-        eventManager.addListener(this);
-
         // Add existing commands in case some have already been registered
         for (String name : commandRegistry.getCommandNames()) {
-            MetaData data = metaConfig.addFile("/commands/" + name);
-            data.addAttribute("COMMAND", commandRegistry.getCommand(name));
+            add(name, commandRegistry.getCommand(name));
         }
+
+        eventManager.addListener(this);
     }
 
     public synchronized void onEvent(final Event event) throws Exception {
@@ -72,18 +73,35 @@
 
         if (event instanceof CommandRegisteredEvent) {
             CommandRegisteredEvent targetEvent = (CommandRegisteredEvent)event;
-
-            //
-            // TODO: Need to allow command instances to be come _aware_ of their mapping
(name + path)
-            //
-
-            MetaData data = metaConfig.addFile("/commands/" + targetEvent.getName());
-            data.addAttribute("COMMAND", targetEvent.getCommand());
+            add(targetEvent.getName(), targetEvent.getCommand());
         }
         else if (event instanceof CommandRemovedEvent) {
             CommandRemovedEvent targetEvent = (CommandRemovedEvent)event;
-
-            // TODO: Remove meta:/commands/<name>
+            remove(targetEvent.getName());
         }
     }
+
+    private FileName createName(final String name) throws FileSystemException {
+        assert name != null;
+        return nameParser.parseUri("/commands/" + name);
+    }
+
+    private void add(final String name, final Command command) throws Exception {
+        assert name != null;
+        assert command != null;
+
+        FileName fileName = createName(name);
+        MetaData data = new MetaData(fileName, FileType.FILE);
+        data.addAttribute("COMMAND", command);
+
+        metaRegistry.registerData(fileName, data);
+    }
+
+    private void remove(final String name) throws Exception {
+        assert name != null;
+
+        FileName fileName = createName(name);
+
+        metaRegistry.removeData(fileName);
+    }
 }
\ No newline at end of file

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=707612&r1=707611&r2=707612&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 05:29:21 2008
@@ -254,7 +254,6 @@
     <bean id="commandsCompleter" class="org.apache.geronimo.gshell.wisdom.completer.CommandsCompleter"
lazy-init="true">
         <constructor-arg ref="eventManager"/>
         <constructor-arg ref="commandRegistry"/>
-        <constructor-arg ref="fileSystemAccess"/>
     </bean>
 
     <bean id="variableNameCompleter" class="org.apache.geronimo.gshell.wisdom.completer.VariableNameCompleter"
lazy-init="true">



Mime
View raw message