[jboss-cvs] JBossAS SVN: r101147 - trunk/system/src/main/java/org/jboss/system/tools.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 19 05:24:51 EST 2010


Author: emuckenhuber
Date: 2010-02-19 05:24:51 -0500 (Fri, 19 Feb 2010)
New Revision: 101147

Modified:
   trunk/system/src/main/java/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java
Log:
JBAS-7751

Modified: trunk/system/src/main/java/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java	2010-02-19 08:54:14 UTC (rev 101146)
+++ trunk/system/src/main/java/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java	2010-02-19 10:24:51 UTC (rev 101147)
@@ -21,19 +21,20 @@
  */
 package org.jboss.system.tools;
 
-import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
 import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.NoSuchProfileException;
@@ -44,8 +45,8 @@
 import org.jboss.system.server.profileservice.hotdeploy.Scanner;
 import org.jboss.system.server.profileservice.repository.HotDeploymentRepository;
 import org.jboss.system.server.profileservice.repository.TypedProfileRepository;
-import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.vfs.helpers.PathTokenizer;
 
 /**
  * Profile deployment repository adapter.
@@ -177,6 +178,21 @@
       Collection<URI> uris = profile.getURIs();
       if (uris.contains(uri) == false)
       {
+         try
+         {
+            // Check whether it's a uri relative to a managed repository URI
+            // in case it is managed we just skip it
+            if(checkRelative(uri))
+            {
+               log.debug("ignoring already managed uri: " + uri);
+               return;
+            }
+         }
+         catch(Exception e)
+         {
+            log.debug(e);
+            return;
+         }
          uris.add(uri);
       }
    }
@@ -235,9 +251,66 @@
             }
          }
       }
-
       return urls.toArray(new String[urls.size()]);
    }
+   
+   /**
+    * Check all deployment repositories, if the they manage the relative
+    * deployment path - so we don't need to add to this profile.
+    * 
+    * @param deploymentURI the deployment URI
+    * @return true if the relative path can be determined
+    * @throws Exception
+    */
+   boolean checkRelative(URI deploymentURI) throws Exception
+   {
+      for(ProfileKey key : this.repositories.getProfileKeys())
+      {
+         DeploymentRepository repository = this.repositories.getProfileDeploymentRepository(key);
+         URI[] uris = repository.getRepositoryURIs();
+         if(uris != null && uris.length > 0)
+         {
+            for(URI uri : uris)
+            {
+               if(isRelative(uri.getPath(), deploymentURI.getPath()))
+               {
+                  return true;
+               }
+            }
+         }
+      }
+      return false;
+   }
+   
+   /**
+    * Check whether a path is relative to another. 
+    * 
+    * @param root the root path
+    * @param relative the relative path
+    * @return true or false
+    */
+   boolean isRelative(String root, String relative)
+   {
+      List<String> roots = PathTokenizer.getTokens(root);
+      List<String> relatives = PathTokenizer.getTokens(relative);
+      Iterator<String> rootsIterator = roots.iterator();
+      Iterator<String> relativesIterator = relatives.iterator();
+      while(rootsIterator.hasNext())
+      {
+         if(relativesIterator.hasNext() == false)
+         {
+            // Would recursively redeploy
+            return true;
+         }
+         String r = rootsIterator.next();
+         String o = relativesIterator.next();
+         if(r.equals(o) == false)
+         {
+            return false;
+         }
+      }
+      return true;
+   }
 
    public static class DeploymentScannerProfile extends HotDeploymentRepository implements MutableProfile
    {




More information about the jboss-cvs-commits mailing list