[jboss-cvs] JBossAS SVN: r104249 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/config and 25 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 26 06:13:21 EDT 2010


Author: emuckenhuber
Date: 2010-04-26 06:13:18 -0400 (Mon, 26 Apr 2010)
New Revision: 104249

Added:
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/MutableRepositoryUnitTestCase.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/TestVirtualDeploymentRepository.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/DeployHandlerUnitTestCase.java
   projects/profileservice/trunk/plugins/src/test/resources/deployments/
   projects/profileservice/trunk/plugins/src/test/resources/deployments/test.deployment
Removed:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/BasicModificationStatus.java
Modified:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceBootstrap.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ArtifactRepositoriesConfig.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConfig.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/HDScanningProfile.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/ScanningProfileFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileSourceMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DefaultNotFoundHandler.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileRepositoryConfiguration.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java
   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/legacy/LegacyHDScanningRepository.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ProfileServiceBootstrap.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileActivationUnitTestCase.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java
   projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/AbstractPersistenceFactory.java
   projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/PersistenceFactory.java
   projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/repository/PersistenceRepository.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.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/management/AggregatingLocalManagementView.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/RemoveComponentAction.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/UpdateComponentAction.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeploymentIDSupport.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/AbstractDeployTest.java
Log:


Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceBootstrap.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceBootstrap.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceBootstrap.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -29,8 +29,8 @@
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.config.ProfileServiceConfig;
 import org.jboss.profileservice.domain.AbstractDomainMetaData;
+import org.jboss.profileservice.domain.spi.DomainMetaData;
 import org.jboss.profileservice.domain.spi.DomainMetaDataFragment;
-import org.jboss.profileservice.domain.spi.DomainMetaData;
 import org.jboss.profileservice.profile.metadata.domain.BasicDomainMetaDataVisitor;
 import org.jboss.profileservice.resolver.BasicResolverFactory;
 import org.jboss.profileservice.spi.NoSuchProfileException;
@@ -45,7 +45,7 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public abstract class AbstractProfileServiceBootstrap extends AbstractProfileServiceInitializer implements ProfileActivationCallback
+public abstract class AbstractProfileServiceBootstrap extends AbstractProfileServiceInitializer implements ProfileActivationCallback, ProfileRequirementResolverFactory
 {
 
    /** The logger. */
@@ -83,7 +83,7 @@
 
    protected void start(AbstractDomainMetaData domainMetaData) throws Throwable
    {
-      ProfileRequirementResolver resolver = createRequirementResolver(domainMetaData);
+      ProfileRequirementResolver resolver = createResolver(domainMetaData);
       BasicDomainMetaDataVisitor visitor = new BasicDomainMetaDataVisitor(resolver, getMetaDataRegistry());
       Collection<DomainMetaDataFragment> features = domainMetaData.getFragments();
       if(features != null && features.isEmpty() == false)
@@ -152,10 +152,15 @@
       }
    }
 
-   protected ProfileRequirementResolver createRequirementResolver(DomainMetaData domainMetaData)
+   protected ProfileRequirementResolver createResolver(DomainMetaData domainMetaData)
    {
-      return resolverFactory.createResolver(getConfig().getServerConfiguration().getServerName());
+      return createResolver(getConfig().getServerConfiguration().getServerName());
    }
+   
+   public ProfileRequirementResolver createResolver(String name)
+   {
+      return resolverFactory.createResolver(name);
+   }
 
    protected void checkShutdown()
    {

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ArtifactRepositoriesConfig.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ArtifactRepositoriesConfig.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ArtifactRepositoriesConfig.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -39,6 +39,8 @@
 public class ArtifactRepositoriesConfig
 {
 
+   private static final ArtifactRepositoriesConfig INSTANCE = new ArtifactRepositoriesConfig();
+   
    private static final Random RANDOM_NUM_GEN = new SecureRandom();
    private static final String JBOSS_TMP_DIR_PROPERTY = "jboss.server.temp.dir";
    private static final String JVM_TMP_DIR_PROPERTY = "java.io.tmpdir";
@@ -47,7 +49,7 @@
    
    /** The exclude filter. */
    private VirtualFileFilter excludeFilter = new ExtensibleFilter();
-   
+
    static
    {
       String configTmpDir = System.getProperty(JBOSS_TMP_DIR_PROPERTY);
@@ -57,6 +59,11 @@
       tmpDirURI = tempDirFile.toURI();
    }
 
+   public static ArtifactRepositoriesConfig getInstance()
+   {
+      return INSTANCE;
+   }
+   
    /**
     * Create a URI for a repository backup location.
     * 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConfig.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConfig.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConfig.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -59,7 +59,7 @@
    private PersistenceRepositoryConfiguration persistenceRepositoryConfiguration;
    
    /** The common artifact repository configuration options. */
-   private ArtifactRepositoriesConfig repositoriesConfiguration = new ArtifactRepositoriesConfig();
+   private ArtifactRepositoriesConfig repositoriesConfiguration = ArtifactRepositoriesConfig.getInstance();
    
    /** The assembly configuration. */
    private VirtualAssemblyConfiguration assemblyConfiguration = new VirtualAssemblyConfiguration();

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -22,6 +22,7 @@
 package org.jboss.profileservice.dependency;
 
 import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.dependency.spi.Controller;
 import org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.profileservice.deployment.ProfileDeployerPlugin;
@@ -41,10 +42,10 @@
  */
 public class ProfileControllerContext extends AbstractKernelControllerContext implements ManagedProfile
 {
-   
+
    /** Some additional meta data information. */
    private ProfileDependencyContext metaDataContext;
-   
+  
    protected ProfileControllerContext(BeanMetaData metaData, Object target)
    {
       super(null, metaData, target != null ? ProfileControllerContextActions.getNoInstantiate() : ProfileControllerContextActions.getInstance() , target);
@@ -55,6 +56,11 @@
       return Profile.class.cast(super.getTarget());
    }
 
+   public void setController(Controller controller)
+   {
+      super.setController(controller);
+   }
+   
    public ProfileKey getProfileKey()
    {
       return getDependencyContext().getKey();

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -267,7 +267,10 @@
    
    protected ProfileKey createProfileKey(String profileName)
    {
-      return new ProfileKey(domainName(), getServerName(), profileName);
+      // FIXME there are too many issues with resolving domain, server, profile
+      // Just use the the default
+      // return new ProfileKey(domainName(), getServerName(), profileName);
+      return new ProfileKey(profileName);
    }
    
 }

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -200,27 +200,28 @@
    public void unInstallAndUnregisterContext(ProfileKey key) throws NoSuchProfileException
    {
       key = resolveProfileKey(key);
-      getRegisteredContext(key); // check if it exists
-      unInstallContext(key);
+      ProfileControllerContext ctx = getRegisteredContext(key); // check if it exists
+      unInstallContext(ctx);
       metaDataRegistry.removeProfile(key);
    }
    
    public void install(ProfileDependencyContext context, Profile profile) throws Throwable
    {
       ProfileControllerContext pCCtx = createControllerContext(context, profile);
-      controller.install(pCCtx);      
+      controller.install(pCCtx);
    }
 
-   void unInstallContext(ProfileKey key)
+   void unInstallContext(ProfileControllerContext ctx)
    {
-      key = resolveProfileKey(key);
-      controller.uninstall(key);
+      controller.uninstall(ctx.getName());
    }
    
    ProfileControllerContext createControllerContext(final ProfileDependencyContext context, Profile profile)
    {
       final ProfileKey key = context.getKey();
-      final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(key.toString(), null);
+      final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(Integer.toHexString(key.hashCode()), null);
+      // Set the profile key as alias only
+      builder.addAlias(key);
       // Aliases
       final Collection<ProfileKey> aliases = context.getAliases();
       if(aliases != null && aliases.isEmpty() == false)
@@ -249,11 +250,9 @@
       }
       // No autowire
       builder.setAutowireType(AutowireType.NONE);
-
+      
       // Create the ControllerContext
       final ProfileControllerContext kCtx = new ProfileControllerContext(builder.getBeanMetaData(), profile);
-      // Set the correct context name, since BMDB just accepts a string
-      kCtx.setName(context.getKey());
       // We control the lifecycle
       kCtx.setMode(ControllerMode.MANUAL);
       // Describe the the controller context
@@ -273,5 +272,5 @@
       // We are done here
       return kCtx;
    }
-
+   
 }

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -45,7 +45,7 @@
  */
 public class ProfileLifeCycleCallbackActions implements LifecycleCallbackItem, KernelControllerContextAware
 {
-
+  
    /** The value. */
    private static final Object value = new Object();
    

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -43,12 +43,8 @@
 import org.jboss.profileservice.spi.managed.ManagedProfileDeployer;
 
 /**
- * The HDScanner.
+ * The HDScanner.  
  * 
- * TODO This needs to be redone, since all deployment action should be using
- * the actionController to get exclusive access to a profile. The checking and
- * deployment should be part of a ModificationAction...  
- * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -209,6 +205,7 @@
          {
             log.trace("Begin deployment scan: " + profile.getKey());
          }
+         boolean modified = false;
          Collection<String> checkCompleteNames = new ArrayList<String>();
          Collection<ModificationInfo> modifiedDeployments = profile.getModifiedDeployments();
          for (ModificationInfo info : modifiedDeployments)
@@ -224,9 +221,11 @@
                      deployer.addDeployment(ctx);
                      checkCompleteNames.add(ctx.getName());
                      deploymentInfo.setFlag(ProfileDeploymentFlag.DEPLOYED);
+                     modified = true;
                      break;
                   case REMOVED:
                      deployer.removeDeployment(ctx);
+                     modified = true;
                      break;
                }
             }
@@ -236,7 +235,7 @@
             }
          }
          // Process the changes
-         if (modifiedDeployments.isEmpty() == false)
+         if (modified)
          {
             deployer.process();
             // Notify

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/BasicModificationStatus.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/BasicModificationStatus.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/BasicModificationStatus.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -1,61 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2010, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.profileservice.management;
-
-import org.jboss.profileservice.spi.action.ModificationStatus;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class BasicModificationStatus implements ModificationStatus
-{
-
-   final boolean success;
-   
-   public BasicModificationStatus(boolean success)
-   {
-      this.success = success;
-   }
-   
-   public Exception getFailure()
-   {
-      return null;
-   }
-
-   public boolean isCompleted()
-   {
-      return true;
-   }
-
-   public boolean isFailed()
-   {
-      return success == false;
-   }
-
-   public boolean isRunning()
-   {
-      return false;
-   }
-
-}
-

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-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/HDScanningProfile.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -21,6 +21,7 @@
 */
 package org.jboss.profileservice.profile;
 
+import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -70,11 +71,13 @@
     * it will point to temp location.
     * 
     * @param deployment the deployment
-    * @param repositoryFile the repository file
+    * @param artifactId the artifact id
     * @return true if the deployment was modified since the last check
+    * @throws IOException
     */
-   protected boolean isModified(ProfileDeployment deployment, VirtualFile repositoryFile)
+   protected boolean isModified(ProfileDeployment deployment, FileArtifactId artifactId) throws IOException
    {
+      VirtualFile repositoryFile = getArtifactRepository().getArtifactFile(artifactId);
       return modificationChecker != null && modificationChecker.isDeploymentModified(deployment, repositoryFile);
    }
    
@@ -103,14 +106,14 @@
             final String deploymentName = deployment.getName();
             // Resolve the repository VirtualFile, which has to point to a backup location
             final FileArtifactId artifactId = getArtifactMetaData(deployment);
-            final VirtualFile repositoryFile = getArtifactRepository().getArtifactFile(artifactId);
-            if(repositoryFile.exists() == false)
+            // Check if the file still exists
+            if(getArtifactRepository().containsArtifact(artifactId) == false)
             {
                internalRemoveDeployment(deploymentName);
                final ModificationInfo modification = new ModificationInfo(deployment, lastModified, ModificationInfo.ModifyStatus.REMOVED);
                modifications.put(deploymentName, modification);
             }
-            else if(info.hasFlag(ProfileDeploymentFlag.MODIFIED) || isModified(deployment, repositoryFile))
+            else if(info.hasFlag(ProfileDeploymentFlag.MODIFIED) || isModified(deployment, artifactId))
             {
                final ModificationInfo modification = new ModificationInfo(deployment, lastModified, ModificationInfo.ModifyStatus.MODIFIED);
                modifications.put(deploymentName, modification);               

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/ScanningProfileFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/ScanningProfileFactory.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/ScanningProfileFactory.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -187,6 +187,7 @@
       FileRepositoryConfiguration configuration = new FileRepositoryConfiguration();
       configuration.setOverrideURI(new URI(source.getPath()));
       configuration.setMutable(mutable);
+      configuration.setCreateIfDoesNotExists(source.isCreateIfDoesNotExist());
       if(mutable)
       {
          configuration.setBackupPolicy(VFSBackupPolicy.BACKUP);

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileMetaData.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileMetaData.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -34,8 +34,10 @@
 import org.jboss.profileservice.domain.spi.DomainMetaDataFragment;
 import org.jboss.profileservice.domain.spi.DomainMetaDataFragmentVisitor;
 import org.jboss.profileservice.profile.metadata.CommonProfileNameSpaces;
+import org.jboss.profileservice.profile.metadata.FeatureRequirement;
 import org.jboss.profileservice.profile.metadata.helpers.AbstractProfileMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
 /**
@@ -50,10 +52,13 @@
       normalizeSpace=true,
       replacePropertyRefs=true)
 @XmlRootElement(name = "static-deployment")
- at XmlType(name = "hotDeploymentType", propOrder = { "source" })
+ at XmlType(name = "propertyProfileType", propOrder = { "source" })
 public class PropertyProfileMetaData extends AbstractProfileMetaData implements DomainMetaDataFragment
 {
 
+   /** Requirement on the bootstrap. */
+   private static FeatureRequirement BOOTSTRAP = new FeatureRequirement(CommonProfileNameSpaces.BOOTSTRAP_PROFILE_NAMESPACE);
+   
    /** The source. */
    private PropertyProfileSourceMetaData source;
    
@@ -106,6 +111,12 @@
       return false;
    }
    
+   public void visit(ProfileMetaDataVisitor visitor)
+   {
+      super.visit(visitor);
+      visitor.addRequirement(BOOTSTRAP);
+   }
+   
    public void visit(DomainMetaDataFragmentVisitor visitor)
    {
       visitor.addProfileMetaData(this);

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileSourceMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileSourceMetaData.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileSourceMetaData.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -38,9 +38,9 @@
    /** The sources. */
    private String path;
 
-   /** The upload dir. */
-   private boolean uploadPath;
-   
+   /** create if does not exist. */
+   private boolean createIfDoesNotExist;
+  
    public PropertyProfileSourceMetaData()
    {
       //
@@ -68,15 +68,15 @@
       this.path = path;
    }
 
-   @XmlAttribute(name = "upload")
-   public boolean isUploadPath()
+   @XmlTransient
+   public boolean isCreateIfDoesNotExist()
    {
-      return uploadPath;
+      return createIfDoesNotExist;
    }
    
-   public void setUploadPath(boolean uploadPath)
+   public void setCreateIfDoesNotExist(boolean createIfDoesNotExist)
    {
-      this.uploadPath = uploadPath;
+      this.createIfDoesNotExist = createIfDoesNotExist;
    }
    
 }

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -53,5 +53,10 @@
       super.cleanup();
    }
    
+   public String toString()
+   {
+      return "BasicProfileDeployment(" + getRoot() != null ? getRoot().getName() : getName() + ")";
+   }
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DefaultNotFoundHandler.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DefaultNotFoundHandler.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DefaultNotFoundHandler.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -48,7 +48,7 @@
    public Artifact<T> handleArtifactNotFound(ArtifactRepository<T> repsoitory, T artifactId)
          throws IOException
    {
-      throw new FileNotFoundException("could not find artifact " + artifactId);
+      throw new FileNotFoundException("failed to find artifact " + artifactId);
    }
    
 }

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileRepositoryConfiguration.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileRepositoryConfiguration.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileRepositoryConfiguration.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -40,6 +40,7 @@
 
    private URI overrideURI;
    private URI backupURI;
+   private boolean createIfDoesNotExists = false;
    private boolean mutable = false;
    private VirtualFileFilter excludeFilter = new ExtensibleFilter();
    private VFSBackupPolicy backupPolicy = VFSBackupPolicy.ORIGINAL;
@@ -96,6 +97,16 @@
       this.excludeFilter = excludeFilter;
    }
    
+   public boolean isCreateIfDoesNotExists()
+   {
+      return createIfDoesNotExists;
+   }
+   
+   public void setCreateIfDoesNotExists(boolean createIfDoesNotExists)
+   {
+      this.createIfDoesNotExists = createIfDoesNotExists;
+   }
+   
    public URI getBackupURI()
    {
       return backupURI;

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -92,6 +92,13 @@
    public void create() throws IOException
    {
       VirtualFile originalLocation = VFS.getChild(getRepositoryURI());
+      if(originalLocation.exists() == false && getConfiguration().isCreateIfDoesNotExists())
+      {
+         if(originalLocation.getPhysicalFile().mkdirs() == false)
+         {
+            throw new IOException("failed to create " + getRepositoryURI());
+         }         
+      }
       if(originalLocation.isDirectory() == false)
       {
          // TODO
@@ -101,6 +108,10 @@
       // In case we only use backups we need to remount
       if(getConfiguration().getBackupPolicy() == VFSBackupPolicy.BACKUP)
       {
+         if(getConfiguration().getBackupURI() == null)
+         {
+            throw new IllegalStateException("null backup uri");
+         }
          VirtualFile backupLocation = VFS.getChild(getConfiguration().getBackupURI());
          this.mount = VFS.mountReal(originalLocation.getPhysicalFile(), backupLocation);
          // The root is not different from the original URI
@@ -152,8 +163,7 @@
    public boolean containsArtifact(FileArtifactId artifact)
    {
       validateArtifactID(artifact);
-      VirtualFile vf = getRepositoryRoot().getChild(artifact.getPath());
-      return vf != null ? vf.exists() : false;
+      return getRepositoryRoot().getChild(artifact.getPath()).exists();
    }
    
    /**
@@ -247,9 +257,9 @@
     */
    public VirtualFile getOriginalFile(FileArtifactId artifactId) throws IOException
    {
-      if(containsArtifact(artifactId) == false)
+      if(getArtifactFile(artifactId, false).exists() == false)
       {
-         getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifactId);         
+         getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifactId);
       }
       if(getConfiguration().getBackupPolicy() == VFSBackupPolicy.BACKUP)
       {
@@ -259,25 +269,25 @@
       }
       else
       {
-         return getArtifactFile(artifactId);
+         return getArtifactFile(artifactId, true);
       }
    }
 
    /**
     * Get the artifact file.
     * 
-    * @param artifact the artifact id
+    * @param artifactId the artifact id
     * @param checkExist fail if does not exist
     * @return the virtual file
     * @throws IOException 
     */
-   protected VirtualFile getArtifactFile(FileArtifactId artifact, boolean checkExist) throws IOException
+   protected VirtualFile getArtifactFile(FileArtifactId artifactId, boolean checkExist) throws IOException
    {
-      validateArtifactID(artifact);
-      VirtualFile vf = getRepositoryRoot().getChild(artifact.getPath());
+      validateArtifactID(artifactId);
+      VirtualFile vf = getRepositoryRoot().getChild(artifactId.getPath());
       if(checkExist && vf.exists() == false)
       {
-         getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifact);
+         getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifactId);
       }
       return vf;
    }

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-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/MutableFileArtifactRepository.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -100,6 +100,22 @@
    /**
     * {@inheritDoc}
     */
+   public boolean containsArtifact(FileArtifactId artifact)
+   {
+      lockRead();
+      try
+      {
+         return super.containsArtifact(artifact);
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public FileArtifact getArtifact(FileArtifactId artifactId)
    {
       lockRead();
@@ -161,6 +177,19 @@
       }
    }
    
+   public VirtualFile getOriginalFile(FileArtifactId artifactId) throws IOException
+   {
+      lockRead();
+      try
+      {
+         return super.getOriginalFile(artifactId);
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
    /**
     * {@inheritDoc}
     */
@@ -169,8 +198,8 @@
       lockWrite();
       try
       {
-         VirtualFile vf = getArtifactFile(artifactId);
-         if(vf == null || vf.exists() == false)
+         VirtualFile vf = getArtifactFile(artifactId, false);
+         if(vf.exists() == false)
          {
             return;
          }

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/legacy/LegacyHDScanningRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/legacy/LegacyHDScanningRepository.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/legacy/LegacyHDScanningRepository.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -21,6 +21,7 @@
 */
 package org.jboss.profileservice.repository.legacy;
 
+import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -68,11 +69,13 @@
     * it will point to temp location.
     * 
     * @param deployment the deployment
-    * @param repositoryFile the repository file
+    * @param artifactId the artifact id
     * @return true if the deployment was modified since the last check
+    * @throws IOException
     */
-   protected boolean isModified(ProfileDeployment deployment, VirtualFile repositoryFile)
+   protected boolean isModified(ProfileDeployment deployment, FileArtifactId artifactId) throws IOException
    {
+      VirtualFile repositoryFile = getArtifactRepository().getArtifactFile(artifactId);
       return modificationChecker != null && modificationChecker.isDeploymentModified(deployment, repositoryFile);
    }
    
@@ -101,14 +104,14 @@
             final String deploymentName = deployment.getName();
             // Resolve the repository VirtualFile, which has to point to a backup location
             final FileArtifactId artifactId = getArtifactMetaData(deployment);
-            final VirtualFile repositoryFile = getArtifactRepository().getArtifactFile(artifactId);
-            if(repositoryFile.exists() == false)
+            // Check if the file still exists
+            if(getArtifactRepository().containsArtifact(artifactId) == false)
             {
                internalRemoveDeployment(deploymentName);
                final ModificationInfo modification = new ModificationInfo(deployment, lastModified, ModificationInfo.ModifyStatus.REMOVED);
                modifications.put(deploymentName, modification);
             }
-            else if(info.hasFlag(ProfileDeploymentFlag.MODIFIED) || isModified(deployment, repositoryFile))
+            else if(info.hasFlag(ProfileDeploymentFlag.MODIFIED) || isModified(deployment, artifactId))
             {
                final ModificationInfo modification = new ModificationInfo(deployment, lastModified, ModificationInfo.ModifyStatus.MODIFIED);
                modifications.put(deploymentName, modification);               

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -72,7 +72,6 @@
    /**
     * {@inheritDoc} 
     */
-   @Override
    protected VirtualFile getOriginalVirtualFile(ArtifactId artifactId) throws IOException
    {
       // return the original

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -54,6 +54,8 @@
 public class HDScannerUnitTestCase extends BaseTestCase
 {
 
+   private static final int sleep = 10;
+   
    private AbstractActionController actionController;
    private DefaultHDScannerFactory scannerFactory;
    
@@ -96,12 +98,12 @@
       scanner1.start();
       scanner2.scan();
       assertTrue(scanner1.isScheduled());
-      Thread.sleep(7);
+      Thread.sleep(sleep);
 
       scanner2.start();
       assertTrue(scanner1.getScanCount() > 0);
       scanner1.scan();
-      Thread.sleep(7);
+      Thread.sleep(sleep);
       assertTrue(scanner2.getScanCount() > 0);
       scanner2.stop();
       
@@ -137,7 +139,7 @@
       
       scannerFactory.enableScanning();
 
-      Thread.sleep(7);
+      Thread.sleep(sleep);
       
       assertTrue(scanner1.isScheduled());
       assertFalse(scanner2.isScheduled());
@@ -146,7 +148,7 @@
 
       scanner2.start();
       
-      Thread.sleep(7);
+      Thread.sleep(sleep);
 
       assertTrue(scanner1.isScheduled());
       assertTrue(scanner2.isScheduled());

Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/MutableRepositoryUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/MutableRepositoryUnitTestCase.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/MutableRepositoryUnitTestCase.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -0,0 +1,119 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.test.profileservice.repository.test;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.jboss.profileservice.config.ArtifactRepositoriesConfig;
+import org.jboss.profileservice.repository.artifact.AbstractRepositoryId;
+import org.jboss.profileservice.repository.artifact.CopyStreamArtifactTransformer;
+import org.jboss.profileservice.repository.artifact.file.FileArtifact;
+import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
+import org.jboss.profileservice.repository.artifact.file.FileRepositoryConfiguration;
+import org.jboss.profileservice.repository.artifact.file.MutableFileArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
+import org.jboss.profileservice.spi.repository.ArtifactTransformer;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration.VFSBackupPolicy;
+import org.jboss.test.profileservice.ProfileServiceTestBase;
+import org.jboss.vfs.VFSUtils;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MutableRepositoryUnitTestCase extends ProfileServiceTestBase
+{
+
+   private final ArtifactRepositoriesConfig repositoriesConfiguration = new ArtifactRepositoriesConfig();
+   
+   public MutableRepositoryUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void test() throws Exception
+   {
+      URL url = getResource("repository");
+      assertNotNull(url);
+      
+      // Create repository
+      MutableFileArtifactRepository repository = createRepository(url.toURI());
+      repository.create();
+      
+      InputStream is = getResource("repository/profiles.xml").openStream();
+      try
+      {
+         // Add artifact
+         FileArtifactId artifactId = new FileArtifactId("test"); 
+         ArtifactTransformer<FileArtifactId> transformer = CopyStreamArtifactTransformer.getInstance();
+         repository.addArtifact(artifactId, is, transformer);
+         
+         // Artifact
+         FileArtifact artifact = repository.getArtifact(artifactId);
+         assertTrue(artifact.isFile());
+         assertNotNull(artifact);
+
+         // Contains added artifact
+         assertTrue(repository.containsArtifact(artifactId));
+
+         // Backup file
+         VirtualFile backup = repository.getArtifactFile(artifactId);
+         getLog().debug(backup);
+         assertTrue(backup.exists());
+         
+         // Original location
+         VirtualFile original = repository.getOriginalFile(artifactId);
+         getLog().debug(original);
+         assertTrue(original.exists());
+
+         // Remove artifact
+         repository.removeArtifact(artifactId);
+         assertFalse(backup.exists());
+         assertFalse(original.exists());
+      }
+      finally
+      {
+         VFSUtils.safeClose(is);
+         VFSUtils.safeClose(repository);
+      }
+   }
+
+   MutableFileArtifactRepository createRepository(URI root) throws URISyntaxException
+   {
+      ArtifactRepositoryId repositoryID = new AbstractRepositoryId("test", FileArtifactId.TYPE);
+      return new MutableFileArtifactRepository(repositoryID, root, createRepositoryConfiguration());
+   }
+   
+   FileRepositoryConfiguration createRepositoryConfiguration() throws URISyntaxException
+   {
+      FileRepositoryConfiguration configuration = new FileRepositoryConfiguration();
+      configuration.setBackupPolicy(VFSBackupPolicy.BACKUP);
+      configuration.setBackupURI(repositoriesConfiguration.createBackupURI());
+      return configuration;
+   }
+   
+}
+

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ProfileServiceBootstrap.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ProfileServiceBootstrap.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ProfileServiceBootstrap.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -28,6 +28,7 @@
 import org.jboss.profileservice.domain.ManagementDomainMetaData;
 import org.jboss.profileservice.domain.ServerMetaData;
 
+
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
@@ -49,6 +50,6 @@
       domain.setServer(server);
       createProfileService(domain);
    }
-   
+
 }
 

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileActivationUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileActivationUnitTestCase.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileActivationUnitTestCase.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -53,11 +53,25 @@
       ProfileKey key = ps.registerProfile(new EmptyProfileMetaData("test"), new TestProfile());
       ps.activateProfile(key);
       ps.validateProfile(key);
-      // 
+      //  
       ps.deactivateProfile(key);
+      ps.activateProfile(key);
+      ps.validateProfile(key);
+      //  
+      ps.deactivateProfile(key);      
+      assertNotNull(getController().getContext(key, null));
       ps.unregisterProfile(key);
+      
+      //
+      key = ps.registerProfile(new EmptyProfileMetaData("test"), new TestProfile());
+      ps.activateProfile(key);
+      ps.validateProfile(key);
+      //  
+      ps.deactivateProfile(key);
+      ps.unregisterProfile(key);
+  
    }
-
+   
    static class TestProfile implements Profile
    {
 

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -106,9 +106,10 @@
       {
          if(profile.getName().equals("test") == false)
          {
+            long start = System.currentTimeMillis();
             ps.activateProfile(profile);
             ps.validateProfile(profile);
-            getLog().debug("activated " + profile.getName());
+            getLog().debug("activated " + profile.getName() + " took: " + (System.currentTimeMillis() - start));
          }
       }
       

Modified: projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/AbstractPersistenceFactory.java
===================================================================
--- projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/AbstractPersistenceFactory.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/AbstractPersistenceFactory.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -71,7 +71,7 @@
    {
       return persistencePlugin;
    }
-   
+
    /**
     * Apply the persisted information to a attachment.
     * 
@@ -108,6 +108,18 @@
    }
    
    /**
+    * {@inheritDoc}
+    */
+   public boolean isSupportPersistence(ManagedObject parent, ManagedComponent component)
+   {
+      if(parent == null)
+      {
+         throw new IllegalArgumentException("null managed object parent");
+      }
+      return getComponentMapper(parent, false) != null;
+   }
+   
+   /**
     * Add a ManagedComponent.
     * 
     * @param root the persistence root
@@ -237,18 +249,31 @@
     */
    protected ComponentMapper getComponentMapper(ManagedObject parent)
    {
+      return getComponentMapper(parent, true);
+   }
+
+   /**
+    * Get the component mapper for a given ManagedObject.
+    * 
+    * @param parent the managed object
+    * @param fail if no component mapper is registered
+    * @return the component mapper
+    */
+   protected ComponentMapper getComponentMapper(ManagedObject parent, boolean fail)
+   {
       ComponentMapper mapper = null;
       if(parent.getAttachmentName() != null)
          mapper = getComponentMapper(parent.getAttachmentName());
       if(mapper == null && parent.getAttachment() != null)
          mapper = getComponentMapper(parent.getAttachment().getClass().getName());
 
-      if(mapper == null)
+      if(mapper == null && fail)
          throw new IllegalStateException("no mapper registered for type: " + parent.getAttachmentName());
       
       return mapper;
    }
    
+   
    /**
     * Get the component mapper for a persistence root.
     * 

Modified: projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/PersistenceFactory.java
===================================================================
--- projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/PersistenceFactory.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/PersistenceFactory.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -73,6 +73,15 @@
    public abstract void restorePersistenceRoot(PersistenceRoot root, Object attachment, ClassLoader classLoader);
    
    /**
+    * Check whether persistence is supported for a given managed object type.
+    * 
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return true if persistence operations are supported, false otherwise 
+    */
+   public abstract boolean isSupportPersistence(ManagedObject parent, ManagedComponent component);
+   
+   /**
     * Add a ManagedComponent.
     * 
     * @param parent the parent managed object

Modified: projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/repository/PersistenceRepository.java
===================================================================
--- projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/repository/PersistenceRepository.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/persistence/src/main/java/org/jboss/profileservice/persistence/repository/PersistenceRepository.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -40,7 +40,7 @@
     * @return the persistence factory
     */
    PersistenceFactory getPersistenceFactory();
-
+   
    /**
     * Load the repository attachment meta data
     * 

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -22,7 +22,7 @@
 package org.jboss.profileservice.plugins.deploy;
 
 import java.io.InputStream;
-import java.util.Arrays;
+import java.lang.reflect.UndeclaredThrowableException;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -130,11 +130,7 @@
             throw new IllegalStateException("failed to get profile " + TransientProfileActivator.getTransientProfileKey());
          }
       }
-      ModificationStatus status = actionController.perform(actions);
-      if(status.isFailed())
-      {
-         throw new IllegalStateException("failed to add deployment " + dtID, status.getFailure());
-      }
+      checkStatus(actionController.perform(actions));
    }
 
    /**
@@ -169,11 +165,7 @@
          }
          actions.addAction(key, new DeploymentStartAction(managed, mappings.get(key), null));
       }
-      ModificationStatus status = actionController.perform(actions);
-      if(status.isFailed())
-      {
-         throw new IllegalStateException("failed to start deployments " + Arrays.asList(deploymentNames), status.getFailure());
-      }
+      checkStatus(actionController.perform(actions));
    }
    
    /**
@@ -195,11 +187,7 @@
          }
          actions.addAction(key, new DeploymentStopAction(managed, mappings.get(key), null));
       }
-      ModificationStatus status = actionController.perform(actions);
-      if(status.isFailed())
-      {
-         throw new IllegalStateException("failed to stop deployments " + Arrays.asList(deploymentNames), status.getFailure());
-      }
+      checkStatus(actionController.perform(actions));
    }
    
    /**
@@ -230,11 +218,7 @@
             actions.addAction(key, action);
          }
       }
-      ModificationStatus status = actionController.perform(actions);
-      if(status.isFailed())
-      {
-         throw new IllegalStateException("failed to remove deployments " + Arrays.asList(deploymentNames), status.getFailure());
-      }
+      checkStatus(actionController.perform(actions));
    }
 
    /**
@@ -338,5 +322,21 @@
       throw new NoSuchDeploymentException(name);
    }
    
+   protected void checkStatus(ModificationStatus status) throws Exception
+   {
+      if(status.isFailed())
+      {
+         Throwable t = status.getFailure();
+         if(t instanceof Exception)
+         {
+            throw Exception.class.cast(t);
+         }
+         else
+         {
+            throw new UndeclaredThrowableException(t);
+         }
+      }
+   }
+   
 }
 

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-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -79,6 +79,7 @@
          VirtualDeploymentRepository deploymentRepository = resolveDeploymentRepository(getProfile());
          if(deploymentRepository == null)
          {
+            response.setFailure(new IllegalStateException("failed to resolve deployment repository"));
             return false;
          }
          MutableArtifactRepository<FileArtifactId> artifactRepository = resolveRepository(deploymentRepository);
@@ -89,7 +90,8 @@
          // Check if the artifact is already there
          if(isFailIfExists() && artifactRepository.containsArtifact(artifactId))
          {
-            throw new SyncFailedException("Deployment content already exists: "+ artifactName);
+            response.setFailure(new SyncFailedException("Deployment content already exists: "+ artifactName));
+            return false;
          }
          // Check if we need unpack this deployment
          ArtifactTransformer<FileArtifactId> transformer = null;
@@ -101,15 +103,15 @@
          {
             transformer = CopyStreamArtifactTransformer.getInstance();
          }
-         
+         // 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
          deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.LOCKED);
          // Add the deployment
          getProfile().addDeployment(deployment);
-         // Add the content
-         artifactRepository.addArtifact(artifactId, contentIS, transformer);
          
          // Notify
          response.fireModificationEvent(ProfileModificationEvent.create(ProfileModificationType.ADD, getProfile().getKey()));

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -342,10 +342,10 @@
       {
          throw new IllegalArgumentException("null deployment name");
       }
-      ManagedDeployment deployment = null;
       lockRead();
       try
       {
+         ManagedDeployment deployment = null;
          for(final ProfileView view : views)
          {
             ManagedDeployment resolved = view.getManagedDeployment(name); 

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/RemoveComponentAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/RemoveComponentAction.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/RemoveComponentAction.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -24,10 +24,8 @@
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction;
-import org.jboss.profileservice.management.event.ProfileModificationEvent;
 import org.jboss.profileservice.persistence.repository.PersistenceRepository;
 import org.jboss.profileservice.spi.action.ProfileModificationResponse;
-import org.jboss.profileservice.spi.action.ProfileModificationType;
 import org.jboss.profileservice.spi.action.management.ManagementAction;
 import org.jboss.profileservice.spi.action.management.ManagementActionContext;
 
@@ -71,8 +69,12 @@
    {
       try
       {
-         ManagedDeployment deployment = component.getDeployment();
-         persistenceRepository.removeComponent(deployment.getName(), component);         
+         // TODO fail if not supported 
+         if(persistenceRepository.isSupportPersistence(component))
+         {
+            ManagedDeployment deployment = component.getDeployment();
+            persistenceRepository.removeComponent(deployment.getName(), component);
+         }
       }
       catch(Exception e)
       {

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/UpdateComponentAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/UpdateComponentAction.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/UpdateComponentAction.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -129,8 +129,11 @@
             }
          }
          // Persistence
-         ManagedDeployment deployment = serverComponent.getDeployment();
-         persistenceRepository.updateDeployment(deployment.getName(), serverComponent);
+         if(persistenceRepository.isSupportPersistence(serverComponent))
+         {
+            ManagedDeployment deployment = serverComponent.getDeployment();
+            persistenceRepository.updateDeployment(deployment.getName(), serverComponent);
+         }
       }
       catch(Throwable t)
       {

Modified: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeploymentIDSupport.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeploymentIDSupport.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeploymentIDSupport.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -22,6 +22,8 @@
 package org.jboss.test.profileservice.plugins.deploy.support;
 
 import java.net.URL;
+import java.util.Collection;
+import java.util.HashSet;
 
 import org.jboss.deployers.spi.management.deploy.DeploymentID;
 import org.jboss.profileservice.spi.DeploymentOption;
@@ -36,6 +38,7 @@
 
    private URL url;
    private String name;
+   Collection<DeploymentOption> options = new HashSet<DeploymentOption>();
    
    public DeploymentIDSupport(URL url, String name)
    {
@@ -81,22 +84,22 @@
 
    public void addDeploymentOption(DeploymentOption option)
    {
-      
+      options.add(option);
    }
 
    public DeploymentOption[] getDeploymentOptions()
    {
-      return null;
+      return options.toArray(new DeploymentOption[options.size()]);
    }
 
    public boolean hasDeploymentOption(DeploymentOption option)
    {
-      return false;
+      return options.contains(option);
    }
 
    public boolean removeDeploymentOption(DeploymentOption option)
    {
-      return false;
+      return options.remove(option);
    }
    
 }

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/TestVirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/TestVirtualDeploymentRepository.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/TestVirtualDeploymentRepository.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -0,0 +1,152 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.test.profileservice.plugins.deploy.support;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.profileservice.config.VirtualAssemblyConfiguration;
+import org.jboss.profileservice.repository.ProfileDeploymentFactory;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
+import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
+import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
+import org.jboss.profileservice.virtual.assembly.AbstractVirtualDeploymentAssembly;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TestVirtualDeploymentRepository extends AbstractVirtualDeploymentAssembly implements VirtualDeploymentRepository
+{
+   
+   /** The deployment factory. */
+   private static final ProfileDeploymentFactory deploymentFactory = ProfileDeploymentFactory.getInstance();
+   
+   /** The repositories. */
+   private Map<String, ArtifactRepository<ArtifactId>> repositories = new ConcurrentHashMap<String, ArtifactRepository<ArtifactId>>();
+   
+   /** The assembly configuration. */
+   private static final VirtualAssemblyConfiguration assemblyConfiguration = new VirtualAssemblyConfiguration();
+   
+   protected VirtualFile getAssembledRoot()
+   {
+      return assemblyConfiguration.getVirtualAssemblyRoot();
+   }
+
+   public Collection<ArtifactRepositoryId> getRepositoryIDs()
+   {
+      return null;
+   }
+   
+   public ArtifactRepository<ArtifactId> resolveArtifactRepository(ArtifactId artifactId)
+   {
+      return repositories.get(artifactId.getType());
+   }
+   
+   /**
+    * Create a ProfileDeployment.
+    * 
+    * @param deployment the virtual deployment descriptor
+    * @return the profile deployment
+    * @throws Exception for any error
+    */
+   public ProfileDeployment createDeployment(VirtualDeploymentMetaData deployment) throws IOException
+   {
+      if(deployment == null)
+      {
+         throw new IllegalArgumentException("null virtual deployment");
+      }
+      // Assemble the virtual deployment
+      VirtualDeploymentAssemblyContext ctx = assemble(deployment);
+      VirtualFile vf = ctx.getRoot();
+      if(vf == null)
+      {
+         throw new IllegalStateException("Assembled null virtual file");
+      }
+      ProfileDeployment profileDeployment = deploymentFactory.createDeployment(vf, deployment);
+      profileDeployment.getTransientAttachments().putAttachment(VirtualDeploymentAssemblyContext.class.getName(), ctx);
+      return profileDeployment;
+   }
+
+   @Override
+   public VirtualFile getOriginalVirtualFile(ArtifactId artifact) throws IOException
+   {
+      return getRepository(artifact).getOriginalFile(artifact);
+   }
+   
+   /**
+    * Resolve the artifact repository
+    * 
+    * @param artifact the artifact id
+    * @return the artifact repository
+    * @throws IllegalStateException if there is no associated artifact repository
+    */
+   public ArtifactRepository<ArtifactId> getRepository(ArtifactId artifact)
+   {
+      ArtifactRepository<ArtifactId> repository = this.repositories.get(artifact.getType());
+      if(repository == null)
+      {
+         throw new IllegalStateException("failed to find repository for artifact " + artifact);
+      }
+      return repository; 
+   }
+ 
+   public void addRepository(ArtifactRepository<ArtifactId> repository)
+   {
+      if(repository == null)
+         throw new IllegalArgumentException("null repository");
+      if(repository.getIdentifier() == null)
+         throw new IllegalArgumentException("null repository configuration");
+      if(repository.getIdentifier().getType() == null)
+         throw new IllegalArgumentException("null repository configuration type");
+      addRepository(repository.getIdentifier().getType(), repository);
+   }
+   
+   public void addRepository(String type, ArtifactRepository<ArtifactId> repository)
+   {
+      this.repositories.put(type, repository);
+   }
+   
+   public void removeRepository(ArtifactRepository<ArtifactId> repository)
+   {
+      if(repository == null)
+         throw new IllegalArgumentException("null repository");
+      if(repository.getIdentifier() == null)
+         throw new IllegalArgumentException("null repository configuration");
+      if(repository.getIdentifier().getType() == null)
+         throw new IllegalArgumentException("null repository configuration type");
+      removeRepository(repository.getIdentifier().getType(), repository);
+   }
+   
+   public void removeRepository(String type, ArtifactRepository<ArtifactId> repository)
+   {
+      this.repositories.remove(type);
+   }
+   
+}

Modified: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/AbstractDeployTest.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/AbstractDeployTest.java	2010-04-26 02:27:18 UTC (rev 104248)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/AbstractDeployTest.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -21,6 +21,8 @@
 */
 package org.jboss.test.profileservice.plugins.deploy.test;
 
+import java.net.URL;
+
 import org.jboss.profileservice.management.AbstractActionController;
 import org.jboss.profileservice.plugins.management.RegisteredProfileViewsWrapper;
 import org.jboss.profileservice.plugins.spi.ProfileView;
@@ -85,6 +87,11 @@
       view.load();
       return view;
    }
+
+   static URL findResource(String name)
+   {
+      return Thread.currentThread().getContextClassLoader().getResource(name);
+   }
    
 }
 

Added: 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	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/DeployHandlerUnitTestCase.java	2010-04-26 10:13:18 UTC (rev 104249)
@@ -0,0 +1,198 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.test.profileservice.plugins.deploy.test;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collection;
+
+import org.jboss.profileservice.config.ArtifactRepositoriesConfig;
+import org.jboss.profileservice.management.actions.BasicProfileModificationRequest;
+import org.jboss.profileservice.plugins.deploy.actions.DeploymentDistributeAction;
+import org.jboss.profileservice.plugins.deploy.actions.DeploymentRemoveAction;
+import org.jboss.profileservice.profile.HDScanningProfile;
+import org.jboss.profileservice.profile.MutableScanningProfile;
+import org.jboss.profileservice.repository.artifact.AbstractRepositoryId;
+import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
+import org.jboss.profileservice.repository.artifact.file.FileRepositoryConfiguration;
+import org.jboss.profileservice.repository.artifact.file.MutableFileArtifactRepository;
+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;
+import org.jboss.profileservice.spi.action.ModificationStatus;
+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.ArtifactRepositoryId;
+import org.jboss.profileservice.spi.repository.MutableArtifactRepository;
+import org.jboss.profileservice.spi.repository.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;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeployHandlerUnitTestCase extends AbstractDeployTest
+{
+
+   private static final ProfileKey profileKey = new ProfileKey("test");
+   private static final String deploymentName = "other.test.deployment";
+   
+   public DeployHandlerUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testBasic() throws Throwable
+   {
+      URL root = findResource("deployments");
+      URL url = findResource("deployments/test.deployment");
+      assertNotNull(url);
+      
+      // Create and register profile
+      MutableScanningProfile profile = new HDScanningProfile(profileKey, createDeploymentRepository(root.toURI()));
+      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);
+      BasicProfileModificationRequest request = new BasicProfileModificationRequest(ProfileModificationType.ADD);
+      request.addAction(profileKey, action);
+      checkStatus(getActionController().perform(request));
+
+      // Check if it exists
+      FileArtifactId id = new FileArtifactId(deploymentName);
+      assertTrue(profile.getDeploymentRepository().resolveArtifactRepository(id).containsArtifact(id));
+      assertTrue(profile.getDeploymentRepository().resolveArtifactRepository(id).getArtifactFile(id).exists());
+      ProfileDeployment deployment = profile.getDeployment(deploymentName);
+      assertNotNull(deployment);
+      
+      Collection<ModificationInfo> modified = profile.getModifiedDeployments();
+      getLog().debug(modified);
+      assertTrue(modified.isEmpty());
+      
+      // Remove deployment
+      ProfileModificationAction remove = new DeploymentRemoveAction(support, deploymentName, null);
+      request = new BasicProfileModificationRequest(ProfileModificationType.DELETE);
+      request.addAction(profileKey, remove);
+      checkStatus(getActionController().perform(request));
+
+      assertFalse(profile.getDeploymentRepository().resolveArtifactRepository(id).containsArtifact(id));
+      assertFalse(profile.hasDeployment(deploymentName));
+      try
+      {
+         profile.getDeploymentRepository().resolveArtifactRepository(id).getOriginalFile(id);
+         fail();
+      }
+      catch(Exception ok) { }
+      try
+      {
+         profile.getDeploymentRepository().resolveArtifactRepository(id).getArtifactFile(id);
+         fail();
+      }
+      catch(IOException ok) { }
+      try
+      {
+         profile.getDeployment(deploymentName);
+         fail();
+      }
+      catch(NoSuchDeploymentException ok) { }
+   }
+
+   public void testHDScanning() throws Throwable
+   {
+      URL root = findResource("deployments");
+      URL url = findResource("deployments/test.deployment");
+      assertNotNull(url);
+      
+      // Create and register profile
+      MutableScanningProfile profile = new HDScanningProfile(profileKey, createDeploymentRepository(root.toURI()));
+      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);
+      BasicProfileModificationRequest request = new BasicProfileModificationRequest(ProfileModificationType.ADD);
+      request.addAction(profileKey, action);
+      checkStatus(getActionController().perform(request));
+
+      // Check if it exists
+      FileArtifactId id = new FileArtifactId(deploymentName);
+      assertTrue(profile.getDeploymentRepository().resolveArtifactRepository(id).containsArtifact(id));
+      assertTrue(profile.getDeploymentRepository().resolveArtifactRepository(id).getArtifactFile(id).exists());
+      ProfileDeployment deployment = profile.getDeployment(deploymentName);
+      assertNotNull(deployment);
+      
+      assertTrue(profile.getDeploymentRepository().resolveArtifactRepository(id).getArtifactFile(id).delete());
+      deployment.getDeploymentInfo().clearFlag(ProfileDeploymentFlag.LOCKED);
+      
+      Collection<ModificationInfo> modified = profile.getModifiedDeployments();
+      getLog().debug(modified);
+      assertFalse(modified.isEmpty());
+
+   }
+   
+   VirtualDeploymentRepository createDeploymentRepository(URI rootURI) throws Exception
+   {
+      TestVirtualDeploymentRepository repository = new TestVirtualDeploymentRepository();
+      repository.addRepository(createFileRepository(rootURI));
+      return repository;
+   }
+   
+   MutableArtifactRepository createFileRepository(URI rootURI) throws Exception
+   {
+      ArtifactRepositoryId repositoryID = new AbstractRepositoryId("test", FileArtifactId.TYPE);
+      MutableFileArtifactRepository repository = new MutableFileArtifactRepository(repositoryID, rootURI, createRepositoryConfiguration());
+      repository.create();
+      return repository;
+   }
+   
+   FileRepositoryConfiguration createRepositoryConfiguration() throws URISyntaxException
+   {
+      FileRepositoryConfiguration configuration = new FileRepositoryConfiguration();
+      configuration.setBackupPolicy(VFSBackupPolicy.BACKUP);
+      configuration.setBackupURI(ArtifactRepositoriesConfig.getInstance().createBackupURI());
+      return configuration;
+   }
+
+   static void checkStatus(ModificationStatus status) throws Throwable
+   {
+      if(status.getFailure() != null)
+      {
+         throw status.getFailure();
+      }      
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/resources/deployments/test.deployment
===================================================================




More information about the jboss-cvs-commits mailing list