[jboss-cvs] JBossAS SVN: r86175 - in branches/Branch_5_x: profileservice/src/main/org/jboss/profileservice/management/upload/remoting and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Mar 21 16:40:25 EDT 2009


Author: emuckenhuber
Date: 2009-03-21 16:40:25 -0400 (Sat, 21 Mar 2009)
New Revision: 86175

Added:
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java
Removed:
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
Modified:
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
   branches/Branch_5_x/profileservice/src/resources/profileservice-jboss-beans.xml
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
Log:
[JBAS-6649] enable distribution for all deployment repositories

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -21,16 +21,18 @@
  */ 
 package org.jboss.profileservice.management.upload;
 
-import java.util.ArrayList;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Collections;
 
 import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.AbstractImmutableProfile;
 
 /**
  * The AbstractTransientProfileManager maintains a profile for transient deployments.
@@ -50,9 +52,6 @@
    /** The transient profile key. */
    public static final ProfileKey TRANSIENT_PROFILE_KEY = new ProfileKey(TRANSIENT_PROFILE_NAME);
    
-   /** The profile factory. */
-   private ProfileFactory profileFactory;
-   
    /** The profile service. */
    protected ProfileService ps;
    
@@ -68,16 +67,6 @@
    {
       this.ps = ps;
    }
-   
-   public ProfileFactory getProfileFactory()
-   {
-      return profileFactory;
-   }
-   
-   public void setProfileFactory(ProfileFactory profileFactory)
-   {
-      this.profileFactory = profileFactory;
-   }
 
    /**
     * Start registers and activates the transient deployments profile
@@ -88,8 +77,6 @@
    {
       if(this.ps == null)
          throw new IllegalStateException("Null profile service.");
-      if(this.profileFactory == null)
-         throw new IllegalStateException("Null profile factory.");
       
       // Create the transient deployment profile
       Profile profile = createTransientProfile();
@@ -137,26 +124,35 @@
     */
    protected Profile createTransientProfile() throws Exception
    {
-      ProfileMetaData metaData = createTransientProfileMetaData();
-      return profileFactory.createProfile(TRANSIENT_PROFILE_KEY, metaData);
+      return new TransientDeploymentProfile(TRANSIENT_PROFILE_KEY);
    }
    
    /**
-    * Create the transient profile meta data.
-    * 
-    * @return the transient profile meta data
+    * The transient deployments profile. 
     */
-   protected ProfileMetaData createTransientProfileMetaData()
+   public static class TransientDeploymentProfile extends AbstractImmutableProfile implements MutableProfile
    {
-      // Source
-      ImmutableProfileSourceMetaData source = new ImmutableProfileSourceMetaData();
-      source.setSources(new ArrayList<String>());
-      // Profile
-      BasicProfileMetaData profile = new BasicProfileMetaData();
-      profile.setSource(source);
-      profile.setName(TRANSIENT_PROFILE_NAME);
-      //
-      return profile;
+      public TransientDeploymentProfile(ProfileKey key)
+      {
+         super(key, new URI[0]);
+      }
+
+      public void addDeployment(ProfileDeployment deployment) throws Exception
+      {
+         if(deployment == null)
+            throw new IllegalArgumentException("Null deployment.");
+         super.addDeployment(deployment.getName(), deployment);
+      }
+
+      public void enableModifiedDeploymentChecks(boolean flag)
+      {
+         //
+      }
+
+      public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+      {
+         return Collections.emptySet();
+      }
    }
    
 }

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -25,7 +25,6 @@
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -36,12 +35,11 @@
 import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget;
-import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileRepository;
 import org.jboss.remoting.InvokerLocator;
-import org.jboss.system.server.profileservice.repository.MutableDeploymentRepository;
 
 /**
  * The remoting base DeploymentManager implementation.
@@ -127,27 +125,7 @@
     */
    public Collection<ProfileKey> getProfiles()
    {
-      Collection<ProfileKey> mutableProfiles = new HashSet<ProfileKey>(); 
-      for(ProfileKey key : this.profileRepository.getProfileKeys())
-      {
-         // Exclude the transient profile
-         if(key.equals(AbstractTransientProfileManager.TRANSIENT_PROFILE_KEY))
-            continue;
-
-         try
-         {
-            // TODO this should not be needed once there are different implementations used for profiles.
-            DeploymentRepository repo = this.profileRepository.getProfileDeploymentRepository(key);
-            // TODO we can only use MutableDeploymentRepositories as target for now.
-            if(repo instanceof MutableDeploymentRepository)
-               mutableProfiles.add(key);
-         }
-         catch(NoSuchProfileException ignore)
-         {
-            //
-         }
-      }
-      return mutableProfiles; 
+      return new ArrayList<ProfileKey>(this.profileRepository.getProfileKeys()); 
    }
    
    public DeploymentProgress distribute(String name, URL contentURL)
@@ -187,15 +165,8 @@
    
    public boolean isRedeploySupported()
    {
-      // TODO
-      return false;
+      return (getTargetProfile() instanceof MutableProfile);
    }
-
-   public boolean isRedeploySupported(ProfileKey key) throws NoSuchProfileException
-   {
-      // FIXME
-      return false;
-   }
    
    public void loadProfile(ProfileKey key) throws NoSuchProfileException
    {

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -33,6 +33,7 @@
 import org.jboss.aop.joinpoint.InvocationResponse;
 import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
 import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.management.upload.SerializableDeploymentID;
 import org.jboss.profileservice.spi.DeploymentRepository;
@@ -209,10 +210,10 @@
    /**
     * Handle a DeploymentManager distribute invocation for copyContent == true
     * 
-    * @see DeploymentManager#distribute(String, java.net.URL, true)
+    * @see DeploymentManager#distribute(String, java.net.URL, boolean)
     * @param request - the remoting invocation
     */
-   public Object handleStream(InputStream contentIS, InvocationRequest request) throws Throwable
+   public InvocationResponse handleStream(InputStream contentIS, InvocationRequest request) throws Throwable
    {
       // Get the deployment repository for this deploymentID
       SerializableDeploymentID deploymentTarget = (SerializableDeploymentID) request.getParameter();
@@ -246,7 +247,7 @@
       for(String name : names)
       {
          // Schedule start for the deployment
-         deployments.add(scheduleStart(name, deploymentRepository));
+         deployments.add(start(name, deploymentRepository));
       }
       // Process
       deployer.process();
@@ -257,27 +258,15 @@
       log.info("End start, "+ deployments);
    }
 
-   protected String scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
+   protected String start(String name, DeploymentRepository repository) throws Exception
    {
-      VirtualFile vf = deploymentRepository.getDeploymentContent(name);
-      return scheduleStart(vf, deploymentRepository);
+      ProfileDeployment deployment = scheduleStart(name, repository);
+      deployer.addDeployment(deployment);
+      log.debug("Scheduling start for deployment: " + deployment);
+      return deployment.getName();
    }
    
-   protected String scheduleStart(VirtualFile vf, DeploymentRepository repository) throws Exception
-   {
-      // Create profile deployment
-      ProfileDeployment profileDeployment = createDeployment(vf);
-      String deploymentName = profileDeployment.getName();
-      // Add deployment to profile
-      repository.addDeployment(deploymentName, profileDeployment);
-      // Add deployment 
-      deployer.addDeployment(profileDeployment);
-      // Unlock the contents
-      repository.unlockDeploymentContent(deploymentName);
-      
-      log.debug("Scheduling start for: "+ profileDeployment);
-      return deploymentName;
-   }
+   protected abstract ProfileDeployment scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception;
    
    /**
     * Stop the deployments.
@@ -295,7 +284,7 @@
       for(String name : names)
       {
          // Schedule stop
-         deployments.add(scheduleStop(name, deploymentRepository));
+         deployments.add(stop(name, deploymentRepository));
       }
       // CheckComplete
       deployer.process();
@@ -303,19 +292,17 @@
       log.info("End stop, "+ deployments);
    }
    
-   protected String scheduleStop(String name, DeploymentRepository repository) throws Exception
+   protected String stop(String name, DeploymentRepository repository) throws Exception
    {
-      // Obtain the deployment
-      ProfileDeployment vfsd = repository.getDeployment(name);
-      // Lock the content to make it unavailable to the deployment scanner
-      repository.lockDeploymentContent(vfsd.getName());
-      // Remove deployment
-      deployer.removeDeployment(vfsd);
+      ProfileDeployment deployment = scheduleStop(name, repository);
+      deployer.removeDeployment(deployment);
+      log.debug("Scheduling stop for deployment: " + deployment);
       
-      log.debug("Scheduling stop for: "+ vfsd);
-      return vfsd.getName();
+      return deployment.getName();
    }
    
+   protected abstract ProfileDeployment scheduleStop(String name, DeploymentRepository repository) throws Exception;
+   
    /**
     * Remove a deployment from the deployment repository.
     * This will delete the file for non-transient deployments.
@@ -336,12 +323,7 @@
       }
    }
    
-   protected void removeDeployment(String name, DeploymentRepository repository) throws Exception
-   {
-      // Remove the deployment
-      ProfileDeployment deployment = repository.removeDeployment(name);
-      log.debug("Removed: "+deployment);
-   }
+   protected abstract void removeDeployment(String name, DeploymentRepository repository) throws Exception;
 
    /**
     * Redeploy a deployment.

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -33,6 +33,9 @@
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.management.upload.AbstractTransientProfileManager;
 import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 
@@ -49,21 +52,29 @@
    /** The logger. */
    static final Logger log = Logger.getLogger(DeployHandler.class);
 
-   /** The transient deployment repository. */
-   private DeploymentRepository transientDeploymentRepository;
+   /** The transient profile. */
+   private MutableProfile transientProfile;
    
+   /** The profile service. */
+   private ProfileService ps;
+   
    /** The transient deployments map. */
-   Map<String, VirtualFile> transientDeployments = new ConcurrentHashMap<String, VirtualFile>();
+   private Map<String, VirtualFile> transientDeployments = new ConcurrentHashMap<String, VirtualFile>();
    
-   public DeploymentRepository getTransientDeploymentRepository()
+   public ProfileService getProfileService()
    {
-      return transientDeploymentRepository;
+      return ps;
    }
    
+   public void setProfileService(ProfileService ps)
+   {
+      this.ps = ps;
+   }
+   
    public void start() throws Exception
    {
-      // Set the transient profile repository
-      this.transientDeploymentRepository = profileRepository.getProfileDeploymentRepository(AbstractTransientProfileManager.TRANSIENT_PROFILE_KEY);
+      // Set the transient profile
+      this.transientProfile = (MutableProfile) ps.getActiveProfile(AbstractTransientProfileManager.TRANSIENT_PROFILE_KEY);
    }
 
    @Override
@@ -78,31 +89,6 @@
       
       return repositoryNames.toArray( new String[repositoryNames.size()] );
    }
-   
-   protected List<String> getTransientRepositoryNames(String[] names)
-   {
-      List<String> repositoryNames = new ArrayList<String>();
-      for(String name : names)
-      {
-         if(this.transientDeployments.containsKey(name))
-         {
-            repositoryNames.add(name);
-            continue;
-         }
-         for(VirtualFile vf : this.transientDeployments.values())
-         {
-            if(vf.getName().equals(name))
-            {
-               try
-               {
-                  repositoryNames.add(vf.toURI().toString());
-               }
-               catch(Exception ignored) { }
-            }
-         }
-      }
-      return repositoryNames;
-   }
 
    /**
     * Distribute a transient (copyContent == false) deployment. 
@@ -128,31 +114,45 @@
    }
 
    @Override
-   protected String scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
+   protected ProfileDeployment scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
    {
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
       {
+         // Create deployment
          VirtualFile vf = this.transientDeployments.get(deploymentName);
-         return super.scheduleStart(vf, this.transientDeploymentRepository);
+         ProfileDeployment deployment = createDeployment(vf);
+         // Add to transient profile
+         this.transientProfile.addDeployment(deployment);
+         return deployment;
       }
       else
       {
-         return super.scheduleStart(name, deploymentRepository);
+         // Create deployment
+         VirtualFile vf = deploymentRepository.getDeploymentContent(name);
+         ProfileDeployment deployment = createDeployment(vf);
+         // Add deployment repository
+         deploymentRepository.addDeployment(deployment.getName(), deployment);
+         deploymentRepository.unlockDeploymentContent(deployment.getName());
+         return deployment;
       }
    }
    
    @Override
-   protected String scheduleStop(String name, DeploymentRepository deploymentRepository) throws Exception
+   protected ProfileDeployment scheduleStop(String name, DeploymentRepository deploymentRepository) throws Exception
    {
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
       {
-         return super.scheduleStop(name, this.transientDeploymentRepository);
+         // Remove from profile
+         return this.transientProfile.removeDeployment(deploymentName); 
       }
       else
       {
-         return super.scheduleStop(name, deploymentRepository);
+         // Lock content
+         ProfileDeployment deployment = deploymentRepository.getDeployment(name);
+         deploymentRepository.lockDeploymentContent(deployment.getName());
+         return deployment;
       }
    }
    
@@ -162,15 +162,41 @@
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
       {
+         // Remove from local cache
          this.transientDeployments.remove(deploymentName);
-         super.removeDeployment(deploymentName, this.transientDeploymentRepository);
       }
       else
       {
-         super.removeDeployment(name, deploymentRepository);
+         // Remove deployment from repository
+         deploymentRepository.removeDeployment(name);
       }
    }
    
+   protected List<String> getTransientRepositoryNames(String[] names)
+   {
+      List<String> repositoryNames = new ArrayList<String>();
+      for(String name : names)
+      {
+         if(this.transientDeployments.containsKey(name))
+         {
+            repositoryNames.add(name);
+            continue;
+         }
+         for(VirtualFile vf : this.transientDeployments.values())
+         {
+            if(vf.getName().equals(name))
+            {
+               try
+               {
+                  repositoryNames.add(vf.toURI().toString());
+               }
+               catch(Exception ignored) { }
+            }
+         }
+      }
+      return repositoryNames;
+   }
+   
    /**
     * Try to resolve the deployment name.
     * 

Modified: branches/Branch_5_x/profileservice/src/resources/profileservice-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/profileservice/src/resources/profileservice-jboss-beans.xml	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/profileservice/src/resources/profileservice-jboss-beans.xml	2009-03-21 20:40:25 UTC (rev 86175)
@@ -61,6 +61,7 @@
             <parameter>DeploymentManager</parameter>
         </uninstall>
         <property name="deployer"><inject bean="ProfileServiceDeployer"/></property>
+        <property name="profileService"><inject bean="ProfileService"/></property>
         <property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
         <depends>TransientDeploymentsProfileManager</depends>
     </bean>
@@ -68,7 +69,6 @@
     <bean name="TransientDeploymentsProfileManager"
         class="org.jboss.profileservice.management.upload.AbstractTransientProfileManager">
         <property name="profileService"><inject bean="ProfileService"/></property>
-        <property name="profileFactory"><inject bean="ProfileFactory" /></property>
     </bean>
 
     <bean name="RuntimeComponentDispatcher" class="org.jboss.profileservice.management.KernelBusRuntimeComponentDispatcher">

Copied: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java (from rev 86168, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java)
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -0,0 +1,246 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.SyncFailedException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.zip.ZipInputStream;
+
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A basic deployment repository.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicDeploymentRepository extends AbstractDeploymentRepository
+{
+
+   /** Should an attempt to overwrite existing content fail in {@link #addDeploymentContent(String, ZipInputStream)}*/
+   private boolean failIfAlreadyExists = false;
+   
+   /** A lock for the hot deployment/{@link #getModifiedDeployments()} */
+   private ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
+   
+   public BasicDeploymentRepository(ProfileKey key, URI[] uris)
+   {
+      super(key, uris);
+   }
+   
+   public boolean isFailIfAlreadyExists()
+   {
+      return failIfAlreadyExists;
+   }
+   
+   public void setFailIfAlreadyExists(boolean failIfAlreadyExists)
+   {
+      this.failIfAlreadyExists = failIfAlreadyExists;
+   }
+
+   public void load() throws Exception
+   {
+      for(URI uri : getRepositoryURIs())
+      {
+         VirtualFile root = getCachedVirtualFile(uri);
+         loadApplications(root);
+      }
+      updateLastModfied();
+   }
+   
+   public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+   {
+      return Collections.emptySet();
+   }
+
+   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
+   {
+      boolean trace = log.isTraceEnabled();
+      // Suspend hot deployment checking
+      if( trace )
+         log.trace("Aquiring content write lock");
+      lockWrite();
+      String repositoryName = null;
+      try
+      {
+         if(getRepositoryURIs().length == 0)
+            throw new IllegalStateException("No uris associated with this repository.");
+         
+         // FIXME, this is writing the content to the first URI
+         // Write the content out
+         File contentRoot = new File(getRepositoryURIs()[0]); 
+         if(contentRoot == null)
+            throw new FileNotFoundException("Failed to obtain content dir for phase: "+vfsPath);
+         File contentFile = new File(contentRoot, vfsPath);
+         
+         // Check if it already exists
+         boolean exists = contentFile.exists();
+         if(exists && isFailIfAlreadyExists())
+            throw new SyncFailedException("Deployment content already exists: "+contentFile.getAbsolutePath());
+         
+         // Copy streams
+         FileOutputStream fos = new FileOutputStream(contentFile);
+         try
+         {
+            byte[] tmp = new byte[4096];
+            int read;
+            while((read = contentIS.read(tmp)) > 0)
+            {
+               if (trace)
+                  log.trace("write, " + read);
+               fos.write(tmp, 0, read);
+            }
+            fos.flush();
+            // Get the vfs uri and add the VFS uri to the cached VFS uris
+            VirtualFile contentVF = VFS.getRoot(contentFile.toURI());
+            try
+            {
+               // Add the new virtual file to the cache
+               repositoryName = addVirtualFileCache(contentVF);
+               
+               if(exists)
+                  cleanUpRoot(contentVF);
+            }
+            catch(URISyntaxException e)
+            {
+               throw new RuntimeException(e); // This should not happen anyway
+            }
+         }
+         finally
+         {
+            try
+            {
+               fos.close();
+            }
+            catch (IOException ignored)
+            {
+            }
+         }
+
+         // Lock the content
+         lockDeploymentContent(repositoryName);
+      }
+      finally
+      {
+         // Allow hot deployment checking
+         unlockWrite();
+         if(trace)
+            log.trace("Released content write lock");
+      }
+      return repositoryName;
+   }
+   
+   public ProfileDeployment removeDeployment(String vfsPath) throws Exception
+   {
+      // Suspend hot deployment checking
+      if( log.isTraceEnabled() )
+         log.trace("Aquiring content write lock");
+      lockWrite();
+      try
+      {
+         // Remove the deployment from the filesystem
+         ProfileDeployment deployment = getDeployment(vfsPath);
+         VirtualFile root = deployment.getRoot();
+         
+         if(root != null)
+         {
+            // Delete the file
+            if(root.delete() == false)
+               throw new IOException("Failed to delete: " + root);
+            
+            cleanUpRoot(root);  
+         }
+         
+         // Cleanup
+         return super.removeDeployment(deployment.getName());
+      }
+      finally
+      {
+         unlockWrite();
+         if (log.isTraceEnabled())
+            log.trace("Released content write lock");
+      }
+   }
+   
+   /**
+    * A way for the hot-deployment repository to cleanup
+    * the root (modification checker).
+    * 
+    * @param vf the deployment root
+    */
+   protected void cleanUpRoot(VirtualFile vf)
+   {
+      //
+   }
+   
+   public void remove() throws Exception
+   {
+      // FIXME remove
+   }
+   
+   /**
+    * Lock for read
+    */
+   protected void lockRead()
+   {
+      lock.readLock().lock();
+   }
+
+   /**
+    * Unlock for read
+    */
+   protected void unlockRead()
+   {
+      lock.readLock().unlock();
+   }
+
+   /**
+    * Lock for write
+    */
+   protected void lockWrite()
+   {
+      lock.writeLock().lock();
+   }
+
+   /**
+    * Unlock for write
+    */
+   protected void unlockWrite()
+   {
+      lock.writeLock().unlock();
+   }
+
+}
+

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -121,7 +121,7 @@
       
       if(mutable)
       {
-         MutableDeploymentRepository repository = new MutableDeploymentRepository(key, uris);
+         HotDeploymentRepository repository = new HotDeploymentRepository(key, uris);
          // Manually inject beans :)
          repository.setDeploymentFilter(deploymentFilter);
          repository.setChecker(checker);
@@ -130,7 +130,7 @@
       }
       else
       {
-         ImmutableDeploymentRepository repository = new ImmutableDeploymentRepository(key, uris);
+         BasicDeploymentRepository repository = new BasicDeploymentRepository(key, uris);
          repository.setDeploymentFilter(deploymentFilter);
          
          return repository;

Copied: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java (from rev 86168, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java)
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
+import org.jboss.profileservice.spi.DeploymentContentFlags;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A deployment repository, with hot deployment capabilities.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ * @version $Revision$
+ */
+public class HotDeploymentRepository extends BasicDeploymentRepository
+{
+
+   /** The structure modification checker */
+   private StructureModificationChecker checker;
+   
+   public HotDeploymentRepository(ProfileKey key, URI[] uris)
+   {
+      super(key, uris);
+   }
+
+   /**
+    * Get the structure modified checker.
+    *
+    * @return the checker
+    */
+   protected StructureModificationChecker getChecker()
+   {
+      if (checker == null)
+         throw new IllegalArgumentException("Checker must be set");
+
+      return checker;
+   }
+
+   /**
+    * Set the checker.
+    *
+    * @param checker the checker
+    */
+   public void setChecker(StructureModificationChecker checker)
+   {
+      this.checker = checker;
+   }
+
+   @Override
+   public synchronized Collection<ModificationInfo> getModifiedDeployments() throws Exception
+   {
+      boolean trace = log.isTraceEnabled();
+      Collection<ProfileDeployment> apps = getDeployments();
+      ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
+      if (trace)
+         log.trace("Checking applications for modifications");
+      if (trace)
+         log.trace("Aquiring content read lock");
+      lockRead();
+      try
+      {
+         if (apps != null)
+         {
+            Iterator<ProfileDeployment> iter = apps.iterator();
+            while (iter.hasNext())
+            {
+               ProfileDeployment ctx = iter.next();
+               VirtualFile root = ctx.getRoot();
+               String pathName = ctx.getName();
+               // Ignore locked or disabled applications
+               if (this.hasDeploymentContentFlags(pathName, ignoreFlags))
+               {
+                  if (trace)
+                     log.trace("Ignoring locked application: " + root);
+                  continue;
+               }
+               // Check for removal
+               if (root.exists() == false)
+               {
+                  long rootLastModified = root.getLastModified();
+                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.REMOVED);
+                  modified.add(info);
+                  iter.remove();
+                  // Remove last modified cache
+                  cleanUpRoot(root);
+                  if (trace)
+                     log.trace(pathName + " was removed");
+               }
+               // Check for modification
+               else if (hasDeploymentContentFlags(pathName, DeploymentContentFlags.MODIFIED)
+                     || getChecker().hasStructureBeenModified(root))
+               {
+                  long rootLastModified = root.getLastModified();
+                  if (trace)
+                     log.trace(pathName + " was modified: " + rootLastModified);
+                  // Create the modification info
+                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.MODIFIED);
+                  modified.add(info);
+               }
+            }
+            // Now check for additions
+            for (URI applicationDir : getRepositoryURIs())
+            {
+               VirtualFile deployDir = getCachedVirtualFile(applicationDir);
+               ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
+               addedDeployments(added, deployDir);
+               for (VirtualFile vf : added)
+               {
+                  // Create deployment
+                  ProfileDeployment ctx = createDeployment(vf);
+                  // Create modification info
+                  ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
+                  // Add
+                  modified.add(info);
+                  addDeployment(ctx.getName(), ctx);
+                  getChecker().addStructureRoot(vf);
+               }
+            }
+         }
+      }
+      finally
+      {
+         unlockRead();
+         if (trace)
+            log.trace("Released content read lock");
+      }
+
+      if (modified.size() > 0)
+         updateLastModfied();
+      return modified;
+   }
+   
+   @Override
+   protected void cleanUpRoot(VirtualFile vf)
+   {
+      getChecker().removeStructureRoot(vf);
+   }
+}

Deleted: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-package org.jboss.system.server.profileservice.repository;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A immutable deployment repository.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ImmutableDeploymentRepository extends AbstractDeploymentRepository
-{
-
-   public ImmutableDeploymentRepository(ProfileKey key, URI[] uris)
-   {
-      super(key, uris);
-   }
-
-   public void load() throws Exception
-   {
-      for(URI uri : getRepositoryURIs())
-      {
-         VirtualFile root = getCachedVirtualFile(uri);
-         loadApplications(root);
-      }
-      updateLastModfied();
-   }
-   
-   public Collection<ModificationInfo> getModifiedDeployments() throws Exception
-   {
-      return Collections.emptySet();
-   }
-
-   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
-   {
-      throw new IllegalStateException("Cannot add content to an immutable repository.");
-   }
-
-   public void remove() throws Exception
-   {
-      throw new IllegalStateException("Cannot remove immutable repository.");
-   }
-
-}
-

Deleted: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -1,308 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-package org.jboss.system.server.profileservice.repository;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.SyncFailedException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.zip.ZipInputStream;
-
-import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
-import org.jboss.profileservice.spi.DeploymentContentFlags;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A mutable deployment repository, with hot deployment capabilities.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- * @version $Revision$
- */
-public class MutableDeploymentRepository extends AbstractDeploymentRepository
-{
-   /** Should an attempt to overwrite existing content fail in {@link #addDeploymentContent(String, ZipInputStream)}*/
-   private boolean failIfAlreadyExists = false;
-
-   /** The structure modification checker */
-   private StructureModificationChecker checker;
-
-   /** A lock for the hot deployment/{@link #getModifiedDeployments()} */
-   private ReentrantReadWriteLock contentLock = new ReentrantReadWriteLock(true);
-   
-   public MutableDeploymentRepository(ProfileKey key, URI[] uris)
-   {
-      super(key, uris);
-   }
-
-   public boolean isFailIfAlreadyExists()
-   {
-      return failIfAlreadyExists;
-   }
-   
-   public void setFailIfAlreadyExists(boolean failIfAlreadyExists)
-   {
-      this.failIfAlreadyExists = failIfAlreadyExists;
-   }
-   
-   /**
-    * Get the structure modified checker.
-    *
-    * @return the checker
-    */
-   protected StructureModificationChecker getChecker()
-   {
-      if (checker == null)
-         throw new IllegalArgumentException("Checker must be set");
-
-      return checker;
-   }
-
-   /**
-    * Set the checker.
-    *
-    * @param checker the checker
-    */
-   public void setChecker(StructureModificationChecker checker)
-   {
-      this.checker = checker;
-   }
-
-   public void load() throws Exception
-   {
-      for(URI uri : getRepositoryURIs())
-      {
-         VirtualFile root = getCachedVirtualFile(uri);
-         loadApplications(root);
-      }
-      updateLastModfied();
-   }
-   
-   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
-   {
-      boolean trace = log.isTraceEnabled();
-      // Suspend hot deployment checking
-      if( trace )
-         log.trace("Aquiring content write lock");
-      contentLock.writeLock().lock();
-      String repositoryName = null;
-      try
-      {
-         if(getRepositoryURIs().length == 0)
-            throw new IllegalStateException("No uris associated with this repository.");
-         
-         // FIXME, this is writing the content to the first URI
-         // Write the content out
-         File contentRoot = new File(getRepositoryURIs()[0]); 
-         if(contentRoot == null)
-            throw new FileNotFoundException("Failed to obtain content dir for phase: "+vfsPath);
-         File contentFile = new File(contentRoot, vfsPath);
-         
-         // Check if it already exists
-         boolean exists = contentFile.exists();
-         if(exists && isFailIfAlreadyExists())
-            throw new SyncFailedException("Deployment content already exists: "+contentFile.getAbsolutePath());
-         
-         // Copy streams
-         FileOutputStream fos = new FileOutputStream(contentFile);
-         try
-         {
-            byte[] tmp = new byte[4096];
-            int read;
-            while((read = contentIS.read(tmp)) > 0)
-            {
-               if (trace)
-                  log.trace("write, " + read);
-               fos.write(tmp, 0, read);
-            }
-            fos.flush();
-            // Get the vfs uri and add the VFS uri to the cached VFS uris
-            VirtualFile contentVF = VFS.getRoot(contentFile.toURI());
-            try
-            {
-               // Add the new virtual file to the cache
-               repositoryName = addVirtualFileCache(contentVF);
-               
-               // If exists do a cleanup
-               if(exists)
-                  getChecker().removeStructureRoot(contentVF);
-            }
-            catch(URISyntaxException e)
-            {
-               throw new RuntimeException(e); // This should not happen anyway
-            }
-         }
-         finally
-         {
-            try
-            {
-               fos.close();
-            }
-            catch (IOException ignored)
-            {
-            }
-         }
-
-         // Lock the content
-         lockDeploymentContent(repositoryName);
-      }
-      finally
-      {
-         // Allow hot deployment checking
-         contentLock.writeLock().unlock();
-         if(trace)
-            log.trace("Released content write lock");
-      }
-      return repositoryName;
-   }
-
-   public synchronized Collection<ModificationInfo> getModifiedDeployments() throws Exception
-   {
-      ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
-      Collection<ProfileDeployment> apps = getDeployments();
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-         log.trace("Checking applications for modifications");
-      if (trace)
-         log.trace("Aquiring content read lock");
-      contentLock.readLock().lock();
-      try
-      {
-         if (apps != null)
-         {
-            Iterator<ProfileDeployment> iter = apps.iterator();
-            while (iter.hasNext())
-            {
-               ProfileDeployment ctx = iter.next();
-               VirtualFile root = ctx.getRoot();
-               String pathName = ctx.getName();
-               // Ignore locked or disabled applications
-               if (this.hasDeploymentContentFlags(pathName, ignoreFlags))
-               {
-                  if (trace)
-                     log.trace("Ignoring locked application: " + root);
-                  continue;
-               }
-               // Check for removal
-               if (root.exists() == false)
-               {
-                  long rootLastModified = root.getLastModified();
-                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.REMOVED);
-                  modified.add(info);
-                  iter.remove();
-                  // Remove last modified cache
-                  getChecker().removeStructureRoot(root);
-                  if (trace)
-                     log.trace(pathName + " was removed");
-               }
-               // Check for modification
-               else if (hasDeploymentContentFlags(pathName, DeploymentContentFlags.MODIFIED)
-                     || getChecker().hasStructureBeenModified(root))
-               {
-                  long rootLastModified = root.getLastModified();
-                  if (trace)
-                     log.trace(pathName + " was modified: " + rootLastModified);
-                  // Create the modification info
-                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.MODIFIED);
-                  modified.add(info);
-               }
-            }
-            // Now check for additions
-            for (URI applicationDir : getRepositoryURIs())
-            {
-               VirtualFile deployDir = getCachedVirtualFile(applicationDir);
-               ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
-               addedDeployments(added, deployDir);
-               for (VirtualFile vf : added)
-               {
-                  // Create deployment
-                  ProfileDeployment ctx = createDeployment(vf);
-                  // Create modification info
-                  ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
-                  // Add
-                  modified.add(info);
-                  addDeployment(ctx.getName(), ctx);
-                  getChecker().addStructureRoot(vf);
-               }
-            }
-         }
-      }
-      finally
-      {
-         contentLock.readLock().unlock();
-         if (trace)
-            log.trace("Released content read lock");
-      }
-
-      if (modified.size() > 0)
-         updateLastModfied();
-      return modified;
-   }
-
-   public ProfileDeployment removeDeployment(String vfsPath) throws Exception
-   {
-      // Suspend hot deployment checking
-      if( log.isTraceEnabled() )
-         log.trace("Aquiring content write lock");
-      contentLock.writeLock().lock();
-      try
-      {
-         // Remove the deployment from the filesystem
-         ProfileDeployment deployment = getDeployment(vfsPath);
-         VirtualFile root = deployment.getRoot();
-         
-         // Delete the file
-         if(root.delete() == false)
-            throw new IOException("Failed to delete: " + root);
-
-         // Remove the deployment from the structure checker.
-         getChecker().removeStructureRoot(root);
-         
-         // Cleanup
-         return super.removeDeployment(deployment.getName());
-      }
-      finally
-      {
-         contentLock.writeLock().unlock();
-         if (log.isTraceEnabled())
-            log.trace("Released content write lock");
-      }
-   }
-   
-   public void remove() throws Exception
-   {
-      // FIXME remove
-   }
-}

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -38,7 +38,7 @@
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.system.server.profileservice.hotdeploy.Scanner;
-import org.jboss.system.server.profileservice.repository.MutableDeploymentRepository;
+import org.jboss.system.server.profileservice.repository.HotDeploymentRepository;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
 
@@ -216,7 +216,7 @@
       return urls.toArray(new String[urls.size()]);
    }
 
-   public static class DeploymentScannerProfile extends MutableDeploymentRepository implements MutableProfile
+   public static class DeploymentScannerProfile extends HotDeploymentRepository implements MutableProfile
    {
       private volatile boolean enableHotDeployment;
 

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java	2009-03-21 15:18:12 UTC (rev 86174)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java	2009-03-21 20:40:25 UTC (rev 86175)
@@ -21,14 +21,19 @@
  */ 
 package org.jboss.test.deployers;
 
+import java.util.Collection;
+
 import javax.naming.InitialContext;
 
 import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.test.JBossTestCase;
 
 /**
+ * Basic DeploymentManager test.
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -41,19 +46,38 @@
    /** A simple nested deployment. */
    final static String NESTED_DEPLOYMENT = "profileservice-datasource.ear";
    
+   /** The deployers target profile. */
+   final static ProfileKey deployersKey = new ProfileKey("deployers");
+   
    /** The deployment manager. */
-   DeploymentManager deployMgr;
+   private DeploymentManager deployMgr;
 
    public DeploymentManagerUnitTestCase(String name)
    {
       super(name);
    }
- 
-   protected void setUp() throws Exception
+   
+   /**
+    * Test the available profiles.
+    * 
+    * @throws Exception
+    */
+   public void testAvaiableProfiles() throws Exception
    {
-      super.setUp();
+      Collection<ProfileKey> keys = getDeploymentManager().getProfiles();
+      assertNotNull(keys);
+      log.debug("available keys: " + keys);
+      assertEquals("keys size", 2, keys.size());
+      keys.contains(new ProfileKey("applications"));
+      keys.contains(deployersKey);
    }
    
+   /**
+    * Test a override of the applications, without
+    * removing/stopping them before.
+    * 
+    * @throws Exception
+    */
    public void testDistributeOverride() throws Exception
    {
       try
@@ -67,10 +91,15 @@
       }
       finally
       {
-         stopAndRemove(new String[] {NESTED_DEPLOYMENT});
+         stopAndRemove(new String[] { NESTED_DEPLOYMENT });
       }
    }
    
+   /**
+    * Basic copyContent test to the default location.
+    * 
+    * @throws Exception
+    */
    public void testCopyContent() throws Exception
    {
       try
@@ -91,6 +120,11 @@
       }
    }
    
+   /**
+    * Basic noCopyContent test.
+    * 
+    * @throws Exception
+    */
    public void testNoCopyContent() throws Exception
    {
       try
@@ -110,6 +144,38 @@
             { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
       }
    }
+   
+   /**
+    * Test copyContent to the deployers target profile.
+    * 
+    * @throws Exception
+    */
+   public void testDepoyersDir() throws Exception
+   {
+      getDeploymentManager().loadProfile(deployersKey);
+      try
+      {
+         // failed 
+         deployFailed(true);
+         // complete
+         deployEmpty(true);
+         // Test redeploy
+         redeployCheckComplete(EMTPY_DEPLOYMENT);
+      }
+      finally
+      {
+         try
+         {
+            stopAndRemove(new String[]
+               { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
+         }
+         finally
+         {
+            // Make sure that we release the profile
+            getDeploymentManager().releaseProfile();
+         }
+      }
+   }
 
    void deployFailed(boolean isCopyContent) throws Exception
    {




More information about the jboss-cvs-commits mailing list