[jboss-cvs] JBossAS SVN: r98983 - in branches/JBPAPP_5_0: system/src/main/org/jboss/system/server/profileservice/repository and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 4 08:35:41 EST 2010


Author: emuckenhuber
Date: 2010-01-04 08:35:41 -0500 (Mon, 04 Jan 2010)
New Revision: 98983

Modified:
   branches/JBPAPP_5_0/profileservice/src/resources/hdscanner-jboss-beans.xml
   branches/JBPAPP_5_0/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
   branches/JBPAPP_5_0/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java
Log:
port rev #93976

Modified: branches/JBPAPP_5_0/profileservice/src/resources/hdscanner-jboss-beans.xml
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/resources/hdscanner-jboss-beans.xml	2010-01-04 13:06:50 UTC (rev 98982)
+++ branches/JBPAPP_5_0/profileservice/src/resources/hdscanner-jboss-beans.xml	2010-01-04 13:35:41 UTC (rev 98983)
@@ -28,6 +28,7 @@
         <parameter><inject bean="ProfileService"/></parameter>
         <parameter><inject bean="StructureModificationChecker"/></parameter>
       </constructor>
+      <property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
     </bean>
 
 </deployment>

Modified: branches/JBPAPP_5_0/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
===================================================================
--- branches/JBPAPP_5_0/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2010-01-04 13:06:50 UTC (rev 98982)
+++ branches/JBPAPP_5_0/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2010-01-04 13:35:41 UTC (rev 98983)
@@ -141,4 +141,45 @@
          this.repositoryFactories.remove(type);
    }
    
+   /**
+    * InCallback to register a repository bean.
+    * 
+    * @param repository the deploymentRepository to register
+    */
+   public void registerDeploymentRepository(AbstractDeploymentRepository repository)
+   {
+      if(repository == null)
+         throw new IllegalArgumentException("null deployment repository");
+      ProfileKey repositoryKey = repository.getProfileKey(); 
+      if(repositoryKey == null)
+         throw new IllegalArgumentException("null profile key");
+      if(this.repositories.containsKey(repositoryKey))
+         throw new IllegalStateException("duplicate repository " + repositoryKey);
+      
+      this.repositories.put(repositoryKey, repository);
+   }
+   
+   /**
+    * UnInCallback to unregister a repository bean.
+    * 
+    * @param repository the deploymentRepository to unregister
+    */
+   public void unregisterDeploymentRepository(AbstractDeploymentRepository repository)
+   {
+      if(repository == null)
+         throw new IllegalArgumentException("null deployment repository");
+      ProfileKey repositoryKey = repository.getProfileKey(); 
+      if(repositoryKey == null)
+         throw new IllegalArgumentException("null profile key");
+      
+      this.unregisterDeploymentRepository(repositoryKey);
+   }
+   
+   public void unregisterDeploymentRepository(ProfileKey repositoryKey)
+   {
+      if(repositoryKey == null)
+         throw new IllegalArgumentException("null profile key");
+      this.repositories.remove(repositoryKey);
+   }
+   
 }

Modified: branches/JBPAPP_5_0/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java
===================================================================
--- branches/JBPAPP_5_0/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java	2010-01-04 13:06:50 UTC (rev 98982)
+++ branches/JBPAPP_5_0/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java	2010-01-04 13:35:41 UTC (rev 98983)
@@ -21,6 +21,7 @@
  */
 package org.jboss.system.tools;
 
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -42,6 +43,8 @@
 import org.jboss.profileservice.spi.ProfileService;
 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;
 
 /**
@@ -57,6 +60,7 @@
 
    private Scanner scanner;
    private ProfileService ps;
+   private TypedProfileRepository repositories;
    private StructureModificationChecker checker;
 
    private DeploymentScannerProfile profile;
@@ -74,6 +78,16 @@
       this.ps = ps;
       this.checker = checker;
    }
+   
+   public TypedProfileRepository getProfileRepository()
+   {
+      return repositories;
+   }
+   
+   public void setProfileRepository(TypedProfileRepository repositories)
+   {
+      this.repositories = repositories;
+   }
 
    /**
     * Create profile.
@@ -112,6 +126,9 @@
       log.debug("Activating deployment scanner profile " + profileName);
       this.ps.activateProfile(profileName);
       this.ps.validateProfile(profileName);
+      // Expose the profile to the DeploymentManager
+      if(this.repositories != null)
+         this.repositories.registerDeploymentRepository(profile);
    }
 
    public void resume()
@@ -129,6 +146,9 @@
     */
    public void stopProfile()
    {
+      // Unregister the profile
+      if(this.repositories != null)
+         this.repositories.unregisterDeploymentRepository(profile);
       try
       {
          // Deactivate
@@ -259,7 +279,7 @@
 
          return super.getModifiedDeployments();
       }
-
+      
       @Override
       protected void checkForAdditions(List<ModificationInfo> modified) throws Exception
       {
@@ -314,6 +334,49 @@
          newCache.put(applicationDir, files);
       }
 
+      @Override
+      protected List<String> findDeploymentContent(String name)
+      {
+         // FIXME this should not be done here
+         // Try to find the VirtualFile, as we only add real file urls
+         VirtualFile cached = getCachedVirtualFile(name);
+         if(cached != null)
+         {
+            try {
+               name = cached.toURI().toString();
+            } catch(Exception ignore) { }
+            return Collections.singletonList(name);
+         }
+         
+         List<String> contents = new ArrayList<String>();
+         for(URI uri : this.uris)
+         {
+            String cacheName = uri.toString(); 
+            String fixedName = cacheName;
+            if(cacheName.endsWith("/"))
+               fixedName = cacheName.substring(0, cacheName.length() -1);
+            
+            if(fixedName.endsWith(name))
+            {
+               VirtualFile vf = getCachedVirtualFile(cacheName);
+               if(vf != null)
+               {
+                  try {
+                     contents.add(vf.toURI().toString()); 
+                  } catch(Exception ignore) { }                  
+               }
+            }
+         }
+         return contents;
+      }
+      
+      @Override
+      public ProfileDeployment removeDeployment(String vfsPath) throws Exception
+      {
+         // We don't remove the actual deployment content
+         return super.removeDeployment(vfsPath, false);
+      }
+      
       public ProfileKey getKey()
       {
          return profileName;




More information about the jboss-cvs-commits mailing list