[jboss-cvs] JBossAS SVN: r109943 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/profile and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Dec 15 15:41:24 EST 2010


Author: emuckenhuber
Date: 2010-12-15 15:41:23 -0500 (Wed, 15 Dec 2010)
New Revision: 109943

Modified:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ProfileDeploymentModificationChecker.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/AbstractScanningProfile.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/HDScanningProfile.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/MutableFileArtifactRepository.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentRemoveAction.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/DeployHandlerUnitTestCase.java
Log:
remove deployment from modification checker on undeployment

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ProfileDeploymentModificationChecker.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ProfileDeploymentModificationChecker.java	2010-12-15 20:38:45 UTC (rev 109942)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ProfileDeploymentModificationChecker.java	2010-12-15 20:41:23 UTC (rev 109943)
@@ -44,5 +44,13 @@
     */
    boolean isDeploymentModified(ProfileDeployment deployment, VirtualFile deploymentRoot);
    
+   /**
+    * Signal when a deployment is removed.
+    * 
+    * @param deployment the deployment
+    * @param deploymentRoot the deployment root
+    */
+   void removed(ProfileDeployment deployment, VirtualFile deploymentRoot);
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/AbstractScanningProfile.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/AbstractScanningProfile.java	2010-12-15 20:38:45 UTC (rev 109942)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/AbstractScanningProfile.java	2010-12-15 20:41:23 UTC (rev 109943)
@@ -211,7 +211,7 @@
       if(artifacts != null && artifacts.isEmpty() == false)
       {
          Collection<ProfileDeployment> deployments = new ArrayList<ProfileDeployment>();
-         for(final Artifact<FileArtifactId> artifact : getArtifacts())
+         for(final Artifact<FileArtifactId> artifact : artifacts)
          {
             //
             final FileArtifactId artifactId = artifact.getIdentifier();

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/HDScanningProfile.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/HDScanningProfile.java	2010-12-15 20:38:45 UTC (rev 109942)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/HDScanningProfile.java	2010-12-15 20:41:23 UTC (rev 109943)
@@ -30,6 +30,7 @@
 import org.jboss.profileservice.deployment.hotdeploy.ProfileDeploymentModificationChecker;
 import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
 import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.VirtualDeploymentRepository;
@@ -141,5 +142,19 @@
       return modifications.values();
    }
 
+   protected ProfileDeployment internalRemoveDeployment(String name) throws NoSuchDeploymentException {
+      final ProfileDeployment deployment = getDeployment(name);
+      final FileArtifactId artifactId = getArtifactMetaData(deployment);
+      if(modificationChecker != null) {
+         try {
+            final VirtualFile deploymentRoot = getArtifactRepository().getArtifactFile(artifactId);
+            modificationChecker.removed(deployment, deploymentRoot);
+         } catch(Exception ignore) {
+            //
+         }
+      }
+      return super.internalRemoveDeployment(name);
+   }
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/MutableFileArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/MutableFileArtifactRepository.java	2010-12-15 20:38:45 UTC (rev 109942)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/MutableFileArtifactRepository.java	2010-12-15 20:41:23 UTC (rev 109943)
@@ -30,10 +30,10 @@
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.repository.artifact.Artifact;
 import org.jboss.profileservice.spi.repository.artifact.ArtifactFilter;
+import org.jboss.profileservice.spi.repository.artifact.ArtifactRepositoryConfiguration.VFSBackupPolicy;
 import org.jboss.profileservice.spi.repository.artifact.ArtifactRepositoryId;
 import org.jboss.profileservice.spi.repository.artifact.ArtifactTransformer;
 import org.jboss.profileservice.spi.repository.artifact.MutableArtifactRepository;
-import org.jboss.profileservice.spi.repository.artifact.ArtifactRepositoryConfiguration.VFSBackupPolicy;
 import org.jboss.vfs.VFSUtils;
 import org.jboss.vfs.VirtualFile;
 

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java	2010-12-15 20:38:45 UTC (rev 109942)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java	2010-12-15 20:41:23 UTC (rev 109943)
@@ -93,6 +93,7 @@
             response.setFailure(new SyncFailedException("Deployment content already exists: "+ artifactName));
             return false;
          }
+         
          // Check if we need unpack this deployment
          ArtifactTransformer<FileArtifactId> transformer = null;
          if(isExplode())
@@ -105,7 +106,7 @@
          }
          // Add the content
          artifactRepository.addArtifact(artifactId, contentIS, transformer);
-
+         
          // Create a new deployment
          ProfileDeployment deployment = deploymentRepository.createDeployment(new BasicProfileDeploymentMetaData(artifactName));
          // Mark it as locked, so we can add contents after

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentRemoveAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentRemoveAction.java	2010-12-15 20:38:45 UTC (rev 109942)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentRemoveAction.java	2010-12-15 20:41:23 UTC (rev 109943)
@@ -80,7 +80,9 @@
          }
          final MutableProfile profile = MutableProfile.class.cast(managed.getProfile());
          final ProfileDeployment deployment = profile.getDeployment(deploymentName);
-         
+         // Remove the deployment from the profile
+         profile.removeDeployment(deployment.getName());
+         //
          final ArtifactId artifactId = resolveArtifactMetaData(deployment);
          // In case there is no artifact we just remove it from the profile
          if(artifactId != null)
@@ -91,8 +93,6 @@
                repository.removeArtifact(artifactId);
             }
          }
-         // Remove the deployment from the profile
-         profile.removeDeployment(deployment.getName());
          
          // Notify
          response.fireModificationEvent(ProfileModificationEvent.create(ProfileModificationType.DELETE, managed.getProfileKey()));

Modified: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/DeployHandlerUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/DeployHandlerUnitTestCase.java	2010-12-15 20:38:45 UTC (rev 109942)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/DeployHandlerUnitTestCase.java	2010-12-15 20:41:23 UTC (rev 109943)
@@ -26,8 +26,11 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.jboss.profileservice.config.ArtifactRepositoriesConfig;
+import org.jboss.profileservice.deployment.hotdeploy.ProfileDeploymentModificationChecker;
 import org.jboss.profileservice.management.actions.BasicProfileModificationRequest;
 import org.jboss.profileservice.plugins.deploy.actions.DeploymentDistributeAction;
 import org.jboss.profileservice.plugins.deploy.actions.DeploymentRemoveAction;
@@ -46,12 +49,13 @@
 import org.jboss.profileservice.spi.action.ProfileModificationAction;
 import org.jboss.profileservice.spi.action.ProfileModificationType;
 import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
+import org.jboss.profileservice.spi.repository.artifact.ArtifactRepositoryConfiguration.VFSBackupPolicy;
 import org.jboss.profileservice.spi.repository.artifact.ArtifactRepositoryId;
 import org.jboss.profileservice.spi.repository.artifact.MutableArtifactRepository;
-import org.jboss.profileservice.spi.repository.artifact.ArtifactRepositoryConfiguration.VFSBackupPolicy;
 import org.jboss.test.profileservice.plugins.deploy.support.DeploymentIDSupport;
 import org.jboss.test.profileservice.plugins.deploy.support.ManagedProfileSupport;
 import org.jboss.test.profileservice.plugins.deploy.support.TestVirtualDeploymentRepository;
+import org.jboss.vfs.VirtualFile;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -75,12 +79,14 @@
       assertNotNull(url);
       
       // Create and register profile
-      MutableScanningProfile profile = new HDScanningProfile(profileKey, createDeploymentRepository(root.toURI()));
+      final Checker checker = new Checker();
+      HDScanningProfile profile = new HDScanningProfile(profileKey, createDeploymentRepository(root.toURI()));
+      profile.setModificationChecker(checker);
       profile.create();
       profile.start();
       ManagedProfileSupport support = new ManagedProfileSupport(profile, getDeployer());
       getActionController().addProfile(support);
-      
+
       // Add deployment
       DeploymentIDSupport dtId = new DeploymentIDSupport(url, deploymentName);
       ProfileModificationAction action = new DeploymentDistributeAction(profile, dtId, url.openStream(), null);
@@ -125,6 +131,7 @@
          fail();
       }
       catch(NoSuchDeploymentException ok) { }
+      assertFalse(checker.names.contains(deploymentName));
    }
 
    public void testHDScanning() throws Throwable
@@ -193,6 +200,19 @@
          throw status.getFailure();
       }      
    }
-   
+
+   private static class Checker implements ProfileDeploymentModificationChecker {
+      final Set<String> names = new HashSet<String>();
+      
+      public boolean isDeploymentModified(ProfileDeployment deployment, VirtualFile deploymentRoot) {
+         names.add(deployment.getName());
+         return false;
+      }
+      
+      public void removed(ProfileDeployment deployment, VirtualFile deploymentRoot) {
+         names.remove(deployment.getName());
+      }
+      
+   }
 }
 



More information about the jboss-cvs-commits mailing list