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/10/05 15:55:16 UTC
svn commit: r701796 - in /geronimo/gshell/trunk:
gshell-api/src/main/java/org/apache/geronimo/gshell/registry/
gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/
gshell-wisdom/gshell-wisdom-core/src/main/jav...
Author: jdillon
Date: Sun Oct 5 06:55:15 2008
New Revision: 701796
URL: http://svn.apache.org/viewvc?rev=701796&view=rev
Log:
Adding Collection<Command> resolveCommands() to CommandResolver API
Updated the CommandResolverImpl.resolveCommand() to use the meta:/commands fs to find commands (currently only at top-level, pending path muck soon)
Moved the mapping of meta:/commands, meta:/aliases, meta:/plugins to {Command|Alias|Plugin}MetaMapper components (event driven)
Added:
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java (with props)
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java (with props)
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java (with props)
Modified:
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.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-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.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/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java?rev=701796&r1=701795&r2=701796&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java Sun Oct 5 06:55:15 2008
@@ -23,6 +23,8 @@
import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.command.CommandException;
+import java.util.Collection;
+
/**
* Resolves {@link Command} instances for a given path.
*
@@ -30,14 +32,7 @@
*/
public interface CommandResolver
{
- /**
- * Resolve the given path to a command instance.
- *
- * @param variables The current shell variables.
- * @param path The path of the command to resolve.
- * @return The resolved command instance; never null.
- *
- * @throws CommandException Failed to resolve command.
- */
- Command resolve(Variables variables, String path) throws CommandException;
+ Command resolveCommand(Variables variables, String path) throws CommandException;
+
+ Collection<Command> resolveCommands(Variables variables, String path) throws CommandException;
}
\ No newline at end of file
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=701796&r1=701795&r2=701796&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 Sun Oct 5 06:55:15 2008
@@ -54,6 +54,10 @@
private final Collection<MetaData> children = new ArrayList<MetaData>();
private long lastModified = -1;
+
+ //
+ // TODO: Consider changing "name" to a String here?
+ //
public MetaData(final FileName name, final FileType type, final MetaDataContent content) {
assert name != null;
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java?rev=701796&r1=701795&r2=701796&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java Sun Oct 5 06:55:15 2008
@@ -32,9 +32,6 @@
import org.apache.geronimo.gshell.spring.BeanContainer;
import org.apache.geronimo.gshell.spring.BeanContainerAware;
import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistryConfigurer;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
@@ -75,11 +72,6 @@
private BeanContainer container;
- @Autowired
- private MetaDataRegistry metaRegistry;
-
- private MetaDataRegistryConfigurer metaConfig;
-
private Set<Plugin> plugins = new LinkedHashSet<Plugin>();
public void setBeanContainer(final BeanContainer container) {
@@ -90,10 +82,6 @@
@PostConstruct
public void init() {
- assert metaRegistry != null;
- metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
- metaConfig.addFolder("/plugins");
-
assert eventManager != null;
eventManager.addListener(new EventListener() {
public void onEvent(Event event) throws Exception {
@@ -151,10 +139,6 @@
plugin.initArtifact(artifact);
plugin.initArtifacts(artifacts);
- assert metaConfig != null;
- MetaData data = metaConfig.addFile("/plugins/" + plugin.getName());
- data.addAttribute("PLUGIN", plugin);
-
plugins.add(plugin);
log.debug("Activating plugin: {}", plugin.getName());
Added: 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=701796&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java (added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java Sun Oct 5 06:55:15 2008
@@ -0,0 +1,70 @@
+/*
+ * 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.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.data.MetaData;
+import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
+import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistryConfigurer;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * Handles mapping of plugins under <tt>meta:/plugins</tt>.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PluginMetaMapper
+ implements EventListener
+{
+ @Autowired
+ private EventManager eventManager;
+
+ @Autowired
+ private MetaDataRegistry metaRegistry;
+
+ private MetaDataRegistryConfigurer metaConfig;
+
+ @PostConstruct
+ public void init() {
+ assert metaRegistry != null;
+ metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
+ metaConfig.addFolder("/plugins");
+
+ assert eventManager != null;
+ eventManager.addListener(this);
+ }
+
+ public 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());
+ }
+
+ // TODO: Handle removing meta:/plugins/<name>
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.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/plugin/PluginMetaMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: 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=701796&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java (added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java Sun Oct 5 06:55:15 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.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.data.MetaData;
+import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
+import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistryConfigurer;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * Handles mapping of aliases under <tt>meta:/aliases</tt>.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AliasMetaMapper
+ implements EventListener
+{
+ @Autowired
+ private EventManager eventManager;
+
+ @Autowired
+ private MetaDataRegistry metaRegistry;
+
+ private MetaDataRegistryConfigurer metaConfig;
+
+ @PostConstruct
+ public void init() {
+ assert metaRegistry != null;
+ metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
+ metaConfig.addFolder("/aliases");
+
+ assert eventManager != null;
+ eventManager.addListener(this);
+ }
+
+ public void onEvent(final Event event) throws Exception {
+ assert event != null;
+
+ if (event instanceof AliasRegisteredEvent) {
+ AliasRegisteredEvent targetEvent = (AliasRegisteredEvent)event;
+
+ MetaData data = metaConfig.addFile("/aliases/" + targetEvent.getName());
+ data.addAttribute("ALIAS", targetEvent.getAlias());
+ }
+ else if (event instanceof AliasRemovedEvent) {
+ AliasRemovedEvent targetEvent = (AliasRemovedEvent)event;
+
+ // TODO: Remove meta:/aliases/<name>
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.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/AliasMetaMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java?rev=701796&r1=701795&r2=701796&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java Sun Oct 5 06:55:15 2008
@@ -22,14 +22,10 @@
import org.apache.geronimo.gshell.event.EventPublisher;
import org.apache.geronimo.gshell.registry.AliasRegistry;
import org.apache.geronimo.gshell.registry.NoSuchAliasException;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistryConfigurer;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.annotation.PostConstruct;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -48,20 +44,8 @@
@Autowired
private EventPublisher eventPublisher;
- @Autowired
- private MetaDataRegistry metaRegistry;
-
- private MetaDataRegistryConfigurer metaConfig;
-
private final Map<String,String> aliases = new LinkedHashMap<String,String>();
- @PostConstruct
- public void init() {
- assert metaRegistry != null;
- metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
- metaConfig.addFolder("/aliases");
- }
-
public void registerAlias(final String name, final String alias) {
assert name != null;
assert alias != null;
@@ -72,10 +56,6 @@
log.debug("Replacing alias: {}", name);
}
- assert metaConfig != null;
- MetaData data = metaConfig.addFile("/aliases/" + name);
- data.addAttribute("ALIAS", alias);
-
aliases.put(name, alias);
eventPublisher.publish(new AliasRegisteredEvent(name, alias));
@@ -90,8 +70,6 @@
throw new NoSuchAliasException(name);
}
- // TODO: Remove from meta
-
aliases.remove(name);
eventPublisher.publish(new AliasRemovedEvent(name));
Added: 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=701796&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java (added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java Sun Oct 5 06:55:15 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.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.data.MetaData;
+import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
+import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistryConfigurer;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * Handles mapping of commands under <tt>meta:/commands</tt>.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CommandMetaMapper
+ implements EventListener
+{
+ @Autowired
+ private EventManager eventManager;
+
+ @Autowired
+ private MetaDataRegistry metaRegistry;
+
+ private MetaDataRegistryConfigurer metaConfig;
+
+ @PostConstruct
+ public void init() {
+ assert metaRegistry != null;
+ metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
+ metaConfig.addFolder("/commands");
+
+ assert eventManager != null;
+ eventManager.addListener(this);
+ }
+
+ public void onEvent(final Event event) throws Exception {
+ assert event != null;
+
+ if (event instanceof CommandRegisteredEvent) {
+ CommandRegisteredEvent targetEvent = (CommandRegisteredEvent)event;
+
+ MetaData data = metaConfig.addFile("/commands/" + targetEvent.getName());
+ data.addAttribute("COMMAND", targetEvent.getCommand());
+ }
+ else if (event instanceof CommandRemovedEvent) {
+ CommandRemovedEvent targetEvent = (CommandRemovedEvent)event;
+
+ // TODO: Remove meta:/commands/<name>
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.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/CommandMetaMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java?rev=701796&r1=701795&r2=701796&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java Sun Oct 5 06:55:15 2008
@@ -22,16 +22,12 @@
import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.event.EventPublisher;
import org.apache.geronimo.gshell.registry.CommandRegistry;
-import org.apache.geronimo.gshell.registry.NoSuchCommandException;
import org.apache.geronimo.gshell.registry.DuplicateCommandException;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistryConfigurer;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
+import org.apache.geronimo.gshell.registry.NoSuchCommandException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.annotation.PostConstruct;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -50,20 +46,8 @@
@Autowired
private EventPublisher eventPublisher;
- @Autowired
- private MetaDataRegistry metaRegistry;
-
- private MetaDataRegistryConfigurer metaConfig;
-
private final Map<String,Command> commands = new LinkedHashMap<String,Command>();
- @PostConstruct
- public void init() {
- assert metaRegistry != null;
- metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
- metaConfig.addFolder("/commands");
- }
-
public void registerCommand(final String name, final Command command) throws DuplicateCommandException {
assert name != null;
assert command != null;
@@ -74,10 +58,6 @@
throw new DuplicateCommandException(name);
}
- assert metaConfig != null;
- MetaData data = metaConfig.addFile("/commands/" + name);
- data.addAttribute("COMMAND", command);
-
commands.put(name, command);
eventPublisher.publish(new CommandRegisteredEvent(name, command));
@@ -92,8 +72,6 @@
throw new NoSuchCommandException(name);
}
- // TODO: Remove from meta
-
commands.remove(name);
eventPublisher.publish(new CommandRemovedEvent(name));
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=701796&r1=701795&r2=701796&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 Sun Oct 5 06:55:15 2008
@@ -27,14 +27,19 @@
import org.apache.geronimo.gshell.registry.CommandRegistry;
import org.apache.geronimo.gshell.registry.CommandResolver;
import org.apache.geronimo.gshell.registry.NoSuchAliasException;
+import org.apache.geronimo.gshell.registry.NoSuchCommandException;
import org.apache.geronimo.gshell.spring.BeanContainer;
import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.apache.geronimo.gshell.wisdom.registry.AliasCommand;
import org.apache.geronimo.gshell.vfs.FileSystemAccess;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.Collection;
+import java.util.Collections;
+
/**
* {@link CommandResolver} component.
*
@@ -45,8 +50,8 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- @Autowired
- private CommandRegistry commandRegistry;
+ // @Autowired
+ // private CommandRegistry commandRegistry;
@Autowired
private AliasRegistry aliasRegistry;
@@ -65,7 +70,7 @@
this.container = container;
}
- public Command resolve(final Variables variables, final String path) throws CommandException {
+ public Command resolveCommand(final Variables variables, final String path) throws CommandException {
assert variables != null;
assert path != null;
@@ -82,8 +87,24 @@
command = createAliasCommand(path);
}
else {
- assert commandRegistry != null;
- command = commandRegistry.getCommand(path);
+ try {
+ FileObject commands = fileSystemAccess.resolveFile("meta:/commands");
+ assert commands.exists();
+ log.debug("Commands base: {}", commands);
+
+ FileObject file = fileSystemAccess.resolveFile(commands, path);
+ log.debug("Command file: {}", file);
+
+ if (file.exists()) {
+ command = (Command) file.getContent().getAttribute("COMMAND");
+ }
+ else {
+ throw new NoSuchCommandException(path);
+ }
+ }
+ catch (FileSystemException e) {
+ throw new CommandException(e);
+ }
}
log.debug("Resolved command: {} -> {}", path, command);
@@ -110,4 +131,15 @@
return command;
}
+
+ public Collection<Command> resolveCommands(final Variables variables, final String path) throws CommandException {
+ assert variables != null;
+ assert path != null;
+
+ //
+ // FIXME:
+ //
+
+ return Collections.emptySet();
+ }
}
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java?rev=701796&r1=701795&r2=701796&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java Sun Oct 5 06:55:15 2008
@@ -214,7 +214,7 @@
// Locate the command
Variables variables = context.getVariables();
- Command command = commandResolver.resolve(variables, path);
+ Command command = commandResolver.resolveCommand(variables, path);
// Hijack the system streams in the current thread's context
IO io = context.getIo();
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml?rev=701796&r1=701795&r2=701796&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml Sun Oct 5 06:55:15 2008
@@ -27,10 +27,16 @@
<bean id="pluginManager" class="org.apache.geronimo.gshell.wisdom.plugin.PluginManagerImpl"/>
+ <bean id="pluginMetaMapper" class="org.apache.geronimo.gshell.wisdom.plugin.PluginMetaMapper"/>
+
<bean id="aliasRegistry" class="org.apache.geronimo.gshell.wisdom.registry.AliasRegistryImpl"/>
+ <bean id="aliasMetaMapper" class="org.apache.geronimo.gshell.wisdom.registry.AliasMetaMapper"/>
+
<bean id="commandRegistry" class="org.apache.geronimo.gshell.wisdom.registry.CommandRegistryImpl"/>
+ <bean id="commandMetaMapper" class="org.apache.geronimo.gshell.wisdom.registry.CommandMetaMapper"/>
+
<bean id="commandResolver" class="org.apache.geronimo.gshell.wisdom.registry.CommandResolverImpl"/>
<bean id="commandLineBuilder" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineBuilderImpl"/>