[jboss-cvs] JBossAS SVN: r101136 - in projects/demos/microcontainer/trunk: vfs and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 18 18:28:27 EST 2010


Author: alesj
Date: 2010-02-18 18:28:27 -0500 (Thu, 18 Feb 2010)
New Revision: 101136

Added:
   projects/demos/microcontainer/trunk/vfs/
   projects/demos/microcontainer/trunk/vfs/pom.xml
   projects/demos/microcontainer/trunk/vfs/src/
   projects/demos/microcontainer/trunk/vfs/src/main/
   projects/demos/microcontainer/trunk/vfs/src/main/java/
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/bootstrap/
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/bootstrap/vfs/
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/bootstrap/vfs/VFSMain.java
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/vfs/
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/vfs/gzip/
   projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/vfs/gzip/GZipFileSystem.java
   projects/demos/microcontainer/trunk/vfs/src/main/resources/
   projects/demos/microcontainer/trunk/vfs/src/main/resources/compressed.gzip
   projects/demos/microcontainer/trunk/vfs/src/main/resources/text.txt
Modified:
   projects/demos/microcontainer/trunk/pom.xml
Log:
Demo VFS3.

Modified: projects/demos/microcontainer/trunk/pom.xml
===================================================================
--- projects/demos/microcontainer/trunk/pom.xml	2010-02-18 23:10:09 UTC (rev 101135)
+++ projects/demos/microcontainer/trunk/pom.xml	2010-02-18 23:28:27 UTC (rev 101136)
@@ -31,7 +31,7 @@
     <!-- module>igloo</module>
     <module>bundle</module>
     <module>bundle_user</module -->
-    <!-- module>vfs</module -->
+    <module>vfs</module>
     <module>policy</module>
     <!-- <module>osgi</module> -->
     <module>build</module>

Added: projects/demos/microcontainer/trunk/vfs/pom.xml
===================================================================
--- projects/demos/microcontainer/trunk/vfs/pom.xml	                        (rev 0)
+++ projects/demos/microcontainer/trunk/vfs/pom.xml	2010-02-18 23:28:27 UTC (rev 101136)
@@ -0,0 +1,35 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.jboss.demos</groupId>
+    <artifactId>jboss-demos</artifactId>
+    <version>2.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.demos</groupId>
+  <artifactId>jboss-demos-vfs</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss MC Demos VFS</name>
+  <url>http://www.jboss.org/jbossmc</url>
+  <description>JBoss MC Demos</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.demos</groupId>
+      <artifactId>jboss-demos-bootstrap</artifactId>
+    </dependency>
+    <!-- Compile (global dependencies) -->
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file

Added: projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/bootstrap/vfs/VFSMain.java
===================================================================
--- projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/bootstrap/vfs/VFSMain.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/bootstrap/vfs/VFSMain.java	2010-02-18 23:28:27 UTC (rev 101136)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.demos.bootstrap.vfs;
+
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+import java.io.*;
+
+/**
+ * Demo simple GZIP usage.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class VFSMain
+{
+   public static void main(String[] args)
+   {
+      try
+      {
+         // demos.home
+         String demosHome = System.getProperty("demos.home");
+         if (demosHome == null)
+         {
+            if (args.length > 0)
+               demosHome = args[0];
+            else
+               demosHome = "/projects/demos";
+         }
+
+         File resources = new File(demosHome + "/vfs/src/main/resources");
+         if (resources.exists() == false)
+            throw new FileNotFoundException(resources.getAbsolutePath());
+
+         VirtualFile root = VFS.getChild(resources.toURI());
+         VirtualFile file = root.getChild("compressed.gzip");
+
+         System.out.println();
+         InputStream is = file.openStream();
+         try
+         {
+            BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
+            String line;
+            while((line = buffer.readLine()) != null)
+            {
+               System.out.println(line);
+            }
+         }
+         finally
+         {
+            is.close();
+         }
+      }
+      catch (Throwable t)
+      {
+         t.printStackTrace();
+      }
+   }
+}

Added: projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/vfs/gzip/GZipFileSystem.java
===================================================================
--- projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/vfs/gzip/GZipFileSystem.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/vfs/src/main/java/org/jboss/demos/vfs/gzip/GZipFileSystem.java	2010-02-18 23:28:27 UTC (rev 101136)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.demos.vfs.gzip;
+
+import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.spi.FileSystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+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 java.util.zip.GZIPInputStream;
+
+/**
+ * GZip file system.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class GZipFileSystem implements FileSystem
+{
+   private final File realRoot;
+
+   public GZipFileSystem(File realRoot)
+   {
+      if (realRoot == null)
+         throw new IllegalArgumentException("Null real file");
+
+      this.realRoot = realRoot;
+   }
+
+   public File getFile(VirtualFile mountPoint, VirtualFile target)
+   {
+      if (mountPoint.equals(target))
+      {
+         return realRoot;
+      }
+      else
+         throw new RuntimeException("GZipFileSystem does not support children");
+   }
+
+   public InputStream openInputStream(VirtualFile mountPoint, VirtualFile target) throws IOException
+   {
+      return new GZIPInputStream(new FileInputStream(getFile(mountPoint, target)));
+   }
+
+   public boolean isReadOnly()
+   {
+      return true;
+   }
+
+   public boolean delete(VirtualFile mountPoint, VirtualFile target)
+   {
+      return getFile(mountPoint, target).delete();
+   }
+
+   public long getSize(VirtualFile mountPoint, VirtualFile target)
+   {
+      return getFile(mountPoint, target).length();
+   }
+
+   public long getLastModified(VirtualFile mountPoint, VirtualFile target)
+   {
+      return getFile(mountPoint, target).lastModified();
+   }
+
+   public boolean exists(VirtualFile mountPoint, VirtualFile target)
+   {
+      return getFile(mountPoint, target).exists();
+   }
+
+   public boolean isFile(final VirtualFile mountPoint, final VirtualFile target)
+   {
+      return getFile(mountPoint, target).isFile();
+   }
+
+   public boolean isDirectory(VirtualFile mountPoint, VirtualFile target)
+   {
+      return getFile(mountPoint, target).isDirectory();
+   }
+
+   public List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target)
+   {
+      final String[] names = getFile(mountPoint, target).list();
+      return names == null ? Collections.<String>emptyList() : Arrays.asList(names);
+   }
+
+   public CodeSigner[] getCodeSigners(VirtualFile mountPoint, VirtualFile target)
+   {
+      return null;
+   }
+
+   public void close() throws IOException
+   {
+   }
+}

Added: projects/demos/microcontainer/trunk/vfs/src/main/resources/compressed.gzip
===================================================================
(Binary files differ)


Property changes on: projects/demos/microcontainer/trunk/vfs/src/main/resources/compressed.gzip
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/demos/microcontainer/trunk/vfs/src/main/resources/text.txt
===================================================================
--- projects/demos/microcontainer/trunk/vfs/src/main/resources/text.txt	                        (rev 0)
+++ projects/demos/microcontainer/trunk/vfs/src/main/resources/text.txt	2010-02-18 23:28:27 UTC (rev 101136)
@@ -0,0 +1,6 @@
+Welcome to DZone's JBoss Microcontainer series!
+
+This article talks about our VFS impl.
+I hope you enjoy it.
+
+-Ales




More information about the jboss-cvs-commits mailing list