geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r701410 - in /geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main: java/org/apache/geronimo/gshell/vfs/ java/org/apache/geronimo/gshell/vfs/config/ resources/META-INF/spring/
Date Fri, 03 Oct 2008 15:20:09 GMT
Author: jdillon
Date: Fri Oct  3 08:20:08 2008
New Revision: 701410

URL: http://svn.apache.org/viewvc?rev=701410&view=rev
Log:
First draft of gshell-vfs spring configuration muck, probably going to simplify the configurers
more

Added:
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java
  (contents, props changed)
      - copied, changed from r701228, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java
  (contents, props changed)
      - copied, changed from r701228, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ExtentionMapConfigurer.java
  (with props)
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileOperationProviderConfigurer.java
  (with props)
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java
  (contents, props changed)
      - copied, changed from r701228, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurer.java
  (with props)
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurerSupport.java
  (with props)
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactoryBean.java
  (contents, props changed)
      - copied, changed from r701228, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemManagerFactoryBean.java
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/MimeTypeMapConfigurer.java
  (with props)
Removed:
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemManagerFactoryBean.java
Modified:
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml

Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java?rev=701410&r1=701409&r2=701410&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
Fri Oct  3 08:20:08 2008
@@ -19,9 +19,9 @@
 
 package org.apache.geronimo.gshell.vfs;
 
-import org.apache.commons.vfs.FileSystemManager;
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemManager;
 import org.apache.geronimo.gshell.command.Variables;
 
 /**

Copied: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java
(from r701228, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java?p2=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java&p1=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java&r1=701228&r2=701410&rev=701410&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java
Fri Oct  3 08:20:08 2008
@@ -17,32 +17,35 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.vfs;
+package org.apache.geronimo.gshell.vfs.config;
 
-import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.geronimo.gshell.command.Variables;
+import org.apache.commons.vfs.CacheStrategy;
+
+import java.beans.PropertyEditorSupport;
 
 /**
- * Provides access to VFS file systems.
+ * Property editor for {@link CacheStrategy} types.
  *
  * @version $Rev$ $Date$
  */
-public interface FileSystemAccess
+public class CacheStrategyEditor
+    extends PropertyEditorSupport
 {
-    String CWD = "vfs.cwd";
-
-    FileSystemManager getManager();
-
-    FileObject getCurrentDirectory(Variables vars) throws FileSystemException;
-
-    FileObject getCurrentDirectory() throws FileSystemException;
-
-    void setCurrentDirectory(Variables vars, FileObject dir) throws FileSystemException;
-
-    FileObject resolveFile(FileObject baseFile, String name) throws FileSystemException;
-
-    FileObject resolveFile(String name) throws FileSystemException;
-
-}
+    @Override
+    public void setAsText(final String text) throws IllegalArgumentException {
+        assert text != null;
+
+        if (text.equalsIgnoreCase("MANUAL")) {
+            setValue(CacheStrategy.MANUAL);
+        }
+        else if (text.equalsIgnoreCase("ON_RESOLVE")) {
+            setValue(CacheStrategy.ON_RESOLVE);
+        }
+        else if (text.equalsIgnoreCase("ON_CALL")) {
+            setValue(CacheStrategy.ON_CALL);
+        }
+        else {
+            throw new IllegalArgumentException("Unknown cache strategy: " + text);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyEditor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java
(from r701228, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java?p2=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java&p1=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java&r1=701228&r2=701410&rev=701410&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java
Fri Oct  3 08:20:08 2008
@@ -17,32 +17,18 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.vfs;
+package org.apache.geronimo.gshell.vfs.config;
 
 import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.geronimo.gshell.command.Variables;
+import org.apache.commons.vfs.impl.DefaultFileSystemManager;
 
 /**
- * Provides access to VFS file systems.
+ * Configurable {@link FileSystemManager}.
  *
  * @version $Rev$ $Date$
  */
-public interface FileSystemAccess
+public class ConfigurableFileSystemManager
+    extends DefaultFileSystemManager
 {
-    String CWD = "vfs.cwd";
-
-    FileSystemManager getManager();
-
-    FileObject getCurrentDirectory(Variables vars) throws FileSystemException;
-
-    FileObject getCurrentDirectory() throws FileSystemException;
-
-    void setCurrentDirectory(Variables vars, FileObject dir) throws FileSystemException;
-
-    FileObject resolveFile(FileObject baseFile, String name) throws FileSystemException;
-
-    FileObject resolveFile(String name) throws FileSystemException;
-
-}
+    // ???
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ConfigurableFileSystemManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ExtentionMapConfigurer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ExtentionMapConfigurer.java?rev=701410&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ExtentionMapConfigurer.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ExtentionMapConfigurer.java
Fri Oct  3 08:20:08 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.config;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * Configures an extention mapping.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtentionMapConfigurer
+extends FileSystemManagerConfigurerSupport
+{
+    private String extention;
+
+    private String scheme;
+
+    public void setExtention(final String extention) {
+        this.extention = extention;
+    }
+
+    public void setScheme(final String scheme) {
+        this.scheme = scheme;
+    }
+
+    @PostConstruct
+    public void init() {
+        // TODO: Complain on null
+
+        log.debug("Adding extention mapping: {} -> {}", extention, scheme);
+        ConfigurableFileSystemManager fsm = getFileSystemManager();
+        fsm.addExtensionMap(extention, scheme);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ExtentionMapConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ExtentionMapConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/ExtentionMapConfigurer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileOperationProviderConfigurer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileOperationProviderConfigurer.java?rev=701410&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileOperationProviderConfigurer.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileOperationProviderConfigurer.java
Fri Oct  3 08:20:08 2008
@@ -0,0 +1,66 @@
+/*
+ * 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.config;
+
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.operations.FileOperationProvider;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Configures a {@link FileOperationProvider}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class FileOperationProviderConfigurer
+    extends FileSystemManagerConfigurerSupport
+{
+    private FileOperationProvider provider;
+
+    private List<String> schemes;
+
+    public void setProvider(final FileOperationProvider provider) {
+        this.provider = provider;
+    }
+
+    public void setSchemes(final List<String> schemes) {
+        this.schemes = schemes;
+    }
+    
+    public void setScheme(final String scheme) {
+        schemes = new ArrayList<String>(1);
+        schemes.add(scheme);
+    }
+
+    @PostConstruct
+    public void init() throws FileSystemException {
+        // TODO: Handle nulls & exceptions
+
+        log.debug("Adding file operation provider: {} -> {}", schemes, provider);
+        ConfigurableFileSystemManager fsm = getFileSystemManager();
+        for (String scheme: schemes) {
+            if (fsm.hasProvider(scheme)) {
+                fsm.addOperationProvider(scheme, provider);
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileOperationProviderConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileOperationProviderConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileOperationProviderConfigurer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java
(from r701228, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java?p2=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java&p1=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java&r1=701228&r2=701410&rev=701410&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java
Fri Oct  3 08:20:08 2008
@@ -17,32 +17,48 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.vfs;
+package org.apache.geronimo.gshell.vfs.config;
 
-import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystemException;
-import org.apache.geronimo.gshell.command.Variables;
+import org.apache.commons.vfs.provider.FileProvider;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
- * Provides access to VFS file systems.
+ * Configures a {@link FileProvider}.
  *
  * @version $Rev$ $Date$
  */
-public interface FileSystemAccess
+public class FileProviderConfigurer
+    extends FileSystemManagerConfigurerSupport
 {
-    String CWD = "vfs.cwd";
-
-    FileSystemManager getManager();
-
-    FileObject getCurrentDirectory(Variables vars) throws FileSystemException;
-
-    FileObject getCurrentDirectory() throws FileSystemException;
-
-    void setCurrentDirectory(Variables vars, FileObject dir) throws FileSystemException;
-
-    FileObject resolveFile(FileObject baseFile, String name) throws FileSystemException;
+    private FileProvider provider;
 
-    FileObject resolveFile(String name) throws FileSystemException;
+    private List<String> schemes;
 
-}
+    public void setProvider(final FileProvider provider) {
+        this.provider = provider;
+    }
+
+    public void setSchemes(final List<String> schemes) {
+        this.schemes = schemes;
+    }
+
+    public void setScheme(final String scheme) {
+        schemes = new ArrayList<String>(1);
+        schemes.add(scheme);
+    }
+
+    @PostConstruct
+    public void init() throws FileSystemException {
+        // TODO: Handle nulls & exceptions
+
+        log.debug("Adding file provider: {} -> {}", schemes, provider);
+        ConfigurableFileSystemManager fsm = getFileSystemManager();
+        for (String scheme: schemes) {
+            fsm.addProvider(scheme, provider);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileProviderConfigurer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurer.java?rev=701410&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurer.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurer.java
Fri Oct  3 08:20:08 2008
@@ -0,0 +1,56 @@
+/*
+ * 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.config;
+
+import org.apache.commons.vfs.FileSystemManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * Support for configuration of a {@link FileSystemManager}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class FileSystemManagerConfigurer
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private ConfigurableFileSystemManager fileSystemManager;
+
+    // TODO: Maybe add a provider configurer, which will support mapping extentions, mime-tyeps
for a single provider?
+
+    // providers Map<List<String>,Provider>
+
+    // operation providers Map<List<String>,Provider>
+
+    // extentions
+
+    // mime-types
+
+    @PostConstruct
+    public void init() {
+        assert fileSystemManager != null;
+        log.debug("Configuring file system manager: {}", fileSystemManager);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurerSupport.java?rev=701410&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurerSupport.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurerSupport.java
Fri Oct  3 08:20:08 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.config;
+
+import org.apache.commons.vfs.FileSystemManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Support for configuration of a {@link FileSystemManager}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class FileSystemManagerConfigurerSupport
+{
+    protected final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private ConfigurableFileSystemManager fileSystemManager;
+
+    public ConfigurableFileSystemManager getFileSystemManager() {
+        assert fileSystemManager != null;
+        return fileSystemManager;
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurerSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurerSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerConfigurerSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactoryBean.java
(from r701228, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemManagerFactoryBean.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactoryBean.java?p2=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactoryBean.java&p1=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemManagerFactoryBean.java&r1=701228&r2=701410&rev=701410&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemManagerFactoryBean.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactoryBean.java
Fri Oct  3 08:20:08 2008
@@ -17,16 +17,25 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.vfs;
+package org.apache.geronimo.gshell.vfs.config;
 
+import org.apache.commons.vfs.CacheStrategy;
+import org.apache.commons.vfs.FileContentInfoFactory;
 import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.VFS;
-import org.apache.commons.vfs.Capability;
-import org.springframework.beans.factory.FactoryBean;
+import org.apache.commons.vfs.FilesCache;
+import org.apache.commons.vfs.cache.SoftRefFilesCache;
+import org.apache.commons.vfs.impl.DefaultFileReplicator;
+import org.apache.commons.vfs.impl.FileContentInfoFilenameFactory;
+import org.apache.commons.vfs.impl.PrivilegedFileReplicator;
+import org.apache.commons.vfs.provider.FileReplicator;
+import org.apache.commons.vfs.provider.TemporaryFileStore;
+import org.apache.commons.vfs.provider.FileProvider;
+import org.apache.commons.vfs.provider.url.UrlFileProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.FactoryBean;
 
-import java.util.Collection;
+import javax.annotation.PostConstruct;
 
 /**
  * Spring {@link FactoryBean} to construct a {@link FileSystemManager} instance.
@@ -38,44 +47,108 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    public Object getObject() throws Exception {
-        //
-        // TODO: Manually construct the FSM stuff, don't use the default
-        //
-        
-        FileSystemManager fsm = VFS.getManager();
+    private FilesCache filesCache;
 
-        log.debug("File system manager: {}", fsm);
-        
-        // Dump some details about the current configuration
-        if (log.isTraceEnabled()) {
-            log.trace("    Cache strategy: {}", fsm.getCacheStrategy());
-            log.trace("    File content info factory: {}", fsm.getFileContentInfoFactory());
-
-            //
-            // TODO: Add commands to inspect all this muck and install new providers, etc.
-            //
-            
-            log.trace("Schemes:");
-            String[] schemes = fsm.getSchemes();
-            for (String scheme : schemes) {
-                log.trace("    {}", scheme);
-
-                // noinspection unchecked
-                Collection<Capability> capabilities = fsm.getProviderCapabilities(scheme);
-                if (!capabilities.isEmpty()) {
-                    for (Capability capability : capabilities) {
-                        log.trace("        {}", capability);
-                    }
-                }
+    private CacheStrategy cacheStrategy = CacheStrategy.ON_RESOLVE;
+
+    private FileReplicator fileReplicator;
+
+    private TemporaryFileStore temporaryFileStore;
+
+    private FileContentInfoFactory fileContentInfoFactory;
+
+    private FileProvider defaultProvider;
+
+    // FileObjectDecorator (Class/Constructor of DecoratedFileObject? or make a factory?)
+
+    public void setFilesCache(final FilesCache cache) {
+        this.filesCache = cache;
+    }
+
+    public void setCacheStrategy(final CacheStrategy strategy) {
+        this.cacheStrategy = strategy;
+    }
+
+    public void setFileReplicator(final FileReplicator replicator) {
+        this.fileReplicator = replicator;
+    }
+
+    public void setTemporaryFileStore(final TemporaryFileStore store) {
+        this.temporaryFileStore = store;
+    }
+
+    public void setFileContentInfoFactory(final FileContentInfoFactory factory) {
+        this.fileContentInfoFactory = factory;
+    }
+
+    public void setDefaultProvider(final FileProvider provider) {
+        this.defaultProvider = provider;
+    }
+
+    @PostConstruct
+    public void init() {
+        if (filesCache == null) {
+            filesCache = new SoftRefFilesCache();
+        }
+
+        if (fileReplicator == null || temporaryFileStore == null) {
+            DefaultFileReplicator replicator = new DefaultFileReplicator();
+            if (fileReplicator == null) {
+                fileReplicator = new PrivilegedFileReplicator(replicator);
             }
+            if (temporaryFileStore == null) {
+                temporaryFileStore = replicator;
+            }
+        }
+
+        if (fileContentInfoFactory == null) {
+            fileContentInfoFactory = new FileContentInfoFilenameFactory();
+        }
+
+        if (defaultProvider == null) {
+            defaultProvider = new UrlFileProvider();
         }
+    }
+
+    //
+    // FactoryBean
+    //
 
+    public Object getObject() throws Exception {
+        ConfigurableFileSystemManager fsm = new ConfigurableFileSystemManager();
+
+        assert fileReplicator != null;
+        log.debug("File replicator: {}", fileReplicator);
+        fsm.setReplicator(fileReplicator);
+
+        assert temporaryFileStore != null;
+        log.debug("Temporary file store: {}", temporaryFileStore);
+        fsm.setTemporaryFileStore(temporaryFileStore);
+
+        assert filesCache != null;
+        log.debug("Files cache: {}", filesCache);
+        fsm.setFilesCache(filesCache);
+
+        assert cacheStrategy != null;
+        log.debug("Cache strategy: {}", cacheStrategy);
+        fsm.setCacheStrategy(cacheStrategy);
+
+        assert fileContentInfoFactory != null;
+        log.debug("File content info factory: {}", fileContentInfoFactory);
+        fsm.setFileContentInfoFactory(fileContentInfoFactory);
+
+        assert defaultProvider != null;
+        log.debug("Default provider: {}", defaultProvider);
+        fsm.setDefaultProvider(defaultProvider);
+
+        // Finally init the manager
+        fsm.init();
+        
         return fsm;
     }
 
     public Class getObjectType() {
-        return FileSystemManager.class;
+        return ConfigurableFileSystemManager.class;
     }
 
     public boolean isSingleton() {

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactoryBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactoryBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/MimeTypeMapConfigurer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/MimeTypeMapConfigurer.java?rev=701410&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/MimeTypeMapConfigurer.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/MimeTypeMapConfigurer.java
Fri Oct  3 08:20:08 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.config;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * Configures a MIME type mapping.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MimeTypeMapConfigurer
+    extends FileSystemManagerConfigurerSupport
+{
+    private String mimeType;
+
+    private String scheme;
+
+    public void setMimeType(final String mimeType) {
+        this.mimeType = mimeType;
+    }
+
+    public void setScheme(final String scheme) {
+        this.scheme = scheme;
+    }
+
+    @PostConstruct
+    public void init() {
+        // TODO: Complain on null
+
+        log.debug("Adding mime-type mapping: {} -> {}", mimeType, scheme);
+        ConfigurableFileSystemManager fsm = getFileSystemManager();
+        fsm.addMimeTypeMap(mimeType, scheme);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/MimeTypeMapConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/MimeTypeMapConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/config/MimeTypeMapConfigurer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=701410&r1=701409&r2=701410&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
Fri Oct  3 08:20:08 2008
@@ -25,7 +25,133 @@
        xsi:schemaLocation="
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-    <bean id="fileSystemManager" class="org.apache.geronimo.gshell.vfs.FileSystemManagerFactoryBean"/>
+    <!--
+    FIXME: Need BeanFactoryPostProcessor support in BeanContainer.
+    -->
+
+    <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
+        <property name="customEditors">
+            <map>
+                <entry key="org.apache.commons.vfs.CacheStrategy">
+                    <bean class="org.apache.geronimo.gshell.vfs.config.CacheStrategyEditor"/>
+                </entry>
+            </map>
+        </property>
+    </bean>
+
+    <bean id="defaultFileReplicator" class="org.apache.commons.vfs.impl.DefaultFileReplicator"/>
+
+    <bean id="fileSystemManager" class="org.apache.geronimo.gshell.vfs.config.FileSystemManagerFactoryBean">
+        <property name="filesCache">
+            <bean class="org.apache.commons.vfs.cache.SoftRefFilesCache"/>
+        </property>
+
+        <property name="cacheStrategy" value="ON_RESOLVE"/>
+        
+        <property name="fileReplicator">
+            <bean class="org.apache.commons.vfs.impl.PrivilegedFileReplicator">
+                <constructor-arg ref="defaultFileReplicator"/>
+            </bean>
+        </property>
+
+        <property name="temporaryFileStore">
+            <ref bean="defaultFileReplicator"/>
+        </property>
+
+        <property name="fileContentInfoFactory">
+            <bean class="org.apache.commons.vfs.impl.FileContentInfoFilenameFactory"/>
+        </property>
+
+        <property name="defaultProvider">
+            <bean class="org.apache.commons.vfs.provider.url.UrlFileProvider"/>
+        </property>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer">
+        <property name="scheme" value="file"/>
+        <property name="provider">
+            <bean class="org.apache.commons.vfs.provider.local.DefaultLocalFileProvider"/>
+        </property>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer">
+        <property name="scheme" value="tmp"/>
+        <property name="provider">
+            <bean class="org.apache.commons.vfs.provider.temp.TemporaryFileProvider"/>
+        </property>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer">
+        <property name="scheme" value="ram"/>
+        <property name="provider">
+            <bean class="org.apache.commons.vfs.provider.ram.RamFileProvider"/>
+        </property>
+    </bean>
+    
+    <!--
+    TODO: Roll up this configuration into one bean for ext another for mime,
+          or maybe just one bean for both.  This is too verbose.
+    -->
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.ExtentionMapConfigurer">
+        <property name="extention" value="zip"/>
+        <property name="scheme" value="zip"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.ExtentionMapConfigurer">
+        <property name="extention" value="tar"/>
+        <property name="scheme" value="tar"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.ExtentionMapConfigurer">
+        <property name="extention" value="tar"/>
+        <property name="scheme" value="tar"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.ExtentionMapConfigurer">
+        <property name="extention" value="jar"/>
+        <property name="scheme" value="jar"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.ExtentionMapConfigurer">
+        <property name="extention" value="bz2"/>
+        <property name="scheme" value="bz2"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.ExtentionMapConfigurer">
+        <property name="extention" value="gz"/>
+        <property name="scheme" value="gz"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.ExtentionMapConfigurer">
+        <property name="extention" value="tgz"/>
+        <property name="scheme" value="tar"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.ExtentionMapConfigurer">
+        <property name="extention" value="tar"/>
+        <property name="scheme" value="tbz2"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.MimeTypeMapConfigurer">
+        <property name="mimeType" value="application/zip"/>
+        <property name="scheme" value="zip"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.MimeTypeMapConfigurer">
+        <property name="mimeType" value="application/x-tar"/>
+        <property name="scheme" value="tar"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.MimeTypeMapConfigurer">
+        <property name="mimeType" value="application/x-gzip"/>
+        <property name="scheme" value="gz"/>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.vfs.config.MimeTypeMapConfigurer">
+        <property name="mimeType" value="application/zip"/>
+        <property name="scheme" value="zip"/>
+    </bean>
 
     <bean id="fileSystemAccess" class="org.apache.geronimo.gshell.vfs.FileSystemAccessImpl"/>
 



Mime
View raw message