[jboss-cvs] JBossAS SVN: r75122 - in trunk: testsuite/src/main/org/jboss/test/profileservice/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 26 10:37:45 EDT 2008


Author: alesj
Date: 2008-06-26 10:37:45 -0400 (Thu, 26 Jun 2008)
New Revision: 75122

Modified:
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
Log:
Use VFS deploy dir cache. Remove obsolte code.
Add commented fix for deployutc on windows.

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2008-06-26 14:30:00 UTC (rev 75121)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2008-06-26 14:37:45 UTC (rev 75122)
@@ -32,13 +32,13 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.HashMap;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.zip.ZipInputStream;
 
@@ -172,6 +172,7 @@
       }
       return uri;
    }
+
    public void setDeploymentURI(URI uri, DeploymentPhase phase)
    {
       switch( phase )
@@ -297,11 +298,13 @@
    public VirtualFile getDeploymentContent(String vfsPath, DeploymentPhase phase)
          throws IOException
    {
-      URI rootURI = this.getDeploymentURI(phase);
-      VirtualFile root = VFS.getRoot(rootURI);
-      VirtualFile content = root.getChild(vfsPath);
+      File rootDir = getPhaseDir(phase);
+      // todo - will this work if vfsPath is more than just name?
+      File contentDir = new File(rootDir, vfsPath);
+      // get cached version
+      VirtualFile content = getDeployDir(contentDir);
       if(content == null)
-         throw new FileNotFoundException(vfsPath+" not found under root: "+rootURI);
+         throw new FileNotFoundException(vfsPath+" not found under root: "+rootDir);
       return content;
    }
 
@@ -649,6 +652,18 @@
    protected VirtualFile getDeployDir(File applicationDir) throws IOException
    {
       URI uri = applicationDir.toURI();
+      return getDeployDir(uri);
+   }
+
+   /**
+    * Get virtual file for app uri.
+    *
+    * @param uri the app uri
+    * @return virtual file representing app uri
+    * @throws IOException for any error
+    */
+   protected VirtualFile getDeployDir(URI uri) throws IOException
+   {
       String uriString = uri.toString();
       VirtualFile dir;
       synchronized (deployDirs)
@@ -686,11 +701,22 @@
    {
       Map<String, Object> map = edits.getAttachments();
       File attachments = new File(adminEditsRoot, vfsPath+".edits");
-      FileOutputStream fos = new FileOutputStream(attachments);
-      ObjectOutputStream oos = new ObjectOutputStream(fos);
-      oos.writeObject(map);
-      oos.close();
-      fos.close();
+      ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(attachments));
+      try
+      {
+         oos.writeObject(map);
+         oos.close();
+      }
+      finally
+      {
+         try
+         {
+            oos.close();
+         }
+         catch (IOException ignore)
+         {
+         }
+      }
       lastModified = System.currentTimeMillis();
    }
 
@@ -718,31 +744,9 @@
    protected Collection<VFSDeployment> getBootstraps()
       throws Exception
    {
-      Collection<VFSDeployment> ctxs = bootstrapCtxs.values();
-      return ctxs;
+      return bootstrapCtxs.values();
    }
 
-   protected URI getPhaseURI(DeploymentPhase phase)
-   {
-      URI uri = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            uri = getBootstrapURI();
-            break;
-         case DEPLOYER:
-            uri = getDeployersURI();
-            break;
-         case APPLICATION:
-            uri = getApplicationURI();
-            break;
-         case APPLICATION_TRANSIENT:
-            // TODO
-            break;
-      }
-      return uri;
-   }
-
    protected File getPhaseDir(DeploymentPhase phase)
    {
       File dir = null;

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java	2008-06-26 14:30:00 UTC (rev 75121)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java	2008-06-26 14:37:45 UTC (rev 75122)
@@ -115,6 +115,8 @@
          }
          finally
          {
+            //Thread.sleep(15 * 1000); // 15 secs >> more than it takes for reaper to run :-)
+
             // Stop/remove the deployment
             progress = deployMgr.stop(DeploymentPhase.APPLICATION, names);
             progress.addProgressListener(this);




More information about the jboss-cvs-commits mailing list