[jboss-cvs] JBossAS SVN: r104193 - in projects/demos/microcontainer/trunk: infinispan/src/main/java/org/jboss/demos/infinispan/gfs and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 23 07:30:53 EDT 2010


Author: alesj
Date: 2010-04-23 07:30:53 -0400 (Fri, 23 Apr 2010)
New Revision: 104193

Modified:
   projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/GridFileSystem.java
   projects/demos/microcontainer/trunk/pom.xml
Log:
Initial GridFS impl.

Modified: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/GridFileSystem.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/GridFileSystem.java	2010-04-23 11:14:43 UTC (rev 104192)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/GridFileSystem.java	2010-04-23 11:30:53 UTC (rev 104193)
@@ -26,11 +26,15 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.security.CodeSigner;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.jboss.vfs.VirtualFile;
 import org.jboss.vfs.spi.FileSystem;
 
+import org.infinispan.io.GridFilesystem;
+
 /**
  * Infinispan's Grid file system.
  *
@@ -38,68 +42,91 @@
  */
 public class GridFileSystem implements FileSystem
 {
+   private GridFilesystem gfs;
+
+   public GridFileSystem(GridFilesystem gfs)
+   {
+      if (gfs == null)
+         throw new IllegalArgumentException("Null GFS");
+      this.gfs = gfs;
+   }
+
+   protected String getRelativePath(VirtualFile mountPoint, VirtualFile target)
+   {
+      return target.getPathNameRelativeTo(mountPoint);
+   }
+
+   public File getSafeFile(VirtualFile mountPoint, VirtualFile target)
+   {
+      String path = getRelativePath(mountPoint, target);
+      return gfs.getFile(path);
+   }
+
    public File getFile(VirtualFile mountPoint, VirtualFile target) throws IOException
    {
-      return null;  //To change body of implemented methods use File | Settings | File Templates.
+      return getSafeFile(mountPoint, target);
    }
 
    public InputStream openInputStream(VirtualFile mountPoint, VirtualFile target) throws IOException
    {
-      return null;  //To change body of implemented methods use File | Settings | File Templates.
+      String path = getRelativePath(mountPoint, target);
+      return gfs.getInput(path);
    }
 
    public boolean isReadOnly()
    {
-      return false;  //To change body of implemented methods use File | Settings | File Templates.
+      return false;
    }
 
    public boolean delete(VirtualFile mountPoint, VirtualFile target)
    {
-      return false;  //To change body of implemented methods use File | Settings | File Templates.
+      String path = getRelativePath(mountPoint, target);
+      gfs.remove(path, true);
+      return true;
    }
 
    public long getSize(VirtualFile mountPoint, VirtualFile target)
    {
-      return 0;  //To change body of implemented methods use File | Settings | File Templates.
+      return getSafeFile(mountPoint, target).length();
    }
 
    public long getLastModified(VirtualFile mountPoint, VirtualFile target)
    {
-      return 0;  //To change body of implemented methods use File | Settings | File Templates.
+      return getSafeFile(mountPoint, target).lastModified();
    }
 
    public boolean exists(VirtualFile mountPoint, VirtualFile target)
    {
-      return false;  //To change body of implemented methods use File | Settings | File Templates.
+      return getSafeFile(mountPoint, target).exists();
    }
 
    public boolean isFile(VirtualFile mountPoint, VirtualFile target)
    {
-      return false;  //To change body of implemented methods use File | Settings | File Templates.
+      return getSafeFile(mountPoint, target).isFile();
    }
 
    public boolean isDirectory(VirtualFile mountPoint, VirtualFile target)
    {
-      return false;  //To change body of implemented methods use File | Settings | File Templates.
+      return getSafeFile(mountPoint, target).isDirectory();
    }
 
    public List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target)
    {
-      return null;  //To change body of implemented methods use File | Settings | File Templates.
+      final String[] names = getSafeFile(mountPoint, target).list();
+      return names == null ? Collections.<String>emptyList() : Arrays.asList(names);
    }
 
    public CodeSigner[] getCodeSigners(VirtualFile mountPoint, VirtualFile target)
    {
-      return new CodeSigner[0];  //To change body of implemented methods use File | Settings | File Templates.
+      return null;
    }
 
    public void close() throws IOException
    {
-      //To change body of implemented methods use File | Settings | File Templates.
    }
 
    public File getMountSource()
    {
-      return null;  //To change body of implemented methods use File | Settings | File Templates.
+      return null;
    }
 }

Modified: projects/demos/microcontainer/trunk/pom.xml
===================================================================
--- projects/demos/microcontainer/trunk/pom.xml	2010-04-23 11:14:43 UTC (rev 104192)
+++ projects/demos/microcontainer/trunk/pom.xml	2010-04-23 11:30:53 UTC (rev 104193)
@@ -136,7 +136,7 @@
     </pluginManagement>
   </build>
   
-  <!-- repositories>
+  <repositories>
     <repository>
       <id>repository.jboss.org</id>
       <name>JBoss Repository</name>
@@ -158,7 +158,7 @@
         <enabled>false</enabled>
       </releases>
     </repository>
-  </repositories -->
+  </repositories>
   
   <dependencyManagement>
     <!-- The parent pom manages the inter-dependencies of the modules. -->




More information about the jboss-cvs-commits mailing list