[jboss-cvs] JBossAS SVN: r105333 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/bootstrap and 31 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 28 10:36:16 EDT 2010


Author: emuckenhuber
Date: 2010-05-28 10:36:12 -0400 (Fri, 28 May 2010)
New Revision: 105333

Added:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileActivationService.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileActivationWrapper.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileValidationUtil.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/BasicProfileDeployment.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/NoopVirtualDeploymentMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeploymentFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfileActivationMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfileActivationParametersMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/AbstractMetaDataContext.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/AbstractProfileRepository.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/CompositeResolutionFilter.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileMetaDataContext.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileRepositories.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileRepository.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileRequirementResolutionContext.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileResolutionFilter.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileResolutionNode.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ActivationProfileMetaData.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/TestProfileActivator.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivation.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivationConfiguration.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivationParameters.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivator.java
Removed:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.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/deployment/ProfileDeploymentRegistry.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/NoopVirtualDeploymentMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java
Modified:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceBootstrap.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileActivationCallback.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConfig.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConstants.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/ProfileDeployAction.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileRequirementDependencyItem.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/AbstractProfileDeployment.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/DeploymentBuilder.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeployerPluginRegistry.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/TwoPCActionWrapper.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/BasicProfileModificationRequest.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ProfileConfigurationExt.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/MutableScanningProfile.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/KernelDeploymentBuilder.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/BasicProfileMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/BasicDomainMetaDataVisitor.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/XmlDomainMetaDataRepository.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/helpers/AbstractProfileMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/ArtifactRepositoryManager.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/virtual/AbstractVirtualDeploymentRepository.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/BasicResolverFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/domain/support/AbstractDomainMetaDataVisitor.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/AbstractResolverTest.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ProcessingUnitTestCase.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/UserRequirementUnitTestCase.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/MainDeployerPlugin.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/NoopProfileFactory.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/support/VDFDeploymentBuilder.java
   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/virtual/support/TestVirtualDeploymentRepository.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java
   projects/profileservice/trunk/core/src/test/resources/metadata/domain/domain1.xml
   projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml
   projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml
   projects/profileservice/trunk/core/src/test/resources/system/profiles/core-profiles.xml
   projects/profileservice/trunk/core/src/test/resources/system/profiles/stack-profiles.xml
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileMetaDataVisitor.java
Log:
initial work on externalizing lifecycle control of a profile.

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -22,26 +22,15 @@
 package org.jboss.profileservice;
 
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
 
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.ControllerStateModel;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.DependencyItem;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.profileservice.dependency.ProfileControllerContext;
-import org.jboss.profileservice.dependency.ProfileServiceController;
+import org.jboss.profileservice.dependency.ProfileActivationService;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.util.JBossStringBuilder;
 
 /**
  * The abstract profile service.
@@ -59,15 +48,15 @@
    private DeploymentManager deploymentMgr;
    
    /** The controller. */
-   private final ProfileServiceController controller;
+   private final ProfileActivationService activationService;
    
-   public AbstractProfileService(ProfileServiceController controller)
+   public AbstractProfileService(ProfileActivationService activationService)
    {
-      if(controller == null)
+      if(activationService == null)
       {
-         throw new IllegalArgumentException("null controller");
+         throw new IllegalArgumentException("null activation service");
       }
-      this.controller = controller;
+      this.activationService = activationService;
    }
    
    /**
@@ -111,7 +100,7 @@
     */
    public Collection<ProfileKey> getProfileKeys()
    {
-      return controller.getRegisteredProfiles();
+      return activationService.getRegisteredKeys();
    }
    
    /**
@@ -119,7 +108,7 @@
     */
    public Collection<ProfileKey> getActiveProfileKeys()
    {
-      return controller.getActiveProfiles();
+      return activationService.getInstalledKeys();
    }
    
    /**
@@ -139,13 +128,9 @@
       {
          throw new IllegalArgumentException("null profile meta data");
       }
-      if(controller.isRegistered(metaData))
-      {
-         return controller.resolveProfileKey(metaData);
-      }
       try
       {
-         return controller.registerAndInstallContext(metaData, profile);
+         return activationService.register(metaData, profile);
       }
       catch(Exception e)
       {
@@ -166,18 +151,7 @@
       {
          throw new IllegalArgumentException("null profile key");
       }
-      try
-      {
-         controller.activate(key);
-      }
-      catch(Exception e)
-      {
-         throw e;
-      }
-      catch(Throwable t)
-      {
-         throw new RuntimeException(t);
-      }
+      activationService.activate(key);
    }
    
    /**
@@ -189,18 +163,7 @@
       {
          throw new IllegalArgumentException("null profile key");
       }
-      if(controller.isInstalled(key) == false)
-      {
-         return;
-      }
-      try
-      {
-         controller.deactivate(key);
-      }
-      catch(Throwable t)
-      {
-         throw new RuntimeException(t);
-      }
+      activationService.deactivate(key);
    }
    
    /**
@@ -212,11 +175,7 @@
       {
          throw new IllegalArgumentException("null profile key");
       }
-      if(controller.isInstalled(key))
-      {
-         throw new RuntimeException("cannot unregister a installed profile");
-      }
-      controller.unInstallAndUnregisterContext(key);
+      activationService.uninstall(key);
    }
 
    /**
@@ -228,156 +187,7 @@
       {
          throw new IllegalArgumentException("null profile key");
       }
-      validate(controller.getRegisteredContext(key));
+      activationService.validate(key);
    }
-
-   /**
-    * Check if all dependencies are satisfied and the profile was installed successfully.
-    * 
-    * @param context the context to validate
-    * @throws Exception
-    */
-   protected void validate(ControllerContext context) throws Exception
-   {
-      // 
-      Set<String> errors = new HashSet<String>();
-      Map<Object, String> map = new HashMap<Object, String>();
-      // Validate the context, with it's dependencies
-      internalValidateContext(context, errors, map);
-      // Create and throw the Exception
-      logErrors(errors, map.values());
-   }
-   
-   /**
-    * Validate the context and create the error messages if needed.
-    * 
-    * TODO maybe recurse into dependent contexts?
-    * 
-    * @param ctx the context to validate
-    * @param errors a set of errors
-    * @param incomplete a set of incomplete contexts
-    */
-   protected void internalValidateContext(ControllerContext ctx, Set<String> errors, Map<Object, String> incomplete)
-   {
-      Object name = ctx.getName();
-      if(ctx instanceof ProfileControllerContext)
-      {
-         name = ProfileControllerContext.class.cast(ctx).getProfileKey();
-      }
-      if (ctx.getState().equals(ControllerState.ERROR))
-      {
-         JBossStringBuilder builder = new JBossStringBuilder();
-         builder.append("Profile: ").append(name);
-         builder.append(" in error due to ").append(ctx.getError()); 
-         errors.add(builder.toString());
-      }
-      else
-      {
-         if(incomplete.containsKey(name))
-            return;
-         
-         DependencyInfo dependsInfo = ctx.getDependencyInfo();
-         Set<DependencyItem> depends = dependsInfo.getIDependOn(null);
-         for (DependencyItem item : depends)
-         {
-            if(item.isResolved())
-               continue;
-            
-            ControllerState dependentState = item.getDependentState();
-            if (dependentState == null)
-               dependentState = ControllerState.INSTALLED;
-            
-            ControllerState otherState = null;
-            ControllerContext other = null; 
-            Object iDependOn = item.getIDependOn();
-
-            if (name.equals(iDependOn) == false)
-            {
-               if (iDependOn != null)
-               {
-                  other = controller.getContext(iDependOn);
-                  if (other != null)
-                     otherState = other.getState();
-               }
-
-               boolean print = true;
-               if (otherState != null && otherState.equals(ControllerState.ERROR) == false)
-               {
-                  ControllerStateModel states = controller.getStates();
-                  if (states.isBeforeState(otherState, dependentState) == false)
-                     print = false;
-               }
-
-               if (print)
-               {
-                  JBossStringBuilder buffer = new JBossStringBuilder();
-                  buffer.append(name).append(" is missing following dependencies: ");
-
-                  buffer.append(iDependOn).append('{').append(dependentState.getStateString());
-                  buffer.append(':');
-                  if (iDependOn == null)
-                  {
-                     buffer.append("** UNRESOLVED " + item.toHumanReadableString() + " **");
-                  }
-                  else
-                  {
-                     if (other == null)
-                     {
-                        buffer.append("** NOT FOUND **");
-                     }
-                     else
-                     {
-                        buffer.append(otherState.getStateString());
-                     }
-                  }
-                  buffer.append('}');
-
-                  // Add Error message and check other context.
-                  incomplete.put(name, buffer.toString());
-                  if(other!= null && incomplete.containsKey(other) == false)
-                  {
-                     internalValidateContext(other, errors, incomplete);
-                  }
-               }
-            }
-         }  
-      }
-   }
-   
-   /**
-    * This method just groups the errors and incomplete messages and throws an
-    * Exception if there are errors or missing dependencies.
-    * 
-    * @param errors a set of errors
-    * @param incomplete a set of missing dependencies
-    * @throws Exception in case there are errors or missing dependencies
-    */
-   protected void logErrors(Set<String> errors, Collection<String> incomplete) throws Exception
-   {
-      if(errors.isEmpty() && incomplete.isEmpty())
-         return;
-
-      JBossStringBuilder buffer = new JBossStringBuilder();
-      buffer.append("Incompletely deployed:\n");
-      
-      // Append errors
-      if(errors.size() != 0)
-      {
-         buffer.append("\n*** PROFILES IN ERROR: Name -> Error\n");
-         for(String error : errors)
-            buffer.append(error).append('\n');
-      }
-      
-      // Append missing dependencies
-      if(incomplete.size() != 0)
-      {
-         buffer.append("\n*** PROFILES MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}\n");
-         for(String missing : incomplete)
-            buffer.append(missing).append('\n');
-      }
-      
-      // Fail
-      throw new IllegalStateException(buffer.toString());
-   }
-   
+  
 }
\ No newline at end of file

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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceBootstrap.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -30,6 +30,7 @@
 import org.jboss.profileservice.domain.AbstractDomainMetaData;
 import org.jboss.profileservice.domain.spi.DomainMetaData;
 import org.jboss.profileservice.profile.metadata.domain.BasicDomainMetaDataVisitor;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
 import org.jboss.profileservice.resolver.BasicResolverFactory;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.ProfileKey;
@@ -75,14 +76,14 @@
    protected ProfileService createProfileService(AbstractDomainMetaData domainMetaData) throws Throwable
    {
       super.initialize(domainMetaData);
-      this.resolverFactory = new BasicResolverFactory(getMetaDataRegistry(), this);
+      this.resolverFactory = new BasicResolverFactory(getProfileRepository(), this);
       return getProfileService();
    }
 
    protected void start(AbstractDomainMetaData domainMetaData) throws Throwable
    {
       ProfileRequirementResolver resolver = createResolver(domainMetaData);
-      BasicDomainMetaDataVisitor visitor = new BasicDomainMetaDataVisitor(resolver, getMetaDataRegistry());
+      BasicDomainMetaDataVisitor visitor = new BasicDomainMetaDataVisitor(resolver, getProfileRepository());
       // visit the domain meta data
       domainMetaData.visit(visitor);
       // Resolve & activate
@@ -90,14 +91,15 @@
       resolver.deploy();
    }
 
-   public void activate(ProfileKey key) throws Exception
+   public void activate(ProfileMetaDataContext context) throws Exception
    {
       checkShutdown();
+      final ProfileKey key = context.getKey();
       if(this.activatedProfiles.contains(key) == false)
       {
          try
          {
-            getController().installRegisteredContext(key);
+            getActivationService().installProfile(context, null);
          }
          catch(Exception e)
          {
@@ -107,7 +109,7 @@
          {
             throw new RuntimeException(t); 
          }
-         getProfileService().activateProfile(key);
+         getActivationService().activate(key);
          // Add in reversed order
          this.activatedProfiles.add(0, key);
       }
@@ -125,7 +127,7 @@
       {
          try
          {
-            getProfileService().deactivateProfile(key);
+            getActivationService().deactivate(key);
          }
          catch(NoSuchProfileException ignore)
          {

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -31,11 +31,12 @@
 import org.jboss.profileservice.config.ProfileServiceConfig;
 import org.jboss.profileservice.config.ProfileServiceConstants;
 import org.jboss.profileservice.config.ServerConfiguration;
-import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
-import org.jboss.profileservice.dependency.ProfileServiceController;
+import org.jboss.profileservice.dependency.ProfileActivationService;
 import org.jboss.profileservice.domain.AbstractDomainMetaData;
 import org.jboss.profileservice.domain.ManagementDomainMetaData;
 import org.jboss.profileservice.domain.ServerMetaData;
+import org.jboss.profileservice.repository.ProfileRepositories;
+import org.jboss.profileservice.repository.ProfileRepository;
 import org.jboss.profileservice.spi.ProfileService;
 
 /**
@@ -51,11 +52,11 @@
    /** The profileservice config. */
    private final ProfileServiceConfig config;
    
-   /** The meta data registry. */
-   private ProfileMetaDataRegistry registry;
+   /** The profile repository. */
+   protected ProfileRepositories profileRepository;
    
-   /** The profile service controller. */
-   private ProfileServiceController controller;
+   /** The activation service. */
+   private ProfileActivationService activationService;
    
    /** The profile service. */
    private ProfileService profileService;
@@ -80,17 +81,13 @@
    }
    
    /**
-    * Get the meta data registry.
+    * Get the profile repository.
     * 
-    * @return the meta data registry.
+    * @return the profile repository
     */
-   protected ProfileMetaDataRegistry getMetaDataRegistry()
+   public ProfileRepository getProfileRepository()
    {
-      if(registry == null)
-      {
-         throw new IllegalStateException("ProfileService not initialized");
-      }
-      return registry;
+      return profileRepository;
    }
    
    /**
@@ -108,17 +105,13 @@
    }
    
    /**
-    * Get the profile service controller.
+    * Get the activation service.
     * 
-    * @return the profile service controller
+    * @return the activation service.
     */
-   public ProfileServiceController getController()
+   protected ProfileActivationService getActivationService()
    {
-      if(controller == null)
-      {
-         throw new IllegalStateException("ProfileService not initialized");
-      }
-      return controller;
+      return activationService;
    }
    
    /**
@@ -152,27 +145,27 @@
     */
    public ProfileService initializeProfileService() throws Throwable
    {
-      // Create the registry
-      this.registry = createProfileMetaDataRegistry();
+      // Create the repository
+      this.profileRepository = createProfileMetaDataRepository();
       // Create the controller
-      this.controller = new ProfileServiceController(getKernel().getController(), registry, config);
+      this.activationService = new ProfileActivationService(getKernel(), this.profileRepository);
       // Create the profile service
-      this.profileService = new AbstractProfileService(controller);
+      this.profileService = new AbstractProfileService(activationService);
       register(ProfileServiceConstants.PROFILESERVICE_NAME, profileService);
       return profileService;
    }
 
    /**
-    * Create the profile meta data registry.
+    * Create the profile meta data repository.
     * 
-    * @return the meta data registry
+    * @return the meta data repository
     * @throws Throwable
     */
-   protected ProfileMetaDataRegistry createProfileMetaDataRegistry() throws Throwable
+   protected ProfileRepositories createProfileMetaDataRepository() throws Throwable
    {
-      ProfileMetaDataRegistry localDomain = new ProfileMetaDataRegistry(config);
-      register(ProfileServiceConstants.METADATA_REGISTRY_NAME, localDomain);
-      return localDomain;
+      ProfileRepositories profileRepository = new ProfileRepositories(config);
+      register(ProfileServiceConstants.PROFILEREPOSITORY_NAME, profileRepository);
+      return profileRepository;
    }
    
    /**

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileActivationCallback.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileActivationCallback.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileActivationCallback.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -21,7 +21,7 @@
 */
 package org.jboss.profileservice.bootstrap;
 
-import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -33,10 +33,10 @@
    /**
     * Activate a profile.
     * 
-    * @param key the profile key
+    * @param context the profile context
     * @throws Exception
     */
-   void activate(ProfileKey key) throws Exception;
+   void activate(ProfileMetaDataContext context) throws Exception;
    
 }
 

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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConfig.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -21,10 +21,14 @@
 */
 package org.jboss.profileservice.config;
 
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 import org.jboss.profileservice.dependency.plugin.ProfileLifeCycleCallbackActions;
 import org.jboss.profileservice.deployment.ProfileDeployerPluginRegistry;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.activation.ProfileActivator;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 
 /**
@@ -64,6 +68,9 @@
    /** The assembly configuration. */
    private VirtualAssemblyConfiguration assemblyConfiguration = new VirtualAssemblyConfiguration();
    
+   /** The activators. */
+   private Map<String, ProfileActivator> activators = new ConcurrentHashMap<String, ProfileActivator>();
+   
    public ProfileServiceConfig()
    {
       //
@@ -155,6 +162,45 @@
    {
       this.assemblyConfiguration = assemblyConfiguration;
    }
+ 
+   /**
+    * Get the activator.
+    * 
+    * @param name the profile name
+    * @return the activator
+    */
+   public ProfileActivator getProfileActivator(String name)
+   {
+      return this.activators.get(name);
+   }
    
+   /**
+    * Add an profile activator callback.
+    * 
+    * @param activator the activator
+    */
+   public void addProfileActivator(ProfileActivator activator)
+   {
+      if(activator == null)
+      {
+         throw new IllegalArgumentException("null activator");
+      }
+      if(activator.getActivatorReference() == null)
+      {
+         throw new IllegalArgumentException("null artivator reference");
+      }
+      this.activators.put(activator.getActivatorReference(), activator);
+   }
+   
+   /**
+    * Remove an profile activator.
+    * 
+    * @param activator the activator.
+    */
+   public void removeProfileActivator(ProfileActivator activator)
+   {
+      this.activators.remove(activator.getActivatorReference());
+   }
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConstants.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConstants.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConstants.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -32,7 +32,7 @@
    String PROFILESERVICE_NAME = "jboss.profileservice:service=ProfileService";
 
    /** The local profile domain bean name. */
-   String METADATA_REGISTRY_NAME = "jboss.profileservice:service=ProfileMetaDataRegistry";
+   String PROFILEREPOSITORY_NAME = "jboss.profileservice:service=ProfileRepository";
    
    
 }

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileActivationService.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileActivationService.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileActivationService.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,346 @@
+/*
+* 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.dependency;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.beans.metadata.api.model.AutowireType;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.builder.ParameterMetaDataBuilder;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.LifecycleCallbackItem;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.profileservice.config.ProfileServiceConfig;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.repository.ProfileRepositories;
+import org.jboss.profileservice.repository.ProfileRepository;
+import org.jboss.profileservice.resolver.ProfileResolutionNode;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.activation.ProfileActivation;
+import org.jboss.profileservice.spi.activation.ProfileActivator;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * The profile activation service. 
+ * 
+ * @author Emanuel Muckenhuber
+ */
+public class ProfileActivationService
+{
+
+   /** The kernel. */
+   private final Kernel kernel;
+
+   /** The profile service meta data repository. */
+   private final ProfileRepositories profileRepository;
+   
+   /** The activations. */
+   private List<ProfileActivationWrapper> activations = new CopyOnWriteArrayList<ProfileActivationWrapper>();
+   private Map<String, ProfileActivationWrapper> activationsByName = new ConcurrentHashMap<String, ProfileActivationWrapper>();
+   
+   public ProfileActivationService(Kernel kernel, ProfileRepositories metaDataRepository)
+   {
+      this.kernel = kernel;
+      this.profileRepository = metaDataRepository;
+      // Initialize contoller
+      ProfileControllerContextActions.initializeController(kernel.getController());
+   }
+
+   /**
+    * Get the profile repository.
+    * 
+    * @return the profile repository
+    */
+   public ProfileRepository getProfileServiceRepository()
+   {
+      return profileRepository;
+   }
+   
+   /**
+    * Get the registered keys.
+    * 
+    * @return the registered keys
+    */
+   public Collection<ProfileKey> getRegisteredKeys()
+   {
+      final Set<ProfileKey> registered = new HashSet<ProfileKey>();
+      for(ProfileActivation activation : activations)
+      {
+         registered.add(activation.getKey());
+      }
+      return registered;
+   }
+   
+   /**
+    * Get the installed keys.
+    * 
+    * @return the installed keys
+    */
+   public Collection<ProfileKey> getInstalledKeys()
+   {
+      final Set<ProfileKey> installed = new HashSet<ProfileKey>();
+      for(ProfileActivation activation : activations)
+      {
+         if(activation.isStarted())
+         {
+            installed.add(activation.getKey());
+         }
+      }
+      return installed;
+   }
+   
+   /**
+    * Get the activator.
+    * 
+    * @param name the profile name
+    * @return the activator
+    */
+   ProfileActivator getProfileActivator(String name)
+   {
+      return getConfiguration().getProfileActivator(name);
+   }
+
+   /**
+    * Register a profile meta data.
+    * 
+    * @param metaData the profile meta data
+    * @param profile the profile
+    * @return the profile key
+    * @throws Throwable for any error
+    */
+   public ProfileKey register(ProfileMetaData metaData, Profile profile) throws Throwable
+   {
+      ProfileMetaDataContext context = this.profileRepository.registerMetaData(metaData);
+      installProfile(context, profile);
+      return context.getKey();
+   }
+   
+   /**
+    * Activate a profile. 
+    * 
+    * @param key the profile key
+    * @throws NoSuchProfileException 
+    * @throws Exception
+    */
+   public void activate(ProfileKey key) throws NoSuchProfileException, Exception
+   {
+      activateProfile(key.getName());
+   }
+   
+   /**
+    * Deactivate a profile.
+    * 
+    * @param key the profile key
+    * @throws NoSuchProfileException
+    */
+   public void deactivate(ProfileKey key) throws NoSuchProfileException
+   {
+      deactivateProfile(key.getName());
+   }
+   
+   /**
+    * Uninstall and unregister a profile.
+    * 
+    * @param key the profile key
+    */
+   public void uninstall(ProfileKey key)
+   {
+      uninstallProfile(key.getName());
+      profileRepository.unRegisterMetaData(key.getName());
+   }
+   
+   /**
+    * Validate a profile and make sure it's in a valid state.
+    * 
+    * @param key the profile key
+    * @throws NoSuchProfileException
+    * @throws Exception
+    */
+   public void validate(ProfileKey key) throws NoSuchProfileException, Exception
+   {
+      final String profileName = key.getName();
+      getProfileActivation(profileName).validate();
+   }
+   
+   /**
+    * Create a profile activator for a given processed profile meta data
+    * 
+    * @param metaData the meta data context
+    * @param profile the instantiated profile (optional) 
+    * @throws Throwable
+    */
+   public void installProfile(ProfileMetaDataContext metaData, Profile profile) throws Throwable
+   {
+      ProfileControllerContext context = createControllerContext(metaData, profile);
+      getController().install(context);
+      ProfileActivationWrapper wrapper = new ProfileActivationWrapper(context);
+      this.activations.add(wrapper);
+      this.activationsByName.put(metaData.getProfileName(), wrapper);
+   }
+
+   protected void activateProfile(final String profileName) throws NoSuchProfileException, Exception
+   {
+      getProfileActivation(profileName).start();
+   }
+   
+   protected void deactivateProfile(final String profileName) throws NoSuchProfileException
+   {
+      getProfileActivation(profileName).stop();
+   }
+   
+   protected void uninstallProfile(String profileName)
+   {
+      final ProfileActivationWrapper wrapper = this.activationsByName.remove(profileName);
+      if(wrapper != null)
+      {
+         if(wrapper.isStarted())
+         {
+            wrapper.stop();
+         }
+         this.activations.remove(wrapper);
+         ProfileControllerContext context = wrapper.getContext();
+         getController().uninstall(context.getName());
+      }
+   }
+   
+   protected boolean isInstalled(final String profileName)
+   {
+      return this.activationsByName.containsKey(profileName);
+   }
+   
+   protected ProfileActivationWrapper getProfileActivation(String profileName) throws NoSuchProfileException
+   {
+      final ProfileActivationWrapper wrapper = this.activationsByName.get(profileName);
+      if(wrapper == null)
+      {
+         throw new NoSuchProfileException("no such profile " + profileName);
+      }
+      return wrapper;
+   }
+   
+   Kernel getKernel()
+   {
+      return kernel;
+   }
+   
+   KernelController getController()
+   {
+      return getKernel().getController();
+   }
+
+   ProfileControllerContext createControllerContext(final ProfileMetaDataContext context, Profile profile)
+   {
+      final ProfileKey key = context.getKey();
+      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)
+      {
+         for(final ProfileKey alias : context.getAliases())
+         {
+            builder.addAlias(alias);
+         }
+      }
+      if(profile != null)
+      {
+         builder.setBean(profile.getClass().getName());
+      }
+      else
+      {
+         // Constructor
+         final ProfileFactory<ProfileMetaData, Profile> profileFactory = getConfiguration().getProfileFactory();
+         builder.setFactory(profileFactory);
+         builder.setFactoryMethod("createProfile");
+         builder.addConstructorParameter(ProfileKey.class.getName(), context.getKey());
+         builder.addConstructorParameter(ProfileMetaData.class.getName(), context.getProfileMetaData());
+         // Uninstall
+         // TODO remove name to TypedProfileFactory
+         ParameterMetaDataBuilder parameters = builder.addUninstallWithParameters("destroyProfile", "TypedProfileFactory");
+         parameters.addParameterMetaData(ProfileMetaData.class.getName(), context.getProfileMetaData());
+         parameters.addParameterMetaData(Profile.class.getName(), builder.createThis());         
+      }
+      // No autowire
+      builder.setAutowireType(AutowireType.NONE);
+      
+      // Create the ControllerContext
+      final ProfileControllerContext kCtx = new ProfileControllerContext(builder.getBeanMetaData(), this, profile);
+      // We control the lifecycle
+      kCtx.setMode(ControllerMode.MANUAL);
+      // Describe the the controller context
+      kCtx.setDependencyContext(context);
+      
+      if(context instanceof ProfileResolutionNode)
+      {
+         ProfileResolutionNode.class.cast(context).describe(kCtx);
+      }
+      else
+      {
+         final Collection<ProfileRequirement> requirements = context.getRequirements();
+         if(requirements != null && requirements.isEmpty() == false)
+         {
+            final DependencyInfo dependencyInfo = kCtx.getDependencyInfo();
+            for(final ProfileRequirement requirement : requirements)
+            {
+               final ControllerState dependentState = ControllerState.INSTALLED;
+               dependencyInfo.addIDependOn(new ProfileRequirementDependencyItem(kCtx,
+                     requirement, null, dependentState));
+            }
+         }
+      }
+
+      // Add the lifecycle callback
+      final LifecycleCallbackItem callbackItem = getConfiguration().getLifeCycleActions();
+      if(callbackItem != null)
+      {
+         kCtx.getDependencyInfo().addLifecycleCallback(callbackItem);
+      }
+
+      // Update scope info
+      // kCtx.getScopeInfo().getScope().addScope(CommonLevels.SERVER, key);
+      // kCtx.getScopeInfo().getMutableScope().addScope(CommonLevels.SERVER, key);
+      
+      // We are done here
+      return kCtx;
+   }
+
+   ProfileServiceConfig getConfiguration()
+   {
+      return profileRepository.getConfiguration();
+   }
+   
+}
+

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileActivationWrapper.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileActivationWrapper.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileActivationWrapper.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,260 @@
+/*
+* 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.dependency;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.ControllerStateModel;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.activation.ProfileActivation;
+import org.jboss.profileservice.spi.activation.ProfileActivationConfiguration;
+import org.jboss.profileservice.spi.activation.ProfileActivator;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * The activation wrapper, delegating activation to a profile activator.
+ * 
+ * @author Emanuel Muckenhuber
+ */
+class ProfileActivationWrapper implements ProfileActivation
+{
+
+   /** The actual activation. */
+   private final BasicProfileActivation activation;
+   
+   /** The activation service. */
+   private final ProfileActivationService activationService;
+   
+   public ProfileActivationWrapper(ProfileControllerContext context)
+   {
+      this.activation = new BasicProfileActivation(context);
+      this.activationService = context.getActivationService();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ProfileKey getKey()
+   {
+      return activation.getKey();
+   }
+   
+   /**
+    * {@inheritDoc}
+    */   
+   public ProfileMetaData getProfileMetaData()
+   {
+      return activation.getProfileMetaData();
+   }
+
+   public void start() throws Exception
+   {
+      if(activation.isStarted())
+      {
+         return;
+      }
+      // describe
+      activation.describe();
+      // resolve activator
+      ProfileActivator activator = resolveActivator(getActivationConfiguration());
+      if(activator != null)
+      {
+         // Register at the activator
+         activator.activate(activation);
+         // Nothing more to do
+         return;
+      }
+      // Start
+      activation.start();
+   }
+   
+   public void stop()
+   {
+      ProfileActivator activator = resolveActivator(getActivationConfiguration());
+      if(activator != null)
+      {
+         // Unregister at the activator
+         activator.deactivate(activation);
+         // Nothing more to do
+         return;
+      }
+      // Stop
+      activation.stop();
+   }
+
+   public boolean isResolved()
+   {
+      return activation.isResolved();
+   }
+   
+   public boolean isStarted()
+   {
+      return activation.isStarted();
+   }
+   
+   public void validate() throws Exception
+   {
+      activation.validate();
+   }
+   
+   ProfileActivator resolveActivator(ProfileActivationConfiguration configuration)
+   {
+      if(configuration != null && configuration.getProfileActivatorRef() != null)
+      {
+         return activationService.getProfileActivator(configuration.getProfileActivatorRef());
+      }
+      return null;
+   }
+   
+   ProfileActivationConfiguration getActivationConfiguration()
+   {
+      return activation.getActivationConfiguration();
+   }
+   
+   ProfileControllerContext getContext()
+   {
+      return activation.getContext();
+   }
+   
+   public String toString()
+   {
+      return getContext().toString();
+   }
+ 
+   /**
+    * The profile activation controlling the lifecycle of a profile.
+    */
+   static class BasicProfileActivation implements ProfileActivation
+   {
+
+      /** The profile controller context. */
+      private final ProfileControllerContext context;
+      
+      public BasicProfileActivation(ProfileControllerContext context)
+      {
+         this.context = context;
+      }
+      
+      ProfileControllerContext getContext()
+      {
+         return context;
+      }
+      
+      public ProfileKey getKey()
+      {
+         return context.getProfileKey();
+      }
+
+      public ProfileMetaData getProfileMetaData()
+      {
+         return context.getProfileMetaData();
+      }
+
+      public boolean isResolved()
+      {
+         if(isBeforeState(ControllerState.DESCRIBED))
+         {
+            return false;
+         }
+         return context.getDependencyInfo().resolveDependencies(getController(), ControllerState.DESCRIBED);
+      }
+      
+      public boolean isStarted()
+      {
+         return isBeforeState(ControllerState.INSTALLED) == false;
+      }
+
+      public void start() throws Exception
+      {
+         try
+         {
+            getController().change(context, ControllerState.INSTALLED);
+         }
+         catch(Exception e)
+         {
+            throw e;
+         }
+         catch(Throwable t)
+         {
+            throw new RuntimeException(t);
+         }
+      }
+
+      public void stop()
+      {
+         if(isBeforeState(ControllerState.DESCRIBED))
+         {
+            return;
+         }
+         try
+         {
+            getController().change(context, ControllerState.DESCRIBED);
+         }
+         catch(Throwable t)
+         {
+            throw new RuntimeException(t);
+         }
+      }
+      
+      public void validate() throws Exception
+      {
+         ProfileValidationUtil.validate(context);
+      }
+
+      void describe() throws Exception 
+      {
+         if(isBeforeState(ControllerState.DESCRIBED))
+         {
+            try
+            {
+               getController().change(context, ControllerState.DESCRIBED);
+            }
+            catch(Exception e)
+            {
+               throw e;
+            }
+            catch(Throwable t)
+            {
+               throw new RuntimeException(t);
+            }         
+         }
+      }
+      
+      boolean isBeforeState(ControllerState state)
+      {
+         final Controller controller = context.getController();
+         final ControllerStateModel model = controller.getStates();
+         return model.isBeforeState(context.getState(), state);
+      }
+      
+      Controller getController()
+      {
+         return context.getController();
+      }
+      
+      ProfileActivationConfiguration getActivationConfiguration()
+      {
+         return context.getDependencyContext().getActivationConfiguration();
+      }
+   }
+   
+}
\ No newline at end of file

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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -22,13 +22,16 @@
 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;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.resolver.ProfileRequirementResolutionContext;
+import org.jboss.profileservice.resolver.ProfileResolutionFilter;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 import org.jboss.profileservice.spi.managed.ManagedProfile;
 import org.jboss.profileservice.spi.managed.ManagedProfileConfiguration;
 import org.jboss.profileservice.spi.managed.ManagedProfileDeployer;
@@ -43,23 +46,22 @@
 public class ProfileControllerContext extends AbstractKernelControllerContext implements ManagedProfile
 {
 
+   /** The profile activation service. */
+   private ProfileActivationService activationService;
+   
    /** Some additional meta data information. */
-   private ProfileDependencyContext metaDataContext;
+   private ProfileMetaDataContext metaDataContext;
   
-   protected ProfileControllerContext(BeanMetaData metaData, Object target)
+   protected ProfileControllerContext(BeanMetaData metaData, ProfileActivationService activationService, Object target)
    {
       super(null, metaData, target != null ? ProfileControllerContextActions.getNoInstantiate() : ProfileControllerContextActions.getInstance() , target);
+      this.activationService = activationService;
    }
    
    public Profile getProfile()
    {
       return Profile.class.cast(super.getTarget());
    }
-
-   public void setController(Controller controller)
-   {
-      super.setController(controller);
-   }
    
    public ProfileKey getProfileKey()
    {
@@ -90,21 +92,32 @@
       return getDeployerPlugin().getManagedDeployment(deployment);
    }
    
-   public ProfileDependencyContext getDependencyContext()
+   public ProfileMetaDataContext getDependencyContext()
    {
       return metaDataContext;
    }
 
    ProfileDeployerPlugin getDeployerPlugin()
    {
-      return getDependencyContext().getDeployer();
+      return getActivationService().getConfiguration().getDeployerRegistry().getDeployer(getProfileMetaData());
    }
    
-   void setDependencyContext(ProfileDependencyContext ctx)
+   void setDependencyContext(ProfileMetaDataContext ctx)
    {
       this.metaDataContext = ctx;
    }
    
+   ProfileKey resolve(ProfileRequirement requirement)
+   {
+      final ProfileRequirementResolutionContext context = new ProfileRequirementResolutionContext(getDependencyContext(), requirement);
+      return getActivationService().getProfileServiceRepository().resolve(context, ProfileResolutionFilter.NOOP_FILTER);
+   }
+   
+   ProfileActivationService getActivationService()
+   {
+      return activationService;
+   }
+   
    static class DelegateDeployer implements ManagedProfileDeployer
    {
 
@@ -134,7 +147,6 @@
       {
          delegate.getDeployerPlugin().removeDeployment(delegate.getProfileKey(), deployment);
       }
-      
    }
    
 }

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -1,229 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.profileservice.dependency;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.profileservice.deployment.ProfileDeployerPlugin;
-import org.jboss.profileservice.profile.metadata.helpers.AbstractProfileKeyCapability;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.dependency.ProfileCapability;
-import org.jboss.profileservice.spi.dependency.ProfileRequirement;
-import org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
-import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
-
-/**
- * A internal profile meta data dependency context. This represents the processed 
- * profile meta data, which is then used to create the actual {@link ControllerContext} 
- * since features might depend on other profiles to be installed/deployed
- * first before they can be processed.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ProfileDependencyContext implements ProfileMetaDataVisitor
-{
-   
-   /** The profile key. */
-   private final ProfileKey key;
-   
-   /** The profile meta data. */
-   private final ProfileMetaData profileMetaData;
-
-   /** The aliases. */
-   private List<ProfileKey> aliases;
-   
-   /** Is on demand. */
-   private boolean onDemand;
-   
-   /** The local PS domain. */
-   private final ProfileMetaDataRegistry domain;
-
-   /** The capabilities. */
-   private List<ProfileCapability> capabilites = new ArrayList<ProfileCapability>();
-   
-   /** The requirements. */
-   private List<ProfileRequirement> requirements = new ArrayList<ProfileRequirement>();
-   
-   /** The profile features. */
-   private List<ProfileFeatureMetaData> features = new ArrayList<ProfileFeatureMetaData>();
-
-   /** The iDependOn. */
-   private List<ProfileRequirementDependencyItem> iDependOn = new ArrayList<ProfileRequirementDependencyItem>();
-   
-   public ProfileDependencyContext(ProfileKey key, ProfileMetaData metaData, ProfileMetaDataRegistry domain)
-   {
-      if(key == null)
-         throw new IllegalArgumentException("null profile key");
-      if(key.getName() == null)
-         throw new IllegalArgumentException("null profile key name");
-      if(metaData == null)
-         throw new IllegalArgumentException("null meta data");
-      this.key = key;
-      this.domain = domain;
-      this.profileMetaData = metaData;
-      visit(profileMetaData);
-   }
-
-   public String getName()
-   {
-      return key.getName();
-   }
-   
-   public ProfileKey getKey()
-   {
-      return key;
-   }
-   
-   public ProfileMetaData getProfileMetaData()
-   {
-      return profileMetaData;
-   }
-   
-   public ProfileDeployerPlugin getDeployer()
-   {
-      return this.domain.getProfileDeployers().getDeployer(getProfileMetaData());
-   }
-   
-   public List<ProfileKey> getAliases()
-   {
-      return aliases;
-   }
-   
-   @Override
-   public void addAlias(String name)
-   {
-      if(aliases == null)
-      {
-         aliases = new ArrayList<ProfileKey>();
-      }
-      // TODO rework how ProfileKey works
-      aliases.add(new ProfileKey(domain.getDomainName(), domain.getServerName(), name));
-      addCapability(new AbstractProfileKeyCapability(name));
-   }
-   
-   public void addCapability(ProfileCapability capability)
-   {
-      this.capabilites.add(capability);
-   }
-
-   public void addRequirement(ProfileRequirement requirement)
-   {
-      this.requirements.add(requirement);
-      // Create the dependency
-      this.iDependOn.add(createDependencyItem(requirement));
-   }
-
-   public Collection<ProfileCapability> getCapabilities()
-   {
-      return this.capabilites;
-   }
-
-   public Collection<ProfileRequirement> getRequirements()
-   {
-      return this.requirements;
-   }
-   
-   public List<ProfileRequirementDependencyItem> getiDependOn()
-   {
-      return iDependOn;
-   }
-   
-   @Override
-   public void addFeature(ProfileFeatureMetaData feature)
-   {
-     this.features.add(feature);
-   }
-   
-   public List<ProfileFeatureMetaData> getFeatures()
-   {
-      return features;
-   }
-
-   public boolean isOnDemandEnabled()
-   {
-      return onDemand;
-   }
-
-   public void enableOnDemand(boolean onDemand)
-   {
-      if(onDemand)
-      {
-         this.onDemand = true;
-      }
-   }
-   
-   public void visit(ProfileMetaDataVisitorNode node)
-   {
-      node.visit(this);
-   }
-   
-   protected ProfileKey resolve(ProfileRequirementDependencyItem requirement)
-   {
-      return domain.resolve(this, requirement.getRequirement(), Collections.EMPTY_SET); 
-   }
-
-   protected ProfileRequirementDependencyItem createDependencyItem(final ProfileRequirement requirement)
-   {
-      return new ProfileRequirementDependencyItem(this, requirement, ControllerState.INSTALLED);
-   }
-   
-   protected void describe(ProfileControllerContext context)
-   {
-      // Add the dependencies
-      Collection<ProfileRequirementDependencyItem> dependencies = getiDependOn();
-      if(dependencies != null && dependencies.isEmpty() == false)
-      {
-         for(DependencyItem dependency : dependencies)
-         {
-            context.getDependencyInfo().addIDependOn(dependency);
-         }
-      }
-      context.setDependencyContext(this);
-   }
-   
-   public String toString()
-   {
-      StringBuilder buffer = new StringBuilder();
-      buffer.append(getClass().getSimpleName()).append('@');
-      buffer.append(Integer.toHexString(System.identityHashCode(this)));
-      buffer.append('{');
-      toString(buffer);
-      buffer.append('}');
-      return buffer.toString();
-   }
-   
-   protected void toString(StringBuilder builder)
-   {
-      builder.append("key=").append(getKey());
-   }
-   
-}
-

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -116,40 +116,51 @@
    
    protected void deploy(final Profile profile, final ManagedProfileDeployer deployer, final boolean isCheckComplete) throws Exception
    {
-      final Collection<? extends ProfileDeployment> deployments = profile.getDeployments();
-      if (deployments != null && deployments.isEmpty() == false)
+      long start = System.currentTimeMillis();
+      try
       {
-         // Add deployments
-         final Set<String> deploymentNames = new HashSet<String>();
-         for (final ProfileDeployment deployment : profile.getDeployments())
+         final Collection<? extends ProfileDeployment> deployments = profile.getDeployments();
+         if (deployments != null && deployments.isEmpty() == false)
          {
-            try
+            // Add deployments
+            final Set<String> deploymentNames = new HashSet<String>();
+            for (final ProfileDeployment deployment : profile.getDeployments())
             {
-               // Add deployment
-               deployer.addDeployment(deployment);
-               // Add to check complete set
-               deploymentNames.add(deployment.getName());
-               // mark as deployed  
-               deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.DEPLOYED);
-            }
-            catch(Exception e)
-            {
-               if(isCheckComplete)
+               try
                {
-                  throw e;
+                  // Add deployment
+                  deployer.addDeployment(deployment);
+                  // Add to check complete set
+                  deploymentNames.add(deployment.getName());
+                  // mark as deployed  
+                  deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.DEPLOYED);
                }
-               else
+               catch(Exception e)
                {
-                  log.error("Failed to add deployment: " + deployment, e);
+                  if(isCheckComplete)
+                  {
+                     throw e;
+                  }
+                  else
+                  {
+                     log.error("Failed to add deployment: " + deployment, e);
+                  }
                }
             }
-         }
-         // deploy
-         deployer.process();
-         // Check complete
-         if(isCheckComplete)
+            // deploy
+            deployer.process();
+            // Check complete
+            if(isCheckComplete)
+            {
+               deployer.checkComplete(deploymentNames.toArray(new String[deploymentNames.size()]));
+            }
+         }         
+      }
+      finally
+      {
+         if(log.isTraceEnabled())
          {
-            deployer.checkComplete(deploymentNames.toArray(new String[deploymentNames.size()]));
+            log.trace("deploying profile (" + profile.getKey().getName() + ") took: " + (System.currentTimeMillis() - start) +"ms");
          }
       }
    }

Deleted: 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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -1,277 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, 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.dependency;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.logging.Logger;
-import org.jboss.profileservice.config.ManagementDomain;
-import org.jboss.profileservice.config.ProfileServiceConfig;
-import org.jboss.profileservice.deployment.ProfileDeployerPluginRegistry;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileFactory;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.dependency.ProfileCapability;
-import org.jboss.profileservice.spi.dependency.ProfileRequirement;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-
-/**
- * The profile meta data registry.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ProfileMetaDataRegistry
-{
-   
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(ProfileMetaDataRegistry.class);
-
-   /** The profile service config. */
-   private final ProfileServiceConfig config;
-   
-   /** The profiles. */
-   private List<ProfileDependencyContext> profiles = new CopyOnWriteArrayList<ProfileDependencyContext>();
-   
-   /** The profiles by name. */
-   private ConcurrentMap<String, ProfileDependencyContext> profilesByName = new ConcurrentHashMap<String, ProfileDependencyContext>();
-   
-   /** The registered profiles. */
-   private List<ProfileKey> registeredProfiles = new ArrayList<ProfileKey>();
-   
-   /** Contexts registered as on-demand. */
-   private List<ProfileKey> onDemandContexts = new ArrayList<ProfileKey>();
-   
-   public ProfileMetaDataRegistry(ProfileServiceConfig config)
-   {
-      if(config == null)
-      {
-         throw new IllegalArgumentException("null profile service config");
-      }
-      this.config = config;
-   }
-   
-   public ProfileDeployerPluginRegistry getProfileDeployers()
-   {
-      return config.getDeployerRegistry();
-   }
-   
-   public ProfileFactory<ProfileMetaData, Profile> getProfileFactory()
-   {
-      return config.getProfileFactory();
-   }
-   
-   public String getDomainName()
-   {
-      return domainName();
-   }
-   
-   public ManagementDomain getDomain()
-   {
-      return config.getManagementDomain();
-   }
-
-   public String getServerName()
-   {
-      return config.getServerConfiguration().getServerName();
-   }
-   
-   public List<ProfileKey> getRegisteredProfiles()
-   {
-      return this.registeredProfiles;
-   }
-   
-   public ProfileKey registerProfileMetaData(ProfileMetaData metaData)
-   {
-      return internalRegister(metaData, true);
-   }
-   
-   ProfileKey internalRegister(ProfileMetaData metaData, boolean failOnDuplicates)
-   {
-      if(metaData == null)
-      {
-         throw new IllegalArgumentException("null profile meta data");
-      }
-      String profileName = metaData.getName();
-      if(profileName == null)
-      {
-         throw new IllegalArgumentException("null profile name");
-      }
-      profileName = profileName.trim();
-      if(profileName.length() == 0)
-      {
-         throw new IllegalArgumentException("empty profile name");
-      }
-      ProfileKey profileKey = createProfileKey(profileName);
-      ProfileDependencyContext context = new ProfileDependencyContext(profileKey, metaData, this);
-      return addContext(context, failOnDuplicates);
-   }
-   
-   public ProfileKey addContext(ProfileDependencyContext context)
-   {
-      return addContext(context, true);
-   }
-   
-   public ProfileKey addContext(ProfileDependencyContext context, boolean failOnDuplicates)
-   {
-      if(context == null)
-      {
-         throw new IllegalArgumentException("null dependency context");
-      }
-      if(this.profilesByName.containsKey(context.getName()))
-      {
-         if(failOnDuplicates)
-         {
-            throw new IllegalStateException("duplicate profile " + context.getKey());
-         }
-         return context.getKey();
-      }
-      this.profiles.add(context);
-      this.registeredProfiles.add(context.getKey());
-      this.profilesByName.put(context.getName(), context);
-      if(context.isOnDemandEnabled())
-      {
-         // TODO
-         this.onDemandContexts.add(context.getKey());
-      }
-      return context.getKey();
-   }
-
-   public ProfileDependencyContext getContext(String name)
-   {
-      if(name == null)
-      {
-         throw new IllegalArgumentException("null profile name");
-      }
-      return this.profilesByName.get(name);
-   }
-   
-   public ProfileDependencyContext getProfile(ProfileKey key)
-   {
-      if(key == null)
-      {
-         throw new IllegalArgumentException("null profile key");
-      }
-      final String profileName = key.getName();
-      if(profileName == null)
-      {
-         throw new IllegalArgumentException("null profile name");
-      }
-      return getContext(profileName);
-   }
-   
-   public void removeProfile(ProfileDependencyContext ctx)
-   {
-      if(ctx == null)
-      {
-         throw new IllegalArgumentException("null context");
-      }
-      if(ctx.getKey() == null)
-      {
-         throw new IllegalArgumentException("null profile key");
-      }
-      removeProfile(ctx.getKey());
-   }
-   
-   public void removeProfile(ProfileKey key)
-   {
-      if(key == null)
-      {
-         throw new IllegalArgumentException("null profile key");
-      }
-      final String profileName = key.getName();
-      if(profileName == null)
-      {
-         throw new IllegalArgumentException("null profle name");
-      }
-      ProfileDependencyContext ctx = this.profilesByName.remove(profileName);
-      if(ctx != null)
-      {
-         this.profiles.remove(ctx);
-      }
-   }
-   
-   protected String domainName()
-   {
-      final String domainName = getDomain().getDomainName();
-      if(domainName == null)
-      {
-         throw new IllegalStateException("null domain name");
-      }
-      return domainName;
-   }
-   
-   public ProfileKey resolve(ProfileDependencyContext ctx, ProfileRequirement requirement, Set<ProfileKey> excludes)
-   {
-      // Resolve the requirements based on the exposed capabilities
-      final boolean trace = log.isTraceEnabled();
-      ProfileKey resolved = null;
-      for(ProfileDependencyContext profile : profiles)
-      {
-         if(excludes.contains(profile.getKey()))
-         {
-            continue;
-         }
-         Collection<ProfileCapability> capabilities = profile.getCapabilities();
-         if(capabilities != null && capabilities.isEmpty() == false)
-         {
-            for(ProfileCapability capability : capabilities)
-            {
-               if(capability.resolves(requirement))
-               {
-                  if(trace)
-                  {
-                     log.trace(profile.getKey() + ":" + capability + " resolved " + requirement);
-                  }
-                  if(resolved == null)
-                  {
-                     resolved = profile.getKey();
-                     break;
-                  }
-                  else
-                  {
-                     return null;
-                  }
-               }
-            }
-         }
-      }
-      // Unresolved
-      return resolved;
-   }
-   
-   protected ProfileKey createProfileKey(String 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/ProfileRequirementDependencyItem.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileRequirementDependencyItem.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileRequirementDependencyItem.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -40,32 +40,32 @@
 {
 
    /** The profile controller context. */
-   private final ProfileDependencyContext context;
+   private final ProfileControllerContext context;
    
    /** The profile requirement to resolve. */
    private final ProfileRequirement requirement;
    
-   public ProfileRequirementDependencyItem(ProfileDependencyContext context, ProfileRequirement requirement, ControllerState state)
+   /** resolved. */
+   private volatile ProfileKey resolved;
+   
+   public ProfileRequirementDependencyItem(ProfileControllerContext context, ProfileRequirement requirement, ProfileKey key,
+         ControllerState dependentState)
    {
-      super(context != null ? context.getKey() : null, null, state, ControllerState.INSTALLED);
+      super(context != null ? context.getProfileKey() : null, null, ControllerState.DESCRIBED, dependentState);
       if(context == null)
          throw new IllegalArgumentException("null context");
       if(requirement == null)
          throw new IllegalArgumentException("null requirement");
       this.context = context;
       this.requirement = requirement;
+      this.resolved = key;
    }
 
    public ProfileKey getName()
    {
-      return context.getKey();
+      return context.getProfileKey();
    }
-   
-   public ProfileKey getIDependOn()
-   {
-      return ProfileKey.class.cast(super.getIDependOn());
-   }
-   
+     
    public ProfileRequirement getRequirement()
    {
       return requirement;
@@ -79,13 +79,13 @@
    @Override
    public boolean resolve(Controller controller)
    {
-      ProfileKey iDependOn = getIDependOn();
+      ProfileKey iDependOn = resolved;
       if(iDependOn == null)
       {
-         iDependOn = getDependencyContext().resolve(this);
+         iDependOn = context.resolve(requirement);
          if(iDependOn != null)
          {
-            setIDependOn(iDependOn);
+            resolved = iDependOn;
          }
       }
 
@@ -99,16 +99,16 @@
       // Self dependencies
       if(getName().equals(iDependOn))
       {
-         ControllerContext context = controller.getContext(iDependOn, null);
-         addDependsOnMe(controller, context);
          setResolved(true);
          return isResolved();
       }
-      
+
+      indexStates(controller, ControllerState.DESCRIBED, ControllerState.INSTALLED);
       ControllerContext context = controller.getContext(iDependOn, getDependentState());
       if(context != null)
       {
          addDependsOnMe(controller, context);
+         setIDependOn(context.getName());
          setResolved(true);
          return isResolved();
       }
@@ -127,6 +127,7 @@
                if(log.isTraceEnabled())
                   log.trace("Unexpected error", ignored);
             }
+            setIDependOn(context.getName());
             setResolved(true);
             return isResolved();
          }
@@ -157,10 +158,5 @@
       builder.append(", requirement=").append(getRequirement());
    }
    
-   protected ProfileDependencyContext getDependencyContext()
-   {
-      return context;
-   }
-   
 }
 

Deleted: 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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -1,276 +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.profileservice.dependency;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.jboss.beans.metadata.api.model.AutowireType;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.beans.metadata.spi.builder.ParameterMetaDataBuilder;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerMode;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.ControllerStateModel;
-import org.jboss.dependency.spi.LifecycleCallbackItem;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.profileservice.config.ProfileServiceConfig;
-import org.jboss.profileservice.spi.NoSuchProfileException;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-
-/**
- * Internal controller, handling the interaction between ProfileMetaData
- * and MC.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ProfileServiceController
-{
-
-   /** The kernel controller. */
-   private final KernelController controller;
-
-   /** The profile service config. */
-   private final ProfileServiceConfig config;
-   
-   /** The meta data registry. */ 
-   private final ProfileMetaDataRegistry metaDataRegistry;
-
-   /** The active profiles. */
-   private List<ProfileKey> activeProfiles = new ArrayList<ProfileKey>();
-
-   public ProfileServiceController(final KernelController controller,
-         final ProfileMetaDataRegistry registry, ProfileServiceConfig config)
-   {
-      this.controller = controller;
-      this.metaDataRegistry = registry;
-      this.config = config;
-      // initialize
-      ProfileControllerContextActions.initializeController(controller);
-   }
-
-   public ProfileKey resolveProfileKey(ProfileKey key)
-   {
-      if(key.getDomain() == ProfileKey.DEFAULT
-            && key.getServer() == ProfileKey.DEFAULT)
-      {
-         return resolveProfileKey(key.getName());
-      }
-      return key;
-   }
-   
-   public ProfileKey resolveProfileKey(String name)
-   {
-      return metaDataRegistry.createProfileKey(name);
-   }
-   
-   public ProfileKey resolveProfileKey(ProfileMetaData metaData)
-   {
-      return resolveProfileKey(metaData.getName());
-   }
-   
-   public List<ProfileKey> getRegisteredProfiles()
-   {
-      return metaDataRegistry.getRegisteredProfiles();
-   }
-   
-   public List<ProfileKey> getActiveProfiles()
-   {
-      return activeProfiles;
-   }
-   
-   public boolean isRegistered(ProfileMetaData metaData)
-   {
-      final ProfileKey key = resolveProfileKey(metaData);
-      return isRegistered(key);
-   }
-   
-   public boolean isRegistered(ProfileKey key)
-   {
-      key = resolveProfileKey(key);
-      return controller.getContext(key, null) != null;
-   }
-   
-   public boolean isInstalled(ProfileKey key)
-   {
-      key = resolveProfileKey(key);
-      return controller.getContext(key, ControllerState.INSTALLED) != null;
-   }
-   
-   public ControllerContext getContext(Object name)
-   {
-      return controller.getContext(name, null);
-   }
-   
-   public ControllerStateModel getStates()
-   {
-      return controller.getStates();
-   }
-   
-   public ProfileControllerContext getRegisteredContext(ProfileKey key) throws NoSuchProfileException
-   {
-      key = resolveProfileKey(key);
-      ControllerContext context = controller.getContext(key, null);
-      if(context instanceof ProfileControllerContext)
-      {
-         return ProfileControllerContext.class.cast(context);
-      }
-      throw new NoSuchProfileException("no such profile registered " + key);
-   }
-   
-   public ProfileControllerContext getInstalledContext(ProfileKey key) throws NoSuchProfileException
-   {
-      key = resolveProfileKey(key);
-      ControllerContext context = controller.getContext(key, ControllerState.INSTALLED);
-      if(context instanceof ProfileControllerContext)
-      {
-         return ProfileControllerContext.class.cast(context);
-      }
-      throw new NoSuchProfileException("no such profile registered " + key);
-   }
-
-   ProfileKey registerProfile(ProfileMetaData metaData) throws Throwable
-   {
-      ProfileDependencyContext metaDataContext = internalRegisterProfile(metaData, false);
-      return metaDataContext.getKey();
-   }
-
-   ProfileDependencyContext internalRegisterProfile(ProfileMetaData metaData, boolean failOnDuplicates)
-   {
-      ProfileKey key = metaDataRegistry.internalRegister(metaData, failOnDuplicates);
-      return metaDataRegistry.getContext(key.getName());
-   }
-   
-   public void installRegisteredContext(ProfileKey key) throws Throwable
-   {
-      ProfileDependencyContext context = metaDataRegistry.getContext(key.getName());
-      if(context == null)
-      {
-         throw new NoSuchProfileException("no such profile "+ key);
-      }
-      install(context, null);
-   }
-   
-   public ProfileKey registerAndInstallContext(ProfileMetaData metaData, Profile profile) throws Throwable
-   {
-      ProfileDependencyContext context = internalRegisterProfile(metaData, false);
-      install(context, profile);
-      return context.getKey();
-   }
-
-   public void activate(ProfileKey key) throws NoSuchProfileException, Throwable
-   {
-      key = resolveProfileKey(key);
-      ProfileControllerContext context = getRegisteredContext(key);
-      controller.change(context, ControllerState.INSTALLED);
-      this.activeProfiles.add(context.getProfileKey());
-   }
-   
-   public void deactivate(ProfileKey key) throws NoSuchProfileException, Throwable
-   {
-      key = resolveProfileKey(key);
-      ProfileControllerContext context = getInstalledContext(key);
-      controller.change(context, ControllerState.NOT_INSTALLED);
-      this.activeProfiles.remove(context.getProfileKey());
-   }
-   
-   public void unInstallAndUnregisterContext(ProfileKey key) throws NoSuchProfileException
-   {
-      key = resolveProfileKey(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);
-   }
-
-   void unInstallContext(ProfileControllerContext ctx)
-   {
-      controller.uninstall(ctx.getName());
-   }
-   
-   ProfileControllerContext createControllerContext(final ProfileDependencyContext context, Profile profile)
-   {
-      final ProfileKey key = context.getKey();
-      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)
-      {
-         for(final ProfileKey alias : context.getAliases())
-         {
-            builder.addAlias(alias);
-         }
-      }
-      if(profile != null)
-      {
-         builder.setBean(profile.getClass().getName());
-      }
-      else
-      {
-         // Constructor
-         builder.setFactory(metaDataRegistry.getProfileFactory());
-         builder.setFactoryMethod("createProfile");
-         builder.addConstructorParameter(ProfileKey.class.getName(), context.getKey());
-         builder.addConstructorParameter(ProfileMetaData.class.getName(), context.getProfileMetaData());
-         // Uninstall
-         // TODO remove name to TypedProfileFactory
-         ParameterMetaDataBuilder parameters = builder.addUninstallWithParameters("destroyProfile", "TypedProfileFactory");
-         parameters.addParameterMetaData(ProfileMetaData.class.getName(), context.getProfileMetaData());
-         parameters.addParameterMetaData(Profile.class.getName(), builder.createThis());         
-      }
-      // No autowire
-      builder.setAutowireType(AutowireType.NONE);
-      
-      // Create the ControllerContext
-      final ProfileControllerContext kCtx = new ProfileControllerContext(builder.getBeanMetaData(), profile);
-      // We control the lifecycle
-      kCtx.setMode(ControllerMode.MANUAL);
-      // Describe the the controller context
-      context.describe(kCtx);
-      
-      // Add the lifecycle callback
-      final LifecycleCallbackItem callbackItem = config.getLifeCycleActions();
-      if(callbackItem != null)
-      {
-         kCtx.getDependencyInfo().addLifecycleCallback(callbackItem);
-      }
-
-      // Update scope info
-      // kCtx.getScopeInfo().getScope().addScope(CommonLevels.SERVER, key);
-      // kCtx.getScopeInfo().getMutableScope().addScope(CommonLevels.SERVER, key);
-      
-      // We are done here
-      return kCtx;
-   }
-   
-}

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileValidationUtil.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileValidationUtil.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileValidationUtil.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,188 @@
+/*
+* 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.dependency;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.ControllerStateModel;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Context validation utils.
+ * 
+ * @author Emanuel Muckenhuber
+ */
+public class ProfileValidationUtil
+{
+
+   /**
+    * Check if all dependencies are satisfied and the profile was installed successfully.
+    * 
+    * @param context the context to validate
+    * @throws Exception
+    */
+   protected static void validate(ProfileControllerContext context) throws Exception
+   {
+      // 
+      Set<String> errors = new HashSet<String>();
+      Map<Object, String> map = new HashMap<Object, String>();
+      // Validate the context, with it's dependencies
+      validateContext(context, errors, map);
+      // Create and throw the Exception
+      logErrors(errors, map.values());
+   }
+   
+   protected static void validateContext(ProfileControllerContext context, Set<String> errors, Map<Object, String> incomplete)
+   {
+      final ProfileKey name = context.getProfileKey();
+      final ControllerState currentState = context.getState();
+      // If in error
+      if(ControllerState.ERROR.equals(currentState))
+      {
+         JBossStringBuilder builder = new JBossStringBuilder();
+         builder.append("Profile: ").append(name);
+         builder.append(" in error due to ").append(context.getError()); 
+         errors.add(builder.toString());         
+      }
+      else
+      {
+         if(incomplete.containsKey(name))
+            return;
+         
+         final Controller controller = context.getController();
+         final DependencyInfo dependencyInfo = context.getDependencyInfo();
+         final Set<DependencyItem> dependencies = dependencyInfo.getIDependOn(null);
+         final ControllerStateModel states = controller.getStates();
+         
+         // Analyze dependencies         
+         for(final DependencyItem dependencyItem : dependencies)
+         {
+            if(dependencyItem.isResolved())
+               continue;
+            
+            ControllerState dependentState = dependencyItem.getDependentState();
+            if (dependentState == null)
+               dependentState = ControllerState.INSTALLED;
+            
+            ControllerState otherState = null;
+            ControllerContext other = null; 
+            Object iDependOn = dependencyItem.getIDependOn();
+            
+            if(context.getName().equals(iDependOn) == false)
+            {
+               if (iDependOn != null)
+               {
+                  other = controller.getContext(iDependOn, null);
+                  if (other != null)
+                     otherState = other.getState();
+               }
+               
+               Object otherName = iDependOn;
+               if(other instanceof ProfileControllerContext)
+               {
+                  otherName = ProfileControllerContext.class.cast(other).getProfileKey(); 
+               }
+               
+               boolean print = true;
+               if (otherState != null && otherState.equals(ControllerState.ERROR) == false)
+               {
+                  if (states.isBeforeState(otherState, dependentState) == false)
+                     print = false;
+               }
+
+               if (print)
+               {
+                  JBossStringBuilder buffer = new JBossStringBuilder();
+                  buffer.append(name).append(" is missing following dependencies: ");
+
+                  buffer.append(otherName).append('{').append(dependentState.getStateString());
+                  buffer.append(':');
+                  if (otherName == null)
+                  {
+                     buffer.append("** UNRESOLVED " + dependencyItem.toHumanReadableString() + " **");
+                  }
+                  else
+                  {
+                     if (other == null)
+                     {
+                        buffer.append("** NOT FOUND **");
+                     }
+                     else
+                     {
+                        buffer.append(otherState.getStateString());
+                     }
+                  }
+                  buffer.append('}');
+               }
+            }
+         }
+      }
+   }
+   
+   /**
+    * This method just groups the errors and incomplete messages and throws an
+    * Exception if there are errors or missing dependencies.
+    * 
+    * @param errors a set of errors
+    * @param incomplete a set of missing dependencies
+    * @throws Exception in case there are errors or missing dependencies
+    */
+   protected static void logErrors(Set<String> errors, Collection<String> incomplete) throws Exception
+   {
+      if(errors.isEmpty() && incomplete.isEmpty())
+         return;
+
+      JBossStringBuilder buffer = new JBossStringBuilder();
+      buffer.append("Incompletely deployed:\n");
+      
+      // Append errors
+      if(errors.size() != 0)
+      {
+         buffer.append("\n*** PROFILES IN ERROR: Name -> Error\n");
+         for(String error : errors)
+            buffer.append(error).append('\n');
+      }
+      
+      // Append missing dependencies
+      if(incomplete.size() != 0)
+      {
+         buffer.append("\n*** PROFILES MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}\n");
+         for(String missing : incomplete)
+            buffer.append(missing).append('\n');
+      }
+      
+      // Fail
+      throw new IllegalStateException(buffer.toString());
+   }
+   
+}
+

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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -30,8 +30,8 @@
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
 import org.jboss.profileservice.dependency.ProfileControllerContext;
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
 import org.jboss.profileservice.management.AbstractActionController;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData;
 import org.jboss.util.collection.ConcurrentReferenceHashMap;
@@ -77,7 +77,7 @@
       actions.remove(callback);
    }
    
-   void processCallbacks(Profile profile, ProfileDependencyContext context, boolean isInstall)
+   void processCallbacks(Profile profile, ProfileMetaDataContext context, boolean isInstall)
    {
       Collection<ProfileFeatureMetaData> features = context.getFeatures();
       if(features != null && features.isEmpty() == false)
@@ -134,7 +134,7 @@
       {
          ProfileControllerContext context = ProfileControllerContext.class.cast(ctx);
          Profile profile = context.getProfile();
-         ProfileDependencyContext metaDataCtx = context.getDependencyContext();
+         ProfileMetaDataContext metaDataCtx = context.getDependencyContext();
          if(profile != null && metaDataCtx != null)
          {
            // Process install callbacks
@@ -153,7 +153,7 @@
       {
          ProfileControllerContext context = ProfileControllerContext.class.cast(ctx);
          Profile profile = context.getProfile();
-         ProfileDependencyContext metaDataCtx = context.getDependencyContext();
+         ProfileMetaDataContext metaDataCtx = context.getDependencyContext();
          if(profile != null && metaDataCtx != null)
          {
             // Unregister the profile

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -23,6 +23,7 @@
 
 import java.io.Closeable;
 
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.deployment.DeploymentAttachments;
 import org.jboss.profileservice.spi.deployment.ProfileDeploymentInfo;

Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/BasicProfileDeployment.java (from rev 105218, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/BasicProfileDeployment.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/BasicProfileDeployment.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.profileservice.deployment;
+
+import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * The basic profile deployment.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+class BasicProfileDeployment extends AbstractProfileDeployment
+{
+   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -1L;
+
+   public BasicProfileDeployment(String name, VirtualDeploymentMetaData deploymentMetaData)
+   {
+      super(name, deploymentMetaData);
+   }
+   
+   public BasicProfileDeployment(VirtualFile vf, VirtualDeploymentMetaData deploymentMetaData)
+   {
+      this(safeVirtualFileName(vf), deploymentMetaData);
+      setRoot(vf);
+   }
+
+   public void cleanup() throws Exception
+   {
+      super.cleanup();
+   }
+   
+   public String toString()
+   {
+      return "BasicProfileDeployment(" + getRoot() != null ? getRoot().getName() : getName() + ")";
+   }
+   
+}
+

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/DeploymentBuilder.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/DeploymentBuilder.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/DeploymentBuilder.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -22,6 +22,7 @@
 package org.jboss.profileservice.deployment;
 
 import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
 
 /**
  * The deployment builder, used to create the actual deployment
@@ -36,11 +37,12 @@
    /**
     * Create a deployment based on the <code>ProfileDeployment</code>.
     * 
+    * @param key the profile key
     * @param profileDeployment the profile deployment
     * @return the actual deployment
     * @throws Exception for any error 
     */
-   T createDeployment(ProfileDeployment profileDeployment) throws Exception;
+   T createDeployment(ProfileKey key, ProfileDeployment profileDeployment) throws Exception;
 
    /**
     * The deployment attachment processor.

Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/NoopVirtualDeploymentMetaData.java (from rev 105218, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/NoopVirtualDeploymentMetaData.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/NoopVirtualDeploymentMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/NoopVirtualDeploymentMetaData.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,62 @@
+/*
+* 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.deployment;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
+import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NoopVirtualDeploymentMetaData implements VirtualDeploymentMetaData
+{
+
+   /** The noop instance. */
+   public static final NoopVirtualDeploymentMetaData INSTANCE = new NoopVirtualDeploymentMetaData();
+   
+   public ArtifactId getArtifact()
+   {
+      return null;
+   }
+
+   public List<VirtualArtifactMetaData> getArtifacts()
+   {
+      return Collections.emptyList();
+   }
+
+   public List<VirtualDeploymentMetaData> getChildren()
+   {
+      return Collections.emptyList();
+   }
+
+   public String getName()
+   {
+      return null;
+   }
+
+}
+

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeployerPluginRegistry.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeployerPluginRegistry.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeployerPluginRegistry.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -21,20 +21,13 @@
  */ 
 package org.jboss.profileservice.deployment;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 
 import org.jboss.kernel.Kernel;
 import org.jboss.profileservice.profile.bootstrap.BootstrapDeployerPlugin;
 import org.jboss.profileservice.profile.bootstrap.BootstrapProfileMetaData;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 
 /**
@@ -44,17 +37,13 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class ProfileDeployerPluginRegistry implements ProfileDeploymentRegistry
+public class ProfileDeployerPluginRegistry
 {
 
    /** The registered deployers. */
    private Map<String, ProfileDeployerPlugin> map = new ConcurrentHashMap<String, ProfileDeployerPlugin>();
    private ProfileDeployerPlugin defaultPlugin = null;
 
-   /** The registered deployments. */
-   private Map<String, ProfileKey> registeredDeployments = new ConcurrentHashMap<String, ProfileKey>();
-   private ConcurrentMap<String, Set<String>> registeredSimpleDeploymentNames = new ConcurrentHashMap<String, Set<String>>();
-   
    public ProfileDeployerPluginRegistry(Kernel kernel)
    {
       ProfileDeployerPlugin kernelDeployer = new BootstrapDeployerPlugin(kernel);
@@ -140,66 +129,6 @@
          deployer.shutdown();
       }
    }
-
-   /**
-    * {@inheritDoc}
-    */
-   public Collection<String> getDeploymentNames()
-   {
-      return this.registeredDeployments.keySet();
-   }
    
-   /**
-    * {@inheritDoc}
-    */
-   public ProfileKey getProfileForDeployment(String deploymentName)
-   {
-      return this.registeredDeployments.get(deploymentName);
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   public Collection<String> resolveDeploymentName(String simpleDeploymentName)
-   {
-      Collection<String> simpleNameMappings = this.registeredSimpleDeploymentNames.get(simpleDeploymentName);
-      if(simpleNameMappings == null)
-      {
-         return Collections.emptySet();
-      }
-      return simpleNameMappings;
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   public void registerDeployment(ProfileKey key, ProfileDeployment deployment)
-   {
-      String deploymentName = deployment.getName();
-      String simpleName = deployment.getSimpleName();
-      this.registeredDeployments.put(deploymentName, key);
-      this.registeredSimpleDeploymentNames.putIfAbsent(simpleName, new HashSet<String>());
-      this.registeredSimpleDeploymentNames.get(simpleName).add(deploymentName);
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   public void unregisterDeployment(ProfileDeployment deployment)
-   {
-      String deploymentName = deployment.getName();
-      String simpleName = deployment.getSimpleName();
-      this.registeredDeployments.remove(deploymentName);
-      Set<String> simpleNameMappings = this.registeredSimpleDeploymentNames.get(simpleName);
-      if(simpleNameMappings != null)
-      {
-         simpleNameMappings.remove(deploymentName);
-         if(simpleNameMappings.isEmpty())
-         {
-            this.registeredSimpleDeploymentNames.remove(simpleName);
-         }
-      }
-   }
-   
 }
 

Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeploymentFactory.java (from rev 105218, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeploymentFactory.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeploymentFactory.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.profileservice.deployment;
+
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * The profile deployment factory.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileDeploymentFactory
+{
+
+   /** The noop deployment meta data. */
+   public static final VirtualDeploymentMetaData noopDeploymentMetaData = NoopVirtualDeploymentMetaData.INSTANCE;
+   
+   /** The instance. */
+   private static final ProfileDeploymentFactory instance = new ProfileDeploymentFactory();
+   
+   public static final ProfileDeploymentFactory getInstance()
+   {
+      return instance;
+   }
+   
+   private ProfileDeploymentFactory()
+   {
+      //
+   }
+
+   public ProfileDeployment createDeployment(String name)
+   {
+      if(name == null)
+      {
+         throw new IllegalArgumentException("null deployment name");
+      }
+      return new BasicProfileDeployment(name, noopDeploymentMetaData);
+   }
+   
+   public ProfileDeployment createDeployment(VirtualFile vf, VirtualDeploymentMetaData metaData)
+   {
+      if(vf == null)
+      {
+         throw new IllegalArgumentException("null virtual file");
+      }
+      return new BasicProfileDeployment(vf, metaData);
+   }
+   
+}
+

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeploymentRegistry.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeploymentRegistry.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeploymentRegistry.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -1,77 +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.deployment;
-
-import java.util.Collection;
-
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
-
-/**
- * Server wide deployment registry.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public interface ProfileDeploymentRegistry
-{
-
-   /**
-    * Get all deployment names.
-    * 
-    * @return the deployment names
-    */
-   Collection<String> getDeploymentNames();
-   
-   /**
-    * Get the profile for a deployment 
-    * 
-    * @param deploymentName the deployment name
-    * @return the profile, null if there is no such deployment
-    */
-   ProfileKey getProfileForDeployment(String deploymentName);
-   
-   /**
-    * Try to resolve the deployment name, based on the simple name.
-    * 
-    * @param simpleDeploymentName the deployments simple name
-    * @return a collection of matching deployments
-    */
-   Collection<String> resolveDeploymentName(String simpleDeploymentName);
-   
-   /**
-    * Register a deployment.
-    * 
-    * @param key the profile key
-    * @param deployment the deployment
-    */
-   void registerDeployment(ProfileKey key, ProfileDeployment deployment);
-   
-   /**
-    * Unregister a deployment.
-    * 
-    * @param deployment the deployment
-    */
-   void unregisterDeployment(ProfileDeployment deployment);
-
-}
-

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/TwoPCActionWrapper.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/TwoPCActionWrapper.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/TwoPCActionWrapper.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -22,11 +22,9 @@
 package org.jboss.profileservice.management;
 
 import org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction;
-import org.jboss.profileservice.management.event.ProfileModificationEvent;
 import org.jboss.profileservice.spi.action.ProfileModificationAction;
 import org.jboss.profileservice.spi.action.ProfileModificationContext;
 import org.jboss.profileservice.spi.action.ProfileModificationResponse;
-import org.jboss.profileservice.spi.action.ProfileModificationType;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/BasicProfileModificationRequest.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/BasicProfileModificationRequest.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/BasicProfileModificationRequest.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -28,8 +28,8 @@
 
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.action.ProfileModificationAction;
+import org.jboss.profileservice.spi.action.ProfileModificationContext;
 import org.jboss.profileservice.spi.action.ProfileModificationRequest;
-import org.jboss.profileservice.spi.action.ProfileModificationContext;
 import org.jboss.profileservice.spi.action.ProfileModificationType;
 
 /**

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ProfileConfigurationExt.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ProfileConfigurationExt.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ProfileConfigurationExt.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -21,6 +21,7 @@
 */
 package org.jboss.profileservice.metadata;
 
+import org.jboss.profileservice.spi.activation.ProfileActivationConfiguration;
 import org.jboss.profileservice.spi.managed.ManagedProfileConfiguration;
 
 /**
@@ -33,6 +34,13 @@
 {
 
    /**
+    * Get the activation configuration.
+    * 
+    * @return the activation configuration
+    */
+   ProfileActivationConfiguration getActivationConfiguration();
+   
+   /**
     * Check complete during the profile lifecycle.
     * 
     * @return

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/MutableScanningProfile.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/MutableScanningProfile.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/MutableScanningProfile.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -131,7 +131,7 @@
       lockWrite();
       try
       {
-         // TODO remove contents here ?
+         // don't remove any contents as part of a profile
          return internalRemoveDeployment(name);
       }
       finally

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -74,7 +74,7 @@
    /** The deployments. */
    private final Map<String, KernelDeployment> deployments = new ConcurrentHashMap<String, KernelDeployment>();
    
-   public BootstrapDeployerPlugin(Kernel kernel)
+   public BootstrapDeployerPlugin(final Kernel kernel)
    {
       if(kernel == null)
       {
@@ -89,13 +89,13 @@
       return deploymentBuilder;
    }
    
-   public void setDeploymentBuilder(DeploymentBuilder<KernelDeployment> deploymentBuilder)
+   public void setDeploymentBuilder(final DeploymentBuilder<KernelDeployment> deploymentBuilder)
    {
       this.deploymentBuilder = deploymentBuilder;
    }
    
    @Override
-   public void addDeployment(ProfileKey key, ProfileDeployment deployment) throws Exception
+   public void addDeployment(final ProfileKey key, final ProfileDeployment deployment) throws Exception
    {
       checkShutdown();
       try
@@ -105,7 +105,7 @@
             throw new FileNotFoundException(deployment.getRoot().getPathName());
          }
          // Create
-         KernelDeployment result = createKernelDeployment(deployment);
+         final KernelDeployment result = createKernelDeployment(key, deployment);
          // Add to the deployments
          this.deployments.put(deployment.getName(), result);
          // Deploy
@@ -126,9 +126,9 @@
    {
       if(names != null && names.length > 0)
       {
-         for(String name : names)
+         for(final String name : names)
          {
-            KernelDeployment deployment = this.deployments.get(name);
+            final KernelDeployment deployment = this.deployments.get(name);
             if(deployment == null)
             {
                // it can also happen that xml parsing did not succeed, so 
@@ -157,7 +157,7 @@
    {
       try
       {
-         for(KernelDeployment deployment : deployments.values())
+         for(final KernelDeployment deployment : deployments.values())
          {
             this.deployer.validate(deployment);            
          }
@@ -179,12 +179,13 @@
    }
 
    @Override
-   public void removeDeployment(ProfileKey key, ProfileDeployment deployment) throws Exception
+   public void removeDeployment(final ProfileKey key, final ProfileDeployment deployment) throws Exception
    {
       if(deployment == null)
+      {
          throw new IllegalArgumentException("null deployment");
-
-      KernelDeployment kernelDeployment = this.deployments.remove(deployment.getName());
+      }
+      final KernelDeployment kernelDeployment = this.deployments.remove(deployment.getName());
       if(kernelDeployment != null)
       {
          this.deployer.undeploy(kernelDeployment);         
@@ -198,13 +199,13 @@
    }
    
    @Override
-   public ManagedDeployment getManagedDeployment(ProfileDeployment deployment)
+   public ManagedDeployment getManagedDeployment(final ProfileDeployment deployment)
    {
       if(deployment == null)
       {
          throw new IllegalArgumentException("null deployment");
       }
-      KernelDeployment result = this.deployments.get(deployment.getName());
+      final KernelDeployment result = this.deployments.get(deployment.getName());
       if(result == null)
       {
          throw new IllegalStateException("no deployment registered with name " + deployment.getName());
@@ -221,7 +222,19 @@
    @Override
    public void shutdown()
    {
-      // TODO
+      if(this.shutdown == false)
+      {
+         this.shutdown = true;
+      }
+      // this should not happen
+      if(this.deployments.size() > 0)
+      {
+         // TODO add warning
+         for(final KernelDeployment deployment : this.deployments.values())
+         {
+            this.deployer.undeploy(deployment);
+         }
+      }
    }
    
    protected void checkShutdown()
@@ -239,9 +252,9 @@
     * @return the kernel deployment
     * @throws Exception for any error
     */
-   protected KernelDeployment createKernelDeployment(final ProfileDeployment profileDeployment) throws Exception
+   protected KernelDeployment createKernelDeployment(final ProfileKey key, final ProfileDeployment profileDeployment) throws Exception
    {
-      return this.deploymentBuilder.createDeployment(profileDeployment);
+      return this.deploymentBuilder.createDeployment(key, profileDeployment);
    }
    
    /**
@@ -250,24 +263,24 @@
     * @param kernelDeployment the kernel deployment
     * @return the managed deployment
     */
-   protected ManagedDeployment createManagedDeployment(KernelDeployment kernelDeployment)
+   protected ManagedDeployment createManagedDeployment(final KernelDeployment kernelDeployment)
    {
-      Map<String, ManagedObject> managedObjects = new HashMap<String, ManagedObject>();
-      Collection<BeanMetaDataFactory> beanFactories = kernelDeployment.getBeanFactories();
+      final Map<String, ManagedObject> managedObjects = new HashMap<String, ManagedObject>();
+      final Collection<BeanMetaDataFactory> beanFactories = kernelDeployment.getBeanFactories();
       if(beanFactories != null && beanFactories.isEmpty() == false)
       {
-         for(BeanMetaDataFactory beanFactory : beanFactories)
+         for(final BeanMetaDataFactory beanFactory : beanFactories)
          {
-            Collection<BeanMetaData> beans = beanFactory.getBeans();
+            final Collection<BeanMetaData> beans = beanFactory.getBeans();
             if(beans != null && beans.isEmpty() == false)
             {
-               for(BeanMetaData bmd : beans)
+               for(final BeanMetaData bmd : beans)
                {
-                  String name = bmd.getName();
-                  ControllerContext context = getKernelController().getContext(bmd.getName(), null);
+                  final String name = bmd.getName();
+                  final ControllerContext context = getKernelController().getContext(bmd.getName(), null);
                   MetaData metaData = getMetaDataRepository().getMetaData(context);
                   // Create the managed object
-                  ManagedObject mo = managedObjectFactory.initManagedObject(bmd, null, metaData, name, null);
+                  final ManagedObject mo = managedObjectFactory.initManagedObject(bmd, null, metaData, name, null);
                   if(mo != null)
                   {
                      managedObjects.put(name, mo);

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/KernelDeploymentBuilder.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/KernelDeploymentBuilder.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/KernelDeploymentBuilder.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -31,6 +31,7 @@
 import org.jboss.kernel.spi.deployment.KernelDeployment;
 import org.jboss.profileservice.deployment.DeploymentBuilder;
 import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
 import org.jboss.xb.binding.Unmarshaller;
 import org.jboss.xb.binding.UnmarshallerFactory;
@@ -61,7 +62,7 @@
    /**
     * {@inheritDoc}
     */
-   public KernelDeployment createDeployment(ProfileDeployment profileDeployment) throws Exception
+   public KernelDeployment createDeployment(ProfileKey key, ProfileDeployment profileDeployment) throws Exception
    {
       final URL url = profileDeployment.getRoot().toURL();
       if (url == null)

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/BasicProfileMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/BasicProfileMetaData.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/BasicProfileMetaData.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -58,11 +58,8 @@
    /** Requirement on our namespace. */
    private static FeatureRequirement REQUIREMENT = new FeatureRequirement(CommonProfileNameSpaces.PROFILE_NAMESPACE);
 
-   private static final boolean disableComplete = Boolean.getBoolean(System.getProperty(Hack.DISABLE_COMPLETE_CHECK, "false"));
+   private static final boolean disableComplete = Boolean.getBoolean(Hack.DISABLE_COMPLETE_CHECK);
    
-   /** enable on demand. */
-   private boolean onDemand;
-   
    /** The aliases. */
    private List<String> aliases;
    
@@ -130,18 +127,7 @@
    {
       this.deployments = deployments;
    }
-
-   @XmlAttribute(name = "enable-on-demand")
-   public boolean isOnDemand()
-   {
-      return onDemand;
-   }
    
-   public void setOnDemand(boolean onDemand)
-   {
-      this.onDemand = onDemand;
-   }
-   
    @Override
    @XmlElement(name = "file-repository", type = FileRepositorySourceConfiguration.class)
    public FileRepositorySourceConfiguration getSource()
@@ -173,10 +159,6 @@
             visitor.visit(deployment);
          }
       }
-      if(onDemand)
-      {
-         visitor.enableOnDemand(onDemand);
-      }
    }
    
    @Override

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfileActivationMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfileActivationMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfileActivationMetaData.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,74 @@
+/*
+* 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.profile.metadata;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.jboss.profileservice.spi.activation.ProfileActivationConfiguration;
+import org.jboss.profileservice.spi.activation.ProfileActivationParameters;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class ProfileActivationMetaData implements ProfileActivationConfiguration, ProfileMetaDataVisitorNode
+{
+
+   /** The activator ref. */
+   private String activatorRef; 
+
+   /** The activation parameters. */
+   private ProfileActivationParameters parameters;
+   
+   @XmlElement(name = "parameters", type = ProfileActivationParametersMetaData.class)
+   public ProfileActivationParameters getParameters()
+   {
+      return parameters;
+   }
+
+   public void setParameters(ProfileActivationParameters parameters)
+   {
+      this.parameters = parameters;
+   }
+   
+   @XmlAttribute(name = "activator")
+   public String getProfileActivatorRef()
+   {
+      return activatorRef;
+   }
+
+   public void setProfileActivatorRef(String activatorRef)
+   {
+      this.activatorRef = activatorRef;
+   }
+
+   public void visit(ProfileMetaDataVisitor visitor)
+   {
+      if(activatorRef != null)
+      {
+         visitor.addRequirement(new FeatureRequirement(activatorRef));
+      }
+   }
+
+}

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfileActivationParametersMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfileActivationParametersMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfileActivationParametersMetaData.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,94 @@
+/*
+* 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.profile.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.jboss.profileservice.spi.activation.ProfileActivationParameters;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class ProfileActivationParametersMetaData implements ProfileActivationParameters
+{
+
+   /** The activation parameters. */
+   private List<ActivationParameter> parameters;
+
+   @XmlElement(name = "parameter", type = ProfileActivationPropertyMetaData.class)
+   public List<ActivationParameter> getParameters()
+   {
+      return parameters;
+   }
+   
+   public void setParameters(List<ActivationParameter> parameters)
+   {
+      this.parameters = parameters;
+   }
+
+   public ActivationParameter getActivationParameter(String name)
+   {
+      if(parameters != null && parameters.isEmpty() == false)
+      {
+         for(ActivationParameter parameter : parameters)
+         {
+            if(parameter.getName().equals(name))
+            {
+               return parameter;
+            }
+         }
+      }
+      return null;
+   }
+   
+   public static class ProfileActivationPropertyMetaData implements ActivationParameter
+   {
+      private String name;
+      private String value;
+
+      @XmlAttribute(name = "name")
+      public String getName()
+      {
+         return name;
+      }
+      public void setName(String name)
+      {
+         this.name = name;
+      }
+      
+      @XmlValue
+      public String getValue()
+      {
+         return value;
+      }
+      public void setValue(String value)
+      {
+         this.value = value;
+      }
+   }
+   
+}
+

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/BasicDomainMetaDataVisitor.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/BasicDomainMetaDataVisitor.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/BasicDomainMetaDataVisitor.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -23,12 +23,12 @@
 
 import java.util.Stack;
 
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.domain.spi.DomainMetaDataFragment;
 import org.jboss.profileservice.domain.spi.DomainMetaDataFragmentVisitor;
 import org.jboss.profileservice.profile.metadata.BasicSubProfileMetaData;
 import org.jboss.profileservice.profile.metadata.domain.RequiredProfiles.ResolveRequirement;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.repository.ProfileRepository;
 import org.jboss.profileservice.spi.dependency.DependencyMode;
 import org.jboss.profileservice.spi.dependency.ProfileCapability;
 import org.jboss.profileservice.spi.dependency.ProfileRequirement;
@@ -48,16 +48,16 @@
    /** The requirement resolver. */
    private final ProfileRequirementResolver resolver;
    
-   /** The profile meta data registry. */
-   private final ProfileMetaDataRegistry registry;
+   /** The profile repository. */
+   private final ProfileRepository profileRepository;
    
    /** Implicit dependencies. */
    private Stack<String> stack = new Stack<String>();
    
-   public BasicDomainMetaDataVisitor(ProfileRequirementResolver resolver, ProfileMetaDataRegistry registry)
+   public BasicDomainMetaDataVisitor(ProfileRequirementResolver resolver, ProfileRepository profileRepository)
    {
       this.resolver = resolver;
-      this.registry = registry;
+      this.profileRepository = profileRepository;
    }
    
    @Override
@@ -70,7 +70,7 @@
       }
       // Add a domain meta data requirement
       addRequirement(new ResolveRequirement(metaData.getName()));
-      registry.registerProfileMetaData(metaData);
+      ProfileMetaDataContext ctx = profileRepository.registerMetaData(metaData);
       
       // Also extract all requirements of the included nodes
       visit(metaData);
@@ -80,7 +80,6 @@
       if(stack.empty() == false)
       {
          String previous = stack.pop();
-         ProfileDependencyContext ctx = registry.getContext(profileName);
          ProfileRequirement requirement = new BasicSubProfileMetaData(previous, DependencyMode.OPTIONAL);
          ctx.addRequirement(requirement);
       }
@@ -111,12 +110,6 @@
    }
    
    @Override
-   public void enableOnDemand(boolean onDemand)
-   {
-      // nothing
-   }
-   
-   @Override
    public void visit(DomainMetaDataFragment node)
    {
       node.visit(this);

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/XmlDomainMetaDataRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/XmlDomainMetaDataRepository.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/XmlDomainMetaDataRepository.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -61,7 +61,7 @@
       addSchemaBinding(CommonProfileNameSpaces.FARMING_PROFILE_NAMESPACE, FarmingProfileMetaData.class);
    }
    
-   protected static void addSchemaBinding(String nsUri, Class<?> clazz)
+   public static void addSchemaBinding(String nsUri, Class<?> clazz)
    {
       resolver.mapURIToClass(nsUri, clazz);
    }

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/helpers/AbstractProfileMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/helpers/AbstractProfileMetaData.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/helpers/AbstractProfileMetaData.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -23,7 +23,10 @@
 
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElement;
+
 import org.jboss.profileservice.metadata.ProfileConfigurationExt;
+import org.jboss.profileservice.spi.activation.ProfileActivationConfiguration;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
@@ -37,6 +40,8 @@
 public abstract class AbstractProfileMetaData extends AbstractProfileKeyCapability implements ProfileMetaData, ProfileConfigurationExt
 {
    
+   private ProfileActivationConfiguration activationConfiguration;
+   
    /** The features. */
    private List<ProfileMetaDataVisitorNode> features;
 
@@ -50,6 +55,17 @@
       super(name);
    }
    
+   @XmlElement(name = "activation")
+   public ProfileActivationConfiguration getActivationConfiguration()
+   {
+      return activationConfiguration;
+   }
+   
+   public void setActivationConfiguration(ProfileActivationConfiguration activationConfiguration)
+   {
+      this.activationConfiguration = activationConfiguration;
+   }
+   
    public List<ProfileMetaDataVisitorNode> getFeatures()
    {
       return features;

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/AbstractMetaDataContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/AbstractMetaDataContext.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/AbstractMetaDataContext.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,199 @@
+/*
+* 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.repository;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.jboss.profileservice.metadata.ProfileConfigurationExt;
+import org.jboss.profileservice.profile.metadata.helpers.AbstractProfileKeyCapability;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.activation.ProfileActivationConfiguration;
+import org.jboss.profileservice.spi.dependency.ProfileCapability;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+import org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class AbstractMetaDataContext implements ProfileMetaDataContext, ProfileMetaDataVisitor
+{
+   
+   /** The profile key. */
+   private final ProfileKey key;
+
+   /** The aliases. */
+   private Collection<ProfileKey> aliases;
+   
+   /** The profile meta data. */
+   private final ProfileMetaData profileMetaData;
+
+   /** The capabilities. */
+   private Collection<ProfileCapability> capabilites;
+   
+   /** The requirements. */
+   private Collection<ProfileRequirement> requirements;
+   
+   /** The profile features. */
+   private Collection<ProfileFeatureMetaData> features;
+   
+   public AbstractMetaDataContext(ProfileKey key, ProfileMetaData metaData)
+   {
+      if(key == null)
+      {
+         throw new IllegalArgumentException("null profile key");
+      }
+      if(metaData == null)
+      {
+         throw new IllegalArgumentException("null meta data");
+      }
+      this.key = key;
+      this.profileMetaData = metaData;
+      // Visit
+      visit(profileMetaData);
+   }
+
+   public String getProfileName()
+   {
+      return key.getName();
+   }
+   
+   public ProfileKey getKey()
+   {
+      return key;
+   }
+   
+   public ProfileMetaData getProfileMetaData()
+   {
+      return profileMetaData;
+   }
+   
+   public ProfileActivationConfiguration getActivationConfiguration()
+   {
+      if(getProfileMetaData() instanceof ProfileConfigurationExt)
+      {
+         return ProfileConfigurationExt.class.cast(getProfileMetaData()).getActivationConfiguration();
+      }
+      return null;
+   }
+   
+   public Collection<ProfileKey> getAliases()
+   {
+      if(aliases == null)
+      {
+         return Collections.emptySet();
+      }
+      return aliases;
+   }
+   
+   public void addAlias(String name)
+   {
+      if(aliases == null)
+      {
+         aliases = new ArrayList<ProfileKey>();
+      }
+      // TODO rework how ProfileKey works
+      aliases.add(new ProfileKey(getKey().getDomain(), getKey().getServer(), name));
+      addCapability(new AbstractProfileKeyCapability(name));
+   }
+   
+   public void addCapability(ProfileCapability capability)
+   {
+      if(this.capabilites == null)
+      {
+         this.capabilites = new ArrayList<ProfileCapability>();
+      }
+      this.capabilites.add(capability);
+   }
+
+   public void addRequirement(ProfileRequirement requirement)
+   {
+      if(this.requirements == null)
+      {
+         this.requirements = new ArrayList<ProfileRequirement>();
+      }
+      this.requirements.add(requirement);
+   }
+
+   public Collection<ProfileCapability> getCapabilities()
+   {
+      if(this.capabilites == null)
+      {
+         return Collections.emptySet();
+      }
+      return this.capabilites;
+   }
+
+   public Collection<ProfileRequirement> getRequirements()
+   {
+      if(this.requirements == null)
+      {
+         return Collections.emptySet();
+      }
+      return this.requirements;
+   }
+   
+   public void addFeature(ProfileFeatureMetaData feature)
+   {
+      if(this.features == null)
+      {
+         this.features = new ArrayList<ProfileFeatureMetaData>();
+      }
+      this.features.add(feature);
+   }
+   
+   public Collection<ProfileFeatureMetaData> getFeatures()
+   {
+      if(this.features == null)
+      {
+         return Collections.emptySet();
+      }
+      return features;
+   }
+
+   public void visit(ProfileMetaDataVisitorNode node)
+   {
+      node.visit(this);
+   }
+   
+   public String toString()
+   {
+      final StringBuilder buffer = new StringBuilder();
+      buffer.append(getClass().getSimpleName()).append('@');
+      buffer.append(Integer.toHexString(System.identityHashCode(this)));
+      buffer.append('{');
+      toString(buffer);
+      buffer.append('}');
+      return buffer.toString();
+   }
+   
+   protected void toString(StringBuilder builder)
+   {
+      builder.append("key=").append(getKey());
+   }
+
+}
+

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/AbstractProfileRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/AbstractProfileRepository.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/AbstractProfileRepository.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,129 @@
+/*
+* 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.repository;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.profileservice.resolver.ProfileRequirementResolutionContext;
+import org.jboss.profileservice.resolver.ProfileResolutionFilter;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.dependency.ProfileCapability;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class AbstractProfileRepository implements ProfileRepository
+{
+
+   /** The repositories. */
+   private final ProfileRepositories repositories;
+   
+   /** The registered contexts. */
+   private Map<String, ProfileMetaDataContext> registered = new ConcurrentHashMap<String, ProfileMetaDataContext>();
+   
+   public AbstractProfileRepository(ProfileRepositories repositories)
+   {
+      this.repositories = repositories;
+   }
+
+   public boolean isRegistered(String profileName)
+   {
+      return this.registered.containsKey(profileName);
+   }
+
+   public ProfileMetaDataContext registerMetaData(ProfileMetaData metaData)
+   {
+      final String profileName = metaData.getName();
+      if(this.registered.containsKey(profileName))
+      {
+         throw new IllegalStateException("duplicate profile " + profileName);
+      }
+      ProfileMetaDataContext context = repositories.createMetaDataContext(profileName, metaData);
+      this.registered.put(profileName, context);
+      return context;
+   }
+   
+   public void unRegisterMetaData(String profileName)
+   {
+      this.registered.remove(profileName);
+   }
+
+   public ProfileMetaDataContext resolve(String profileName)
+   {
+      if(profileName == null)
+      {
+         throw new IllegalArgumentException("null profile name");
+      }
+      return this.registered.get(profileName);
+   }
+
+   public boolean accepts(ProfileMetaDataContext context)
+   {
+      // Ignore all registered profiles when this repository is used as filter
+      final String profileName = context.getProfileName();
+      return isRegistered(profileName) == false;
+   }
+   
+   public ProfileKey resolve(final ProfileRequirementResolutionContext resolutionContext, final ProfileResolutionFilter filter)
+   {
+      ProfileKey resolved = null;
+      final ProfileRequirement requirement = resolutionContext.getRequirement();
+      for(final ProfileMetaDataContext other : registered.values())
+      {
+         // Check excludes
+         if(filter != null && filter.accepts(other) == false)
+         {
+            continue;
+         }
+         final Collection<ProfileCapability> capabilities = other.getCapabilities();
+         if(capabilities != null && capabilities.isEmpty() == false)
+         {
+            for(final ProfileCapability capability : capabilities)
+            {
+               if(capability.resolves(requirement))
+               {
+                  final ProfileKey r = other.getKey();
+                  resolutionContext.addResolved(r);
+                  // multiple resolved contexts are unresolved
+                  if(resolved == null)
+                  {
+                     resolved = r;
+                     break;
+                  }
+                  else
+                  {
+                     // Unresolved
+                     return null;
+                  }
+               }
+            }
+         }
+      }
+      return resolved;
+   }
+   
+}
+

Deleted: 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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.profileservice.repository;
-
-import org.jboss.profileservice.deployment.AbstractProfileDeployment;
-import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
-import org.jboss.vfs.VirtualFile;
-
-/**
- * The basic profile deployment.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-class BasicProfileDeployment extends AbstractProfileDeployment
-{
-   
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -1L;
-
-   public BasicProfileDeployment(String name, VirtualDeploymentMetaData deploymentMetaData)
-   {
-      super(name, deploymentMetaData);
-   }
-   
-   public BasicProfileDeployment(VirtualFile vf, VirtualDeploymentMetaData deploymentMetaData)
-   {
-      this(safeVirtualFileName(vf), deploymentMetaData);
-      setRoot(vf);
-   }
-
-   public void cleanup() throws Exception
-   {
-      super.cleanup();
-   }
-   
-   public String toString()
-   {
-      return "BasicProfileDeployment(" + getRoot() != null ? getRoot().getName() : getName() + ")";
-   }
-   
-}
-

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/CompositeResolutionFilter.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/CompositeResolutionFilter.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/CompositeResolutionFilter.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,51 @@
+/*
+* 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.repository;
+
+import org.jboss.profileservice.resolver.ProfileResolutionFilter;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class CompositeResolutionFilter implements ProfileResolutionFilter
+{
+  
+   private final ProfileResolutionFilter filter;
+   private final ProfileResolutionFilter delegate;
+   
+   public CompositeResolutionFilter(final ProfileResolutionFilter filter, final ProfileResolutionFilter delegate)
+   {
+      this.filter = filter;
+      this.delegate = delegate;
+   }
+
+   public boolean accepts(ProfileMetaDataContext context)
+   {
+      if(filter.accepts(context))
+      {
+         return true;
+      }
+      return delegate.accepts(context);
+   }  
+   
+}
+

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/NoopVirtualDeploymentMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/NoopVirtualDeploymentMetaData.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/NoopVirtualDeploymentMetaData.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -1,62 +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.repository;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.profileservice.spi.repository.ArtifactId;
-import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
-import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class NoopVirtualDeploymentMetaData implements VirtualDeploymentMetaData
-{
-
-   /** The noop instance. */
-   public static final NoopVirtualDeploymentMetaData INSTANCE = new NoopVirtualDeploymentMetaData();
-   
-   public ArtifactId getArtifact()
-   {
-      return null;
-   }
-
-   public List<VirtualArtifactMetaData> getArtifacts()
-   {
-      return Collections.emptyList();
-   }
-
-   public List<VirtualDeploymentMetaData> getChildren()
-   {
-      return Collections.emptyList();
-   }
-
-   public String getName()
-   {
-      return null;
-   }
-
-}
-

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.profileservice.repository;
-
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
-import org.jboss.vfs.VirtualFile;
-
-/**
- * The profile deployment factory.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ProfileDeploymentFactory
-{
-
-   /** The noop deployment meta data. */
-   public static final VirtualDeploymentMetaData noopDeploymentMetaData = NoopVirtualDeploymentMetaData.INSTANCE;
-   
-   /** The instance. */
-   private static final ProfileDeploymentFactory instance = new ProfileDeploymentFactory();
-   
-   public static final ProfileDeploymentFactory getInstance()
-   {
-      return instance;
-   }
-   
-   private ProfileDeploymentFactory()
-   {
-      //
-   }
-
-   public ProfileDeployment createDeployment(String name)
-   {
-      if(name == null)
-      {
-         throw new IllegalArgumentException("null deployment name");
-      }
-      return new BasicProfileDeployment(name, noopDeploymentMetaData);
-   }
-   
-   public ProfileDeployment createDeployment(VirtualFile vf, VirtualDeploymentMetaData metaData)
-   {
-      if(vf == null)
-      {
-         throw new IllegalArgumentException("null virtual file");
-      }
-      return new BasicProfileDeployment(vf, metaData);
-   }
-   
-}
-

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileMetaDataContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileMetaDataContext.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileMetaDataContext.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,99 @@
+/*
+* 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.repository;
+
+import java.util.Collection;
+
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.activation.ProfileActivationConfiguration;
+import org.jboss.profileservice.spi.dependency.ProfileCapability;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+import org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
+
+/**
+ * The processed profile repository meta data.
+ * 
+ * @author Emanuel Muckenhuber
+ */
+public interface ProfileMetaDataContext extends ProfileMetaDataVisitor
+{
+
+   /**
+    * Get the profile key.
+    * 
+    * @return the profile key
+    */
+   ProfileKey getKey();
+   
+   /**
+    * Get the profile name.
+    * 
+    * @return the profile name
+    */
+   String getProfileName();
+   
+   /**
+    * Get the aliases.
+    * 
+    * @return the aliases
+    */
+   Collection<ProfileKey> getAliases();
+   
+   /**
+    * Get the profile meta data.
+    * 
+    * @return the profile meta data
+    */
+   ProfileMetaData getProfileMetaData();
+   
+   /**
+    * Get the activation configuration.
+    * 
+    * @return the activation configuraiton
+    */
+   ProfileActivationConfiguration getActivationConfiguration();
+   
+   /**
+    * Get the profile capabilities.
+    * 
+    * @return the profile capabilities
+    */
+   Collection<ProfileCapability> getCapabilities();
+   
+   /**
+    * Get the profile requirements.
+    * 
+    * @return the requirements
+    */
+   Collection<ProfileRequirement> getRequirements();
+   
+   /**
+    * Get the profile features.
+    * 
+    * @return the features
+    */
+   Collection<ProfileFeatureMetaData> getFeatures();
+   
+}
+

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileRepositories.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileRepositories.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileRepositories.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,145 @@
+/*
+* 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.repository;
+
+import org.jboss.profileservice.config.ProfileServiceConfig;
+import org.jboss.profileservice.resolver.ProfileRequirementResolutionContext;
+import org.jboss.profileservice.resolver.ProfileResolutionFilter;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class ProfileRepositories implements ProfileRepository
+{
+
+   /** The profile service config. */
+   private final ProfileServiceConfig configuration;
+   
+   /** The domain profile repository. */
+   // Rather a runtime profile meta data repository ?
+   private final ProfileRepository domainRepository;
+   
+   /** The local profile repository. */
+   private final ProfileRepository profileRepository;
+
+   public ProfileRepositories(ProfileServiceConfig configuration)
+   {
+      this.configuration = configuration;
+      this.domainRepository = new AbstractProfileRepository(this);
+      this.profileRepository = new AbstractProfileRepository(this);
+   }
+   
+   public ProfileServiceConfig getConfiguration()
+   {
+      return configuration;
+   }
+   
+   public ProfileRepository getDomainRepository()
+   {
+      return domainRepository;
+   }
+   
+   public ProfileRepository getProfileRepository()
+   {
+      return profileRepository;
+   }
+   
+   public boolean isRegistered(String profileName)
+   {
+      if(domainRepository.isRegistered(profileName))
+      {
+         return true;
+      }
+      return profileRepository.isRegistered(profileName);
+   }
+
+   public ProfileMetaDataContext registerMetaData(ProfileMetaData metaData)
+   {
+      final String profileName = metaData.getName();
+      if(isRegistered(profileName))
+      {
+         throw new IllegalArgumentException("profile already registered " + profileName);
+      }
+      return domainRepository.registerMetaData(metaData);
+   }
+
+   public void unRegisterMetaData(final String profileName)
+   {
+      domainRepository.unRegisterMetaData(profileName);
+   }
+   
+   public ProfileMetaDataContext resolve(String profileName)
+   {
+      ProfileMetaDataContext context = domainRepository.resolve(profileName);
+      if(context == null)
+      {
+         context = profileRepository.resolve(profileName);
+      }
+      return context;
+   }
+
+   public ProfileKey resolve(ProfileRequirementResolutionContext context, ProfileResolutionFilter filter)
+   {
+      final ProfileKey resolvedDomain = domainRepository.resolve(context, filter);
+      final ProfileKey resolved = profileRepository.resolve(context, new CompositeResolutionFilter(filter, domainRepository));
+      if(resolvedDomain == null)
+      {
+         return resolved;
+      }
+      else if(resolved == null)
+      {
+         return resolvedDomain;
+      }
+      return null;
+   }
+   
+   public boolean accepts(ProfileMetaDataContext context)
+   {
+      // Ignore all registered profiles in case this repository is used as filter
+      final String profileName = context.getProfileName();
+      return isRegistered(profileName) == false;
+   }
+   
+   protected ProfileMetaDataContext createMetaDataContext(String profileName, ProfileMetaData metaData)
+   {
+      final ProfileKey key = createProfileKey(profileName);
+      return new AbstractMetaDataContext(key, metaData);
+   }
+   
+   protected ProfileKey createProfileKey(String profileName)
+   {
+      return new ProfileKey(getDomainName(), getServerName(), profileName);
+   }
+   
+   protected String getDomainName()
+   {
+      return getConfiguration().getManagementDomain().getDomainName();
+   }
+   
+   protected String getServerName()
+   {
+      return getConfiguration().getServerConfiguration().getServerName();
+   }
+
+}

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileRepository.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileRepository.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,76 @@
+/*
+* 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.repository;
+
+import org.jboss.profileservice.resolver.ProfileRequirementResolutionContext;
+import org.jboss.profileservice.resolver.ProfileResolutionFilter;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public interface ProfileRepository extends ProfileResolutionFilter
+{
+   
+   /**
+    * Check whether a profile is registered.
+    * 
+    * @param profileName the profile name
+    * @return true if registered, false otherwise
+    */
+   boolean isRegistered(String profileName);
+   
+   /**
+    * Register a profile meta data.
+    * 
+    * @param metaData the profile meta data
+    * @return the processed meta data context
+    */
+   ProfileMetaDataContext registerMetaData(ProfileMetaData metaData);
+   
+   /**
+    * Unregister a given profile.
+    * 
+    * @param profileName the profile name
+    */
+   void unRegisterMetaData(String profileName);
+   
+   /**
+    * Resolve a meta data context.
+    * 
+    * @param profileName the profile name
+    * @return the meta data context, null if not registered
+    */
+   ProfileMetaDataContext resolve(String profileName);
+   
+   /**
+    * Try to resolve a given requirement for a profile. 
+    * 
+    * @param resolutionContext the resolution context
+    * @param filter the profile resolution filter
+    * @return the resolved profile, null if not resolvable 
+    */
+   ProfileKey resolve(ProfileRequirementResolutionContext resolutionContext, ProfileResolutionFilter filter);
+   
+}
+

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/ArtifactRepositoryManager.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/ArtifactRepositoryManager.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/ArtifactRepositoryManager.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -88,7 +88,6 @@
    /**
     * {@inheritDoc}
     */
-   @Override
    public ArtifactRepository<ArtifactId> createArtifactRepository(ArtifactRepositoryId repositoryId,
          ArtifactRepositoryConfiguration<ArtifactId> configuration) throws IOException
    {
@@ -123,13 +122,12 @@
       }
       // Track usage
       incrementUsage(repositoryId);
-      return repository; 
+      return repository;
    }
    
    /**
     * {@inheritDoc}
     */
-   @Override
    public String getRepositoryType()
    {
       return DEFAULT_NAME;

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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -309,9 +309,9 @@
       // TODO better check, we just need to make sure that artifacts are always relative and inside our root 
       for(String token : tokens)
       {
-         if(PathTokenizer.isReverseToken(token))
+         if(PathTokenizer.isCurrentToken(token) || PathTokenizer.isReverseToken(token))
          {
-            throw new IllegalStateException("Illegal artifact path, no reverse tokens allowed " + pathString);
+            throw new IllegalStateException("Illegal artifact path, no current/reverse tokens allowed " + pathString);
          }
       }
    }

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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -24,7 +24,7 @@
 import java.io.IOException;
 import java.util.Collection;
 
-import org.jboss.profileservice.repository.ProfileDeploymentFactory;
+import org.jboss.profileservice.deployment.ProfileDeploymentFactory;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.VirtualDeploymentRepository;
 import org.jboss.profileservice.spi.deployment.DeploymentAttachments;

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -23,7 +23,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -32,9 +31,8 @@
 import java.util.Set;
 
 import org.jboss.logging.Logger;
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
-import org.jboss.profileservice.dependency.ProfileRequirementDependencyItem;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.repository.ProfileRepository;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.dependency.DependencyMode;
 import org.jboss.profileservice.spi.dependency.ProfileCapability;
@@ -46,40 +44,40 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class AbstractRequirementResolver
+public class AbstractRequirementResolver implements ProfileResolutionFilter
 {
 
    /** The logger. */
    private static final Logger log = Logger.getLogger(AbstractRequirementResolver.class);
    
    /** The profile meta data registry. */
-   private final ProfileMetaDataRegistry registry;
+   private final ProfileRepository profileRepository;
 
    /** The included nodes. */
-   private Set<ProfileNode> included = new HashSet<ProfileNode>();
+   private Set<ProfileResolutionNode> included = new HashSet<ProfileResolutionNode>();
    
    /** The included keys. */
    private Set<ProfileKey> includedKeys = new HashSet<ProfileKey>();
    
    /** The activation callback registry. */
-   private List<ProfileNode> callbacks = new ArrayList<ProfileNode>();
+   private List<ProfileResolutionNode> callbacks = new ArrayList<ProfileResolutionNode>();
    
    /** The unresolved requirements. */
    private List<ProfileRequirement> unresolved = new ArrayList<ProfileRequirement>();
    
    /** All referenced nodes. */
-   private Map<ProfileKey, ProfileNode> nodes = new HashMap<ProfileKey, ProfileNode>();
+   private Map<ProfileKey, ProfileResolutionNode> nodes = new HashMap<ProfileKey, ProfileResolutionNode>();
    
    /** The included root contexts. */
-   private List<ProfileDependencyContext> includedContexts = new ArrayList<ProfileDependencyContext>();
+   private List<ProfileMetaDataContext> includedContexts = new ArrayList<ProfileMetaDataContext>();
    
-   public AbstractRequirementResolver(ProfileMetaDataRegistry registry)
+   public AbstractRequirementResolver(ProfileRepository profileRepository)
    {
-      if(registry == null)
+      if(profileRepository == null)
       {
          throw new IllegalArgumentException("null profile metadata registry");
       }
-      this.registry = registry;
+      this.profileRepository = profileRepository;
    }
    
    /**
@@ -87,7 +85,7 @@
     * 
     * @param context
     */
-   public void resolve(final ProfileDependencyContext context)
+   public void resolve(final ProfileMetaDataContext context)
    {
       if(context == null)
       {
@@ -97,6 +95,14 @@
    }
    
    /**
+    * {@inheritDoc}
+    */
+   public boolean accepts(ProfileMetaDataContext context)
+   {
+      return this.includedKeys.contains(context.getKey()) == false;
+   }
+   
+   /**
     * Resolve the root context. The root context should specify the configuration,
     * also have the ability to select specific profiles which both expose a common
     * capability (which cannot be resolved). Therefore those contexts are resolved
@@ -105,25 +111,25 @@
     * 
     * @param context the root context to resolve
     */
-   void resolveRoot(final ProfileDependencyContext context)
+   void resolveRoot(final ProfileMetaDataContext context)
    {
       final ProfileKey currentKey = context.getKey();
-      final ProfileNode currentNode = getNode(context);
+      final ProfileResolutionNode currentNode = getNode(context);
       
       // Include it in the configuration
       included.add(currentNode);
       includedKeys.add(currentKey);
       
-      final List<ProfileDependencyContext> toProcess = new ArrayList<ProfileDependencyContext>();
+      final List<ProfileMetaDataContext> toProcess = new ArrayList<ProfileMetaDataContext>();
       
-      final Collection<ProfileRequirementDependencyItem> requirements = context.getiDependOn();
+      final Collection<ProfileRequirement> requirements = context.getRequirements();
       if(requirements != null && requirements.isEmpty() == false)
       {
-         for(final ProfileRequirementDependencyItem dependencyItem : requirements)
+         for(final ProfileRequirement requirement : requirements)
          {
             // Try to resolve the requirement
-            final ProfileRequirement requirement = dependencyItem.getRequirement();
-            final ProfileKey dependencyKey = registry.resolve(context, requirement, Collections.EMPTY_SET); 
+            final ProfileRequirementResolutionContext resolution = new ProfileRequirementResolutionContext(context, requirement);
+            final ProfileKey dependencyKey = profileRepository.resolve(resolution, ProfileResolutionFilter.NOOP_FILTER); 
             if(dependencyKey == null)
             {
                // if the requirement is not optional add to unresolved
@@ -134,21 +140,21 @@
                continue;
             }
             // Ignore self dependencies
-            dependencyItem.setIDependOn(dependencyKey);
             if(currentKey.equals(dependencyKey))
             {
                continue;
             }
             
             // Get the dependency context
-            final ProfileDependencyContext dependencyContext = registry.getProfile(dependencyKey);
-            final ProfileNode depenencyNode = getNode(dependencyContext);
+            final ProfileMetaDataContext dependencyContext = profileRepository.resolve(dependencyKey.getName());
+            final ProfileResolutionNode depenencyNode = getNode(dependencyContext);
             
             // Add the dependency context
             addDependencyContext(dependencyContext);
             toProcess.add(dependencyContext);
             
-            final ProfileNodeDependency dependency = new ProfileNodeDependency(dependencyItem, false);
+            final boolean requireInstalled = dependencyContext.getActivationConfiguration() != null;
+            final ProfileNodeDependency dependency = new ProfileNodeDependency(resolution, dependencyKey, requirement, false, requireInstalled);
 
             // Add dependency information
             currentNode.addIDependOn(dependency);
@@ -162,23 +168,23 @@
          return;
       }
       // Process the referenced contexts
-      for(final ProfileDependencyContext process : toProcess)
+      for(final ProfileMetaDataContext process : toProcess)
       {
          resolve(process, false);
       }
    }
-   
+
    /**
     * Try to resolve a context based on it's meta data dependencies.
     * 
     * @param context the context
     * @param fromActivationCallback is recursively called from an activation callback
     */
-   void resolve(final ProfileDependencyContext context, final boolean fromActivationCallback)
+   void resolve(final ProfileMetaDataContext context, final boolean fromActivationCallback)
    {
       final boolean trace = log.isTraceEnabled();
       final ProfileKey currentKey = context.getKey();
-      final ProfileNode currentNode = getNode(context);
+      final ProfileResolutionNode currentNode = getNode(context);
       // Don't process a node twice
       if(included(currentNode))
       {
@@ -205,17 +211,17 @@
          // Don't include callbacks we need to process them afterwards
          callbacks.add(currentNode);
       }
-      final Collection<ProfileRequirementDependencyItem> requirements = context.getiDependOn();
+      final Collection<ProfileRequirement> requirements = context.getRequirements();
       if(requirements != null && requirements.isEmpty() == false)
       {
-         for(final ProfileRequirementDependencyItem dependencyItem : requirements)
+         for(final ProfileRequirement requirement : requirements)
          {
             // Try to resolve the requirement
-            final ProfileRequirement requirement = dependencyItem.getRequirement();
+            final ProfileRequirementResolutionContext resolution = new ProfileRequirementResolutionContext(context, requirement);
             ProfileKey dependencyKey = internalResolve(context, requirement); 
             if(dependencyKey == null)
             {
-               dependencyKey = registry.resolve(context, requirement, this.includedKeys);
+               dependencyKey = profileRepository.resolve(resolution, this);
             }
             if(dependencyKey == null)
             {
@@ -227,7 +233,6 @@
                continue;
             }
             // Ignore self dependencies
-            dependencyItem.setIDependOn(dependencyKey);
             if(currentKey.equals(dependencyKey))
             {
                continue;
@@ -235,13 +240,13 @@
             
             // Get the mode and dependency context
             final DependencyMode mode = getDependencyMode(requirement);
-            final ProfileDependencyContext dependencyContext = registry.getProfile(dependencyKey);
-            final ProfileNode depenencyNode = getNode(dependencyContext);
+            final ProfileMetaDataContext dependencyContext = profileRepository.resolve(dependencyKey.getName());
+            final ProfileResolutionNode depenencyNode = getNode(dependencyContext);
 
             // Add the dependency context
             addDependencyContext(dependencyContext);
             
-            if(mode == DependencyMode.RESOLVE || dependencyContext.isOnDemandEnabled())
+            if(mode == DependencyMode.RESOLVE)
             {
                // Resolve
                resolve(dependencyContext, false);
@@ -255,7 +260,8 @@
             // If the dependency is already included we can mark it as non-optional
             final boolean dependencyIncluded = included(depenencyNode);
             final boolean optional = requirement.isOptional() && dependencyIncluded == false;
-            final ProfileNodeDependency dependency = new ProfileNodeDependency(dependencyItem, optional);
+            final boolean requireInstalled = dependencyContext.getActivationConfiguration() != null;
+            final ProfileNodeDependency dependency = new ProfileNodeDependency(resolution, dependencyKey, requirement, optional, requireInstalled);
 
             // Add dependency information
             currentNode.addIDependOn(dependency);
@@ -282,11 +288,11 @@
     * @param requirement the requirement
     * @return the resolved profile key, null if it can't be resolved
     */
-   protected ProfileKey internalResolve(ProfileDependencyContext ctx, ProfileRequirement requirement)
+   protected ProfileKey internalResolve(ProfileMetaDataContext ctx, ProfileRequirement requirement)
    {
       // Resolve the requirements based on the exposed capabilities
       final boolean trace = log.isTraceEnabled();
-      for(ProfileDependencyContext profile : includedContexts)
+      for(ProfileMetaDataContext profile : includedContexts)
       {
          Collection<ProfileCapability> capabilities = profile.getCapabilities();
          if(capabilities != null && capabilities.isEmpty() == false)
@@ -315,7 +321,7 @@
     * 
     * @param context the context to add
     */
-   protected void addDependencyContext(final ProfileDependencyContext context)
+   protected void addDependencyContext(final ProfileMetaDataContext context)
    {
       if(this.includedContexts.contains(context))
       {
@@ -326,7 +332,7 @@
       {
          for(final ProfileCapability capability : capabilities)
          {
-            for(final ProfileDependencyContext included : this.includedContexts)
+            for(final ProfileMetaDataContext included : this.includedContexts)
             {
                final Collection<ProfileCapability> includedCapabilities = included.getCapabilities();
                if(includedCapabilities != null && includedCapabilities.isEmpty() == false)
@@ -335,8 +341,8 @@
                   {
                      if(capability.isConsistent(other) == false)
                      {
-                        throw new IllegalStateException(context.getName() + " has an incosistent capability " + capability + " with module "
-                              + included.getName() + " / " + other);
+                        throw new IllegalStateException(context.getProfileName() + " has an incosistent capability " + capability + " with module "
+                              + included.getProfileName() + " / " + other);
                      }
                   }
                }
@@ -352,16 +358,20 @@
     * 
     * @return the sorted list of profile keys 
     */
-   public List<ProfileKey> sort()
+   public List<ProfileMetaDataContext> sort()
    {
       if(this.unresolved.isEmpty() == false)
       {
          throw new IllegalStateException("unresolved " + this.unresolved);
       }
+      
+      log.debug("nodes " + nodes.size());
+      log.debug("incl " + included.size() +" / "+ includedKeys.size());
+      
       // Process activation callbacks to determine if they can be included
-      for(Iterator<ProfileNode> i = callbacks.iterator() ;  i.hasNext() ;)
+      for(Iterator<ProfileResolutionNode> i = callbacks.iterator() ;  i.hasNext() ;)
       {
-         final ProfileNode callback = i.next();
+         final ProfileResolutionNode callback = i.next();
          if(included(callback) == false)
          {
             // Check if the activation callback can be resolved
@@ -386,7 +396,7 @@
     * @param key the profile key
     * @return the profile node
     */
-   ProfileNode getNode(ProfileDependencyContext ctx)
+   ProfileResolutionNode getNode(ProfileMetaDataContext ctx)
    {
       final ProfileKey key = ctx.getKey();
       if(nodes.containsKey(key))
@@ -395,13 +405,13 @@
       }
       else
       {
-         final ProfileNode node = new ProfileNode(ctx);
+         final ProfileResolutionNode node = new ProfileResolutionNode(ctx);
          nodes.put(key, node);
          return node;
       }
    }
    
-   ProfileNode getProcessedNode(ProfileKey key)
+   ProfileResolutionNode getProcessedNode(ProfileKey key)
    {
       return nodes.get(key);
    }
@@ -412,7 +422,7 @@
     * @param node the node
     * @return true if included, false otherwise
     */
-   boolean included(ProfileNode node)
+   boolean included(ProfileResolutionNode node)
    {
       return includedKeys.contains(node.getKey());
    }
@@ -438,19 +448,19 @@
        * 
        * @return the sorted profile keys.
        */
-      List<ProfileKey> sort()
+      List<ProfileMetaDataContext> sort()
       {
          final boolean trace = log.isTraceEnabled();
-         List<ProfileKey> sorted = new ArrayList<ProfileKey>();
-         List<ProfileNode> roots = getRoots();
+         List<ProfileMetaDataContext> sorted = new ArrayList<ProfileMetaDataContext>();
+         List<ProfileResolutionNode> roots = getRoots();
          if(trace)
          {
             log.trace("roots: " + roots);
          }
          while(roots.isEmpty() == false)
          {
-            final ProfileNode node = roots.remove(0);
-            sorted.add(node.getKey());
+            final ProfileResolutionNode node = roots.remove(0);
+            sorted.add(node);
             if(node.hasDependsOnMe())
             {
                for(final ProfileNodeDependency dependsOnMe : node.getDependsOnMe())
@@ -462,7 +472,7 @@
                      continue;
                   }
                   // Get the dependent node
-                  final ProfileNode otherNode = getProcessedNode(dependsOnMe.getFrom());
+                  final ProfileResolutionNode otherNode = getProcessedNode(dependsOnMe.getFrom());
                   if(otherNode == null || included(otherNode) == false)
                   {
                      throw new IllegalStateException("trying to activate non included node " + otherNode);
@@ -495,12 +505,12 @@
        * 
        * @return the roots
        */
-      List<ProfileNode> getRoots()
+      List<ProfileResolutionNode> getRoots()
       {
-         final ArrayList<ProfileNode> roots = new ArrayList<ProfileNode>();
-         for(Iterator<ProfileNode> i = included.iterator(); i.hasNext() ;)
+         final ArrayList<ProfileResolutionNode> roots = new ArrayList<ProfileResolutionNode>();
+         for(Iterator<ProfileResolutionNode> i = included.iterator(); i.hasNext() ;)
          {
-            ProfileNode node = i.next();
+            ProfileResolutionNode node = i.next();
             if(node.isResolved())
             {
                roots.add(node);
@@ -514,7 +524,7 @@
    protected String debug()
    {
       StringBuilder builder = new StringBuilder("failed to resolve dependencies: \n");
-      for(ProfileNode node : included)
+      for(ProfileResolutionNode node : included)
       {
          builder.append(node.getKey().getName()).append("\n");
          for(ProfileNodeDependency dependency : node.getiDependOn())

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/BasicResolverFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/BasicResolverFactory.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/BasicResolverFactory.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -25,10 +25,9 @@
 import java.util.List;
 
 import org.jboss.profileservice.bootstrap.ProfileActivationCallback;
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
-import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.repository.ProfileRepository;
 import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 import org.jboss.profileservice.spi.dependency.ProfileRequirementResolver;
 import org.jboss.profileservice.spi.dependency.ProfileRequirementResolverFactory;
@@ -41,12 +40,12 @@
 {
 
    /** The profile meta data registry. */
-   private final ProfileMetaDataRegistry registry;
+   private final ProfileRepository profileRepository;
    private final ProfileActivationCallback callback;
    
-   public BasicResolverFactory(ProfileMetaDataRegistry registry, ProfileActivationCallback callback)
+   public BasicResolverFactory(ProfileRepository profileRepository, ProfileActivationCallback callback)
    {
-      this.registry = registry;
+      this.profileRepository = profileRepository;
       this.callback = callback;
    }   
    
@@ -57,19 +56,18 @@
          throw new IllegalArgumentException("null profile name");
       }
       final EmptyProfileMetaData metaData = new EmptyProfileMetaData(name);
-      registry.registerProfileMetaData(metaData);
-      final ProfileDependencyContext ctx = registry.getContext(name);
+      final ProfileMetaDataContext ctx = profileRepository.registerMetaData(metaData);
       return new ProfileResolverFacade(ctx, callback);
    }
    
    public class ProfileResolverFacade implements ProfileRequirementResolver
    {
 
-      private final ProfileDependencyContext context;
+      private final ProfileMetaDataContext context;
       private final ProfileActivationCallback callback;
-      private List<ProfileKey> resolved;
+      private List<ProfileMetaDataContext> resolved;
       
-      public ProfileResolverFacade(ProfileDependencyContext context, ProfileActivationCallback callback)
+      public ProfileResolverFacade(ProfileMetaDataContext context, ProfileActivationCallback callback)
       {
          this.context = context;
          this.callback = callback;
@@ -84,9 +82,9 @@
       {
          if(resolved != null && resolved.isEmpty() == false)
          {
-            for(ProfileKey key : resolved)
+            for(ProfileMetaDataContext context : resolved)
             {
-               callback.activate(key);
+               callback.activate(context);
             }
          }
       }
@@ -98,7 +96,7 @@
 
       public boolean resolve()
       {
-         AbstractRequirementResolver resolver = new AbstractRequirementResolver(registry);
+         AbstractRequirementResolver resolver = new AbstractRequirementResolver(profileRepository);
          resolver.resolve(context);
          resolved = resolver.sort();
          return true;

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -1,166 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, 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.resolver;
-
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.spi.ProfileKey;
-
-/**
- * The profile node.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-class ProfileNode
-{
-
-   /** The meta data context. */
-   private final ProfileDependencyContext ctx;
-   
-   /** I depend on. */
-   private List<ProfileNodeDependency> iDependOn = new LinkedList<ProfileNodeDependency>();
-   private ConcurrentMap<String, Set<ProfileNodeDependency>> iDependOnByName = new ConcurrentHashMap<String, Set<ProfileNodeDependency>>();
-   
-   /** Depends on me. */
-   private List<ProfileNodeDependency> dependsOnMe = new LinkedList<ProfileNodeDependency>();
-
-   public ProfileNode(ProfileDependencyContext ctx)
-   {
-      this.ctx = ctx;
-   }
-
-   public ProfileKey getKey()
-   {
-      return ctx.getKey();
-   }
-   
-   void addIDependOn(ProfileNodeDependency dependency)
-   {
-      this.iDependOn.add(dependency);
-      this.iDependOnByName.putIfAbsent(dependency.getTo().getName(), new HashSet<ProfileNodeDependency>());
-      this.iDependOnByName.get(dependency.getTo().getName()).add(dependency);
-   }
-   
-   public List<ProfileNodeDependency> getiDependOn()
-   {
-      return iDependOn;
-   }
-   
-   void markAsResolved(ProfileKey key)
-   {
-      Set<ProfileNodeDependency> dependencies = this.iDependOnByName.get(key.getName());
-      for(final ProfileNodeDependency dependency : dependencies)
-      {
-         dependency.markAsResolved();
-      }
-//      for(final ProfileNodeDependency dependency : iDependOn)
-//      {
-//         if(key.equals(dependency.getTo()))
-//         {
-//            dependency.markAsResolved();
-//         }
-//      }
-   }
-   
-   void addDependsOnMe(ProfileNodeDependency dependency)
-   {
-      this.dependsOnMe.add(dependency);
-   }
-   
-   List<ProfileNodeDependency> getDependsOnMe()
-   {
-      return this.dependsOnMe;
-   }
-   
-   void hardenDependsOnMe()
-   {
-      for(ProfileNodeDependency dependency : dependsOnMe)
-      {
-         dependency.hardenDependency();
-         dependency.hardenOptionalDependsOnTo();
-      }
-   }
-   
-   boolean hasDependsOnMe()
-   {
-      return this.dependsOnMe.size() > 0;
-   }
-   
-   boolean checkResolved(Set<ProfileKey> included)
-   {
-      boolean resolved = true;
-      for(ProfileNodeDependency dependency : iDependOn)
-      {
-         if(dependency.isOptional() == false)
-         {
-            ProfileKey key = dependency.getTo();
-            if(key == null || included.contains(key) == false)
-               resolved = false;
-         }
-      }
-      return resolved;
-   }
-   
-   boolean isResolved()
-   {
-      boolean resolved = true;
-      for(ProfileNodeDependency dependency : iDependOn)
-      {
-         if(dependency.isResolved() == false && dependency.isOptional() == false)
-            resolved = false;
-      }
-      return resolved;
-   }
-   
-   @Override
-   public int hashCode()
-   {
-      return getKey().hashCode();
-   }
-   
-   @Override
-   public boolean equals(Object obj)
-   {
-      if(obj == this)
-         return true;
-      if(obj == null || obj instanceof ProfileNode == false)
-         return false;
-      ProfileNode other = (ProfileNode) obj;
-      return getKey().equals(other.getKey());
-   }
-   
-   @Override
-   public String toString()
-   {
-      return getKey().getName();
-   }
-   
-}
-
-

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -21,7 +21,6 @@
 */
 package org.jboss.profileservice.resolver;
 
-import org.jboss.profileservice.dependency.ProfileRequirementDependencyItem;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 
@@ -31,35 +30,48 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-class ProfileNodeDependency
+class ProfileNodeDependency 
 {
 
+   /** to. */
+   private final ProfileKey to;
+   
    /** Is optional from -> to. */
    private boolean optional;
    
-   /** Is optional from <- to. */
+   /** Is optional to -> from. */
    private boolean optionalDependsOnTo;
    
    /** Is marked as resolved. */
    private boolean resolved = false;
+
+   /** Require installed. */
+   private final boolean requireInstalled;
    
-   /** The dependency item. */
-   private final ProfileRequirementDependencyItem dependencyItem;
+   /** resultion. */
+   private final ProfileRequirementResolutionContext resolution;
    
-   public ProfileNodeDependency(final ProfileRequirementDependencyItem dependencyItem, boolean optional)
+   /** The profile requirement. */
+   private final ProfileRequirement requirement;
+   
+   public ProfileNodeDependency(ProfileRequirementResolutionContext resolution, ProfileKey to,
+         ProfileRequirement requirement, boolean optional, boolean requireInstalled)
    {
-      this.dependencyItem = dependencyItem;
+      this.resolution = resolution;
+      this.to = to;
       this.optional = optional;
+      this.requirement = requirement;
+      this.requireInstalled = requireInstalled;
    }
-
+   
    ProfileKey getFrom()
    {
-      return dependencyItem.getName();
+      return resolution.getMetaDataContext().getKey();
    }
    
    ProfileKey getTo()
    {
-      return dependencyItem.getIDependOn();
+      return to;
    }
    
    boolean isOptional()
@@ -97,6 +109,16 @@
       resolved = true;
    }
    
+   ProfileRequirement getRequirement()
+   {
+      return requirement;
+   }
+   
+   boolean isRequireInstalled()
+   {
+      return requireInstalled;
+   }
+   
    @Override
    public String toString()
    {

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileRequirementResolutionContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileRequirementResolutionContext.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileRequirementResolutionContext.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,85 @@
+/*
+* 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.resolver;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class ProfileRequirementResolutionContext
+{
+
+   /** The profile. */
+   private final ProfileMetaDataContext metaDataContext;
+   
+   /** The requirement. */
+   private final ProfileRequirement requirement;
+
+   /** The resolved profiles. */
+   private Set<ProfileKey> resolved;
+   
+   public ProfileRequirementResolutionContext(ProfileMetaDataContext context, ProfileRequirement requirement)
+   {
+      this.metaDataContext = context;
+      this.requirement = requirement;
+   }
+   
+   public ProfileMetaDataContext getMetaDataContext()
+   {
+      return metaDataContext;
+   }
+   
+   public ProfileRequirement getRequirement()
+   {
+      return requirement;
+   }
+   
+   public void addResolved(ProfileKey key)
+   {
+      if(this.resolved == null)
+      {
+         this.resolved = new HashSet<ProfileKey>();
+      }
+      if(this.resolved.contains(key) == false)
+      {
+         this.resolved.add(key);
+      }
+   }
+
+   public Set<ProfileKey> getResolved()
+   {
+      if(this.resolved == null)
+      {
+         return Collections.emptySet();
+      }
+      return this.resolved;
+   }
+   
+}
+

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileResolutionFilter.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileResolutionFilter.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileResolutionFilter.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,49 @@
+/*
+* 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.resolver;
+
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public interface ProfileResolutionFilter
+{
+
+   public static ProfileResolutionFilter NOOP_FILTER = new ProfileResolutionFilter()
+   {
+      public boolean accepts(ProfileMetaDataContext context)
+      {
+         return true;
+      }
+   };
+   
+   /**
+    * Check whether to resolve against the given context.
+    * 
+    * @param context the profile
+    * @return false when not to resolve requirement against this profile 
+    */
+   boolean accepts(ProfileMetaDataContext context);
+   
+}
+

Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileResolutionNode.java (from rev 105218, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileResolutionNode.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileResolutionNode.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,291 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.resolver;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.profileservice.dependency.ProfileControllerContext;
+import org.jboss.profileservice.dependency.ProfileRequirementDependencyItem;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.activation.ProfileActivationConfiguration;
+import org.jboss.profileservice.spi.dependency.ProfileCapability;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+import org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
+
+/**
+ * The profile node.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileResolutionNode implements ProfileMetaDataContext
+{
+
+   /** The meta data context. */
+   private final ProfileMetaDataContext delegate;
+   
+   /** I depend on. */
+   private List<ProfileNodeDependency> iDependOn = new LinkedList<ProfileNodeDependency>();
+   private ConcurrentMap<String, Set<ProfileNodeDependency>> iDependOnByName = new ConcurrentHashMap<String, Set<ProfileNodeDependency>>();
+   
+   /** Depends on me. */
+   private List<ProfileNodeDependency> dependsOnMe = new LinkedList<ProfileNodeDependency>();
+
+   public ProfileResolutionNode(ProfileMetaDataContext ctx)
+   {
+      this.delegate = ctx;
+   }
+
+   public ProfileKey getKey()
+   {
+      return delegate.getKey();
+   }
+   
+   void addIDependOn(ProfileNodeDependency dependency)
+   {
+      this.iDependOn.add(dependency);
+      this.iDependOnByName.putIfAbsent(dependency.getTo().getName(), new HashSet<ProfileNodeDependency>());
+      this.iDependOnByName.get(dependency.getTo().getName()).add(dependency);
+   }
+   
+   public List<ProfileNodeDependency> getiDependOn()
+   {
+      return iDependOn;
+   }
+   
+   void markAsResolved(ProfileKey key)
+   {
+      Set<ProfileNodeDependency> dependencies = this.iDependOnByName.get(key.getName());
+      for(final ProfileNodeDependency dependency : dependencies)
+      {
+         dependency.markAsResolved();
+      }
+   }
+   
+   void addDependsOnMe(ProfileNodeDependency dependency)
+   {
+      this.dependsOnMe.add(dependency);
+   }
+   
+   List<ProfileNodeDependency> getDependsOnMe()
+   {
+      return this.dependsOnMe;
+   }
+   
+   void hardenDependsOnMe()
+   {
+      for(ProfileNodeDependency dependency : dependsOnMe)
+      {
+         dependency.hardenDependency();
+         dependency.hardenOptionalDependsOnTo();
+      }
+   }
+   
+   boolean hasDependsOnMe()
+   {
+      return this.dependsOnMe.size() > 0;
+   }
+   
+   boolean checkResolved(Collection<ProfileKey> included)
+   {
+      boolean resolved = true;
+      for(ProfileNodeDependency dependency : iDependOn)
+      {
+         if(dependency.isOptional() == false)
+         {
+            ProfileKey key = dependency.getTo();
+            if(key == null || included.contains(key) == false)
+               resolved = false;
+         }
+      }
+      return resolved;
+   }
+   
+   boolean isResolved()
+   {
+      boolean resolved = true;
+      for(ProfileNodeDependency dependency : iDependOn)
+      {
+         if(dependency.isResolved() == false && dependency.isOptional() == false)
+            resolved = false;
+      }
+      return resolved;
+   }
+   
+   @Override
+   public int hashCode()
+   {
+      return getKey().hashCode();
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      if(obj == this)
+         return true;
+      if(obj == null || obj instanceof ProfileResolutionNode == false)
+         return false;
+      ProfileResolutionNode other = (ProfileResolutionNode) obj;
+      return getKey().equals(other.getKey());
+   }
+   
+   @Override
+   public String toString()
+   {
+      return getKey().getName();
+   }
+
+   public void describe(ProfileControllerContext context)
+   {      
+      final DependencyInfo dependencyInfo = context.getDependencyInfo();
+      for(ProfileNodeDependency dependency : iDependOn)
+      {
+         if(dependency.isOptional()) continue;
+         final ProfileRequirement requirement = dependency.getRequirement();
+         ControllerState dependentState = dependency.isRequireInstalled() ? ControllerState.INSTALLED : ControllerState.DESCRIBED;
+         dependencyInfo.addIDependOn(new ProfileRequirementDependencyItem(context, requirement, dependency.getTo(),
+               dependentState));
+      }
+   }
+   
+   /**
+    * @param name
+    * @see org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor#addAlias(java.lang.String)
+    */
+   public void addAlias(String name)
+   {
+      delegate.addAlias(name);
+   }
+
+   /**
+    * @param capability
+    * @see org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor#addCapability(org.jboss.profileservice.spi.dependency.ProfileCapability)
+    */
+   public void addCapability(ProfileCapability capability)
+   {
+      delegate.addCapability(capability);
+   }
+
+   /**
+    * @param feature
+    * @see org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor#addFeature(org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData)
+    */
+   public void addFeature(ProfileFeatureMetaData feature)
+   {
+      delegate.addFeature(feature);
+   }
+
+   /**
+    * @param requirement
+    * @see org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor#addRequirement(org.jboss.profileservice.spi.dependency.ProfileRequirement)
+    */
+   public void addRequirement(ProfileRequirement requirement)
+   {
+      delegate.addRequirement(requirement);
+   }
+
+   /**
+    * @return
+    * @see org.jboss.profileservice.repository.ProfileMetaDataContext#getActivationConfiguration()
+    */
+   public ProfileActivationConfiguration getActivationConfiguration()
+   {
+      return delegate.getActivationConfiguration();
+   }
+
+   /**
+    * @return
+    * @see org.jboss.profileservice.repository.ProfileMetaDataContext#getAliases()
+    */
+   public Collection<ProfileKey> getAliases()
+   {
+      return delegate.getAliases();
+   }
+
+   /**
+    * @return
+    * @see org.jboss.profileservice.repository.ProfileMetaDataContext#getCapabilities()
+    */
+   public Collection<ProfileCapability> getCapabilities()
+   {
+      return delegate.getCapabilities();
+   }
+
+   /**
+    * @return
+    * @see org.jboss.profileservice.repository.ProfileMetaDataContext#getFeatures()
+    */
+   public Collection<ProfileFeatureMetaData> getFeatures()
+   {
+      return delegate.getFeatures();
+   }
+
+   /**
+    * @return
+    * @see org.jboss.profileservice.repository.ProfileMetaDataContext#getProfileMetaData()
+    */
+   public ProfileMetaData getProfileMetaData()
+   {
+      return delegate.getProfileMetaData();
+   }
+
+   /**
+    * @return
+    * @see org.jboss.profileservice.repository.ProfileMetaDataContext#getProfileName()
+    */
+   public String getProfileName()
+   {
+      return delegate.getProfileName();
+   }
+
+   /**
+    * @return
+    * @see org.jboss.profileservice.repository.ProfileMetaDataContext#getRequirements()
+    */
+   public Collection<ProfileRequirement> getRequirements()
+   {
+      return delegate.getRequirements();
+   }
+
+   /**
+    * @param node
+    * @see org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor#visit(org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode)
+    */
+   public void visit(ProfileMetaDataVisitorNode node)
+   {
+      delegate.visit(node);
+   }
+   
+}
+
+

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/domain/support/AbstractDomainMetaDataVisitor.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/domain/support/AbstractDomainMetaDataVisitor.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/domain/support/AbstractDomainMetaDataVisitor.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -25,14 +25,13 @@
 import java.util.Stack;
 
 import org.jboss.logging.Logger;
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.domain.spi.DomainMetaDataFragment;
 import org.jboss.profileservice.domain.spi.DomainMetaDataFragmentVisitor;
 import org.jboss.profileservice.profile.metadata.BasicSubProfileMetaData;
 import org.jboss.profileservice.profile.metadata.domain.RequiredProfiles.ResolveRequirement;
 import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
-import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.repository.ProfileRepository;
 import org.jboss.profileservice.spi.dependency.DependencyMode;
 import org.jboss.profileservice.spi.dependency.ProfileCapability;
 import org.jboss.profileservice.spi.dependency.ProfileRequirement;
@@ -51,20 +50,20 @@
    /** The logger. */
    private static final Logger log = Logger.getLogger(AbstractDomainMetaDataVisitor.class);
    
-   private final ProfileDependencyContext ctx;
+   private final ProfileMetaDataContext ctx;
    
-   private ProfileMetaDataRegistry registry;
+   private final ProfileRepository profileRepository;
    
    /** Implicit dependencies. */
    private Stack<String> stack = new Stack<String>();
    
-   public AbstractDomainMetaDataVisitor(ProfileMetaDataRegistry domain)
+   public AbstractDomainMetaDataVisitor(ProfileRepository profileRepository)
    {
-      this.ctx = new ProfileDependencyContext(new ProfileKey("test"), new EmptyProfileMetaData(), domain);
-      this.registry = domain;
+      this.profileRepository = profileRepository;
+      this.ctx = profileRepository.registerMetaData(new EmptyProfileMetaData("test"));
    }
    
-   public ProfileDependencyContext getCtx()
+   public ProfileMetaDataContext getCtx()
    {
       return ctx;
    }
@@ -82,13 +81,9 @@
       {
          throw new IllegalArgumentException("null profile name");
       }
-      if(metaData.getName().equals("test"))
-      {
-         return;
-      }
       // Add a domain meta data requirement
       addRequirement(new ResolveRequirement(metaData.getName()));
-      registry.registerProfileMetaData(metaData);
+      ProfileMetaDataContext ctx = profileRepository.registerMetaData(metaData);
       
       // Also extract all requirements of the included nodes
       visit(metaData);
@@ -97,8 +92,7 @@
       // create a implicit one
       if(stack.empty() == false)
       {
-         String previous = stack.pop();
-         ProfileDependencyContext ctx = registry.getContext(profileName);        
+         String previous = stack.pop();        
          ProfileRequirement requirement = new BasicSubProfileMetaData(previous, DependencyMode.OPTIONAL);
          ctx.addRequirement(requirement);
          log.info("setting implicit dependency from (" + profileName +") to ("+previous +")");
@@ -132,12 +126,6 @@
    }
    
    @Override
-   public void enableOnDemand(boolean onDemand)
-   {
-      // nothing
-   }
-   
-   @Override
    public void visit(DomainMetaDataFragment node)
    {
       node.visit(this);

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -22,16 +22,15 @@
 package org.jboss.test.profileservice.metadata.test;
 
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
 
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
 import org.jboss.profileservice.domain.spi.DomainMetaData;
 import org.jboss.profileservice.metadata.ProfilesMetaDataFactory;
 import org.jboss.profileservice.profile.metadata.domain.XmlDomainMetaDataRepository;
+import org.jboss.profileservice.repository.AbstractMetaDataContext;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.test.profileservice.ProfileServiceTestBase;
+import org.jboss.test.profileservice.support.ActivationProfileMetaData;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -40,8 +39,8 @@
 public class BasicDomainMetaDataUnitTestCase extends ProfileServiceTestBase
 {
    
-   List<ProfileDependencyContext> profileCtxs = new ArrayList<ProfileDependencyContext>();
    
+   
    public BasicDomainMetaDataUnitTestCase(String name)
    {
       super(name);
@@ -55,15 +54,14 @@
       metaDataFactory.parse(profiles);
     
       URL domain = findResource("metadata/domain/domain1.xml");
+      XmlDomainMetaDataRepository.addSchemaBinding(ActivationProfileMetaData.NAMESPACE, ActivationProfileMetaData.class);
       XmlDomainMetaDataRepository support = new XmlDomainMetaDataRepository(domain);
       DomainMetaData metaData = support.getDomainMetaData();
       assertNotNull(metaData);
       
       for(ProfileMetaData md : metaDataFactory.getProfiles().values())
       {
-         ProfileDependencyContext ctx = new ProfileDependencyContext(new ProfileKey(md.getName()), md, null);
-         ctx.visit(md);
-         profileCtxs.add(ctx);
+         new AbstractMetaDataContext(new ProfileKey(md.getName()), md);
       }
    }
    

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/AbstractResolverTest.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/AbstractResolverTest.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/AbstractResolverTest.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -28,12 +28,12 @@
 import org.jboss.profileservice.config.ManagementDomain;
 import org.jboss.profileservice.config.ProfileServiceConfig;
 import org.jboss.profileservice.config.ServerConfiguration;
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.profile.metadata.domain.RequiredProfiles.ResolveRequirement;
 import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.repository.ProfileRepositories;
+import org.jboss.profileservice.repository.ProfileRepository;
 import org.jboss.profileservice.resolver.AbstractRequirementResolver;
-import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.test.profileservice.ProfileServiceTestBase;
 import org.jboss.test.profileservice.resolver.support.TestProfilesMetaData;
@@ -46,7 +46,7 @@
 public abstract class AbstractResolverTest extends ProfileServiceTestBase
 {
 
-   private ProfileMetaDataRegistry registry;
+   private ProfileRepositories registry;
    private AbstractRequirementResolver resolver;
    private ProfileServiceConfig config;
    
@@ -60,7 +60,7 @@
       return "test-profile";
    }
    
-   public ProfileMetaDataRegistry getRegistry()
+   public ProfileRepository getRegistry()
    {
       return registry;
    }
@@ -77,19 +77,19 @@
       return new ProfileServiceConfig(domain, server);
    }
    
-   protected ProfileMetaDataRegistry createRegistry()
+   protected ProfileRepositories createRepository()
    {
       this.config = createConfig();
       
       this.config.setProfileFactory(new NoopProfileFactory());
       
-      this.registry = new ProfileMetaDataRegistry(this.config);
+      this.registry = new ProfileRepositories(this.config);
       return this.registry;
    }
    
    protected TestProfilesMetaData parse(String file) throws Exception
    {
-      createRegistry();
+      createRepository();
       resolver = new AbstractRequirementResolver(registry);
       TestProfilesMetaData profiles = unmarshal(file, TestProfilesMetaData.class);
       for(ProfileMetaData profile : profiles.getProfiles())
@@ -101,8 +101,7 @@
 
    void addProfile(ProfileMetaData metaData)
    {
-      ProfileDependencyContext context = new ProfileDependencyContext(new ProfileKey(metaData.getName()), metaData, registry);
-      registry.addContext(context);
+      registry.registerMetaData(metaData);
    }
 
    List<String> resolve(String xml, String... requirements) throws Exception
@@ -114,7 +113,7 @@
    List<String> resolveRequirements(String... requirements)
    {
       ProfileMetaData testProfile = createTestProfileMetaData();
-      ProfileDependencyContext context = new ProfileDependencyContext(new ProfileKey(testProfile.getName()), testProfile, registry);
+      ProfileMetaDataContext context = registry.registerMetaData(testProfile);
       for(String requirement : requirements)
       {
          context.addRequirement(new ResolveRequirement(requirement));
@@ -122,19 +121,18 @@
       return resolveRequirements(context);
    }
    
-   List<String> resolveRequirements(ProfileDependencyContext context)
+   List<String> resolveRequirements(ProfileMetaDataContext context)
    {
-      registry.addContext(context);
       resolver.resolve(context);
       return getNames(resolver.sort());      
    }
    
-   List<String> getNames(List<ProfileKey> contexts)
+   List<String> getNames(List<ProfileMetaDataContext> contexts)
    {
       List<String> names = new ArrayList<String>();
-      for(ProfileKey context : contexts)
+      for(ProfileMetaDataContext context : contexts)
       {
-            names.add(context.getName());
+            names.add(context.getProfileName());
       }
       getLog().debug(names);
       return names;

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ProcessingUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ProcessingUnitTestCase.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ProcessingUnitTestCase.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -24,14 +24,18 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.dependency.ProfileServiceController;
+import org.jboss.profileservice.TypedProfileFactory;
+import org.jboss.profileservice.dependency.ProfileActivationService;
 import org.jboss.profileservice.profile.metadata.domain.RequiredProfiles.ResolveRequirement;
 import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
 import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData.DependencyModeRequirement;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.repository.ProfileRepositories;
 import org.jboss.profileservice.resolver.AbstractRequirementResolver;
+import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.dependency.DependencyMode;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
@@ -44,7 +48,7 @@
 {
 
    Kernel kernel;
-   ProfileServiceController controller;
+   ProfileActivationService activationService;
    
    public ProcessingUnitTestCase(String name)
    {
@@ -57,14 +61,15 @@
       BasicBootstrap bootstrap = new BasicBootstrap();
       bootstrap.run();
       kernel = bootstrap.getKernel();
-      controller = new ProfileServiceController(kernel.getController(), createRegistry(), getConfig());
+      workaround();
+      this.activationService = new ActivationService(kernel, createRepository());
    }
    
    public void tearDown() throws Exception
    {
       super.tearDown();
       // kernel.getController().shutdown();
-      controller = null;
+      activationService = null;
       kernel = null;
    }
    
@@ -73,7 +78,9 @@
       createProfileMetaData(100);
       for(int i = 1; i <= 100; i++)
       {
-         controller.activate(new ProfileKey("profile"+i));
+         final ProfileKey key = new ProfileKey("profile"+i);
+         activationService.activate(key);
+         activationService.validate(key);
       }
    }
 
@@ -85,8 +92,13 @@
       for(int i = 1; i <= numbers; i++)
       // for(int i = numbers; i > 0 ; i--)
       {
-         controller.activate(new ProfileKey("profile"+i));
+         activationService.activate(new ProfileKey("profile"+i));
       }
+      for(int i = 1; i <= numbers; i++)
+         // for(int i = numbers; i > 0 ; i--)
+      {
+         activationService.validate(new ProfileKey("profile"+i));
+      }
       getLog().debug("time: " +  (System.currentTimeMillis() - millis));
    }
    
@@ -98,28 +110,26 @@
       
       createProfileMetaData(numbers);
 
-      ProfileDependencyContext d = new ProfileDependencyContext(new ProfileKey("test"), new EmptyProfileMetaData(), getRegistry());
+      ProfileMetaDataContext d = activationService.getProfileServiceRepository().registerMetaData(new EmptyProfileMetaData("test"));
       d.addRequirement(new ResolveRequirement("profile"+numbers));
-      
-      controller.install(d, null);
-      
+
       AbstractRequirementResolver resolver = new AbstractRequirementResolver(getRegistry());
 
       resolver.resolve(d);
-      List<ProfileKey> sorted = resolver.sort();
+      List<ProfileMetaDataContext> sorted = resolver.sort();
       getLog().debug(sorted);
       
-      getLog().debug("time: " +  (System.currentTimeMillis() - millis));
+      getLog().debug("time1: " +  (System.currentTimeMillis() - millis));
       millis = System.currentTimeMillis();
-      for(ProfileKey key : sorted)
+      for(ProfileMetaDataContext ctx : sorted)
       {
-         controller.activate(key);
+         activationService.installProfile(ctx, null);
+         activationService.activate(ctx.getKey());
+         activationService.validate(ctx.getKey());
       }
-      getLog().debug("time: " +  (System.currentTimeMillis() - millis));
+      getLog().debug("time2: " +  (System.currentTimeMillis() - millis));
    }
 
-
-   
    protected void createProfileMetaData(int numbers) throws Exception
    {
       int blah = 0;
@@ -148,7 +158,7 @@
          }
          try
          {
-            controller.registerAndInstallContext(metaData, null);
+            activationService.getProfileServiceRepository().registerMetaData(metaData);
          }
          catch(Throwable t)
          {
@@ -157,6 +167,42 @@
       }
       getLog().debug("blah " + blah);
    }
+
+   protected void workaround() throws Exception
+   {
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("TypedProfileFactory", TypedProfileFactory.class.getName());
+      
+      try
+      {
+         kernel.getController().install(builder.getBeanMetaData());
+      }
+      catch(Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+
+   class ActivationService extends ProfileActivationService
+   {
+
+      public ActivationService(Kernel kernel, ProfileRepositories metaDataRepository)
+      {
+         super(kernel, metaDataRepository);
+      }
+
+      public void activate(ProfileKey key) throws NoSuchProfileException, Exception
+      {
+         final String profileName = key.getName();
+         if(isInstalled(key.getName()) == false) {
+            ProfileMetaDataContext ctx = getProfileServiceRepository().resolve(profileName);
+            try {
+               installProfile(ctx, null);
+            } catch(Throwable t) { throw new RuntimeException(t); }
+         }
+         super.activate(key);
+      }
+      
+   }
    
 }
 

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/UserRequirementUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/UserRequirementUnitTestCase.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/UserRequirementUnitTestCase.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -23,7 +23,8 @@
 
 import java.util.List;
 
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
+import org.jboss.profileservice.repository.AbstractMetaDataContext;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.test.profileservice.resolver.dependency.support.ServiceRequirement;
@@ -86,7 +87,7 @@
    {
       parse(file);
       ProfileMetaData testProfile = createTestProfileMetaData();
-      ProfileDependencyContext context = new ProfileDependencyContext(new ProfileKey(testProfile.getName()), testProfile, getRegistry());
+      ProfileMetaDataContext context = new AbstractMetaDataContext(new ProfileKey(testProfile.getName()), testProfile);
       for(String service : services)
       {
          context.addRequirement(new ServiceRequirement(service));

Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ActivationProfileMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ActivationProfileMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ActivationProfileMetaData.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,68 @@
+/*
+* 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.support;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.profileservice.profile.metadata.ProfileActivationMetaData;
+import org.jboss.profileservice.profile.metadata.plugin.PropertyProfileMetaData;
+import org.jboss.profileservice.spi.activation.ProfileActivationConfiguration;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+ at JBossXmlSchema(namespace="urn:jboss:profileservice:profile:activation",
+      elementFormDefault=XmlNsForm.QUALIFIED,
+      normalizeSpace=true,
+      replacePropertyRefs=true)
+ at XmlRootElement(name = "activation-profile")
+ at XmlType(name = "propertyProfileType", propOrder = { "source" })
+public class ActivationProfileMetaData extends PropertyProfileMetaData
+{
+
+   /** The namespace. */
+   public static final String NAMESPACE = "urn:jboss:profileservice:profile:activation";
+   
+   /** The activation. */
+   private static final ProfileActivationMetaData activation;
+
+   static
+   {
+      activation = new ProfileActivationMetaData();
+      activation.setProfileActivatorRef(NAMESPACE);
+   }
+   
+   public ProfileActivationConfiguration getActivationConfiguration()
+   {
+      return activation;
+   }
+
+   public String getNameSpace()
+   {
+      return NAMESPACE;
+   }
+   
+}
+

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/MainDeployerPlugin.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/MainDeployerPlugin.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/MainDeployerPlugin.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -134,7 +134,7 @@
    
    Deployment createDeployment(ProfileDeployment deployment)
    {
-      return deploymentBuilder.createDeployment(deployment);
+      return deploymentBuilder.createDeployment(null, deployment);
    }
    
 }

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/NoopProfileFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/NoopProfileFactory.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/NoopProfileFactory.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -54,7 +54,8 @@
       return new String[] {
             PropertyProfileMetaData.class.getName(),
             HotDeploymentProfileMetaData.class.getName(),
-            FarmingProfileMetaData.class.getName()
+            FarmingProfileMetaData.class.getName(),
+            ActivationProfileMetaData.class.getName()
       };
    }
 

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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/ProfileServiceBootstrap.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -24,6 +24,7 @@
 import org.jboss.kernel.Kernel;
 import org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap;
 import org.jboss.profileservice.config.ProfileServiceConfig;
+import org.jboss.profileservice.dependency.ProfileActivationService;
 import org.jboss.profileservice.domain.AbstractDomainMetaData;
 import org.jboss.profileservice.domain.ManagementDomainMetaData;
 import org.jboss.profileservice.domain.ServerMetaData;
@@ -41,6 +42,11 @@
       super(kernel, config);
    }
 
+   public ProfileActivationService getActivationService()
+   {
+      return super.getActivationService();
+   }
+   
    public void start() throws Throwable
    {
       AbstractDomainMetaData domain = new AbstractDomainMetaData();

Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/TestProfileActivator.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/TestProfileActivator.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/TestProfileActivator.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,56 @@
+/*
+* 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.support;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.activation.ProfileActivation;
+import org.jboss.profileservice.spi.activation.ProfileActivator;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class TestProfileActivator implements ProfileActivator
+{
+   
+   private static final Logger log = Logger.getLogger(ProfileActivator.class);
+
+   public void activate(ProfileActivation activation) throws Exception
+   {
+      if(activation.isResolved() == false)
+      {
+         log.error("not resolved" + activation);
+      }
+      log.info("activating " + activation.getKey());
+   }
+
+   public void deactivate(ProfileActivation activation)
+   {
+      log.info("deactivating " + activation.getKey());
+   }
+
+   public String getActivatorReference()
+   {
+      return ActivationProfileMetaData.NAMESPACE;
+   }
+
+}
+

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/VDFDeploymentBuilder.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/VDFDeploymentBuilder.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/VDFDeploymentBuilder.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -26,6 +26,7 @@
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.profileservice.deployment.DeploymentBuilder;
 import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.test.profileservice.virtual.support.StructureMetaDataBuilder;
 
 
@@ -49,7 +50,7 @@
       return instance;
    }
    
-   public Deployment createDeployment(ProfileDeployment profileDeployment)
+   public Deployment createDeployment(ProfileKey key, ProfileDeployment profileDeployment)
    {
       Deployment d = null;
       if(profileDeployment.getRoot() == null)

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-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -28,18 +28,20 @@
 import org.jboss.deployers.client.spi.main.MainDeployer;
 import org.jboss.profileservice.Hack;
 import org.jboss.profileservice.config.ProfileServiceConstants;
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.deployment.hotdeploy.HDScannerFactory;
 import org.jboss.profileservice.domain.spi.DomainMetaData;
 import org.jboss.profileservice.metadata.ProfilesMetaDataFactory;
 import org.jboss.profileservice.profile.metadata.domain.XmlDomainMetaDataRepository;
+import org.jboss.profileservice.repository.ProfileMetaDataContext;
+import org.jboss.profileservice.repository.ProfileRepository;
 import org.jboss.profileservice.resolver.AbstractRequirementResolver;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.test.profileservice.domain.support.AbstractDomainMetaDataVisitor;
+import org.jboss.test.profileservice.support.ActivationProfileMetaData;
 import org.jboss.test.profileservice.support.MainDeployerPlugin;
+import org.jboss.test.profileservice.support.ProfileServiceBootstrap;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -65,48 +67,45 @@
       metaDataFactory.parse(profiles);
     
       URL domainMetaData = findResource("metadata/domain/domain1.xml");
+      // activation
+      XmlDomainMetaDataRepository.addSchemaBinding(ActivationProfileMetaData.NAMESPACE, ActivationProfileMetaData.class);
       XmlDomainMetaDataRepository support = new XmlDomainMetaDataRepository(domainMetaData);
       DomainMetaData metaData = support.getDomainMetaData();
       assertNotNull(metaData);
 
       ProfileService ps = getBean(ProfileServiceConstants.PROFILESERVICE_NAME, ProfileService.class);
-      ProfileMetaDataRegistry domain = getBean(ProfileServiceConstants.METADATA_REGISTRY_NAME, ProfileMetaDataRegistry.class);
+      ProfileRepository profileRepository = getBean(ProfileServiceConstants.PROFILEREPOSITORY_NAME, ProfileRepository.class);
+      ProfileServiceBootstrap bootstrap = getBean("ProfileServiceBootstrap", ProfileServiceBootstrap.class);
       assertNotNull(ps);
-      assertNotNull(domain);
+      assertNotNull(profileRepository);
 
       long millis = System.currentTimeMillis();
       for(ProfileMetaData md : metaDataFactory.getProfiles().values())
       {
-         domain.registerProfileMetaData(md);
+         profileRepository.registerMetaData(md);
       }
-      AbstractDomainMetaDataVisitor visitor = new AbstractDomainMetaDataVisitor(domain);
+      AbstractDomainMetaDataVisitor visitor = new AbstractDomainMetaDataVisitor(profileRepository);
       metaData.visit(visitor);
       
-      AbstractRequirementResolver resolver = new AbstractRequirementResolver(domain);
+      AbstractRequirementResolver resolver = new AbstractRequirementResolver(profileRepository);
       resolver.resolve(visitor.getCtx());
-      List<ProfileKey> list = resolver.sort();
-      
-      for(ProfileKey key : list)
+      List<ProfileMetaDataContext> list = resolver.sort();
+
+      for(ProfileMetaDataContext ctx : list)
       {
-         if(key.getName().equals("test") == false)
-         {
-            ProfileDependencyContext ctx = domain.getProfile(key);
-            ps.registerProfile(ctx.getProfileMetaData());
-         }
+         bootstrap.getActivationService().installProfile(ctx, null);
       }
-
+      
       getLog().debug("processing took " + (System.currentTimeMillis() - millis));      
       getLog().debug(list);
       
-      for(ProfileKey profile : list)
+      for(ProfileMetaDataContext profile : list)
       {
-         if(profile.getName().equals("test") == false)
-         {
-            long start = System.currentTimeMillis();
-            ps.activateProfile(profile);
-            ps.validateProfile(profile);
-            getLog().debug("activated " + profile.getName() + " took: " + (System.currentTimeMillis() - start));
-         }
+         final ProfileKey key = profile.getKey();
+         long start = System.currentTimeMillis();
+         ps.activateProfile(key);
+         ps.validateProfile(key);
+         getLog().debug("activated " + key.getName() + " took: " + (System.currentTimeMillis() - start));
       }
       
       // Check MainDeployer 
@@ -123,19 +122,13 @@
 
       // reverse
       Collections.reverse(list);
-      for(ProfileKey key : list)
+      for(ProfileMetaDataContext ctx : list)
       {
-         if(key.getName().equals("test") == false)
-         {
-            ps.deactivateProfile(key);
-         }
+         ps.deactivateProfile(ctx.getKey());
       }
-      for(ProfileKey key : list)
+      for(ProfileMetaDataContext ctx : list)
       {
-         if(key.getName().equals("test") == false)
-         {
-            ps.unregisterProfile(key);
-         }
+         ps.unregisterProfile(ctx.getKey());
       }
    }
    

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -27,7 +27,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.jboss.profileservice.config.VirtualAssemblyConfiguration;
-import org.jboss.profileservice.repository.ProfileDeploymentFactory;
+import org.jboss.profileservice.deployment.ProfileDeploymentFactory;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.VirtualDeploymentRepository;
 import org.jboss.profileservice.spi.repository.ArtifactId;

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -21,22 +21,18 @@
  */ 
 package org.jboss.test.profileservice.virtual.test;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.plugins.structure.MetaDataEntryImpl;
-import org.jboss.deployers.spi.structure.ClassPathEntry;
-import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.spi.structure.StructureMetaData;
 import org.jboss.profileservice.Hack;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.VirtualDeploymentRepository;
 import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
+import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
+import org.jboss.profileservice.virtual.assembly.AbstractVirtualAssemblyContext;
+import org.jboss.profileservice.virtual.assembly.BasicVirtualAssemblyContext;
 import org.jboss.test.profileservice.metadata.support.VirtualRepositoryMetaData;
-import org.jboss.test.profileservice.support.VDFDeploymentBuilder;
 
 /**
  * Test StructureMetaData creation.
@@ -48,7 +44,6 @@
 {
 
    private VirtualDeploymentRepository profileDeploymentFactory;
-   private final VDFDeploymentBuilder mcDeploymentBuilder = VDFDeploymentBuilder.getInstance();
    
    public StructureMetaDataUnitTestCase(String name)
    {
@@ -68,23 +63,15 @@
     
       this.profileDeploymentFactory = createRepository(REPOSITORY_LOCATION);
       
-      // test.simple
-      /**
-      VirtualDeployment simpleVD = deployments.get("simple.deployer");
-      ProfileDeployment simple = createProfileDeployment(simpleVD);
-      assertNull(createStructureMetaData(simple));
-      **/
-      
       // test.deployer
       VirtualDeploymentMetaData deployerVD = deployments.get("test.deployer");
       ProfileDeployment deployer = createProfileDeployment(deployerVD);
       try
       {
-         StructureMetaData deployerStructure = createStructureMetaData(deployer);
-         assertNotNull("null deployer structure", deployerStructure);
-         assertMetaDataLocations(deployerStructure.getContext(""));
-         assertClassPathEntries(deployerStructure.getContext(""), new String[] 
-            {"deployer.jar", "fake.jar", "fake2.jar"});
+         AbstractVirtualAssemblyContext ctx = getAssemblyContext(deployer);
+         assertNotNull("null deployer structure", ctx);
+         assertMetaDataLocations(ctx);
+         assertClassPathEntries(ctx, new String[]  {"deployer.jar", "fake.jar", "fake2.jar"});
       }
       finally
       {
@@ -96,16 +83,15 @@
       ProfileDeployment deployment = createProfileDeployment(deploymentVD);
       try
       {
-         StructureMetaData deploymentStructure = createStructureMetaData(deployment);
-         assertNotNull("null deployment structure", deploymentStructure);
-         assertMetaDataLocations(deploymentStructure.getContext(""));
-         assertClassPathEntries(deploymentStructure.getContext(""),
-               new String[] {"deployment.jar"});
+         AbstractVirtualAssemblyContext ctx = getAssemblyContext(deployment);
+         
+         assertMetaDataLocations(ctx);
+         assertClassPathEntries(ctx, new String[] {"deployment.jar"});
          // Check sub deployment ctx
-         assertNotNull("test sub deployment", deploymentStructure.getContext("test-sub-deployment"));
-         assertMetaDataLocations(deploymentStructure.getContext("test-sub-deployment"));
-         assertClassPathEntries(deploymentStructure.getContext("test-sub-deployment"),
-               new String[] {"test.jar"});         
+         BasicVirtualAssemblyContext subCtx = BasicVirtualAssemblyContext.class.cast(ctx.getChildren().get(0));
+         assertEquals("test-sub-deployment", subCtx.getRoot().getName());
+         assertMetaDataLocations(subCtx);
+         assertClassPathEntries(subCtx, new String[] {"test.jar"});         
       }
       finally
       {
@@ -113,42 +99,38 @@
       }
    }
    
-   protected void assertMetaDataLocations(ContextInfo info)
+   protected void assertMetaDataLocations(AbstractVirtualAssemblyContext assembled)
    {
-      assertMetaDataLocations(info, "META-INF");
+      assertMetaDataLocations(assembled, "META-INF");
    }
    
-   protected void assertMetaDataLocations(ContextInfo info, String... metaDataLocations)
+   protected void assertMetaDataLocations(AbstractVirtualAssemblyContext assembled, String... metaDataLocations)
    {
-      assertNotNull("null meta data path", info.getMetaDataPath());
-      assertEquals("same size", metaDataLocations.length, info.getMetaDataPath().size());
+      assertNotNull("null meta data path", assembled.getMetaDataLocations());
+      assertEquals("same size", metaDataLocations.length, assembled.getMetaDataLocations().size());
       for(String location : metaDataLocations)
       {
-         assertTrue(info.getMetaDataPath().contains(new MetaDataEntryImpl(location)));
-      }
+         assertTrue(assembled.getMetaDataLocations().contains(location));
+      }      
    }
    
-   protected void assertClassPathEntries(ContextInfo info, String... paths)
+   protected void assertClassPathEntries(AbstractVirtualAssemblyContext assembled, String... paths)
    {
-      assertNotNull(info.getClassPath());
+      assertNotNull(assembled.getClassPathLocations());
       List<String> original = Arrays.asList(paths);
-      List<String> generated = new ArrayList<String>();
-      for(ClassPathEntry entry : info.getClassPath())
-         generated.add(entry.getPath());
+      List<String> generated = assembled.getClassPathLocations();
       assertEquals("same size" + generated, original.size(), generated.size());
-      assertTrue("expected " + original + " was "+ generated, generated.containsAll(original));
+      assertTrue("expected " + original + " was "+ generated, generated.containsAll(original));      
    }
-   
-   protected ProfileDeployment createProfileDeployment(VirtualDeploymentMetaData deployment) throws Exception
+
+   private ProfileDeployment createProfileDeployment(VirtualDeploymentMetaData virtual) throws Exception
    {
-      return profileDeploymentFactory.createDeployment(deployment);
+      return this.profileDeploymentFactory.createDeployment(virtual);
    }
-   
-   protected StructureMetaData createStructureMetaData(ProfileDeployment deployment)
+
+   static AbstractVirtualAssemblyContext getAssemblyContext(ProfileDeployment deployment)
    {
-      // Create the MC deployment
-      Deployment mcD = mcDeploymentBuilder.createDeployment(deployment);
-      return mcD.getPredeterminedManagedObjects().getAttachment(StructureMetaData.class);
+      return AbstractVirtualAssemblyContext.class.cast(deployment.getTransientAttachments().getAttachment(VirtualDeploymentAssemblyContext.class.getName()));
    }
    
 }

Modified: projects/profileservice/trunk/core/src/test/resources/metadata/domain/domain1.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/metadata/domain/domain1.xml	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/resources/metadata/domain/domain1.xml	2010-05-28 14:36:12 UTC (rev 105333)
@@ -41,6 +41,12 @@
 			xmlns="urn:jboss:profileservice:profile:static:1.0">
 		<source path="${jboss.server.home.url}deployers" />
 	</static-deployment>
+	
+	<activation-profile name="jboss:profile=activation"
+			xmlns="urn:jboss:profileservice:profile:activation">
+		<source path="${jboss.server.home.url}deployers" />
+	</activation-profile>
+	
 	<!-- 
 		The hot deployment profile.
 	 -->

Modified: projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml	2010-05-28 14:36:12 UTC (rev 105333)
@@ -2,6 +2,7 @@
 
 	<profile name="activation-group1">
 		<requires name="test" mode="activation-callback" />
+		<requires name="test2" optional="true" />
 	</profile>
 	
 	<profile name="activation-group2">
@@ -16,11 +17,13 @@
 
 	<profile name="test1">
 		<requires name="other" />
+		<requires name="test" />
 		<requires name="test3" optional="true" />
 	</profile>
 
 	<profile name="test2">
 		<requires name="other" />
+		<requires name="test" optional="true" />
 		<requires name="test1" optional="true" />
 	</profile>
 
@@ -29,5 +32,5 @@
 	</profile>
 
 	<profile name="other" />
-
+	
 </profiles>
\ No newline at end of file

Modified: projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml	2010-05-28 14:36:12 UTC (rev 105333)
@@ -9,6 +9,8 @@
 		<property name="deployerRegistry"><inject bean="ProfileDeployerPluginRegistry" /></property>
 		<property name="profileFactory"><inject bean="TypedProfileFactory" /></property>
 		<property name="lifeCycleActions"><inject bean="ProfileLifeCycleCallbackActions" /></property>
+		<incallback method="addProfileActivator" />
+		<uncallback method="removeProfileActivator" />
 	</bean>
 
 	<!-- The Profile Service Bootstrap -->
@@ -72,4 +74,6 @@
 		</constructor>
 	</bean>
 	
+	<bean name="TestActivator" class="org.jboss.test.profileservice.support.TestProfileActivator" />
+	
 </deployment>
\ No newline at end of file

Modified: projects/profileservice/trunk/core/src/test/resources/system/profiles/core-profiles.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/profiles/core-profiles.xml	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/resources/system/profiles/core-profiles.xml	2010-05-28 14:36:12 UTC (rev 105333)
@@ -5,8 +5,11 @@
 	-->
 	<profile-group name="jboss:profile=minimal">
 		<requires name="jboss:profile=bootstrap" mode="resolve" />
+		<requires name="jboss:profile=logging,flavor=deployer" mode="resolve" />
 		<requires name="jboss:profile=logging" mode="resolve" />
+		<requires name="jboss:profile=threads,flavor=deployer" mode="resolve" />
 		<requires name="jboss:profile=threads" mode="resolve" />
+		<requires name="jboss:profile=deployment,flavor=hot-deployment" mode="resolve" />
 	</profile-group>
 
 	<bootstrap name="jboss:profile=bootstrap">
@@ -33,7 +36,7 @@
 		other profiles require the namespace only. No direct reference
 		needed, as this is bound to a meta data model anyway
 	 -->
-	<profile name="jboss:profile=deployment,flavor=hot-deployment" enable-on-demand="true" >
+	<profile name="jboss:profile=deployment,flavor=hot-deployment" >
 		<file-repository group="deployment" />
 		<deployment name="hd-scanner-jboss-beans.xml" />
 		<requires name="jboss:profile=threads" />
@@ -50,7 +53,7 @@
 		<requires name="jboss:profile=logging,flavor=deployer" />
 	</profile>
 
-	<profile name="jboss:profile=logging,flavor=deployer" enable-on-demand="true" >
+	<profile name="jboss:profile=logging,flavor=deployer" >
 		<file-repository group="logging" />
 		<virtual-deployment name="logging.deployer">
 			<meta-inf path="logmanager-jboss-beans.xml" />
@@ -68,7 +71,7 @@
 		<requires name="jboss:profile=threads,flavor=deployer" />
 	</profile>
 
-	<profile name="jboss:profile=threads,flavor=deployer" enable-on-demand="true" >
+	<profile name="jboss:profile=threads,flavor=deployer" >
 		<file-repository group="threads" />
 		<virtual-deployment name="threads.deployer">
 			<meta-inf path="threads-deployer-jboss-beans.xml" />
@@ -79,7 +82,7 @@
 	<!--
 		Profiles should set an explicit requirement on the service binding manager. 
 	 -->
-	<profile name="jboss:profile=servicebindingmanager" enable-on-demand="true" >
+	<profile name="jboss:profile=servicebindingmanager" >
 		<file-repository group="servicebindingmanager" />
 		<virtual-deployment name="service.binding.manager">
 			<meta-inf path="jboss-beans.xml" />

Modified: projects/profileservice/trunk/core/src/test/resources/system/profiles/stack-profiles.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/profiles/stack-profiles.xml	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/core/src/test/resources/system/profiles/stack-profiles.xml	2010-05-28 14:36:12 UTC (rev 105333)
@@ -24,6 +24,7 @@
 			<meta-inf path="jboss-beans.xml" />
 			<artifact groupId="org.jboss.stack1" artifactId="stack-configuration" />
 		</virtual-deployment>
+		<requires name="jboss:profile=minimal" />
 	</profile>
 	<!-- 
 		Stack two.
@@ -38,6 +39,7 @@
 			<!-- artifacts for stack2 -->
 			<artifact groupId="org.jboss.stack2" artifactId="stack-configuration" />
 		</virtual-deployment>
+		<requires name="jboss:profile=minimal" />
 	</profile>
 
 </profiles>
\ No newline at end of file

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivation.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivation.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivation.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,87 @@
+/*
+* 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.spi.activation;
+
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * The profile activation.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ProfileActivation
+{
+
+   /**
+    * Get the profile key.
+    * 
+    * @return the profile key
+    */
+   ProfileKey getKey();
+   
+   /**
+    * Get the profile meta data. 
+    * 
+    * @return the profile meta data
+    */
+   ProfileMetaData getProfileMetaData();
+   
+   /**
+    * start()
+    * 
+    * @throws Exception for any error
+    */
+   void start() throws Exception;
+
+   /**
+    * isStarted()
+    * 
+    * @return true if started, false otherwise
+    */
+   boolean isStarted();
+   
+   /**
+    * Check whether the dependencies of the
+    * profile are resolved.
+    * 
+    * @return true if resolved, false otherwise
+    */
+   boolean isResolved();
+   
+   /**
+    * Validate the current state of the 
+    * underlying profile. 
+    * 
+    * @throws Exception
+    */
+   void validate() throws Exception;
+   
+   /**
+    * stop()
+    *
+    */
+   void stop();
+   
+}
+

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivationConfiguration.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivationConfiguration.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivationConfiguration.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,47 @@
+/*
+* 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.spi.activation;
+
+/**
+ * The profile activation configuration.
+ * 
+ * @author Emanuel Muckenhuber
+ */
+public interface ProfileActivationConfiguration
+{
+
+   /**
+    * Get the profile activator reference.
+    * 
+    * @return the profile activator ref
+    */
+   String getProfileActivatorRef();
+   
+   /**
+    * Get the activation parameters.
+    * 
+    * @return the activation parameters
+    */
+   ProfileActivationParameters getParameters();
+   
+}
+

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivationParameters.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivationParameters.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivationParameters.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,58 @@
+/*
+* 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.spi.activation;
+
+/**
+ * The profile activation parameters.
+ * 
+ * @author Emanuel Muckenhuber
+ */
+public interface ProfileActivationParameters
+{
+
+   /**
+    * Get a activation parameter.
+    * 
+    * @param name the parameter name
+    * @return the activation parameter
+    */
+   ActivationParameter getActivationParameter(String name);
+   
+   public static interface ActivationParameter
+   {
+      /**
+       * Get the parameter name.
+       * 
+       * @return the parameter name
+       */
+      String getName();
+      
+      /**
+       * Get the parameter value.
+       * 
+       * @return the parameter value
+       */
+      String getValue();
+   }
+   
+}
+

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivator.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivator.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/activation/ProfileActivator.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -0,0 +1,54 @@
+/*
+* 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.spi.activation;
+
+/**
+ * The profile activator
+ * 
+ * @author Emanuel Muckenhuber
+ */
+public interface ProfileActivator
+{
+
+   /**
+    * Get the reference to this activator.
+    * 
+    * @return the profile activator ref
+    */
+   String getActivatorReference();
+
+   /**
+    * Activate a profile.
+    * 
+    * @param activation the profile activation
+    */
+   void activate(ProfileActivation activation) throws Exception;
+   
+   /**
+    * Deactivate a profile. 
+    *  
+    * @param activation the profile activation
+    */
+   void deactivate(ProfileActivation activation);
+   
+}
+

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileMetaDataVisitor.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileMetaDataVisitor.java	2010-05-28 12:16:01 UTC (rev 105332)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileMetaDataVisitor.java	2010-05-28 14:36:12 UTC (rev 105333)
@@ -60,15 +60,8 @@
     * @param feature the feature
     */
    void addFeature(ProfileFeatureMetaData feature);
-   
+  
    /**
-    * Enable on demand.
-    * 
-    * @param onDemand 
-    */
-   void enableOnDemand(boolean onDemand);
-   
-   /**
     * Visit a profile meta data node.
     * 
     * @param node the profile meta data node.




More information about the jboss-cvs-commits mailing list