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 17:16:08 UTC

svn commit: r701650 - in /geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main: java/org/apache/geronimo/gshell/vfs/provider/meta/ resources/META-INF/spring/

Author: jdillon
Date: Sat Oct  4 08:16:07 2008
New Revision: 701650

URL: http://svn.apache.org/viewvc?rev=701650&view=rev
Log:
Added MetaFileDataRegistry[Impl] and using that for the source of MetaFileData nodes
Added some notes on what is left to do for the registry

Added:
    geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java   (with props)
Modified:
    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/MetaFileObject.java
    geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileProvider.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-meta/src/main/resources/META-INF/spring/components.xml

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=701650&r1=701649&r2=701650&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 08:16:07 2008
@@ -50,10 +50,17 @@
 
     private final Collection<MetaFileData> children = Collections.synchronizedCollection(new ArrayList<MetaFileData>());
 
-    public MetaFileData(final FileName name) {
+    public MetaFileData(final FileName name, final FileType type) {
         assert name != null;
+        assert type != null;
 
         this.name = name;
+        this.type = type;
+    }
+
+
+    public MetaFileData(final FileName name) {
+        this(name, FileType.IMAGINARY);
     }
 
     public FileName getName() {
@@ -64,6 +71,10 @@
         return type;
     }
 
+    //
+    // TODO: Used by MetaFileObject.injectType() see if we can nuke that and this.  Finalize type once that is done.
+    //
+
     public void setType(final FileType type) {
         assert type != null;
 

Added: 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=701650&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java Sat Oct  4 08:16:07 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.vfs.provider.meta;
+
+import org.apache.commons.vfs.FileName;
+
+/**
+ * Meta file data registry.
+ *
+ * @version $Rev$ $Date$
+ */
+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 register(FileName name, MetaFileData data);
+
+    void remove(FileName name);
+
+    //
+    // TODO: Consider making this always return non-null, throw exception when not found, add contains(FileName)
+    //
+    
+    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/MetaFileDataRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.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/MetaFileDataRegistry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=701650&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java Sat Oct  4 08:16:07 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.vfs.provider.meta;
+
+import org.apache.commons.vfs.FileName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * {@link MetaFileDataRegistry} component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MetaFileDataRegistryImpl
+    implements MetaFileDataRegistry
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final Map<FileName,MetaFileData> nodes = Collections.synchronizedMap(new HashMap<FileName,MetaFileData>());
+
+    //
+    // TODO: Add some helpers to assist registration of new data.
+    //
+
+    public void register(final FileName name, final MetaFileData data) {
+        assert name != null;
+        assert data != null;
+
+        log.debug("Registering: {} -> {}", name, data);
+
+        nodes.put(name, data);
+    }
+
+    public void remove(final FileName name) {
+        assert name != null;
+
+        log.debug("Removing: {}", name);
+
+        nodes.remove(name);
+    }
+
+    public MetaFileData lookup(final FileName name) {
+        assert name != null;
+
+        return nodes.get(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/MetaFileDataRegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.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/MetaFileDataRegistryImpl.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/MetaFileObject.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/MetaFileObject.java?rev=701650&r1=701649&r2=701650&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileObject.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileObject.java Sat Oct  4 08:16:07 2008
@@ -36,8 +36,6 @@
 public class MetaFileObject
     extends AbstractFileObject
 {
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
     private final MetaFileSystem fileSystem;
 
     private MetaFileData data;
@@ -116,7 +114,9 @@
 
     @Override
     protected void doAttach() throws Exception {
-        fileSystem.attach(this);
+        if (data == null) {
+            fileSystem.attach(this);
+        }
     }
 
     @Override
@@ -124,6 +124,10 @@
         data = null;
     }
 
+    //
+    // TODO: See where this is called and figure out if we can nuke it.
+    //
+
     @Override
     protected void injectType(final FileType type) {
         assert type != null;

Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileProvider.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/MetaFileProvider.java?rev=701650&r1=701649&r2=701650&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileProvider.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileProvider.java Sat Oct  4 08:16:07 2008
@@ -27,6 +27,7 @@
 import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -44,8 +45,11 @@
 
     public static final Collection<Capability> CAPABILITIES = Collections.unmodifiableCollection(Arrays.asList(
         Capability.ATTRIBUTES,
+
+        // TODO: All modification should be done via the registry, see about nuking these
         Capability.CREATE,
         Capability.DELETE,
+        
         Capability.GET_TYPE,
         Capability.GET_LAST_MODIFIED,
         Capability.LAST_MODIFIED,
@@ -53,12 +57,17 @@
         Capability.URI
     ));
 
+    @Autowired
+    private MetaFileDataRegistry registry;
+
     public Collection getCapabilities() {
         return CAPABILITIES;
     }
 
     protected FileSystem doCreateFileSystem(final FileName fileName, final FileSystemOptions options) throws FileSystemException {
-        MetaFileSystem fs = new MetaFileSystem(fileName, options);
+        assert registry != null;
+
+        MetaFileSystem fs = new MetaFileSystem(registry, fileName, options);
 
         log.debug("Created file system: {}", fs);
 

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=701650&r1=701649&r2=701650&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 08:16:07 2008
@@ -30,10 +30,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Meta file system.
@@ -45,16 +42,22 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private final Map<FileName,MetaFileData> nodes = Collections.synchronizedMap(new HashMap<FileName,MetaFileData>());
+    private MetaFileDataRegistry registry;
 
-    public MetaFileSystem(final FileName rootName, final FileSystemOptions options) {
+    public MetaFileSystem(final MetaFileDataRegistry registry, final FileName rootName, final FileSystemOptions options) {
         super(rootName, null, options);
 
+        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);
-        data.setType(FileType.FOLDER);
+        MetaFileData data = new MetaFileData(rootName, FileType.FOLDER);
         data.updateLastModified();
-        nodes.put(rootName, data);
+        registry.register(rootName, data);
     }
 
     protected FileObject createFile(final FileName fileName) throws Exception {
@@ -74,7 +77,6 @@
 
     @Override
     public void close() {
-        nodes.clear();
         super.close();
     }
 
@@ -82,6 +84,10 @@
     // Internal bits invoked from MetaFileObject
     //
 
+    //
+    // TODO: Need to remove some of this, as the files aren't created per-normal, they need to be bound in the registry
+    //
+    
     void save(final MetaFileObject file) throws FileSystemException {
         assert file != null;
 
@@ -91,7 +97,7 @@
         MetaFileData data = file.getData();
 
         if (name.getDepth() > 0) {
-            MetaFileData parentData = nodes.get(file.getParent().getName());
+            MetaFileData parentData = registry.lookup(file.getParent().getName());
 
             if (!parentData.hasChild(data)) {
                 MetaFileObject parent = (MetaFileObject)file.getParent();
@@ -100,7 +106,7 @@
             }
         }
 
-        nodes.put(name, data);
+        registry.register(name, data);
         file.getData().updateLastModified();
         file.close();
     }
@@ -113,7 +119,7 @@
         FileName name = file.getName();
         assert name != null;
 
-        MetaFileData data = nodes.get(name);
+        MetaFileData data = registry.lookup(name);
         if (data == null) {
             data = new MetaFileData(name);
         }
@@ -130,7 +136,7 @@
             throw new FileSystemException("Can not delete file-system root");
         }
 
-        nodes.remove(file.getName());
+        registry.remove(file.getName());
 
         MetaFileObject parent = (MetaFileObject) resolveFile(file.getParent().getName());
         parent.getData().removeChild(file.getData());
@@ -144,7 +150,7 @@
 
         log.debug("Listing children: {}", name);
 
-        MetaFileData data = nodes.get(name);
+        MetaFileData data = registry.lookup(name);
         Collection<MetaFileData> children = data.getChildren();
 
         List<String> names = new ArrayList<String>(children.size());

Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml?rev=701650&r1=701649&r2=701650&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml Sat Oct  4 08:16:07 2008
@@ -24,6 +24,8 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
+    <bean id="metaFileDataRegistry" class="org.apache.geronimo.gshell.vfs.provider.meta.MetaFileDataRegistryImpl"/>
+    
     <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer">
         <property name="scheme" value="meta"/>
         <property name="provider">