[jboss-cvs] JBossAS SVN: r104215 - in projects/demos/microcontainer/trunk/infinispan/src/main: resources and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Apr 24 15:34:38 EDT 2010


Author: alesj
Date: 2010-04-24 15:34:37 -0400 (Sat, 24 Apr 2010)
New Revision: 104215

Added:
   projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/MountGFStoVFS.java
   projects/demos/microcontainer/trunk/infinispan/src/main/resources/META-INF/
   projects/demos/microcontainer/trunk/infinispan/src/main/resources/META-INF/infinispan-beans.xml
Log:
Mount GFS to VFS.

Added: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/MountGFStoVFS.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/MountGFStoVFS.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/MountGFStoVFS.java	2010-04-24 19:34:37 UTC (rev 104215)
@@ -0,0 +1,73 @@
+/*
+ * 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.infinispan.gfs;
+
+import java.io.Closeable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+import org.infinispan.io.GridFilesystem;
+
+/**
+ * Mount GFS to VFS.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MountGFStoVFS
+{
+   /** The temp counter - temp workaround */
+   private AtomicInteger counter = new AtomicInteger();
+
+   // closeable handle for file system
+   private Map<GridFilesystem, Closeable> handles = new HashMap<GridFilesystem, Closeable>();
+
+   /**
+    * Mount GFS to VFS.
+    *
+    * @param gfs the GFS bean
+    * @throws Exception for any error
+    */
+   public void mount(GridFilesystem gfs) throws Exception
+   {
+      VirtualFile grid = VFS.getChild("GFS-" + counter.incrementAndGet()); // TODO gfs should have some qualifier
+      Closeable closeable = VFS.mount(grid, new GridFileSystem(gfs));
+      handles.put(gfs, closeable);
+   }
+
+   /**
+    * Unmount GFS form VFS.
+    *
+    * @param gfs the GFS bean
+    * @throws Exception for any error
+    */
+   public void unmount(GridFilesystem gfs) throws Exception
+   {
+      Closeable closeable = handles.get(gfs);
+      if (closeable != null)
+         closeable.close();
+   }
+}

Added: projects/demos/microcontainer/trunk/infinispan/src/main/resources/META-INF/infinispan-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/resources/META-INF/infinispan-beans.xml	                        (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/resources/META-INF/infinispan-beans.xml	2010-04-24 19:34:37 UTC (rev 104215)
@@ -0,0 +1,16 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+    <bean name="CMParsingDeployer" class="org.jboss.demos.infinispan.deployers.CacheManagerParsingDeployer"/>
+
+    <bean name="CMBeanDeployer" class="org.jboss.demos.infinispan.deployers.CacheManagerBeanDeployer"/>
+
+    <bean name="GFSParsingDeployer" class="org.jboss.demos.infinispan.deployers.GFSParsingDeployer"/>
+
+    <bean name="GFSBeanDeployer" class="org.jboss.demos.infinispan.deployers.GFSBeanDeployer"/>
+
+    <bean name="GFSMounter" class="org.jboss.demos.infinispan.gfs.MountGFStoVFS">
+        <incallback method="mount"/>
+        <uncallback method="unmount"/>
+    </bean>
+
+</deployment>




More information about the jboss-cvs-commits mailing list