[jboss-cvs] JBossAS SVN: r94273 - projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/cache.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 2 09:55:27 EDT 2009


Author: alesj
Date: 2009-10-02 09:55:27 -0400 (Fri, 02 Oct 2009)
New Revision: 94273

Modified:
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java
Log:
Fix preinitialization helper.

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java	2009-10-02 13:47:38 UTC (rev 94272)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java	2009-10-02 13:55:27 UTC (rev 94273)
@@ -23,12 +23,15 @@
 
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.jboss.logging.Logger;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.spi.ExceptionHandler;
+import org.jboss.virtual.spi.TempStore;
 
 /**
  * Initialize vfs contexts - performance improvements.
@@ -37,8 +40,10 @@
  */
 public class PreInitializeVFSContexts
 {
-   private Logger log = Logger.getLogger(PreInitializeVFSContexts.class);
+   protected Logger log = Logger.getLogger(getClass());
+
    private Map<URL, ExceptionHandler> initializedVFSContexts;
+   private Map<URL, TempStore> tempStores;
    private boolean holdReference;
    private List<VFS> references;
 
@@ -49,26 +54,47 @@
     */
    public void start() throws Exception
    {
+      Map<URL, VFS> refs = new HashMap<URL, VFS>();
+
+      // apply exception handlers
       if (initializedVFSContexts != null && initializedVFSContexts.isEmpty() == false)
       {
-         if (holdReference)
-            references = new ArrayList<VFS>();
-
          for (Map.Entry<URL, ExceptionHandler> entry : initializedVFSContexts.entrySet())
          {
-            VFS vfs = VFS.getVFS(entry.getKey());
+            URL url = entry.getKey();
+            VFS vfs = VFS.getVFS(url);
 
             ExceptionHandler eh = entry.getValue();
             if (eh != null)
                vfs.setExceptionHandler(eh);
 
             log.debug("Initialized Virtual File: " + vfs.getRoot());
-            if (holdReference)
+            refs.put(url, vfs);
+         }
+      }
+
+      // apply stores
+      if (tempStores != null && tempStores.isEmpty() == false)
+      {
+         for (Map.Entry<URL, TempStore> entry : tempStores.entrySet())
+         {
+            URL url = entry.getKey();
+            VFS vfs = refs.get(url);
+            if (vfs == null)
             {
-               references.add(vfs);
+               vfs = VFS.getVFS(url);
+               log.debug("Initialized Virtual File: " + vfs.getRoot());
+               refs.put(url, vfs);
             }
+
+            TempStore ts = entry.getValue();
+            if (ts != null)
+               vfs.setTempStore(ts);
          }
       }
+
+      if (holdReference)
+         references = new ArrayList<VFS>(refs.values());
    }
 
    /**
@@ -87,7 +113,10 @@
     */
    public List<VFS> getReferences()
    {
-      return references;
+      if (references == null || references.isEmpty())
+         return Collections.emptyList();
+      else
+         return Collections.unmodifiableList(references);
    }
 
    /**
@@ -101,6 +130,16 @@
    }
 
    /**
+    * Set temp stores.
+    *
+    * @param tempStores the temp stores
+    */
+   public void setTempStores(Map<URL, TempStore> tempStores)
+   {
+      this.tempStores = tempStores;
+   }
+
+   /**
     * Should we hold the reference to initialized VFSs.
     *
     * @param holdReference the hold reference flag




More information about the jboss-cvs-commits mailing list