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/04 20:32:21 UTC
svn commit: r701682 - in /geronimo/gshell/trunk:
gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/
gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/
gshell-support/gshell-vfs-meta/src/test/ gsh...
Author: jdillon
Date: Sat Oct 4 11:32:21 2008
New Revision: 701682
URL: http://svn.apache.org/viewvc?rev=701682&view=rev
Log:
Hooked up the basic registration of meta:/commands stuff
Added:
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryConfigurer.java (contents, props changed)
- copied, changed from r701651, geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/test/
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/test/java/
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/test/resources/
Modified:
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileData.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileNameParser.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java
geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml?rev=701682&r1=701681&r2=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml Sat Oct 4 11:32:21 2008
@@ -71,8 +71,11 @@
<null/>
</gshell:completers>
</gshell:command>
-
+
+ <!--
+ HACK: Disabled for now, until the meta:// stuff can properly encode bits like "." into the filename
<gshell:link name="." target="source"/>
+ -->
<gshell:command name="set">
<gshell:action class="org.apache.geronimo.gshell.commands.builtins.SetAction"/>
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileData.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/MetaFileData.java?rev=701682&r1=701681&r2=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileData.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileData.java Sat Oct 4 11:32:21 2008
@@ -82,6 +82,19 @@
return attributes;
}
+ public void addAttribute(final String name, final Object value) {
+ assert name != null;
+ // value could be null
+
+ getAttributes().put(name, value);
+ }
+
+ public Object removeAttribute(final String name) {
+ assert name != null;
+
+ return getAttributes().remove(name);
+ }
+
public Collection<MetaFileData> getChildren() {
return children;
}
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.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/MetaFileDataRegistry.java?rev=701682&r1=701681&r2=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java Sat Oct 4 11:32:21 2008
@@ -28,19 +28,11 @@
*/
public interface MetaFileDataRegistry
{
- //
- // TODO: Add some helpers to assist registration of new data. Specifically register(String name, MetaFileData)
- // and maybe even registerChild(FileName parent, FileName name, MetaFileData)
- // Might also not need the child name, as data contains it already?
- //
+ void registerData(FileName name, MetaFileData data);
- void register(FileName name, MetaFileData data);
+ void removeData(FileName name);
- void remove(FileName name);
+ MetaFileData lookupData(FileName name) /* throws MetaFileDataRegistryException */;
- //
- // TODO: Consider making this always return non-null, throw exception when not found, add contains(FileName)
- //
-
- MetaFileData lookup(FileName name);
+ boolean containsData(FileName name);
}
\ No newline at end of file
Copied: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryConfigurer.java (from r701651, geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.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/MetaFileDataRegistryConfigurer.java?p2=geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryConfigurer.java&p1=geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java&r1=701651&r2=701682&rev=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryConfigurer.java Sat Oct 4 11:32:21 2008
@@ -20,27 +20,84 @@
package org.apache.geronimo.gshell.vfs.provider.meta;
import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * Meta file data registry.
+ * Helper to configure the contents of a {@link MetaFileDataRegistry}.
*
* @version $Rev$ $Date$
*/
-public interface MetaFileDataRegistry
+public class MetaFileDataRegistryConfigurer
{
- //
- // TODO: Add some helpers to assist registration of new data. Specifically register(String name, MetaFileData)
- // and maybe even registerChild(FileName parent, FileName name, MetaFileData)
- // Might also not need the child name, as data contains it already?
- //
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final MetaFileDataRegistry registry;
+
+ private final MetaFileNameParser nameParser;
+
+ public MetaFileDataRegistryConfigurer(final MetaFileDataRegistry registry) {
+ assert registry != null;
+
+ this.registry = registry;
+ this.nameParser = new MetaFileNameParser();
+ }
+
+ public MetaFileDataRegistry getRegistry() {
+ return registry;
+ }
+
+ public MetaFileNameParser getNameParser() {
+ return nameParser;
+ }
+
+ private FileName parseName(final String name) {
+ assert name != null;
+
+ try {
+ return nameParser.parseUri(name);
+ }
+ catch (FileSystemException e) {
+ throw new RuntimeException("Failed to parse file name: " + name, e);
+ }
+ }
+
+ public MetaFileData add(final FileName name, final MetaFileData data) {
+ assert name != null;
+ assert data != null;
+
+ if (registry.containsData(name)) {
+ log.warn("Replacing contents for name: {}", name);
+ }
+
+ registry.registerData(name, data);
+
+ return data;
+ }
+
+ public MetaFileData add(final String name, final MetaFileData data) {
+ return add(parseName(name), data);
+ }
+
+ public MetaFileData addFile(final FileName name) {
+ return add(name, new MetaFileData(name, FileType.FILE));
+ }
+
+ public MetaFileData addFile(final String name) {
+ return addFile(parseName(name));
+ }
- void register(FileName name, MetaFileData data);
+ public MetaFileData addFolder(final FileName name) {
+ return add(name, new MetaFileData(name, FileType.FOLDER));
+ }
- void remove(FileName name);
+ public MetaFileData addFolder(final String name) {
+ return addFolder(parseName(name));
+ }
//
- // TODO: Consider making this always return non-null, throw exception when not found, add contains(FileName)
+ // TODO: Add remove methods, and nested namespace muck, once we get base stuff working in the parser
//
-
- MetaFileData lookup(FileName name);
}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryConfigurer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryConfigurer.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryConfigurer.java
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryConfigurer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.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/MetaFileDataRegistryImpl.java?rev=701682&r1=701681&r2=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java Sat Oct 4 11:32:21 2008
@@ -20,9 +20,12 @@
package org.apache.geronimo.gshell.vfs.provider.meta;
import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -39,26 +42,119 @@
private final Map<FileName,MetaFileData> nodes = Collections.synchronizedMap(new HashMap<FileName,MetaFileData>());
- public void register(final FileName name, final MetaFileData data) {
+ private String rootFileName = MetaFileName.SCHEME + ":/";
+
+ @PostConstruct
+ public void init() throws FileSystemException {
+ // Register the root folder
+ MetaFileNameParser parser = new MetaFileNameParser();
+ FileName rootName = parser.parseUri(rootFileName);
+ registerData(rootName, new MetaFileData(rootName, FileType.FOLDER));
+ }
+
+ public void registerData(final FileName name, final MetaFileData data) {
assert name != null;
assert data != null;
- log.debug("Registering: {} -> {}", name, data);
+ log.debug("Registering data: {} -> {}", name, data);
+
+ if (name.getDepth() > 0) {
+ FileName parentName = name.getParent();
+ if (containsData(parentName)) {
+ MetaFileData parent = lookupData(parentName);
+
+ if (!parent.hasChild(data)) {
+ try {
+ parent.addChild(data);
+ }
+ catch (FileSystemException ignore) {
+ throw new Error(ignore);
+ }
+ }
+ }
+ else {
+ log.warn("Missing parent folder: " + parentName);
+ }
+ }
nodes.put(name, data);
+
+ // HACK:
}
- public void remove(final FileName name) {
+ public void removeData(final FileName name) {
assert name != null;
- log.debug("Removing: {}", name);
+ log.debug("Removing data: {}", name);
+
+ MetaFileData data = nodes.remove(name);
+
+ FileName parentName = name.getParent();
+ if (containsData(parentName)) {
+ MetaFileData parent = lookupData(parentName);
+ try {
+ parent.removeChild(data);
+ }
+ catch (FileSystemException ignore) {
+ throw new Error(ignore);
+ }
+ }
+ }
+
+ public boolean containsData(final FileName name) {
+ assert name != null;
- nodes.remove(name);
+ return nodes.containsKey(name);
}
- public MetaFileData lookup(final FileName name) {
+ public MetaFileData lookupData(final FileName name) {
assert name != null;
+ log.debug("Looking up data: {}", name);
+
return nodes.get(name);
}
+
+ /*
+ void save(final MetaFileObject file) throws FileSystemException {
+ assert file != null;
+
+ log.debug("Saving: {}", file);
+
+ FileName name = file.getName();
+ MetaFileData data = file.getData();
+
+ if (name.getDepth() > 0) {
+ MetaFileData parentData = registry.lookup(file.getParent().getName());
+
+ if (!parentData.hasChild(data)) {
+ MetaFileObject parent = (MetaFileObject)file.getParent();
+ parent.getData().addChild(data);
+ parent.close();
+ }
+ }
+
+ registry.register(name, data);
+ file.getData().updateLastModified();
+ file.close();
+ }
+
+ void delete(final MetaFileObject file) throws FileSystemException {
+ assert file != null;
+
+ log.debug("Deleting: {}", file);
+
+ if (file.getParent() == null) {
+ throw new FileSystemException("Can not delete file-system root");
+ }
+
+ registry.remove(file.getName());
+
+ MetaFileObject parent = (MetaFileObject) resolveFile(file.getParent().getName());
+ parent.getData().removeChild(file.getData());
+ parent.close();
+
+ file.close();
+ }
+ */
}
\ 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/MetaFileNameParser.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/MetaFileNameParser.java?rev=701682&r1=701681&r2=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileNameParser.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileNameParser.java Sat Oct 4 11:32:21 2008
@@ -50,21 +50,23 @@
this(MetaFileName.SCHEME);
}
- public FileName parseUri(final VfsComponentContext context, final FileName baseName, final String fileName) throws FileSystemException {
- // context is ignored
+ public FileName parseUri(final FileName baseName, final String fileName) throws FileSystemException {
// baseName could be null
assert fileName != null;
- log.info("Parsing URI; base={}, filename={}", baseName, fileName);
+ log.trace("Parsing URI; base={}, filename={}", baseName, fileName);
+ /*
if (baseName != null) {
//
// FIXME: Do something with base. Maybe need to build a filename first, then if its relative, prefix base?
+ // only support using base when its meta: ?
//
throw new UnsupportedOperationException("Base prefixing is not yet supported");
}
-
+ */
+
StringBuffer buff = new StringBuffer();
String scheme = UriParser.extractScheme(fileName, buff);
@@ -76,7 +78,9 @@
UriParser.fixSeparators(buff);
FileType type = UriParser.normalisePath(buff);
- log.info("Creating file name; scheme={}, path={}, type={}", new Object[] {scheme, buff, type});
+ if (log.isTraceEnabled()) {
+ log.trace("Creating file name; scheme={}, path={}, type={}", new Object[] {scheme, buff, type});
+ }
//
// TODO: Need to make sure that we end up with something looking abs here?
@@ -84,8 +88,16 @@
FileName name = new MetaFileName(scheme, buff.toString(), type);
- log.info("Created file name: {}", name);
+ log.trace("Created file name: {}", name);
return name;
}
+
+ public FileName parseUri(final VfsComponentContext context, final FileName baseName, final String fileName) throws FileSystemException {
+ return parseUri(baseName, fileName);
+ }
+
+ public FileName parseUri(final String fileName) throws FileSystemException {
+ return parseUri(null, fileName);
+ }
}
\ 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/MetaFileSystem.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/MetaFileSystem.java?rev=701682&r1=701681&r2=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java Sat Oct 4 11:32:21 2008
@@ -49,15 +49,6 @@
assert registry != null;
this.registry = registry;
-
- //
- // TODO: Probably don't need this, as the root file should have been registered, but lets see
- //
-
- // Setup the root file's data
- MetaFileData data = new MetaFileData(rootName, FileType.FOLDER);
- data.updateLastModified();
- registry.register(rootName, data);
}
protected FileObject createFile(final FileName fileName) throws Exception {
@@ -75,11 +66,6 @@
capabilities.addAll(MetaFileProvider.CAPABILITIES);
}
- @Override
- public void close() {
- super.close();
- }
-
//
// Internal bits invoked from MetaFileObject
//
@@ -93,7 +79,7 @@
assert name != null;
// FIXME: This should probably toss an exception if the data is not registered
- MetaFileData data = registry.lookup(name);
+ MetaFileData data = registry.lookupData(name);
if (data == null) {
data = new MetaFileData(name, FileType.IMAGINARY);
}
@@ -101,57 +87,12 @@
return data;
}
- /*
- TODO: Move this stuff into the registry impl
-
- void save(final MetaFileObject file) throws FileSystemException {
- assert file != null;
-
- log.debug("Saving: {}", file);
-
- FileName name = file.getName();
- MetaFileData data = file.getData();
-
- if (name.getDepth() > 0) {
- MetaFileData parentData = registry.lookup(file.getParent().getName());
-
- if (!parentData.hasChild(data)) {
- MetaFileObject parent = (MetaFileObject)file.getParent();
- parent.getData().addChild(data);
- parent.close();
- }
- }
-
- registry.register(name, data);
- file.getData().updateLastModified();
- file.close();
- }
-
- void delete(final MetaFileObject file) throws FileSystemException {
- assert file != null;
-
- log.debug("Deleting: {}", file);
-
- if (file.getParent() == null) {
- throw new FileSystemException("Can not delete file-system root");
- }
-
- registry.remove(file.getName());
-
- MetaFileObject parent = (MetaFileObject) resolveFile(file.getParent().getName());
- parent.getData().removeChild(file.getData());
- parent.close();
-
- file.close();
- }
- */
-
String[] listChildren(final FileName name) throws FileSystemException {
assert name != null;
log.debug("Listing children: {}", name);
- MetaFileData data = registry.lookup(name);
+ MetaFileData data = registry.lookupData(name);
Collection<MetaFileData> children = data.getChildren();
List<String> names = new ArrayList<String>(children.size());
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml?rev=701682&r1=701681&r2=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml Sat Oct 4 11:32:21 2008
@@ -77,6 +77,10 @@
</bean>
<!--
+ TODO: Setup repo:// to access the local repository.
+ -->
+
+ <!--
TODO: Setup authentication support.
-->
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml?rev=701682&r1=701681&r2=701682&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml Sat Oct 4 11:32:21 2008
@@ -67,7 +67,12 @@
<groupId>org.apache.geronimo.gshell.support</groupId>
<artifactId>gshell-artifact</artifactId>
</dependency>
-
+
+ <dependency>
+ <groupId>org.apache.geronimo.gshell.support</groupId>
+ <artifactId>gshell-vfs-meta</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.geronimo.gshell</groupId>
<artifactId>gshell-parser</artifactId>
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=701682&r1=701681&r2=701682&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 Sat Oct 4 11:32:21 2008
@@ -24,10 +24,14 @@
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.MetaFileDataRegistry;
+import org.apache.geronimo.gshell.vfs.provider.meta.MetaFileDataRegistryConfigurer;
+import org.apache.geronimo.gshell.vfs.provider.meta.MetaFileData;
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;
@@ -46,8 +50,20 @@
@Autowired
private EventPublisher eventPublisher;
+ @Autowired
+ private MetaFileDataRegistry metaRegistry;
+
+ private MetaFileDataRegistryConfigurer metaConfig;
+
private final Map<String,Command> commands = new LinkedHashMap<String,Command>();
+ @PostConstruct
+ public void init() {
+ assert metaRegistry != null;
+ metaConfig = new MetaFileDataRegistryConfigurer(metaRegistry);
+ metaConfig.addFolder("/commands");
+ }
+
public void registerCommand(final String name, final Command command) throws DuplicateCommandException {
assert name != null;
assert command != null;
@@ -58,6 +74,12 @@
throw new DuplicateCommandException(name);
}
+ assert metaConfig != null;
+ MetaFileData data = metaConfig.addFile("/commands/" + name);
+
+ // HACK: For now just add something
+ data.addAttribute("COMMAND", command);
+
commands.put(name, command);
eventPublisher.publish(new CommandRegisteredEvent(name, command));
@@ -72,6 +94,8 @@
throw new NoSuchCommandException(name);
}
+ // TODO: Remove from meta
+
commands.remove(name);
eventPublisher.publish(new CommandRemovedEvent(name));