geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r698675 - in /geronimo/gshell/trunk/gshell-commands/gshell-vfs: ./ src/main/java/org/apache/geronimo/gshell/commands/vfs/ src/main/resources/META-INF/spring/
Date Wed, 24 Sep 2008 17:56:11 GMT
Author: jdillon
Date: Wed Sep 24 10:56:11 2008
New Revision: 698675

URL: http://svn.apache.org/viewvc?rev=698675&view=rev
Log:
Created factory bean to produce the FileSystemManager, autowire it into the copy command

Added:
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileSystemManagerFactoryBean.java
  (with props)
Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/pom.xml
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/pom.xml?rev=698675&r1=698674&r2=698675&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/pom.xml Wed Sep 24 10:56:11 2008
@@ -42,6 +42,11 @@
             <groupId>commons-vfs</groupId>
             <artifactId>commons-vfs</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-spring</artifactId>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java?rev=698675&r1=698674&r2=698675&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
Wed Sep 24 10:56:11 2008
@@ -22,13 +22,12 @@
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystemManager;
 import org.apache.commons.vfs.FileUtil;
-import org.apache.commons.vfs.VFS;
-import org.apache.commons.vfs.FileSystemException;
 import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.command.CommandContext;
 import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * Copy files.
@@ -39,7 +38,10 @@
     implements CommandAction
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
-    
+
+    @Autowired
+    private FileSystemManager fsm;
+
     @Argument(index=0, required=true)
     private String sourceName;
 
@@ -48,8 +50,7 @@
 
     public Object execute(final CommandContext context) throws Exception {
         assert context != null;
-    
-        FileSystemManager fsm = getFileSystemManager();
+
         FileObject source = fsm.resolveFile(sourceName);
         FileObject target = fsm.resolveFile(targetName);
 
@@ -59,21 +60,4 @@
 
         return Result.SUCCESS;
     }
-
-    // TODO: Move this to a bean factory and inject
-
-    private FileSystemManager fsManager;
-
-    protected FileSystemManager getFileSystemManager() {
-        if (fsManager == null) {
-            try {
-                fsManager = VFS.getManager();
-            }
-            catch (FileSystemException e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        return fsManager;
-    }
 }
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileSystemManagerFactoryBean.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileSystemManagerFactoryBean.java?rev=698675&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileSystemManagerFactoryBean.java
(added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileSystemManagerFactoryBean.java
Wed Sep 24 10:56:11 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.commands.vfs;
+
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.VFS;
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * Sprint {@link FactoryBean} to construct the {@link FileSystemManager} instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public class FileSystemManagerFactoryBean
+    implements FactoryBean
+{
+    public Object getObject() throws Exception {
+        return VFS.getManager();
+    }
+
+    public Class getObjectType() {
+        return FileSystemManager.class;
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+}

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

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

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

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml?rev=698675&r1=698674&r2=698675&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml
Wed Sep 24 10:56:11 2008
@@ -35,4 +35,6 @@
         </gshell:command-bundle>
     </gshell:plugin>
 
+    <bean id="fileSystemManager" class="org.apache.geronimo.gshell.commands.vfs.FileSystemManagerFactoryBean"/>
+
 </beans>
\ No newline at end of file



Mime
View raw message