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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 20 10:10:47 EST 2010


Author: emuckenhuber
Date: 2010-01-20 10:10:45 -0500 (Wed, 20 Jan 2010)
New Revision: 99661

Added:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/
   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/ProfileKernelControllerContext.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileCapability.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileRequirement.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/RequiredProfiles.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DefaultNotFoundHandler.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.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/deployment/
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/TestProfilesMetaData.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/
   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/ActivationCallbackUnitTestCase.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/BasicResolverUnitTestCase.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/RequirementResolverTestSuite.java
   projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/
   projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/
   projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/basic.xml
   projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/DependencyMode.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolver.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolverFactory.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactNotFoundHandler.java
Removed:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/NoopProfileDeployerPlugin.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileServiceConstants.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileCapability.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileRequirement.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/LocalProfileServiceDomain.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ImplicitProfileRequirement.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ActivationPolicy.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/Engine.java
Modified:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/ProfileDeployerPlugin.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/ProfileDeployerPluginRegistry.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/dependency/ProfileControllerContext.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileInstantiateAction.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileRequirementDependencyItem.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployers/MainDeployerPlugin.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ProfileMetaDataFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyCapability.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractSubProfileKeyMetaData.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/BootstrapProfileMetaData.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/BasicSubProfileMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureCapability.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureRequirement.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfilesMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/VirtualProfileDeploymentMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/EmptyProfileMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileSourceMetaData.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/plugin/ClassPathAdapterProfile.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/BasicRepositoryConfiguration.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeploymentRequirement.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/domain/support/DomainMetaDataRepoSupport.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/test/AbstractProfileServiceTest.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java
   projects/profileservice/trunk/core/src/test/resources/metadata/domain/domain1.xml
   projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml
   projects/profileservice/trunk/core/src/test/resources/system/profiles/clustering-profiles.xml
   projects/profileservice/trunk/core/src/test/resources/system/profiles/common-profiles.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/core/src/test/resources/system/profiles/web-profiles.xml
   projects/profileservice/trunk/core/src/test/resources/system/static/bootstrap/profile.xml
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKey.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileCapability.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirement.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileKeyMetaData.java
   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/repository/ArtifactRepository.java
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryConfiguration.java
Log:
some metadata classes update, initial work on resolving bootstrap requirements

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -38,7 +38,7 @@
 import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.kernel.Kernel;
 import org.jboss.logging.Logger;
-import org.jboss.profileservice.dependency.LocalProfileServiceDomain;
+import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.dependency.ProfileControllerContext;
 import org.jboss.profileservice.dependency.ProfileDependencyContext;
 import org.jboss.profileservice.dependency.ProfileServiceController;
@@ -65,7 +65,7 @@
    private final ProfileServiceController controller;
    
    /** The local profile registry. */
-   private LocalProfileServiceDomain domain;
+   private ProfileMetaDataRegistry domain;
 
    /** The deployment manager plugin. */
    private DeploymentManager deploymentMgr;
@@ -103,12 +103,12 @@
       this.mgtView = mgtView;
    }
    
-   public LocalProfileServiceDomain getDomain()
+   public ProfileMetaDataRegistry getDomain()
    {
       return domain;
    }
    
-   public void setDomain(LocalProfileServiceDomain domain)
+   public void setDomain(ProfileMetaDataRegistry domain)
    {
       this.domain = domain;
    }
@@ -261,7 +261,7 @@
       ProfileDependencyContext dependency = new ProfileDependencyContext(key, metaData, domain);
       domain.addProfile(dependency);
       
-      ProfileControllerContext ctx = new ProfileControllerContext(dependency);
+      ProfileControllerContext ctx = new ProfileControllerContext(dependency, profile);
       if(ctx == null)
       {
          throw new IllegalStateException("created null profile context");

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/NoopProfileDeployerPlugin.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/NoopProfileDeployerPlugin.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/NoopProfileDeployerPlugin.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,109 +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;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.plugins.ManagedDeploymentImpl;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.ProfileDeployment;
-
-/**
- * A profile deployer plugin which does not perform any deployment actions.
- * 
- * TODO move this class to src/tests
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class NoopProfileDeployerPlugin implements ProfileDeployerPlugin
-{
-
-   /** The added deployments. */
-   private Map<String, ProfileDeployment> deployments = new HashMap<String, ProfileDeployment>();
-   
-   /** The Logger. */
-   private static final Logger log = Logger.getLogger(NoopProfileDeployerPlugin.class);
-   
-   @Override
-   public void addDeployment(ProfileDeployment deployment) throws Exception
-   {
-      if(deployment == null)
-         throw new IllegalArgumentException("null profile deployment");
-      this.deployments.put(deployment.getName(), deployment);
-      log.debug("add " + deployment);
-   }
-
-   @Override
-   public void checkComplete(String... names) throws Exception
-   {
-      ///
-   }
-
-   @Override
-   public void checkComplete() throws Exception
-   {
-      ///
-   }
-
-   @Override
-   public void process()
-   {
-      ///
-   }
-
-   @Override
-   public void removeDeployment(ProfileDeployment deployment) throws Exception
-   {
-      if(deployments == null)
-         throw new IllegalArgumentException("null profile deployment");
-      this.deployments.remove(deployment.getName());
-      if(log.isTraceEnabled())
-         log.trace("remove " + deployment);
-   }
-   
-   @Override
-   public boolean isSupportRedeployment()
-   {
-      return true;
-   }
-
-   @Override
-   public ManagedDeployment getManagedDeployment(ProfileDeployment deployment) throws NoSuchDeploymentException
-   {
-      if(deployment == null)
-      {
-         throw new IllegalArgumentException("null profile deployment");
-      }
-      if(deployments.containsKey(deployment.getName()) == false)
-      {
-         throw new NoSuchDeploymentException(deployment.getName());
-      }      
-      String deploymentName = deployment.getName();
-      return new ManagedDeploymentImpl(deploymentName, deploymentName);
-   }
-   
-}
-

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/ProfileDeployerPlugin.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/ProfileDeployerPlugin.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/ProfileDeployerPlugin.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -73,8 +73,7 @@
     * @return true if deployments can be re-added, false otherwise
     */
    boolean isSupportRedeployment();
-   
-   
+
    /**
     * Get a managed deployment.
     * 
@@ -84,5 +83,15 @@
     */
    ManagedDeployment getManagedDeployment(ProfileDeployment deployment) throws Exception;
    
+   /**
+    * Tell the deployer we are about to shutdown
+    */
+   void prepareShutdown();
+   
+   /**
+    * Shutdown. Removes all the deployments.
+    */
+   void shutdown();
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/ProfileDeployerPluginRegistry.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/ProfileDeployerPluginRegistry.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/ProfileDeployerPluginRegistry.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -36,11 +36,26 @@
  */
 public class ProfileDeployerPluginRegistry
 {
+   /** The instance. */
+   private static final ProfileDeployerPluginRegistry INSTANCE = new ProfileDeployerPluginRegistry();
+   
    /** The default. */
    private static final String DEFAULT = "___default___";
    
+   /** The registered deployers. */
    private Map<String, ProfileDeployerPlugin> map = new ConcurrentHashMap<String, ProfileDeployerPlugin>();
+
+   public static ProfileDeployerPluginRegistry getInstance()
+   {
+      return INSTANCE;
+   }
+
+   protected ProfileDeployerPluginRegistry()
+   {
+      
+   }
    
+   
    public ProfileDeployerPlugin getDeployer(ProfileMetaData metaData)
    {
       String type = metaData.getClass().getName();
@@ -51,7 +66,7 @@
       return plugin;
    }
    
-   public void addDefaultPlugin(ProfileDeployerPlugin plugin)
+   public void setDefaultPlugin(ProfileDeployerPlugin plugin)
    {
       if(plugin == null)
          throw new IllegalArgumentException("null deployer plugin");
@@ -59,6 +74,11 @@
       map.put(DEFAULT, plugin);
    }
    
+   public void removedefaultPlugin()
+   {
+      map.remove(DEFAULT);
+   }
+   
    public void addPlugin(String type, ProfileDeployerPlugin plugin)
    {
       if(type == null)
@@ -69,5 +89,34 @@
       map.put(type, plugin);
    }
 
+   public void removePlugin(String type)
+   {
+      if(type == null)
+         throw new IllegalArgumentException("null plugin type");
+      this.map.remove(type);
+   }
+   
+   /**
+    * Tell the deployers we are about to shutdown
+    */
+   void prepareShutdown()
+   {
+      for(ProfileDeployerPlugin deployer : map.values())
+      {
+         deployer.prepareShutdown();
+      }
+   }
+   
+   /**
+    * Shutdown. Removes all the deployments.
+    */
+   void shutdown()
+   {
+      for(ProfileDeployerPlugin deployer : map.values())
+      {
+         deployer.shutdown();
+      }
+   }
+
 }
 

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceBootstrap.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -23,8 +23,6 @@
 
 import java.util.Collection;
 
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
 import org.jboss.kernel.Kernel;
 import org.jboss.profileservice.domain.AbstractDomainMetaData;
 import org.jboss.profileservice.domain.spi.DomainFeatureNode;
@@ -60,9 +58,8 @@
    
    protected ProfileService createProfileService(AbstractDomainMetaData domainMetaData) throws Throwable
    {
-      super.initialize(domainMetaData);
-      ControllerContext context = kernel.getController().getContext(ProfileServiceConstants.PROFILESERVICE_NAME, ControllerState.INSTALLED);
-      return ProfileService.class.cast(context.getTarget());
+      this.profileService = super.initialize(domainMetaData);
+      return this.profileService;
    }
    
    protected void start(AbstractDomainMetaData domainMetaData) throws Throwable

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -21,23 +21,22 @@
 */
 package org.jboss.profileservice.bootstrap;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.kernel.Kernel;
-import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
-import org.jboss.kernel.plugins.deployment.BasicKernelDeployer;
+import org.jboss.kernel.plugins.registry.BeanKernelRegistryEntry;
+import org.jboss.kernel.spi.config.KernelConfig;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
 import org.jboss.profileservice.AbstractProfileService;
 import org.jboss.profileservice.ManagementDomain;
 import org.jboss.profileservice.ProfileDeployerPluginRegistry;
-import org.jboss.profileservice.dependency.LocalProfileServiceDomain;
+import org.jboss.profileservice.config.ProfileServiceConstants;
+import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.domain.AbstractDomainMetaData;
 import org.jboss.profileservice.domain.ManagementDomainMetaData;
 import org.jboss.profileservice.domain.ServerMetaData;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 
 
@@ -47,36 +46,25 @@
  */
 abstract class AbstractProfileServiceInitializer
 {
-
-   /** The kernel controller. */
-   private BasicKernelDeployer deployer;
-   
    protected abstract Kernel getKernel();
    protected abstract ProfileDeployerPluginRegistry getDeployerRegistry();
    protected abstract ProfileFactory<ProfileMetaData, Profile> getProfileFactory();
    
    public AbstractProfileServiceInitializer(Kernel kernel)
    {
-      deployer = new BasicKernelDeployer(kernel);
+      
    }
    
-   public void initialize(AbstractDomainMetaData domainMetaData) throws Throwable
+   public ProfileService initialize(AbstractDomainMetaData domainMetaData) throws Throwable
    {
-      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
-      deployment.setBeanFactories(createBeanFactories(domainMetaData));
-      deployer.deploy(deployment);
-      deployer.validate(deployment);
+      ProfileMetaDataRegistry domain = createLocalDomain(domainMetaData);
+      AbstractProfileService ps = new AbstractProfileService(getKernel());
+      ps.setDomain(domain);
+      register(getKernel(), ProfileServiceConstants.PROFILESERVICE_NAME, ps);
+      return ps;
    }
-   
-   protected List<BeanMetaDataFactory> createBeanFactories(AbstractDomainMetaData domainMetaData)
-   {
-      List<BeanMetaDataFactory> factories = new ArrayList<BeanMetaDataFactory>();
-      factories.add(createLocalDomain(domainMetaData));
-      factories.add(createProfileService());
-      return factories;
-   }
 
-   protected BeanMetaDataFactory createLocalDomain(AbstractDomainMetaData domainMetaData)
+   protected ProfileMetaDataRegistry createLocalDomain(AbstractDomainMetaData domainMetaData) throws Throwable
    {
       ManagementDomainMetaData domain = domainMetaData.getDomain();
       if(domain == null)
@@ -93,8 +81,7 @@
       if(domainName.length() == 0)
       {
          throw new IllegalArgumentException("empty domain name");
-      }
-      
+      }      
       ServerMetaData serverMetaData = domainMetaData.getServer();
       if(serverMetaData == null)
       {
@@ -113,28 +100,42 @@
       }
       // The management domain
       ManagementDomain mgtDomain = new ManagementDomain(domainName);
-      return createLocalProfileServiceDomain(mgtDomain, serverName);
+      ProfileMetaDataRegistry localDomain = new ProfileMetaDataRegistry(mgtDomain, serverName);
+      localDomain.setProfileDeployers(getDeployerRegistry());
+      localDomain.setProfileFactory(getProfileFactory());
+      register(getKernel(), ProfileServiceConstants.METADATA_REGISTRY_NAME, localDomain);
+      return localDomain;
    }
    
-   protected BeanMetaDataFactory createLocalProfileServiceDomain(ManagementDomain mgtDomain, String serverName)
+   /**
+    * Register an object
+    * 
+    * @param kernel the kernel
+    * @param name the name
+    * @param object the object
+    * @throws Throwable for any error
+    */
+   @SuppressWarnings("deprecation")
+   protected void register(Kernel kernel, Object name, Object object) throws Throwable
    {
-      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(
-            ProfileServiceConstants.LOCALDOMAIN_NAME, LocalProfileServiceDomain.class.getName());
-      builder.addConstructorParameter(ManagementDomain.class.getName(), mgtDomain);
-      builder.addConstructorParameter(String.class.getName(), serverName);
-      // Inject the DeployersRegistry and profileFactory
-      builder.addPropertyMetaData("profileDeployers", getDeployerRegistry());
-      builder.addPropertyMetaData("profileFactory", getProfileFactory());
-      return builder.getBeanMetaDataFactory();
+      KernelRegistryEntry entry = createKernelRegistryEntry(kernel, object);
+      org.jboss.kernel.spi.registry.KernelRegistry registry = kernel.getRegistry();
+      registry.registerEntry(name, entry);
    }
    
-   protected BeanMetaDataFactory createProfileService()
+   /**
+    * Create a kernel registry entry
+    * 
+    * @param kernel the kernel
+    * @param object the object
+    * @return the entry
+    * @throws Throwable for any error
+    */
+   protected KernelRegistryEntry createKernelRegistryEntry(Kernel kernel, Object object) throws Throwable
    {
-      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(ProfileServiceConstants.PROFILESERVICE_NAME,
-               AbstractProfileService.class.getName());
-      builder.addConstructorParameter(Kernel.class.getName(), getKernel());
-      builder.addPropertyMetaData("domain", builder.createInject(ProfileServiceConstants.LOCALDOMAIN_NAME));
-      return builder.getBeanMetaDataFactory();
+      KernelConfig config = kernel.getConfig();
+      BeanInfo info = config.getBeanInfo(object.getClass());
+      return new BeanKernelRegistryEntry(object, info);
    }
    
 }

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileServiceConstants.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileServiceConstants.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileServiceConstants.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,39 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.profileservice.bootstrap;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public interface ProfileServiceConstants
-{
-   
-   /** The profile service name. */
-   String PROFILESERVICE_NAME = "jboss.profileservice:service=ProfileService";
-
-   /** The local profile domain bean name. */
-   String LOCALDOMAIN_NAME = "jboss.profileservice:service=LocalProfileServiceDomain";
-   
-   
-}
-

Added: 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	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConfig.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,60 @@
+/*
+* 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.config;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.profileservice.domain.spi.DomainMetaDataRepository;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * Configuration helper to initialize ProfileService.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ProfileServiceConfig
+{
+
+   /**
+    * Get the MC Kernel.
+    * 
+    * @return the kernel.
+    */
+   Kernel getKernel();
+   
+   /**
+    * Create the domain meta data repository.
+    * 
+    * @return the repository
+    */
+   DomainMetaDataRepository createDomainMetaDataRepository();
+
+   /**
+    * Create the profile factory.
+    * 
+    * @return the profile factory
+    */
+   ProfileFactory<ProfileMetaData, Profile> createProfileFactory();
+}
+

Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConstants.java (from rev 99447, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/ProfileServiceConstants.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConstants.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/config/ProfileServiceConstants.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.profileservice.config;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ProfileServiceConstants
+{
+   
+   /** The profile service name. */
+   String PROFILESERVICE_NAME = "jboss.profileservice:service=ProfileService";
+
+   /** The local profile domain bean name. */
+   String METADATA_REGISTRY_NAME = "jboss.profileservice:service=ProfileMetaDataRegistry";
+   
+   
+}
+

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileCapability.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileCapability.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileCapability.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,101 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2007, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.profileservice.dependency;
-
-import org.jboss.profileservice.spi.dependency.ProfileCapability;
-import org.jboss.profileservice.version.helpers.NameAndVersionSupport;
-
-/**
- * AbstractCapability.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public abstract class AbstractProfileCapability extends NameAndVersionSupport implements ProfileCapability
-{
-   
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 5707892139772442117L;
-
-   /**
-    * Create a new AbstractCapability
-    */
-   public AbstractProfileCapability()
-   {
-   }
-   
-   /**
-    * Create a new AbstractCapability
-    * 
-    * @param name the name
-    * @throws IllegalArgumentException for a null name
-    */
-   public AbstractProfileCapability(String name)
-   {
-      super(name);
-   }
-   
-   /**
-    * Create a new AbstractCapability.
-    * 
-    * @param name the name
-    * @param version the version - pass null for the default version
-    * @throws IllegalArgumentException for a null name
-    */
-   public AbstractProfileCapability(String name, Object version)
-   {
-      super(name, version);
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (obj == this)
-         return true;
-      if (obj == null || obj instanceof AbstractProfileCapability == false)
-         return false;
-      return super.equals(obj);
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuffer buffer = new StringBuffer();
-      buffer.append(getClass().getSimpleName());
-      buffer.append("{");
-      toString(buffer);
-      buffer.append("}");
-      return buffer.toString();
-   }
-   
-   /**
-    * For subclasses to override toString()
-    * 
-    * @param buffer the buffer
-    */
-   protected void toString(StringBuffer buffer)
-   {
-      buffer.append(getName());
-      buffer.append(" ").append(getVersion());
-   }
-}

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileRequirement.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileRequirement.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileRequirement.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,166 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2007, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.profileservice.dependency;
-
-import javax.xml.bind.annotation.XmlAttribute;
-
-import org.jboss.profileservice.spi.dependency.ProfileRequirement;
-import org.jboss.profileservice.version.VersionRange;
-import org.jboss.profileservice.version.helpers.NameAndVersionRangeSupport;
-
-/**
- * AbstractRequirement.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class AbstractProfileRequirement extends NameAndVersionRangeSupport implements ProfileRequirement
-{
-
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -9013971913225421465L;
-   
-   /** Whether the requirement is optional */
-   private boolean optional = false;
-   
-   /**
-    * Create a new AbstractRequirement
-    */
-   public AbstractProfileRequirement()
-   {
-   }
-   
-   /**
-    * Create a new AbstractRequirement
-    * 
-    * @param name the name
-    * @throws IllegalArgumentException for a null name
-    */
-   public AbstractProfileRequirement(String name)
-   {
-      super(name);
-   }
-   
-   /**
-    * Create a new AbstractRequirement.
-    * 
-    * @param name the name
-    * @param versionRange the version range - pass null for all versions
-    * @throws IllegalArgumentException for a null name
-    */
-   public AbstractProfileRequirement(String name, VersionRange versionRange)
-   {
-      super(name, versionRange);
-   }
-
-   public boolean isOptional()
-   {
-      return optional;
-   }
-   
-   /**
-    * Set the optional.
-    * 
-    * @param optional the optional.
-    */
-   @XmlAttribute(name="optional")
-   public void setOptional(boolean optional)
-   {
-      this.optional = optional;
-   }
-   
-   public boolean isConsistent(ProfileRequirement other)
-   {
-      return isConsistent(other, null);
-   }
-
-   /**
-    * Check whether the requirements are consistent
-    * 
-    * @param other the other requirement
-    * @param requirementType the class to check when looking for inconsistencies (uses getClass() when null)
-    * @return true when consistent, false otherwise
-    */
-   protected boolean isConsistent(ProfileRequirement other, Class<? extends ProfileRequirement> requirementType)
-   {
-      if (other == null)
-         throw new IllegalArgumentException("Null requirement");
-      if (requirementType == null)
-         requirementType = getClass();
-      
-      // Not our type
-      if (requirementType.isInstance(other) == false)
-         return true;
-      
-      AbstractProfileRequirement otherRequirement = (AbstractProfileRequirement) other;
-      // Not the same name
-      String name = getName();
-      String otherName = otherRequirement.getName();
-      if (name.equals(otherName) == false)
-         return true;
-
-      // Check the version ranges are consistent
-      VersionRange range = getVersionRange();
-      VersionRange otherRange = otherRequirement.getVersionRange();
-      return range.isConsistent(otherRange);
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (obj == this)
-         return true;
-      if (obj == null || obj instanceof AbstractProfileRequirement == false)
-         return false;
-      if (super.equals(obj) == false)
-         return false;
-      AbstractProfileRequirement other = (AbstractProfileRequirement) obj;
-      if (this.isOptional() != other.isOptional())
-         return false;
-      return true;
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuffer buffer = new StringBuffer();
-      buffer.append(getClass().getSimpleName());
-      buffer.append("{");
-      toString(buffer);
-      buffer.append("}");
-      return buffer.toString();
-   }
-   
-   /**
-    * For subclasses to override toString()
-    * 
-    * @param buffer the buffer
-    */
-   protected void toString(StringBuffer buffer)
-   {
-      buffer.append(getName());
-      buffer.append(" ").append(getVersionRange());
-      if (isOptional())
-         buffer.append(" OPTIONAL");
-   }
-}

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/LocalProfileServiceDomain.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/LocalProfileServiceDomain.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/LocalProfileServiceDomain.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,279 +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.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.logging.Logger;
-import org.jboss.profileservice.ManagementDomain;
-import org.jboss.profileservice.ProfileDeployerPlugin;
-import org.jboss.profileservice.ProfileDeployerPluginRegistry;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileDeployment;
-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 local profile service domain.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class LocalProfileServiceDomain
-{
-   
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(LocalProfileServiceDomain.class);
-
-   /** The management domain information. */
-   private final ManagementDomain domain;
-   
-   /** The server name. */
-   private final String server;
-
-   /** The profile deployers registry. */
-   private ProfileDeployerPluginRegistry deployers;
-   
-   /** The profile factory. */
-   private ProfileFactory<ProfileMetaData, Profile> profileFactory;
-   
-   /** The profiles. */
-   private List<ProfileDependencyContext> profiles = new CopyOnWriteArrayList<ProfileDependencyContext>();
-   
-   /** The profiles by name. */
-   private Map<String, ProfileDependencyContext> profilesByKey = new ConcurrentHashMap<String, ProfileDependencyContext>();
-  
-   /** The deployments to profile mapping. */
-   private Map<String, String> deploymentsToProfile = new ConcurrentHashMap<String, String>();
-   
-   /** The activation callback. */
-   private Map<String, ProfileDependencyContext> activationCallback = new ConcurrentHashMap<String, ProfileDependencyContext>();
-   
-   public LocalProfileServiceDomain(ManagementDomain domain, String server)
-   {
-      if(domain == null)
-      {
-         throw new IllegalArgumentException("null management domain");
-      }
-      if(server == null)
-      {
-         throw new IllegalArgumentException("null server name");
-      }
-      this.domain = domain;
-      this.server = server;
-   }
-   
-   public ProfileDeployerPluginRegistry getProfileDeployers()
-   {
-      return deployers;
-   }
-   
-   public void setProfileDeployers(ProfileDeployerPluginRegistry deployers)
-   {
-      this.deployers = deployers;
-   }
-   
-   public ProfileFactory<ProfileMetaData, Profile> getProfileFactory()
-   {
-      return profileFactory;
-   }
-   
-   public void setProfileFactory(ProfileFactory<ProfileMetaData, Profile> profileFactory)
-   {
-      this.profileFactory = profileFactory;
-   }
-   
-   public String getDomainName()
-   {
-      return domainName();
-   }
-   
-   public ManagementDomain getDomain()
-   {
-      return this.domain;
-   }
-
-   public String getServerName()
-   {
-      return this.server;
-   }
-   
-   public void addProfile(ProfileDependencyContext ctx)
-   {
-      if(ctx == null)
-      {
-         throw new IllegalArgumentException("null context");
-      }
-      if(ctx.getKey() == null)
-      {
-         throw new IllegalArgumentException("null profile key");
-      }
-      String profileName = ctx.getKey().getName();
-      if(profileName == null)
-      {
-         throw new IllegalArgumentException("null profile name");
-      }
-      profileName = profileName.trim();
-      if(profileName.length() == 0)
-      {
-         throw new IllegalArgumentException("empty profile name");
-      }
-      this.profiles.add(ctx);
-      this.profilesByKey.put(profileName, ctx);
-   }
-   
-   public ProfileDependencyContext getProfile(String name)
-   {
-      if(name == null)
-      {
-         throw new IllegalArgumentException("null profile name");
-      }
-      return this.profilesByKey.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 getProfile(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.profilesByKey.remove(profileName);
-      if(ctx != null)
-      {
-         this.profiles.remove(ctx);
-      }
-   }
-   
-   public ProfileDependencyContext getDeploymentProfile(String deploymentName)
-   {
-      if(deploymentName == null)
-      {
-         throw new IllegalArgumentException("null deployment name");
-      }
-      final String profileName = this.deploymentsToProfile.get(deploymentName);
-      if(profileName != null)
-      {
-         return getProfile(profileName);
-      }
-      return null;
-   }
-   
-   public void deploy(Profile profile) throws Exception
-   {
-      ProfileKey key = profile.getKey();
-      ProfileDependencyContext ctx = getProfile(key);
-      Collection<ProfileDeployment> deployments = profile.getDeployments();
-      if(deployments != null && deployments.isEmpty() == false)
-      {
-         ProfileDeployerPlugin deployer = getProfileDeployers().getDeployer(ctx.getProfileMetaData());
-         if(deployer == null)
-         {
-            throw new IllegalStateException("no registered deployer for " + profile);
-         }
-         for(ProfileDeployment deployment : deployments)
-         {
-            deploymentsToProfile.put(deployment.getName(), key.getName());
-            deployer.addDeployment(deployment);
-         }
-         deployer.process();
-         // TODO checkComplete
-      }
-   }
-   
-   protected String domainName()
-   {
-      final String domainName = domain.getName();
-      if(domainName == null)
-      {
-         throw new IllegalStateException("null domain name");
-      }
-      return domainName;
-   }
-   
-   // TODO this should be protected
-   public ProfileKey resolve(ProfileDependencyContext ctx, ProfileRequirement requirement)
-   {
-      // Resolve the requirements based on the exposed capabilities
-      final boolean trace = log.isTraceEnabled();
-      for(ProfileDependencyContext profile : profiles)
-      {
-         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);
-                  }
-                  return profile.getKey();
-               }
-            }
-         }
-      }
-      // Unresolved
-      return null;
-   }
-   
-}
-

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -52,7 +52,7 @@
       return ctx.getKey();
    }
    
-   public ProfileControllerContext(ProfileDependencyContext ctx)
+   protected ProfileControllerContext(ProfileDependencyContext ctx)
    {
       this(ctx, null);
    }
@@ -71,8 +71,16 @@
          // Set the target
          setTarget(profile);
       }
-      // Make all contexts ON_DEMAND
-      setMode(ControllerMode.ON_DEMAND);
+      // Make all contexts manual
+      if(ctx.isOnDemandEnabled())
+      {
+         setMode(ControllerMode.ON_DEMAND);
+      }
+      else
+      {
+         // Maybe automatic ?
+         setMode(ControllerMode.MANUAL);
+      }
       // Build the dependencies
       getDependencyContext().describe(this);
    }

Modified: 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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -23,12 +23,11 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 
-import org.jboss.dependency.plugins.AbstractDependencyItem;
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.profileservice.ProfileDeployerPlugin;
+import org.jboss.profileservice.metadata.helpers.AbstractProfileKeyCapability;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileFactory;
 import org.jboss.profileservice.spi.ProfileKey;
@@ -37,7 +36,6 @@
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
-import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 
 /**
  * The dependency context.
@@ -57,19 +55,24 @@
    /** The aliases. */
    private List<ProfileKey> aliases;
    
+   /** Is on demand. */
+   private boolean onDemand;
+   
    /** The local PS domain. */
-   private final LocalProfileServiceDomain domain;
+   private final ProfileMetaDataRegistry domain;
 
    /** The capabilities. */
    private List<ProfileCapability> capabilites = new ArrayList<ProfileCapability>();
    
    /** The requirements. */
    private List<ProfileRequirement> requirements = new ArrayList<ProfileRequirement>();
-   
-   public ProfileDependencyContext(ProfileKey key, ProfileMetaData metaData, LocalProfileServiceDomain domain)
+      
+   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;
@@ -77,20 +80,17 @@
       this.profileMetaData = metaData;
       visit(profileMetaData);
    }
+
+   public String getName()
+   {
+      return key.getName();
+   }
    
    public ProfileKey getKey()
    {
       return key;
    }
    
-   public List<ProfileKey> getAliases()
-   {
-      if(aliases != null)
-         return aliases;
-      else
-         return Collections.emptyList();
-   }
-   
    public ProfileMetaData getProfileMetaData()
    {
       return profileMetaData;
@@ -114,7 +114,8 @@
          aliases = new ArrayList<ProfileKey>();
       }
       // TODO rework how ProfileKey works
-      aliases.add(new ProfileKey(key.getDomain(), key.getServer(), name));
+      aliases.add(new ProfileKey(domain.getDomainName(), domain.getServerName(), name));
+      addCapability(new AbstractProfileKeyCapability(name));
    }
    
    public void addCapability(ProfileCapability capability)
@@ -137,6 +138,19 @@
       return this.requirements;
    }
 
+   public boolean isOnDemandEnabled()
+   {
+      return onDemand;
+   }
+
+   public void enableOnDemand(boolean onDemand)
+   {
+      if(onDemand)
+      {
+         this.onDemand = true;
+      }
+   }
+   
    public void visit(ProfileMetaDataVisitorNode node)
    {
       node.visit(this);
@@ -155,20 +169,9 @@
       {
          for(ProfileRequirement requirement : requirements)
          {
-            // FIXME
-            if(requirement instanceof SubProfileMetaData)
-            {
-               String profileName = ((SubProfileMetaData)requirement).getName();
-               context.getDependencyInfo().addIDependOn(new AbstractDependencyItem(getKey(),
-                     new ProfileKey(key.getDomain(), key.getServer(), profileName),
-                     ControllerState.DESCRIBED, ControllerState.INSTALLED));
-            }
-            else
-            {
                context.getDependencyInfo().addIDependOn(
                      new ProfileRequirementDependencyItem(this,
                            requirement, ControllerState.DESCRIBED));
-            }
          }
       }
    }
@@ -189,5 +192,12 @@
       builder.append("key=").append(getKey());
    }
    
+   
+   class RequirementWrapper
+   {
+      ProfileRequirement requirement;
+      ProfileKey resolvesTo;
+   }
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileInstantiateAction.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileInstantiateAction.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileInstantiateAction.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -21,14 +21,10 @@
  */ 
 package org.jboss.profileservice.dependency;
 
-import java.util.List;
-
 import org.jboss.dependency.plugins.action.ControllerContextAction;
-import org.jboss.dependency.spi.Controller;
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileFactory;
-import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 
 /**
@@ -53,8 +49,6 @@
       ProfileControllerContext ctx = (ProfileControllerContext) context;
       
       ProfileDependencyContext profileCtx = ctx.getDependencyContext();
-      // FIXME Add aliases, since we install all contexts ON_DEMAND
-      addAliases(context.getController(), ctx.getProfileKey(), profileCtx.getAliases());
 
       ProfileFactory<ProfileMetaData, Profile> factory = profileCtx.getProfileFactory();
       Profile profile = factory.createProfile(ctx.getProfileKey(), ctx.getProfileMetaData());
@@ -72,24 +66,6 @@
       ProfileControllerContext ctx = (ProfileControllerContext) context;
       ctx.setTarget(null);
    }
-   
-   /**
-    * FIXME Add aliases. 
-    * 
-    * @param controller
-    * @param original
-    * @param aliases
-    * @throws Throwable
-    */
-   protected void addAliases(Controller controller, ProfileKey original, List<ProfileKey> aliases) throws Throwable
-   {
-      if(aliases != null && aliases.isEmpty() == false)
-      {
-         for(ProfileKey alias : aliases)
-         {
-            controller.addAlias(alias, original);
-         }
-      }
-   }
+
 }
 

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileKernelControllerContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileKernelControllerContext.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileKernelControllerContext.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,49 @@
+/*
+* 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 org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileKernelControllerContext extends AbstractKernelControllerContext
+{
+
+   public ProfileKernelControllerContext(BeanInfo info, BeanMetaData metaData, Object target)
+   {
+      // FIXME ProfileKernelControllerContext constructor
+      super(info, metaData, target);
+   }
+
+   @Override
+   public void setController(Controller controller)
+   {
+      // FIXME setController
+      super.setController(controller);
+   }
+}
+

Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java (from rev 99447, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/LocalProfileServiceDomain.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,269 @@
+/*
+* 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.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.ManagementDomain;
+import org.jboss.profileservice.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 local profile service domain.
+ * 
+ * @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 management domain information. */
+   private final ManagementDomain domain;
+   
+   /** The server name. */
+   private final String server;
+
+   /** The profile deployers registry. */
+   private ProfileDeployerPluginRegistry deployers;
+   
+   /** The profile factory. */
+   private ProfileFactory<ProfileMetaData, Profile> profileFactory;
+   
+   /** The profiles. */
+   private List<ProfileDependencyContext> profiles = new CopyOnWriteArrayList<ProfileDependencyContext>();
+   
+   /** The profiles by name. */
+   private Map<String, ProfileDependencyContext> profilesByKey = new ConcurrentHashMap<String, ProfileDependencyContext>();
+   
+   /** Check consistency. */
+   private boolean checkConsistency = true;
+   
+   public ProfileMetaDataRegistry(ManagementDomain domain, String server)
+   {
+      if(domain == null)
+      {
+         throw new IllegalArgumentException("null management domain");
+      }
+      if(server == null)
+      {
+         throw new IllegalArgumentException("null server name");
+      }
+      this.domain = domain;
+      this.server = server;
+   }
+   
+   public ProfileDeployerPluginRegistry getProfileDeployers()
+   {
+      return deployers;
+   }
+   
+   public void setProfileDeployers(ProfileDeployerPluginRegistry deployers)
+   {
+      this.deployers = deployers;
+   }
+   
+   public ProfileFactory<ProfileMetaData, Profile> getProfileFactory()
+   {
+      return profileFactory;
+   }
+   
+   public void setProfileFactory(ProfileFactory<ProfileMetaData, Profile> profileFactory)
+   {
+      this.profileFactory = profileFactory;
+   }
+   
+   public String getDomainName()
+   {
+      return domainName();
+   }
+   
+   public ManagementDomain getDomain()
+   {
+      return this.domain;
+   }
+
+   public String getServerName()
+   {
+      return this.server;
+   }
+   
+   public void addProfile(ProfileDependencyContext ctx)
+   {
+      if(ctx == null)
+      {
+         throw new IllegalArgumentException("null context");
+      }
+      if(ctx.getKey() == null)
+      {
+         throw new IllegalArgumentException("null profile key");
+      }
+      String profileName = ctx.getKey().getName();
+      if(profileName == null)
+      {
+         throw new IllegalArgumentException("null profile name");
+      }
+      profileName = profileName.trim();
+      if(profileName.length() == 0)
+      {
+         throw new IllegalArgumentException("empty profile name");
+      }
+      if(checkConsistency)
+      {
+         // Check if all new capabilities are consistent
+         checkConsistent(ctx);
+      }
+      
+      this.profiles.add(ctx);
+      this.profilesByKey.put(profileName, ctx);
+   }
+   
+   public ProfileDependencyContext getProfile(String name)
+   {
+      if(name == null)
+      {
+         throw new IllegalArgumentException("null profile name");
+      }
+      return this.profilesByKey.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 getProfile(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.profilesByKey.remove(profileName);
+      if(ctx != null)
+      {
+         this.profiles.remove(ctx);
+      }
+   }
+   
+   protected String domainName()
+   {
+      final String domainName = domain.getName();
+      if(domainName == null)
+      {
+         throw new IllegalStateException("null domain name");
+      }
+      return domainName;
+   }
+   
+   public ProfileKey resolve(ProfileDependencyContext ctx, ProfileRequirement requirement)
+   {
+      // Resolve the requirements based on the exposed capabilities
+      final boolean trace = log.isTraceEnabled();
+      for(ProfileDependencyContext profile : profiles)
+      {
+         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);
+                  }
+                  return profile.getKey();
+               }
+            }
+         }
+      }
+      // Unresolved
+      return null;
+   }
+
+   void checkConsistent(ProfileDependencyContext context)
+   {
+      for(ProfileDependencyContext profile : profiles)
+      {
+         Collection<ProfileCapability> capabilities = profile.getCapabilities();
+         if(capabilities != null && capabilities.isEmpty() == false)
+         {
+            for(ProfileCapability capability : capabilities)
+            {
+               Collection<ProfileCapability> newCapabilities = context.getCapabilities();
+               if(newCapabilities != null && newCapabilities.isEmpty() == false)
+               {
+                  for(ProfileCapability newCapability : newCapabilities)
+                  {
+                     if(newCapability.isConsistent(capability) == false)
+                     {
+                        throw new IllegalStateException("capability " + newCapability + " inconsistent with " + capability);
+                     }
+                  }
+               }
+               
+            }
+         }
+      }
+   }
+   
+}
+

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileRequirementDependencyItem.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -45,9 +45,6 @@
    /** The profile requirement to resolve. */
    private ProfileRequirement requirement;
    
-   /** The on demand ctx. */
-   private ProfileKey resolvedCtx;
-   
    public ProfileRequirementDependencyItem(ProfileDependencyContext context, ProfileRequirement requirement, ControllerState state)
    {
       super(context != null ? context.getKey() : null, null, state, ControllerState.INSTALLED);
@@ -67,58 +64,53 @@
    @Override
    public boolean resolve(Controller controller)
    {
-      ProfileKey iDependOn = resolvedCtx;
+      ProfileKey iDependOn = getDependencyContext().resolve(this);
+
+      // Not resolvable 
       if(iDependOn == null)
       {
-         // Cache the result
-         iDependOn = context.resolve(this);
+         setResolved(getRequirement().isOptional());
+         return isResolved();
       }
-      if(iDependOn != null)
+
+      // Self dependencies
+      if(getName().equals(iDependOn))
       {
-         // Resolve dependencies on ourself
-         if(getName().equals(iDependOn))
+         ControllerContext context = controller.getContext(iDependOn, null);
+         setIDependOn(iDependOn);
+         addDependsOnMe(controller, context);
+         setResolved(true);
+         return isResolved();
+      }
+      
+      ControllerContext context = controller.getContext(iDependOn, getDependentState());
+      if(context != null)
+      {
+         setIDependOn(iDependOn);
+         addDependsOnMe(controller, context);
+         setResolved(true);
+         return isResolved();
+      }
+      else
+      {
+         // Check on demand
+         context = controller.getContext(iDependOn, null);
+         if(context != null && ControllerMode.ON_DEMAND.equals(context.getMode()))
          {
-            setResolved(true);
-         }
-         else
-         {
-            ControllerContext context = controller.getContext(iDependOn, getDependentState());
-            if(context != null)
+            try
             {
-               setIDependOn(iDependOn);
-               addDependsOnMe(controller, context);
-               setResolved(true);  
+               controller.enableOnDemand(context);
             }
-            else
+            catch(Throwable ignored)
             {
-               context = controller.getContext(iDependOn, null);
-               if(context != null && ControllerMode.ON_DEMAND.equals(context.getMode()))
-               {
-                  try
-                  {
-                     // Cache the ctx, so that we don't need to resolve it again
-                     resolvedCtx = iDependOn;
-                     controller.enableOnDemand(context);
-                  }
-                  catch(Throwable ignored)
-                  {
-                     if(log.isTraceEnabled())
-                        log.trace("Unexpected error", ignored);
-                  }
-               }
-               else
-               {
-                  setResolved(false);
-               }
-            }            
+               if(log.isTraceEnabled())
+                  log.trace("Unexpected error", ignored);
+            }
+            setResolved(true);
+            return isResolved();
          }
       }
-      else
-      {
-         // Resolve optional requirements
-         if(getRequirement().isOptional())
-            setResolved(true);
-      }
+      setResolved(false);
       return isResolved();
    }
    
@@ -127,7 +119,6 @@
    {
       setIDependOn(null);
       setResolved(false);
-      resolvedCtx = null;
       return true;
    }
  
@@ -145,5 +136,10 @@
       builder.append(", requirement=").append(getRequirement());
    }
    
+   protected ProfileDependencyContext getDependencyContext()
+   {
+      return context;
+   }
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployers/MainDeployerPlugin.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployers/MainDeployerPlugin.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployers/MainDeployerPlugin.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -25,6 +25,7 @@
 import org.jboss.deployers.client.spi.main.MainDeployer;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.profileservice.ProfileDeployerPlugin;
+import org.jboss.profileservice.ProfileDeployerPluginRegistry;
 import org.jboss.profileservice.spi.ProfileDeployment;
 
 /**
@@ -49,6 +50,16 @@
       this.deployer = deployer;
    }
    
+   public void start()
+   {
+      ProfileDeployerPluginRegistry.getInstance().setDefaultPlugin(this);
+   }
+   
+   public void stop()
+   {
+      ProfileDeployerPluginRegistry.getInstance().removedefaultPlugin();
+   }
+   
    @Override
    public void addDeployment(ProfileDeployment deployment) throws Exception
    {
@@ -104,6 +115,18 @@
       this.deployer.removeDeployment(deployment.getName());
    }
 
+   @Override
+   public void prepareShutdown()
+   {
+      this.deployer.prepareShutdown();
+   }
+   
+   @Override
+   public void shutdown()
+   {
+      this.deployer.shutdown();
+   }
+   
    Deployment createDeployment(ProfileDeployment deployment)
    {
       return deploymentBuilder.createDeployment(deployment);

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -44,8 +44,8 @@
    protected static final Logger log = Logger.getLogger(HDScannerFactory.class);
    
    /** The active scans. */
-   private Map<ProfileKey, ScannerWrapper> activeScans = new ConcurrentHashMap<ProfileKey, ScannerWrapper>(); 
-
+   private Map<ProfileKey, ScannerWrapper> registeredScans = new ConcurrentHashMap<ProfileKey, ScannerWrapper>(); 
+  
    /**
     * Schedule a HDScanner for execution.
     * 
@@ -56,6 +56,18 @@
     * @return the scheduled future
     */
    abstract <T extends Runnable> ScheduledFuture<Void> schedule(T scanner, int scanPeriod, TimeUnit timeUnit);
+
+   /**
+    * Stop and unregister all still active scanners.
+    */
+   public void stop()
+   {
+      // Actually all scanners should be unregistered during the profile lifecycle
+      for(ProfileKey key : this.registeredScans.keySet())
+      {
+         unregisterScanner(key, true);
+      }
+   }
    
    /**
     * {@inheritDoc}
@@ -72,18 +84,45 @@
       {
          throw new IllegalArgumentException("null profile key");
       }
-      if(this.activeScans.containsKey(key))
+      if(configuration == null)
       {
+         throw new IllegalArgumentException("null scanner configuration.");
+      }
+      if(this.registeredScans.containsKey(key))
+      {
          throw new IllegalArgumentException("scanner already registered for profile " + key);
       }
-      HDScanner scanner = new HDScanner(profile, null, configuration);
-      ScheduledFuture<Void> future = schedule(scanner, scanner.getScanPeriod(), scanner.getTimeUnit());      
-      return addScanner(key, scanner, future);
+      HDScanner scanner = new HDScanner(profile, null);      
+      return createScannerWrapper(key, scanner, configuration);
    }
 
    /**
     * {@inheritDoc}
     */
+   public void activateScanner(ProfileKey key)
+   {
+      Scanner scanner = this.registeredScans.get(key);
+      if(scanner != null)
+      {
+         scanner.start();
+      }
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public void stopScanner(ProfileKey key)
+   {
+      Scanner scanner = this.registeredScans.get(key);
+      if(scanner != null)
+      {
+         scanner.stop();
+      }
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
    @Override
    public Scanner unregisterScanner(ProfileKey key)
    {
@@ -91,6 +130,22 @@
    }
    
    /**
+    * Schedule a HDScanner for execution.
+    * 
+    * @param scanner the hd scanner
+    * @param configuration the scanner configuration
+    * @return the scheduled future
+    */
+   protected ScheduledFuture<Void> schedule(HDScanner scanner, ScannerConfiguration configuration)
+   {
+      if(this.registeredScans.containsKey(scanner.getKey()) == false)
+      {
+         throw new IllegalStateException("Scanner unregistered " + scanner.getKey());
+      }
+      return schedule(scanner, configuration.getScanPeriod(), configuration.getTimeUnit());
+   }
+   
+   /**
     * Internally unregister a scanner.
     * 
     * @param key the profile key
@@ -99,7 +154,7 @@
     */
    protected Scanner unregisterScanner(ProfileKey key, boolean mayInterruptIfRunning)
    {
-      ScannerWrapper wrapper = this.activeScans.remove(key);
+      ScannerWrapper wrapper = this.registeredScans.remove(key);
       if(wrapper != null)
       {
          wrapper.stop(mayInterruptIfRunning);
@@ -115,55 +170,79 @@
     * @param activeScan the schedule future
     * @return the scanner wrapper
     */
-   protected Scanner addScanner(ProfileKey key, HDScanner scanner,
-         ScheduledFuture<Void> activeScan)
+   protected Scanner createScannerWrapper(ProfileKey key, HDScanner scanner, ScannerConfiguration configuration)
    {
-      ScannerWrapper wrapper = new ScannerWrapper(scanner, activeScan);
-      this.activeScans.put(key, wrapper);
+      ScannerWrapper wrapper = new ScannerWrapper(scanner, configuration);
+      this.registeredScans.put(key, wrapper);
       return wrapper;
    }
    
-   /**
-    * Stop and unregister all still active scanners.
-    */
-   public void stop()
+   class ScannerWrapper implements Scanner, ScannerConfiguration
    {
-      // Actually all scanners should be unregistered
-      // during the profile lifecycle
-      for(ProfileKey key : this.activeScans.keySet())
-      {
-         unregisterScanner(key, true);
-      }
-   }
-   
-   class ScannerWrapper implements Scanner
-   {
+      /** The scanner configuration. */
+      private final ScannerConfiguration configuration;
       /** The actual scanner. */
       private final HDScanner scanner;
       /** The scanner future. */
       private ScheduledFuture<Void> activeScan;
       
-      public ScannerWrapper(HDScanner scanner, ScheduledFuture<Void> activeScan)
+      public ScannerWrapper(HDScanner scanner, ScannerConfiguration configuration)
       {
          this.scanner = scanner;
-         this.activeScan = activeScan;
+         this.configuration = configuration;
       }
       
       @Override
+      public ProfileKey getKey()
+      {
+         return scanner.getKey();
+      }
+      
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public int getScanPeriod()
+      {
+         return configuration.getScanPeriod();
+      }
+      
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public TimeUnit getTimeUnit()
+      {
+         return configuration.getTimeUnit();
+      }
+      
+      /**
+       * {@inheritDoc}
+       */
+      @Override
       public int getScanCount()
       {
          return scanner.getScanCount();
       }
+
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public boolean isScheduled()
+      {
+         return activeScan != null;
+      }
       
       @Override
-      public synchronized void resume()
+      public synchronized void start()
       {
          if(activeScan == null)
          {
-            activeScan = schedule(scanner, scanner.getScanPeriod(), scanner.getTimeUnit());
+            activeScan = schedule(scanner, configuration);
          }
       }
-
+      
       @Override
       public synchronized void scan() throws Exception
       {
@@ -171,7 +250,7 @@
       }
 
       @Override
-      public synchronized void suspend()
+      public synchronized void stop()
       {
          if (activeScan != null)
          {

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -23,12 +23,10 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.concurrent.TimeUnit;
 
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.ProfileDeployerPlugin;
-import org.jboss.profileservice.hotdeploy.HDScannerFactory.ScannerConfiguration;
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.ProfileDeployment;
@@ -41,7 +39,7 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-class HDScanner implements Runnable, ScannerConfiguration
+class HDScanner implements Runnable
 {
 
    /** The logger. */
@@ -53,23 +51,15 @@
    /** The mutable profile. */
    private final MutableProfile profile;
    
-   /** The configuration. */
-   private final ScannerConfiguration configuration;
-   
    /** TODO we should not use the deployer here. 
     * @see DeploymentAction
     */
    private final ProfileDeployerPlugin deployer;
 
-   protected HDScanner(MutableProfile profile, ProfileDeployerPlugin plugin, ScannerConfiguration configuration)
+   protected HDScanner(MutableProfile profile, ProfileDeployerPlugin plugin)
    {
-      if(configuration == null)
-      {
-         throw new IllegalArgumentException("null configuration");
-      }
       this.profile = profile;
       this.deployer = plugin;
-      this.configuration = configuration;
    }
    
    /**
@@ -77,30 +67,12 @@
     * 
     * @return the profile key
     */
-   public ProfileKey getKey()
+   protected ProfileKey getKey()
    {
       return profile.getKey();
    }
    
-   /**
-    * {@inheritDoc}
-    */
    @Override
-   public int getScanPeriod()
-   {
-      return configuration.getScanPeriod();
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   public TimeUnit getTimeUnit()
-   {
-      return configuration.getTimeUnit();
-   }
-
-   @Override
    public void run()
    {
       try
@@ -145,7 +117,7 @@
       boolean trace = log.isTraceEnabled();
       if(trace)
       {
-         log.trace("Begin deployment scan: " + profile.getKey());
+         log.debug("Begin deployment scan: " + profile.getKey());
       }
       boolean modified = false;
       Collection<String> modifiedDeploymentNames = new ArrayList<String>();

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -21,12 +21,12 @@
 */
 package org.jboss.profileservice.hotdeploy;
 
-import java.util.concurrent.TimeUnit;
-
 import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.ProfileKey;
 
 /**
+ * The HDScanner factory.
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -42,29 +42,25 @@
    Scanner registerScanner(MutableProfile profile, ScannerConfiguration configuration);
    
    /**
+    * Activate a scanner.
+    * 
+    * @param key the profile key
+    */
+   void activateScanner(ProfileKey key);
+   
+   /**
+    * Stop a scanner.
+    * 
+    * @param key the profile key
+    */
+   void stopScanner(ProfileKey key);
+   
+   /**
     * Unregister a profile from HDScanning.
     * 
     * @param key the profile key
     */
    Scanner unregisterScanner(ProfileKey key);
    
-   public interface ScannerConfiguration
-   {
-      /**
-       * Get the scan period.
-       * 
-       * @return the scan period
-       */
-      int getScanPeriod();
-      
-      /**
-       * Get the time unit
-       * 
-       * @return the time unit
-       */
-      TimeUnit getTimeUnit();
-      
-   }
-   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -21,44 +21,77 @@
  */
 package org.jboss.profileservice.hotdeploy;
 
+import java.util.concurrent.TimeUnit;
+
 import org.jboss.managed.api.annotation.ManagementOperation;
 import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.profileservice.spi.ProfileKey;
 
 /**
  * The scanner interface.
  *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  */
 // TODO we need to merge a scanner into a Profile MO 
 // @ManagementObject(componentType = @ManagementComponent(type="Profile", subtype = "HDScanner"))
-public interface Scanner
+public interface Scanner extends ScannerConfiguration
 {
+   
    /**
+    * Get the associated profile key.
+    * 
+    * @return the profile key
+    */
+   @ManagementProperty(name = "profile", description = "The associated profile", readOnly = true)
+   ProfileKey getKey();
+   
+   /**
+    * {@inheritDoc}
+    */
+   @ManagementProperty(name = "scan-period", description = "The scan period", readOnly = true)
+   public int getScanPeriod();
+   
+   /**
+    * {@inheritDoc}
+    */
+   @ManagementProperty(name = "time-unit", description = "The time unit", readOnly = true)
+   public TimeUnit getTimeUnit();
+   
+   /**
     * Get the scan count.
     * 
     * @return the scan count
     */
-   @ManagementProperty(name = "scan-count", readOnly = true)
+   @ManagementProperty(name = "scan-count", description = "The scan count", readOnly = true)
    int getScanCount();
    
    /**
+    * Boolean flag indicating if the scanner is scheduled.
+    * 
+    * @return true if schedule
+    */
+   @ManagementProperty(name = "is-scheduled", description = "Is the scanner scheduled", readOnly = true)
+   boolean isScheduled();
+   
+   /**
     * Suspend scanning.
     */
-   @ManagementOperation
-   void suspend();
+   @ManagementOperation(name = "stop", description = "Stop the scanning")
+   void stop();
 
    /**
     * Resume scanning.
     */
-   @ManagementOperation
-   void resume();
+   @ManagementOperation(name = "start", description = "Start the scanning")
+   void start();
 
    /**
     * Do scan.
     *
     * @throws Exception for any error
     */
-   @ManagementOperation
+   @ManagementOperation(name = "scan", description = "Scan the profile for modified deployments")
    void scan() throws Exception;
-}
\ No newline at end of file
+   
+}
+

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,50 @@
+/*
+* 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.hotdeploy;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * The hot deployment scanner configuration.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ScannerConfiguration
+{
+
+   /**
+    * Get the scan period.
+    * 
+    * @return the scan period
+    */
+   int getScanPeriod();
+   
+   /**
+    * Get the time unit
+    * 
+    * @return the time unit
+    */
+   TimeUnit getTimeUnit();
+   
+}
+

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ImplicitProfileRequirement.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ImplicitProfileRequirement.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ImplicitProfileRequirement.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,70 +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.metadata;
-
-import org.jboss.profileservice.metadata.helpers.AbstractSubProfileKeyMetaData;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
-
-/**
- * A implicit profile requirement, used by the parsing layer to set a
- * dependency on a previous profile. This requirement is optional.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ImplicitProfileRequirement extends AbstractSubProfileKeyMetaData 
-{
-
-   public ImplicitProfileRequirement()
-   {
-      super();
-   }
-   
-   public ImplicitProfileRequirement(String name)
-   {
-      super(name);
-   }
-   
-   public ImplicitProfileRequirement(String domain, String server, String name)
-   {
-      super(domain, server, name);
-   }
-   
-   public ImplicitProfileRequirement(ProfileKeyMetaData metaData)
-   {
-      super(metaData.getDomain(), metaData.getServer(), metaData.getName());
-   }
-   
-   public ImplicitProfileRequirement(ProfileKey key)
-   {
-      super(key);
-   }
-   
-   @Override
-   public boolean isOptional()
-   {
-      return true;
-   }
-   
-}
-

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ProfileMetaDataFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ProfileMetaDataFactory.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/ProfileMetaDataFactory.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -125,7 +125,7 @@
       }
    }
    
-   protected void addProfileMetaData(ProfileMetaData metaData)
+   protected String addProfileMetaData(ProfileMetaData metaData)
    {
       String profileName = metaData.getName();
       if(profileName == null)
@@ -143,18 +143,26 @@
          throw new IllegalStateException("duplicate profile name " + profileName);
       }
       profiles.put(profileName, metaData);
+      return profileName;
    }
    
    protected void parse(VirtualFile vf) throws JBossXBException, IOException
    {
+      InputStream is = null; 
       try
       {
-         processProfilesMetaData(unmarshal(vf.openStream(), ProfilesMetaData.class));
+         is = vf.openStream();
+         processProfilesMetaData(unmarshal(is, ProfilesMetaData.class));
       }
       catch(Exception e)
       {
          throw new RuntimeException("failed to parse : " + vf.getPathName(), e);
       }
+      finally
+      {
+         try { if(is != null) { is.close(); }
+         } catch (IOException ignore) { }
+      }
    }
 
    protected <T> T unmarshal(InputStream is, Class<T> clazz) throws JBossXBException

Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileCapability.java (from rev 99447, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileCapability.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileCapability.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileCapability.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,101 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.profileservice.metadata.helpers;
+
+import org.jboss.profileservice.spi.dependency.ProfileCapability;
+import org.jboss.profileservice.version.helpers.NameAndVersionSupport;
+
+/**
+ * AbstractCapability.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractProfileCapability extends NameAndVersionSupport implements ProfileCapability
+{
+   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 5707892139772442117L;
+
+   /**
+    * Create a new AbstractCapability
+    */
+   public AbstractProfileCapability()
+   {
+   }
+   
+   /**
+    * Create a new AbstractCapability
+    * 
+    * @param name the name
+    * @throws IllegalArgumentException for a null name
+    */
+   public AbstractProfileCapability(String name)
+   {
+      super(name);
+   }
+   
+   /**
+    * Create a new AbstractCapability.
+    * 
+    * @param name the name
+    * @param version the version - pass null for the default version
+    * @throws IllegalArgumentException for a null name
+    */
+   public AbstractProfileCapability(String name, Object version)
+   {
+      super(name, version);
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+         return true;
+      if (obj == null || obj instanceof AbstractProfileCapability == false)
+         return false;
+      return super.equals(obj);
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append(getClass().getSimpleName());
+      buffer.append("{");
+      toString(buffer);
+      buffer.append("}");
+      return buffer.toString();
+   }
+   
+   /**
+    * For subclasses to override toString()
+    * 
+    * @param buffer the buffer
+    */
+   protected void toString(StringBuffer buffer)
+   {
+      buffer.append(getName());
+      buffer.append(" ").append(getVersion());
+   }
+}

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyCapability.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyCapability.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyCapability.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -38,12 +38,28 @@
       super();
    }
    
+   public AbstractProfileKeyCapability(String name)
+   {
+      super(name);
+   }
+   
    public boolean resolves(ProfileRequirement requirement)
    {
       return super.equals(requirement);
    }
    
    @Override
+   public boolean isConsistent(ProfileCapability other)
+   {
+      // If the other capability is the same, it is not consistent
+      if(equals(other))
+      {
+         return false;
+      }
+      return true;
+   }
+   
+   @Override
    public boolean equals(Object obj)
    {
       if (obj == this)

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileKeyMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -37,12 +37,6 @@
    /** The profile name. */
    private String name;
    
-   /** The server. */
-   private String server;
-   
-   /** The domain. */
-   private String domain;
-   
    public AbstractProfileKeyMetaData()
    {
       //
@@ -50,20 +44,15 @@
    
    public AbstractProfileKeyMetaData(String name)
    {
-      this(null, null, name);
-   }
-   
-   public AbstractProfileKeyMetaData(String domain, String server, String name)
-   {
-      this.domain = domain;
-      this.server = server;
+      if(name == null)
+      {
+         throw new IllegalArgumentException("null name");
+      }
       this.name = name;
    }
    
    public AbstractProfileKeyMetaData(ProfileKey key)
    {
-      this.domain = key.getDomain();
-      this.server = key.getServer();
       this.name = key.getName();
    }
 
@@ -74,29 +63,13 @@
 
    public void setName(String name)
    {
+      if(name == null)
+      {
+         throw new IllegalArgumentException("null name.");
+      }
       this.name = name;
    }
    
-   public String getServer()
-   {
-      return server;
-   }
-
-   public void setServer(String server)
-   {
-      this.server = server;
-   }
-
-   public String getDomain()
-   {
-      return domain;
-   }
-
-   public void setDomain(String domain)
-   {
-      this.domain = domain;
-   }
-   
    @Override
    public boolean equals(Object obj)
    {
@@ -106,13 +79,7 @@
          return false;
       
       AbstractProfileKeyMetaData other = (AbstractProfileKeyMetaData) obj;
-      if(equals(domain, other.domain) == false)
-         return false;
-      if(equals(server, other.server) == false)
-         return false;
-      if(equals(name, other.name) == false)
-         return false;
-      return true; 
+      return equals(name, other.name);
    }
    
    @Override
@@ -135,12 +102,9 @@
    protected void toString(StringBuilder builder)
    {
       builder.append("name=").append(getName());
-      // TODO remove domain and server from the meta data ?
-      // builder.append(", domain=").append(getDomain());
-      // builder.append(", server=").append(getServer());
    }
 
-   private static boolean equals(Object one, Object two)
+   static boolean equals(Object one, Object two)
    {
       if (one == null && two == null)
          return true;

Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileRequirement.java (from rev 99447, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/AbstractProfileRequirement.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileRequirement.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractProfileRequirement.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,185 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.profileservice.metadata.helpers;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+import org.jboss.profileservice.spi.dependency.DependencyMode;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+import org.jboss.profileservice.version.VersionRange;
+import org.jboss.profileservice.version.helpers.NameAndVersionRangeSupport;
+
+/**
+ * AbstractRequirement.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractProfileRequirement extends NameAndVersionRangeSupport implements ProfileRequirement
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -9013971913225421465L;
+
+   /** The dependency mode. */
+   private DependencyMode mode = DependencyMode.getDefault();
+   
+   /**
+    * Create a new AbstractRequirement
+    */
+   public AbstractProfileRequirement()
+   {
+   }
+   
+   /**
+    * Create a new AbstractRequirement
+    * 
+    * @param name the name
+    * @throws IllegalArgumentException for a null name
+    */
+   public AbstractProfileRequirement(String name)
+   {
+      super(name);
+   }
+   
+   /**
+    * Create a new AbstractRequirement.
+    * 
+    * @param name the name
+    * @param versionRange the version range - pass null for all versions
+    * @throws IllegalArgumentException for a null name
+    */
+   public AbstractProfileRequirement(String name, VersionRange versionRange)
+   {
+      super(name, versionRange);
+   }
+
+   @XmlAttribute(name = "mode")
+   public DependencyMode getDependencyMode()
+   {
+      return mode;
+   }
+   
+   protected void setDependencyMode(DependencyMode mode)
+   {
+      this.mode = mode;
+   }
+   
+   
+   /**
+    * {@inheritDoc}
+    */
+   public boolean isOptional()
+   {
+      return mode == DependencyMode.OPTIONAL;
+   }
+   
+   /**
+    * Set the optional.
+    * 
+    * @param optional the optional.
+    */
+   @XmlAttribute(name="optional")
+   public void setOptional(boolean optional)
+   {
+      if(optional)
+      {
+         mode = DependencyMode.OPTIONAL;
+      }
+   }
+   
+   public boolean isConsistent(ProfileRequirement other)
+   {
+      return isConsistent(other, null);
+   }
+
+   /**
+    * Check whether the requirements are consistent
+    * 
+    * @param other the other requirement
+    * @param requirementType the class to check when looking for inconsistencies (uses getClass() when null)
+    * @return true when consistent, false otherwise
+    */
+   protected boolean isConsistent(ProfileRequirement other, Class<? extends ProfileRequirement> requirementType)
+   {
+      if (other == null)
+         throw new IllegalArgumentException("Null requirement");
+      if (requirementType == null)
+         requirementType = getClass();
+      
+      // Not our type
+      if (requirementType.isInstance(other) == false)
+         return true;
+      
+      AbstractProfileRequirement otherRequirement = (AbstractProfileRequirement) other;
+      // Not the same name
+      String name = getName();
+      String otherName = otherRequirement.getName();
+      if (name.equals(otherName) == false)
+         return true;
+
+      // Check the version ranges are consistent
+      VersionRange range = getVersionRange();
+      VersionRange otherRange = otherRequirement.getVersionRange();
+      return range.isConsistent(otherRange);
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+         return true;
+      if (obj == null || obj instanceof AbstractProfileRequirement == false)
+         return false;
+      if (super.equals(obj) == false)
+         return false;
+      AbstractProfileRequirement other = (AbstractProfileRequirement) obj;
+      if (this.isOptional() != other.isOptional())
+         return false;
+      return true;
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append(getClass().getSimpleName());
+      buffer.append("{");
+      toString(buffer);
+      buffer.append("}");
+      return buffer.toString();
+   }
+   
+   /**
+    * For subclasses to override toString()
+    * 
+    * @param buffer the buffer
+    */
+   protected void toString(StringBuffer buffer)
+   {
+      buffer.append(getName());
+      buffer.append(" ").append(getVersionRange());
+      if (isOptional())
+         buffer.append(" OPTIONAL");
+   }
+}

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractSubProfileKeyMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractSubProfileKeyMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/metadata/helpers/AbstractSubProfileKeyMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -22,7 +22,6 @@
 package org.jboss.profileservice.metadata.helpers;
 
 import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 
@@ -35,7 +34,6 @@
  */
 public abstract class AbstractSubProfileKeyMetaData extends AbstractProfileKeyMetaData implements SubProfileMetaData
 {
-
    
    public AbstractSubProfileKeyMetaData()
    {
@@ -47,11 +45,6 @@
       super(name);
    }
    
-   public AbstractSubProfileKeyMetaData(String domain, String server, String name)
-   {
-      super(domain, server, name);
-   }
-   
    public AbstractSubProfileKeyMetaData(ProfileKey key)
    {
       super(key);
@@ -61,7 +54,7 @@
    {
       visitor.addRequirement(this);  
    }
-
+   
    @Override
    public boolean equals(Object obj)
    {
@@ -71,12 +64,6 @@
          return false;
       return super.equals(obj);
    }
-   
-   @Override
-   public boolean isConsistent(ProfileRequirement other)
-   {
-      // We don't have a version
-      return true;
-   }
+
 }
 

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -44,6 +44,9 @@
    /** The deployer. */
    private final BasicXMLDeployer deployer;
 
+   /** Shutdown. */
+   private volatile boolean shutdown = false;
+   
    public BootstrapDeployerPlugin(Kernel kernel)
    {
       if(kernel == null)
@@ -54,6 +57,7 @@
    @Override
    public void addDeployment(ProfileDeployment deployment) throws Exception
    {
+      checkShutdown();
       try
       {
          // Deploy
@@ -154,5 +158,25 @@
       return null;
    }
    
+   @Override
+   public void prepareShutdown()
+   {
+      this.shutdown = true;
+   }
+   
+   @Override
+   public void shutdown()
+   {
+      // TODO
+   }
+   
+   protected void checkShutdown()
+   {
+      if(shutdown)
+      {
+         throw new IllegalStateException("deployer is shutdown");
+      }
+   }
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapProfileMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapProfileMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapProfileMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -28,7 +28,6 @@
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
 import org.jboss.profileservice.domain.spi.DomainFeatureNode;
@@ -37,8 +36,8 @@
 import org.jboss.profileservice.profile.metadata.BasicProfileDeploymentMetaData;
 import org.jboss.profileservice.profile.metadata.BasicSubProfileMetaData;
 import org.jboss.profileservice.profile.metadata.CommonProfileNameSpaces;
-import org.jboss.profileservice.profile.metadata.FileRepositorySourceConfiguration;
 import org.jboss.profileservice.profile.metadata.FeatureCapability;
+import org.jboss.profileservice.profile.metadata.FileRepositorySourceConfiguration;
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
@@ -73,31 +72,7 @@
       return this.deployments;
    }
    
-   /**
-    * The domain attribute needs to be configured
-    * in the domain meta data and is shared across
-    * all local profiles.
-    */
    @Override
-   @XmlTransient
-   public String getDomain()
-   {
-      return super.getDomain();
-   }
-   
-   /**
-    * The server attribute needs to be configured
-    * in the domain meta data and is shared across
-    * all local profiles.
-    */
-   @Override
-   @XmlTransient
-   public String getServer()
-   {
-      return super.getServer();
-   }
-   
-   @Override
    @XmlAttribute(name = "name")
    public String getName()
    {

Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ActivationPolicy.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ActivationPolicy.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ActivationPolicy.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,46 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.profileservice.profile.metadata;
-
-import javax.xml.bind.annotation.XmlEnumValue;
-
-/**
- * The activation policy.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public enum ActivationPolicy
-{
-//   /**
-//    * optional
-//    */
-//   @XmlEnumValue("optional")
-//   OPTIONAL,
-   
-   /**
-    * install when dependencies are satisfied
-    */
-   @XmlEnumValue("satisfied")
-   SATISFIED
-}
-

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/BasicProfileMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -28,7 +28,6 @@
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
 import org.jboss.profileservice.domain.spi.DomainFeatureNode;
@@ -58,6 +57,9 @@
    /** Requirement on the bootstrap. */
    private static FeatureRequirement BOOTSTRAP = new FeatureRequirement(CommonProfileNameSpaces.BOOTSTRAP_PROFILE_NAMESPACE);
    
+   /** enable on demand. */
+   private boolean onDemand;
+   
    /** The aliases. */
    private List<String> aliases;
    
@@ -77,31 +79,7 @@
       return this.deployments;
    }
    
-   /**
-    * The domain attribute needs to be configured
-    * in the domain meta data and is shared across
-    * all local profiles.
-    */
    @Override
-   @XmlTransient
-   public String getDomain()
-   {
-      return super.getDomain();
-   }
-   
-   /**
-    * The server attribute needs to be configured
-    * in the domain meta data and is shared across
-    * all local profiles.
-    */
-   @Override
-   @XmlTransient
-   public String getServer()
-   {
-      return super.getServer();
-   }
-   
-   @Override
    @XmlAttribute(name = "name")
    public String getName()
    {
@@ -144,6 +122,17 @@
       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()
@@ -175,6 +164,10 @@
             visitor.visit(deployment);
          }
       }
+      if(onDemand)
+      {
+         visitor.enableOnDemand(onDemand);
+      }
    }
    
    @Override

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/BasicSubProfileMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/BasicSubProfileMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/BasicSubProfileMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -26,6 +26,7 @@
 
 import org.jboss.profileservice.metadata.helpers.AbstractSubProfileKeyMetaData;
 import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.dependency.DependencyMode;
 
 /**
  * The basic sub profile meta data.
@@ -35,12 +36,9 @@
  */
 public class BasicSubProfileMetaData extends AbstractSubProfileKeyMetaData
 {
-
-   /** Is optional. */
-   private boolean optional = false;
    
-   /** The activation policy. */
-   private ActivationPolicy activationPolicy;
+   /** The dependency mode. */
+   private DependencyMode mode = DependencyMode.EXPLICIT;
    
    public BasicSubProfileMetaData()
    {
@@ -52,41 +50,12 @@
       super(name);
    }
    
-   public BasicSubProfileMetaData(String domain, String server, String name)
-   {
-      super(domain, server, name);
-   }
-   
    public BasicSubProfileMetaData(ProfileKey key)
    {
       super(key);
    }
    
-   /**
-    * The domain attribute needs to be configured
-    * in the domain meta data and is shared across
-    * all local profiles.
-    */
    @Override
-   @XmlTransient
-   public String getDomain()
-   {
-      return super.getDomain();
-   }
-   
-   /**
-    * The server attribute needs to be configured
-    * in the domain meta data and is shared across
-    * all local profiles.
-    */
-   @Override
-   @XmlTransient
-   public String getServer()
-   {
-      return super.getServer();
-   }
-   
-   @Override
    @XmlAttribute(name = "name")
    public String getName()
    {
@@ -96,25 +65,24 @@
    @Override
    public boolean isOptional()
    {
-      return optional;
+      return getDependencyMode() == DependencyMode.OPTIONAL;
    }
 
    @XmlAttribute(name = "optional")
    public void setOptional(boolean optional)
    {
-      this.optional = optional;
+      if(optional)
+      {
+         this.mode = DependencyMode.OPTIONAL;
+      }
    }
    
-   @XmlAttribute(name = "activation-policy")
-   public ActivationPolicy getActivationPolicy()
+   @XmlTransient
+   // we don't allow anything else than optional here
+   public DependencyMode getDependencyMode()
    {
-      return activationPolicy;
+      return mode;
    }
    
-   public void setActivationPolicy(ActivationPolicy activationPolicy)
-   {
-      this.activationPolicy = activationPolicy;
-   }
-   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureCapability.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureCapability.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureCapability.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -85,6 +85,16 @@
    }
 
    @Override
+   public boolean isConsistent(ProfileCapability other)
+   {
+      if(this.equals(other))
+      {
+         return false;
+      }
+      return true;
+   }
+   
+   @Override
    public void visit(ProfileMetaDataVisitor visitor)
    {
       visitor.addCapability(this);
@@ -103,5 +113,26 @@
       buffer.append("{namespace=").append(nsUri).append("}");
       return buffer.toString();
    }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+         return true;
+      if (obj == null || obj instanceof FeatureCapability == false)
+         return false;
+      
+      FeatureCapability other = (FeatureCapability) obj;
+      return equals(nsUri, other.nsUri);
+   }
+   
+   private static boolean equals(Object one, Object two)
+   {
+      if (one == null && two == null)
+         return true;
+      if (one == null && two != null)
+         return false;
+      return one.equals(two);
+   }
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureRequirement.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureRequirement.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/FeatureRequirement.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -23,6 +23,7 @@
 
 import javax.xml.bind.annotation.XmlAttribute;
 
+import org.jboss.profileservice.spi.dependency.DependencyMode;
 import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
@@ -74,15 +75,15 @@
    }
 
    @Override
-   public boolean isConsistent(ProfileRequirement other)
+   public boolean isOptional()
    {
-      return true;
+      return false;
    }
-
+   
    @Override
-   public boolean isOptional()
+   public DependencyMode getDependencyMode()
    {
-      return false;
+      return DependencyMode.EXPLICIT;
    }
 
    @Override

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfilesMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfilesMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/ProfilesMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -30,6 +30,7 @@
 import javax.xml.bind.annotation.XmlType;
 
 import org.jboss.profileservice.profile.bootstrap.BootstrapProfileMetaData;
+import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
@@ -63,7 +64,8 @@
    
    @XmlElements({
       @XmlElement(name = "profile", type = BasicProfileMetaData.class),
-      @XmlElement(name = "bootstrap", type = BootstrapProfileMetaData.class)
+      @XmlElement(name = "bootstrap", type = BootstrapProfileMetaData.class),
+      @XmlElement(name = "profile-group", type = EmptyProfileMetaData.class)
    })
    public List<ProfileMetaData> getProfiles()
    {

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/VirtualProfileDeploymentMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/VirtualProfileDeploymentMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/VirtualProfileDeploymentMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -25,7 +25,7 @@
 
 import javax.xml.bind.annotation.XmlType;
 
-import org.jboss.profileservice.dependency.AbstractProfileRequirement;
+import org.jboss.profileservice.metadata.helpers.AbstractProfileRequirement;
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.profileservice.virtual.deployment.AbstractVirtualDeployment;

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/RequiredProfiles.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/RequiredProfiles.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/domain/RequiredProfiles.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,125 @@
+/*
+* 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.profile.metadata.domain;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.profileservice.domain.spi.DomainFeatureNode;
+import org.jboss.profileservice.domain.spi.DomainFeatureVisitor;
+import org.jboss.profileservice.metadata.helpers.AbstractProfileMetaData;
+import org.jboss.profileservice.metadata.helpers.AbstractSubProfileKeyMetaData;
+import org.jboss.profileservice.profile.metadata.CommonProfileNameSpaces;
+import org.jboss.profileservice.spi.dependency.DependencyMode;
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * The required profile from the domain meta data. The requirements are
+ * all set to resolve, since this is what we want to do.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at JBossXmlSchema(namespace=CommonProfileNameSpaces.REQUIRED_PROFILE_NAMESPACE,
+      elementFormDefault=XmlNsForm.QUALIFIED,
+      normalizeSpace=true,
+      replacePropertyRefs=false)
+ at XmlRootElement(name = "required-profiles")
+ at XmlType(name = "emptyProfileType", propOrder = "features")
+public class RequiredProfiles extends AbstractProfileMetaData implements DomainFeatureNode
+{
+
+   @Override
+   public List<? extends ProfileDeploymentMetaData> getDeployments()
+   {
+      return Collections.emptyList();
+   }
+
+   @Override
+   public ProfileSourceMetaData getSource()
+   {
+      return null;
+   }
+
+   @XmlElement(name = "requires", type = ResolveRequirement.class)
+   public List<ProfileMetaDataVisitorNode> getFeatures()
+   {
+      return super.getFeatures();
+   }
+
+   @Override
+   public String getNameSpace()
+   {
+      return CommonProfileNameSpaces.REQUIRED_PROFILE_NAMESPACE;
+   }
+   
+   @Override
+   public void visit(DomainFeatureVisitor visitor)
+   {
+      visitor.addProfileMetaData(this);
+   }
+   
+   public static class ResolveRequirement extends AbstractSubProfileKeyMetaData
+   {
+
+      public ResolveRequirement()
+      {
+         //
+      }
+      
+      public ResolveRequirement(String name)
+      {
+         super(name);
+      }
+      
+      @XmlAttribute(name = "name")
+      public String getName()
+      {
+         return super.getName();
+      }
+      
+      @XmlTransient
+      public DependencyMode getDependencyMode()
+      {
+         return DependencyMode.RESOLVE; 
+      }
+      
+      @Override
+      public boolean isOptional()
+      {
+         return false;
+      }
+      
+   }
+   
+}
+

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/EmptyProfileMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/EmptyProfileMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/EmptyProfileMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -26,21 +26,16 @@
 
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
-import org.jboss.profileservice.domain.spi.DomainFeatureNode;
-import org.jboss.profileservice.domain.spi.DomainFeatureVisitor;
 import org.jboss.profileservice.metadata.helpers.AbstractProfileMetaData;
-import org.jboss.profileservice.profile.metadata.BasicSubProfileMetaData;
-import org.jboss.profileservice.profile.metadata.CommonProfileNameSpaces;
+import org.jboss.profileservice.metadata.helpers.AbstractSubProfileKeyMetaData;
+import org.jboss.profileservice.spi.dependency.DependencyMode;
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
 import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
-import org.jboss.xb.annotations.JBossXmlSchema;
 
 /**
  * A empty profile meta meta, which only has a name and dependencies 
@@ -49,13 +44,8 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
- at JBossXmlSchema(namespace=CommonProfileNameSpaces.REQUIRED_PROFILE_NAMESPACE,
-      elementFormDefault=XmlNsForm.QUALIFIED,
-      normalizeSpace=true,
-      replacePropertyRefs=false)
- at XmlRootElement(name = "profiles")
 @XmlType(name = "emptyProfileType", propOrder = "features")
-public class EmptyProfileMetaData extends AbstractProfileMetaData implements ProfileMetaData, DomainFeatureNode
+public class EmptyProfileMetaData extends AbstractProfileMetaData implements ProfileMetaData
 {
    
    public EmptyProfileMetaData()
@@ -63,6 +53,11 @@
       super();
    }
    
+   public EmptyProfileMetaData(String name)
+   {
+      setName(name);
+   }
+   
    @Override
    @XmlAttribute(name = "name")
    public String getName()
@@ -71,7 +66,7 @@
    }
    
    @Override
-   @XmlElement(name = "requires", type = BasicSubProfileMetaData.class)
+   @XmlElement(name = "requires", type = DependencyModeRequirement.class)
    public List<ProfileMetaDataVisitorNode> getFeatures()
    {
       return super.getFeatures();
@@ -88,17 +83,46 @@
    {
       return null;
    }
-
-   @Override
-   public String getNameSpace()
+ 
+   @XmlType(name = "dependencyModeRequirementType", propOrder = "dependencyMode")
+   public static class DependencyModeRequirement extends AbstractSubProfileKeyMetaData
    {
-      return CommonProfileNameSpaces.REQUIRED_PROFILE_NAMESPACE;
-   }
+      /** The dependency mode. */
+      private DependencyMode mode = DependencyMode.getDefault();
 
-   @Override
-   public void visit(DomainFeatureVisitor visitor)
-   {
-      visitor.addProfileMetaData(this);
+      @XmlAttribute(name = "name")
+      public String getName()
+      {
+         return super.getName();
+      }
+      
+      
+      
+      @XmlAttribute(name = "mode")
+      public DependencyMode getDependencyMode()
+      {
+         return mode;
+      }
+      
+      public void setDependencyMode(DependencyMode mode)
+      {
+         this.mode = mode;
+      }
+
+      @Override
+      @XmlAttribute(name = "optional")
+      public boolean isOptional()
+      {
+         return mode == DependencyMode.OPTIONAL || mode == DependencyMode.ACTIVATION_CALLBACK;
+      }
+      
+      public void setOptional(boolean optional)
+      {
+         if(optional)
+         {
+            mode = DependencyMode.OPTIONAL;
+         }
+      }
    }
    
 }

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileSourceMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileSourceMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/PropertyProfileSourceMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -38,6 +38,9 @@
    /** The sources. */
    private String path;
 
+   /** The upload dir. */
+   private boolean uploadPath;
+   
    @XmlTransient
    public String getType()
    {
@@ -55,5 +58,16 @@
       this.path = path;
    }
 
+   @XmlAttribute(name = "upload")
+   public boolean isUploadPath()
+   {
+      return uploadPath;
+   }
+   
+   public void setUploadPath(boolean uploadPath)
+   {
+      this.uploadPath = uploadPath;
+   }
+   
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -28,7 +28,7 @@
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlValue;
 
-import org.jboss.profileservice.hotdeploy.HDScannerFactory.ScannerConfiguration;
+import org.jboss.profileservice.hotdeploy.ScannerConfiguration;
 import org.jboss.profileservice.profile.metadata.FeatureRequirement;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
 import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/plugin/ClassPathAdapterProfile.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/plugin/ClassPathAdapterProfile.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/plugin/ClassPathAdapterProfile.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -36,7 +36,6 @@
 import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.profile.metadata.plugin.ClassPathProfileMetaData.ClassPathItem;
-import org.jboss.profileservice.repository.BasicProfileDeployment;
 import org.jboss.profileservice.repository.ProfileDeploymentFactory;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
 import org.jboss.profileservice.spi.Profile;

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/BasicRepositoryConfiguration.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/BasicRepositoryConfiguration.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/BasicRepositoryConfiguration.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -23,6 +23,8 @@
 
 import java.net.URI;
 
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactNotFoundHandler;
 import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
 
 /**
@@ -31,9 +33,12 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class BasicRepositoryConfiguration implements ArtifactRepositoryConfiguration
+public class BasicRepositoryConfiguration<T extends ArtifactId> implements ArtifactRepositoryConfiguration<T>
 {
    
+   /** The not found handler. */
+   ArtifactNotFoundHandler<T> notFoundHandler = DefaultNotFoundHandler.getInstance();
+   
    /** The repository location. */
    private URI location;
    
@@ -60,5 +65,11 @@
       return mutable;
    }
    
+   @Override
+   public ArtifactNotFoundHandler<T> getNotFoundHandler()
+   {
+      return notFoundHandler;
+   }
+   
 }
 

Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DefaultNotFoundHandler.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DefaultNotFoundHandler.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DefaultNotFoundHandler.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,55 @@
+/*
+* 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.repository.artifact;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.jboss.profileservice.spi.repository.Artifact;
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactNotFoundHandler;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DefaultNotFoundHandler<T extends ArtifactId> implements ArtifactNotFoundHandler<T>
+{
+
+   /** The instance. */
+   private static final DefaultNotFoundHandler instance = new DefaultNotFoundHandler();
+   
+   public static DefaultNotFoundHandler getInstance()
+   {
+      return instance;
+   }
+   
+   @Override
+   public Artifact<T> handleArtifactNotFound(ArtifactRepository<T> repsoitory, T artifactId)
+         throws IOException
+   {
+      throw new FileNotFoundException("could not find artifact" + artifactId);
+   }
+   
+}
+

Added: 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	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,325 @@
+/*
+* 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.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+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.spi.ProfileKey;
+import org.jboss.profileservice.spi.dependency.DependencyMode;
+import org.jboss.profileservice.spi.dependency.ProfileRequirement;
+
+/**
+ * The abstract requirement resolver.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractRequirementResolver
+{
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(AbstractRequirementResolver.class);
+   
+   /** The profile meta data registry. */
+   private final ProfileMetaDataRegistry registry;
+
+   /** The included nodes. */
+   private Set<ProfileNode> included = new HashSet<ProfileNode>();
+   
+   /** The included keys. */
+   private List<ProfileKey> includedKeys = new ArrayList<ProfileKey>();
+   
+   /** The activation callback registry. */
+   private List<ProfileNode> callbacks = new LinkedList<ProfileNode>();
+   
+   /** The unresolved requirements. */
+   private List<ProfileRequirement> unresolved = new ArrayList<ProfileRequirement>();
+   
+   /** All referenced nodes. */
+   private Map<ProfileKey, ProfileNode> nodes = new HashMap<ProfileKey, ProfileNode>();
+   
+   public AbstractRequirementResolver(ProfileMetaDataRegistry registry)
+   {
+      if(registry == null)
+      {
+         throw new IllegalArgumentException("null profile metadata registry");
+      }
+      this.registry = registry;
+   }
+   
+   public void resolve(final ProfileDependencyContext context)
+   {
+      if(context == null)
+      {
+         throw new IllegalArgumentException("null dependency context");
+      }
+      resolve(context, false);
+   }
+   
+   void resolve(final ProfileDependencyContext context, final boolean fromActivationCallback)
+   {
+      final boolean trace = log.isTraceEnabled();
+      final ProfileKey currentKey = context.getKey();
+      final ProfileNode currentNode = getNode(currentKey);
+      // Don't process a node twice
+      if(included(currentNode))
+      {
+         return;
+      }
+      if(trace)
+      {
+         log.trace("* processing " + currentNode);
+      }
+      if(fromActivationCallback == false)
+      {
+         // Since we are included harden all depends on me
+         currentNode.hardenDependsOnMe();
+         // Include it in the configuration
+         included.add(currentNode);
+         includedKeys.add(currentKey);
+      }
+      else
+      {
+         // Store callbacks, we need to process them afterwards
+         callbacks.add(currentNode);
+      }
+      final Collection<ProfileRequirement> requirements = context.getRequirements();
+      if(requirements != null && requirements.isEmpty() == false)
+      {
+         for(final ProfileRequirement requirement : requirements)
+         {
+            // Try to resolve the requirement
+            final ProfileKey dependencyKey = registry.resolve(context, requirement);
+            if(dependencyKey == null)
+            {
+               // if the requirement is not optional add to unresolved
+               if(requirement.isOptional() == false)
+               {
+                  unresolved.add(requirement);
+               }
+               continue;
+            }
+            // Ignore self dependencies
+            if(currentKey.equals(dependencyKey))
+            {
+               continue;
+            }
+            // Get the mode and dependency context
+            final DependencyMode mode = getDependencyMode(requirement);
+            final ProfileNode depenencyNode = getNode(dependencyKey);
+            final ProfileDependencyContext dependencyContext = registry.getProfile(dependencyKey);
+            if(mode == DependencyMode.RESOLVE || dependencyContext.isOnDemandEnabled())
+            {
+               // Resolve
+               resolve(dependencyContext, false);
+            }
+            // We don't support nested activation callbacks
+            else if(fromActivationCallback == false && mode == DependencyMode.ACTIVATION_CALLBACK)
+            {
+               // Process activation callbacks
+               resolve(dependencyContext, true);
+            }
+            // If the dependency is already included we can mark it as non-optional
+            boolean dependencyIncluded = included(depenencyNode);
+            boolean optional = requirement.isOptional() && dependencyIncluded == false;
+            ProfileNodeDependency dependency = new ProfileNodeDependency(currentKey, dependencyKey, optional);
+
+            // Add dependency information
+            currentNode.addIDependOn(dependency);
+            depenencyNode.addDependsOnMe(dependency);
+            
+            if(fromActivationCallback && dependencyIncluded == false)
+            {
+               // Weaken DependsOn, so that it does not activate this node
+               dependency.weakenOptionalDependsOnTo();
+            }
+            if(trace)
+            {
+               log.trace(" ** adding dependency: "  + dependency);
+            }
+         }
+      }
+   }
+   
+   /**
+    * Sort the included profile nodes and check if we can include
+    * some additional activation callbacks.
+    * 
+    * @return the sorted list of profile keys 
+    */
+   public List<ProfileKey> sort()
+   {
+      if(this.unresolved.isEmpty() == false)
+      {
+         throw new IllegalStateException("unresolved " + this.unresolved);
+      }
+      // Process activation callbacks to determine if they can be included
+      for(Iterator<ProfileNode> i = callbacks.iterator() ;  i.hasNext() ;)
+      {
+         ProfileNode callback = i.next();
+         if(included(callback) == false)
+         {
+            // Check if the activation callback can be resolved
+            // based on the already included keys 
+            if(callback.checkResolved(includedKeys))
+            {
+               callback.hardenDependsOnMe();
+               included.add(callback);
+            }
+         }
+         i.remove();
+      }
+      // Sort
+      return new Sorter().sort();
+   }
+   
+   /**
+    * Get the node. This creates a new node if 
+    * it does not exist
+    * 
+    * @param key the profile key
+    * @return the profile node
+    */
+   ProfileNode getNode(ProfileKey key)
+   {
+      if(nodes.containsKey(key))
+      {
+         return nodes.get(key);
+      }
+      else
+      {
+         final ProfileNode node = new ProfileNode(key);
+         nodes.put(key, node);
+         return node;
+      }
+   }
+   
+   /**
+    * Check whether a node is included or not. 
+    * 
+    * @param node the node
+    * @return true if included, false otherwise
+    */
+   boolean included(ProfileNode node)
+   {
+      return included.contains(node);
+   }
+   
+   
+   static DependencyMode getDependencyMode(ProfileRequirement requirement)
+   {
+      DependencyMode mode = requirement.getDependencyMode();
+      if(mode == null) mode = DependencyMode.getDefault();
+      return mode;
+   }
+   
+   class Sorter
+   {     
+      /**
+       * Do a topological sort based on the previously resolved
+       * dependencies. 
+       * 
+       * @return the sorted profile keys.
+       */
+      List<ProfileKey> sort()
+      {
+         final boolean trace = log.isTraceEnabled();
+         List<ProfileKey> sorted = new ArrayList<ProfileKey>();
+         List<ProfileNode> roots = getRoots();
+         while(roots.isEmpty() == false)
+         {
+            final ProfileNode node = roots.remove(0);
+            sorted.add(node.getKey());
+            if(node.hasDependsOnMe())
+            {
+               for(final ProfileNodeDependency dependsOnMe : node.getDependsOnMe())
+               {
+                  // If the dependency comes from an activation callback, which
+                  // has not been included we can skip activating it
+                  if(dependsOnMe.isOptionalDependsOnTo())
+                  {
+                     continue;
+                  }
+                  // Get the dependent node
+                  final ProfileNode otherNode = getNode(dependsOnMe.getFrom());
+                  if(included(otherNode) == false)
+                  {
+                     throw new IllegalArgumentException("trying to activate non included node " + otherNode);
+                  }
+                  // Mark my dependency as resolved
+                  otherNode.markAsResolved(node.getKey());
+                  // Check if it's resolved now
+                  if(otherNode.isResolved())
+                  {
+                     roots.add(otherNode);
+                     included.remove(otherNode);
+                     if(trace)
+                     {
+                        log.trace("resolved " + otherNode);
+                     }
+                  }
+               }
+            }
+         }
+         if(included.size() > 0)
+         {
+            throw new IllegalStateException("failed to resolve dependencies " + included);
+         }
+         return sorted;
+      }
+
+      /**
+       * Get the roots, which don't have any unresolved
+       * dependencies.
+       * 
+       * @return the roots
+       */
+      List<ProfileNode> getRoots()
+      {
+         ArrayList<ProfileNode> roots = new ArrayList<ProfileNode>();
+         for(Iterator<ProfileNode> i = included.iterator(); i.hasNext() ;)
+         {
+            ProfileNode node = i.next();
+            if(node.isResolved())
+            {
+               roots.add(node);
+               i.remove();
+               log.debug("resolved " + node);
+            }
+         }
+         return roots;
+      }
+   }
+   
+}
+

Added: 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	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,155 @@
+/*
+* 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.LinkedList;
+import java.util.List;
+
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileNode
+{
+
+   /** The node key. */
+   private ProfileKey key;
+   
+   /** I depend on. */
+   private List<ProfileNodeDependency> iDependOn = new LinkedList<ProfileNodeDependency>();
+   
+   /** Depends on me. */
+   private List<ProfileNodeDependency> dependsOnMe = new LinkedList<ProfileNodeDependency>();
+
+   public ProfileNode(ProfileKey key)
+   {
+      this.key = key;
+   }
+
+   public ProfileKey getKey()
+   {
+      return key;
+   }
+   
+   public String getName()
+   {
+      return key.getName();
+   }
+   
+   void addIDependOn(ProfileNodeDependency dependency)
+   {
+      this.iDependOn.add(dependency);
+   }
+   
+   public List<ProfileNodeDependency> getiDependOn()
+   {
+      return iDependOn;
+   }
+   
+   void markAsResolved(ProfileKey key)
+   {
+      for(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(List<ProfileKey> included)
+   {
+      boolean resolved = true;
+      for(ProfileNodeDependency dependency : iDependOn)
+      {
+         if(dependency.isOptional() == false)
+         {
+            if(included.contains(dependency.getTo()) == 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 key.equals(other.key);
+   }
+   
+   @Override
+   public String toString()
+   {
+      return getName();
+   }
+   
+}
+
+

Added: 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	                        (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,108 @@
+/*
+* 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 org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileNodeDependency
+{
+
+   private final ProfileKey from;
+   private final ProfileKey to;
+   
+   private boolean optional;
+   private boolean optionalDependsOnTo;
+   
+   private boolean resolved;
+   
+   ProfileNodeDependency(final ProfileKey from, final ProfileKey to, final boolean optional)
+   {
+      this.from = from;
+      this.to = to;
+      this.optional = optional;
+   }
+   
+   ProfileKey getFrom()
+   {
+      return from;
+   }
+   
+   ProfileKey getTo()
+   {
+      return to;
+   }
+   
+   boolean isOptional()
+   {
+      return optional;
+   }
+   
+   void hardenDependency()
+   {
+      this.optional = false;
+   }
+   
+   boolean isOptionalDependsOnTo()
+   {
+      return optionalDependsOnTo;
+   }
+   
+   void weakenOptionalDependsOnTo()
+   {
+      this.optionalDependsOnTo = true;
+   }
+   
+   void hardenOptionalDependsOnTo()
+   {
+      this.optionalDependsOnTo = false;
+   }
+   
+   boolean isResolved()
+   {
+      return resolved;
+   }
+   
+   void markAsResolved()
+   {
+      resolved = true;
+   }
+   
+   @Override
+   public String toString()
+   {
+      StringBuilder builder = new StringBuilder("dependency{");
+      builder.append(getFrom()).append(" >> ").append(getTo());
+      builder.append(", optional=").append(isOptional());
+      if(isOptionalDependsOnTo())
+      {
+         builder.append(", optionalDependsTo=").append(isOptionalDependsOnTo());
+      }
+      builder.append("}");
+      return builder.toString();
+   }
+   
+}
+

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -27,8 +27,9 @@
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlType;
 
-import org.jboss.profileservice.dependency.AbstractProfileCapability;
-import org.jboss.profileservice.dependency.AbstractProfileRequirement;
+import org.jboss.profileservice.metadata.helpers.AbstractProfileCapability;
+import org.jboss.profileservice.metadata.helpers.AbstractProfileRequirement;
+import org.jboss.profileservice.spi.dependency.ProfileCapability;
 import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
 import org.jboss.profileservice.spi.virtual.VirtualDeployment;
@@ -171,6 +172,13 @@
    }
 
    @Override
+   public boolean isConsistent(ProfileCapability other)
+   {
+      // TODO
+      return true;
+   }
+   
+   @Override
    public boolean resolves(ProfileRequirement requirement)
    {
       if(requirement instanceof AbstractVirtualDeploymentRequirement)
@@ -194,7 +202,7 @@
       return super.equals(obj);
    }
    
-   private static boolean equals(Object one, Object two)
+   static boolean equals(Object one, Object two)
    {
       if (one == null && two == null)
          return true;

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeploymentRequirement.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeploymentRequirement.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeploymentRequirement.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -21,7 +21,7 @@
 */
 package org.jboss.profileservice.virtual.deployment;
 
-import org.jboss.profileservice.dependency.AbstractProfileRequirement;
+import org.jboss.profileservice.metadata.helpers.AbstractProfileRequirement;
 import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 
 /**

Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,171 @@
+/*
+* 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.test.profileservice.deployment.test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.profileservice.hotdeploy.DefaultHDScannerFactory;
+import org.jboss.profileservice.hotdeploy.Scanner;
+import org.jboss.profileservice.hotdeploy.ScannerConfiguration;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class HDScannerUnitTestCase extends BaseTestCase
+{
+
+   public HDScannerUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void test() throws Exception
+   {
+      enableTrace("org.jboss.profileservice.hotdeploy");
+      DefaultHDScannerFactory scannerFactory = new DefaultHDScannerFactory();
+      scannerFactory.start();
+      
+      Scanner scanner1 = scannerFactory.registerScanner(new TestProfile(new ProfileKey("test1")), new TestConfiguration());
+      Scanner scanner2 = scannerFactory.registerScanner(new TestProfile(new ProfileKey("test2")), new TestConfiguration());
+      
+      assertNotNull(scanner1);
+      assertNotNull(scanner2);
+      assertFalse(scanner1.isScheduled());
+      assertFalse(scanner2.isScheduled());
+      assertEquals(0, scanner1.getScanCount());
+      assertEquals(0, scanner2.getScanCount());
+      
+      scanner1.start();
+      scanner2.scan();
+      assertTrue(scanner1.isScheduled());
+      Thread.sleep(6);
+
+      scanner2.start();
+      assertTrue(scanner1.getScanCount() > 0);
+      scanner1.scan();
+      Thread.sleep(6);
+      assertTrue(scanner2.getScanCount() > 0);
+      scanner2.stop();
+      
+      assertFalse(scanner2.isScheduled());
+      
+      // Stop
+      scannerFactory.stop();
+      assertFalse(scanner1.isScheduled());
+      try
+      {
+         scanner1.start();
+         fail("able to start scanner after unregistering");
+      }
+      catch(IllegalStateException e)
+      {
+         // ok
+      }
+   }
+ 
+   static class TestConfiguration implements ScannerConfiguration
+   {
+      @Override
+      public int getScanPeriod()
+      {
+         return 1;
+      }
+      @Override
+      public TimeUnit getTimeUnit()
+      {
+         return TimeUnit.MILLISECONDS;
+      }
+   }
+   
+   static class TestProfile implements MutableProfile
+   {
+      private final ProfileKey key;
+      public TestProfile(ProfileKey key)
+      {
+         this.key = key;
+      }
+      @Override
+      public void addDeployment(ProfileDeployment deployment) throws Exception
+      {
+      }
+      @Override
+      public void enableModifiedDeploymentChecks(boolean flag)
+      {
+      }
+      @Override
+      public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+      {
+         return Collections.emptySet();
+      }
+      @Override
+      public ProfileDeployment removeDeployment(String name) throws NoSuchDeploymentException, Exception
+      {
+         return null;
+      }
+      @Override
+      public ProfileDeployment getDeployment(String name) throws NoSuchDeploymentException
+      {
+         return null;
+      }
+      @Override
+      public Set<String> getDeploymentNames()
+      {
+         return null;
+      }
+      @Override
+      public Collection<ProfileDeployment> getDeployments()
+      {
+         return null;
+      }
+      @Override
+      public ProfileKey getKey()
+      {
+         return key;
+      }
+      @Override
+      public long getLastModified()
+      {
+         return 0;
+      }
+      @Override
+      public boolean hasDeployment(String name)
+      {
+         return false;
+      }
+      @Override
+      public boolean isMutable()
+      {
+         return true;
+      }
+   }
+}
+

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/domain/support/AbstractDomainMetaDataVisitor.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -21,13 +21,16 @@
 */
 package org.jboss.test.profileservice.domain.support;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
 import java.util.Stack;
 
 import org.jboss.logging.Logger;
+import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
+import org.jboss.profileservice.dependency.ProfileDependencyContext;
 import org.jboss.profileservice.domain.spi.DomainFeatureNode;
 import org.jboss.profileservice.domain.spi.DomainFeatureVisitor;
+import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
+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;
@@ -44,17 +47,26 @@
    /** The logger. */
    private static final Logger log = Logger.getLogger(AbstractDomainMetaDataVisitor.class);
    
-   /** The collected requirements. */
-   private List<ProfileRequirement> requirements = new ArrayList<ProfileRequirement>();
+   private final ProfileDependencyContext ctx;
    
    /** The namespace stack. */
    private Stack<String> stack = new Stack<String>();
    
-   public List<ProfileRequirement> getRequirements()
+   public AbstractDomainMetaDataVisitor(ProfileMetaDataRegistry domain)
    {
-      return requirements;
+      this.ctx = new ProfileDependencyContext(new ProfileKey("test"), new EmptyProfileMetaData(), domain);
    }
    
+   public ProfileDependencyContext getCtx()
+   {
+      return ctx;
+   }
+   
+   public Collection<ProfileRequirement> getRequirements()
+   {
+      return ctx.getRequirements();
+   }
+   
    @Override
    public void addProfileMetaData(ProfileMetaData metaData)
    {
@@ -77,10 +89,16 @@
    @Override
    public void addRequirement(ProfileRequirement requirement)
    {
-      this.requirements.add(requirement);
+      this.ctx.addRequirement(requirement);
    }
 
    @Override
+   public void enableOnDemand(boolean onDemand)
+   {
+      // nothing
+   }
+   
+   @Override
    public void visit(DomainFeatureNode node)
    {
       stack.push(node.getNameSpace());

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/domain/support/DomainMetaDataRepoSupport.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/domain/support/DomainMetaDataRepoSupport.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/domain/support/DomainMetaDataRepoSupport.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -29,8 +29,8 @@
 import org.jboss.profileservice.profile.bootstrap.BootstrapProfileMetaData;
 import org.jboss.profileservice.profile.metadata.BasicProfileMetaData;
 import org.jboss.profileservice.profile.metadata.CommonProfileNameSpaces;
+import org.jboss.profileservice.profile.metadata.domain.RequiredProfiles;
 import org.jboss.profileservice.profile.metadata.plugin.ClassPathProfileMetaData;
-import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
 import org.jboss.profileservice.profile.metadata.plugin.FarmingProfileMetaData;
 import org.jboss.profileservice.profile.metadata.plugin.HotDeploymentProfileMetaData;
 import org.jboss.profileservice.profile.metadata.plugin.PropertyProfileMetaData;
@@ -56,7 +56,7 @@
       addSchemaBinding(CommonProfileNameSpaces.BOOTSTRAP_PROFILE_NAMESPACE, BootstrapProfileMetaData.class);
       addSchemaBinding(CommonProfileNameSpaces.PROFILE_NAMESPACE, BasicProfileMetaData.class);
       addSchemaBinding(CommonProfileNameSpaces.CLASSPATH_PROFILE_NAMESPACE, ClassPathProfileMetaData.class);
-      addSchemaBinding(CommonProfileNameSpaces.REQUIRED_PROFILE_NAMESPACE, EmptyProfileMetaData.class);
+      addSchemaBinding(CommonProfileNameSpaces.REQUIRED_PROFILE_NAMESPACE, RequiredProfiles.class);
       addSchemaBinding(CommonProfileNameSpaces.HOTDEPLOY_PROFILE_NAMESPACE, HotDeploymentProfileMetaData.class);
       addSchemaBinding(CommonProfileNameSpaces.IMMUTABLE_PROFILE_NAMESPACE, PropertyProfileMetaData.class);
       addSchemaBinding(CommonProfileNameSpaces.FARMING_PROFILE_NAMESPACE, FarmingProfileMetaData.class);

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -26,6 +26,7 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.dependency.ProfileDependencyContext;
 import org.jboss.profileservice.domain.spi.DomainFeatureNode;
 import org.jboss.profileservice.domain.spi.DomainMetaData;
@@ -74,18 +75,18 @@
       
       
       
-      AbstractDomainMetaDataVisitor visitor = new AbstractDomainMetaDataVisitor();
-      for(DomainFeatureNode node : metaData.getFeatures())
-      {
-         visitor.visit(node);
-      }
-      for(ProfileRequirement requirement : visitor.getRequirements())
-      {
-         ProfileKey key = resolve(null, requirement);
-         getLog().debug(requirement + " resolved " + key);
-         
-      }
-      
+//      AbstractDomainMetaDataVisitor visitor = new AbstractDomainMetaDataVisitor(new LocalProfileServiceDomain(domain, server));
+//      for(DomainFeatureNode node : metaData.getFeatures())
+//      {
+//         visitor.visit(node);
+//      }
+//      for(ProfileRequirement requirement : visitor.getRequirements())
+//      {
+//         ProfileKey key = resolve(null, requirement);
+//         getLog().debug(requirement + " resolved " + key);
+//         
+//      }
+//      
    }
    
    static URL findResource(String name)

Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/TestProfilesMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/TestProfilesMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/support/TestProfilesMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,63 @@
+/*
+* 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.test.profileservice.resolver.support;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at XmlRootElement(name = "profiles")
+ at JBossXmlSchema(ignoreUnresolvedFieldOrClass=false,
+      namespace= "urn:jboss:profileservice:profiles:1.0",
+      elementFormDefault=XmlNsForm.QUALIFIED,
+      normalizeSpace=true,
+      replacePropertyRefs=false)
+ at XmlType(name = "profilesType", propOrder = {"profiles"})
+public class TestProfilesMetaData
+{
+
+   private List<ProfileMetaData> profiles;
+   
+   @XmlElement(name = "profile", type = EmptyProfileMetaData.class)
+   public List<ProfileMetaData> getProfiles()
+   {
+      return profiles;
+   }
+   
+   public void setProfiles(List<ProfileMetaData> profiles)
+   {
+      this.profiles = profiles;
+   }
+   
+}
+

Added: 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	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/AbstractResolverTest.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,125 @@
+/*
+* 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.test.profileservice.resolver.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.profileservice.ManagementDomain;
+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.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;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractResolverTest extends ProfileServiceTestBase
+{
+
+   private ProfileMetaDataRegistry registry;
+   private AbstractRequirementResolver resolver;
+
+   
+   public AbstractResolverTest(String name)
+   {
+      super(name);
+   }
+
+   protected String getTestProfileName()
+   {
+      return "test-profile";
+   }
+   
+   protected void parse(String file) throws Exception
+   {
+      registry = new ProfileMetaDataRegistry(new ManagementDomain("default"), "default");
+      resolver = new AbstractRequirementResolver(registry);
+      TestProfilesMetaData profiles = unmarshal(file, TestProfilesMetaData.class);
+      for(ProfileMetaData profile : profiles.getProfiles())
+      {
+         addProfile(profile);
+      }
+   }
+   
+   void addProfile(ProfileMetaData metaData)
+   {
+      ProfileDependencyContext context = new ProfileDependencyContext(new ProfileKey(metaData.getName()), metaData, registry);
+      registry.addProfile(context);
+   }
+
+   List<String> resolve(String xml, String... requirements) throws Exception
+   {
+      parse(xml);
+      return resolveRequirements(requirements);
+   }
+   
+   List<String> resolveRequirements(String... requirements)
+   {
+      ProfileMetaData testProfile = createTestProfileMetaData();
+      ProfileDependencyContext context = new ProfileDependencyContext(new ProfileKey(testProfile.getName()), testProfile, registry);
+      for(String requirement : requirements)
+      {
+         context.addRequirement(new ResolveRequirement(requirement));
+      }
+      registry.addProfile(context);
+      resolver.resolve(context);
+      return getNames(resolver.sort());
+   }
+   
+   List<String> getNames(List<ProfileKey> contexts)
+   {
+      List<String> names = new ArrayList<String>();
+      for(ProfileKey context : contexts)
+      {
+            names.add(context.getName());
+      }
+      getLog().debug(names);
+      return names;
+   }
+  
+   void assertOrdering(Collection<String> originals, String... values)
+   {
+      getLog().debug(originals);
+      List<String> copy = new ArrayList<String>(originals);
+      for(String value : values)
+      {
+         String original = copy.remove(0);
+         assertEquals(original, value);
+      }
+      assertEquals(getTestProfileName(), copy.remove(0));
+      assertEquals(0, copy.size());
+   }
+   
+   protected ProfileMetaData createTestProfileMetaData()
+   {
+      return new EmptyProfileMetaData(getTestProfileName());
+   }
+}
+

Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ActivationCallbackUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ActivationCallbackUnitTestCase.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ActivationCallbackUnitTestCase.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,51 @@
+/*
+* 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.test.profileservice.resolver.test;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ActivationCallbackUnitTestCase extends AbstractResolverTest
+{
+
+   public ActivationCallbackUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testSimpleOptional() throws Exception
+   {
+      List<String> result = resolve("callbacks.xml", "activation-group1");
+      assertOrdering(result, "activation-group1");
+   }
+
+   public void testActivation() throws Exception
+   {
+      List<String> result = resolve("callbacks.xml", "other", "activation-group1");
+      assertOrdering(result, "other", "test", "activation-group1");
+   }
+   
+}
+

Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/BasicResolverUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/BasicResolverUnitTestCase.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/BasicResolverUnitTestCase.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,110 @@
+/*
+* 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.test.profileservice.resolver.test;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicResolverUnitTestCase extends AbstractResolverTest
+{
+
+   public BasicResolverUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testNothing() throws Exception
+   {
+      List<String> result = resolve("basic.xml", new String[0]);
+      assertTrue(result.size() == 1);
+   }
+   
+   public void testSelfDependency() throws Exception
+   {
+      List<String> result = resolve("basic.xml", getTestProfileName());
+      assertTrue(result.size() == 1);
+   }
+
+   public void testRequirement() throws Exception
+   {
+      List<String> result = resolve("basic.xml", "test");
+      assertTrue(result.size() == 2);
+      assertTrue(result.contains("test"));
+      assertOrdering(result, "test");
+   }
+ 
+   public void testMissingRequirement() throws Exception
+   {
+      try
+      {
+         resolve("basic.xml", "test2");
+         fail("resolved, although missing hard dependencies");
+      }
+      catch(Exception e)
+      {
+         getLog().debug(e);
+      }
+   }
+   
+   public void testOptionalRequirementNonExisting() throws Exception
+   {
+      List<String> result = resolve("basic.xml", "test1");
+      assertTrue(result.size() == 2);
+      assertOrdering(result, "test1");
+   }
+
+   public void testOptionalRequirementExisting() throws Exception
+   {
+      List<String> result = resolve("basic.xml", "test", "test1");
+      assertOrdering(result, "test", "test1");
+   }
+   
+   public void testOptionalRequirements() throws Exception
+   {
+      List<String> result = resolve("basic.xml", "test1", "optional1");
+      assertOrdering(result, "optional1", "test1");
+      
+      result = resolve("basic.xml", "test1", "optional1", "optional2");
+      assertOrdering(result, "optional2", "optional1", "test1");
+      
+      result = resolve("basic.xml", "optional1", "optional2", "optional3", "test1");
+      assertOrdering(result, "optional3", "optional2", "optional1", "test1");
+      
+      try
+      {
+         result = resolve("basic.xml", "test1", "optional1", "optional2", "optional3", "optional4");
+         fail("missing dependency test");
+      }
+      catch(Exception e)
+      {
+         getLog().debug(e);
+      }
+      
+      result = resolve("basic.xml", "test1", "optional1", "optional2", "optional3", "optional4", "test");
+      assertOrdering(result, "test", "optional4", "optional3", "optional2", "optional1", "test1");
+   }
+   
+}
+

Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/RequirementResolverTestSuite.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/RequirementResolverTestSuite.java	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/RequirementResolverTestSuite.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,45 @@
+/*
+* 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.test.profileservice.resolver.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class RequirementResolverTestSuite extends TestSuite
+{
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("PS requirement resolver test suite.");
+      
+      suite.addTestSuite(BasicResolverUnitTestCase.class);
+      suite.addTestSuite(ActivationCallbackUnitTestCase.class);
+      
+      return suite;
+   }
+   
+}
+

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -28,6 +28,7 @@
 import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
 import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
 import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
 import org.jboss.test.profileservice.ProfileServiceTestBase;
 
 /**
@@ -106,9 +107,9 @@
    
    protected <T> T getBean(String name, Class<T> clazz)
    {
-      ControllerContext ctx = getController().getInstalledContext(name);
-      assertNotNull(name, ctx);
-      return clazz.cast(ctx.getTarget());
+      KernelRegistryEntry entry = getKernel().getRegistry().getEntry(name);
+      assertNotNull(name, entry);
+      return clazz.cast(entry.getTarget());
    }
    
    private Kernel bootstrapKernel()

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -22,19 +22,18 @@
 package org.jboss.test.profileservice.test;
 
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.profileservice.bootstrap.ProfileServiceConstants;
-import org.jboss.profileservice.dependency.LocalProfileServiceDomain;
+import org.jboss.profileservice.config.ProfileServiceConstants;
+import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.deployers.MainDeployerPlugin;
 import org.jboss.profileservice.domain.spi.DomainFeatureNode;
 import org.jboss.profileservice.domain.spi.DomainMetaData;
 import org.jboss.profileservice.metadata.ProfileMetaDataFactory;
+import org.jboss.profileservice.resolver.AbstractRequirementResolver;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.profileservice.spi.dependency.ProfileRequirement;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.test.profileservice.domain.support.AbstractDomainMetaDataVisitor;
 import org.jboss.test.profileservice.domain.support.DomainMetaDataRepoSupport;
@@ -63,32 +62,42 @@
       
       metaDataFactory.parse(profiles);
     
-      URL domain = findResource("metadata/domain/domain1.xml");
-      DomainMetaDataRepoSupport support = new DomainMetaDataRepoSupport(domain);
+      URL domainMetaData = findResource("metadata/domain/domain1.xml");
+      DomainMetaDataRepoSupport support = new DomainMetaDataRepoSupport(domainMetaData);
       DomainMetaData metaData = support.getDomainMetaData();
       assertNotNull(metaData);
 
       ProfileService ps = getBean(ProfileServiceConstants.PROFILESERVICE_NAME, ProfileService.class);
-      LocalProfileServiceDomain resolver = getBean(ProfileServiceConstants.LOCALDOMAIN_NAME, LocalProfileServiceDomain.class);
+      ProfileMetaDataRegistry domain = getBean(ProfileServiceConstants.METADATA_REGISTRY_NAME, ProfileMetaDataRegistry.class);
       assertNotNull(ps);
-      assertNotNull(resolver);
+      assertNotNull(domain);
 
+      long millis = System.currentTimeMillis();
       for(ProfileMetaData md : metaDataFactory.getProfiles().values())
       {
          ps.registerProfile(md);
       }
-      AbstractDomainMetaDataVisitor visitor = new AbstractDomainMetaDataVisitor();
+      AbstractDomainMetaDataVisitor visitor = new AbstractDomainMetaDataVisitor(domain);
       for(DomainFeatureNode node : metaData.getFeatures())
       {
          visitor.visit(node);
       }
-      List<ProfileKey> activated = new ArrayList<ProfileKey>();
-      for(ProfileRequirement requirement : visitor.getRequirements())
+      
+      AbstractRequirementResolver resolver = new AbstractRequirementResolver(domain);
+      resolver.resolve(visitor.getCtx());
+      List<ProfileKey> list = resolver.sort();
+      
+      getLog().debug("processing took " + (System.currentTimeMillis() - millis));      
+      getLog().debug(list);
+      
+      for(ProfileKey profile : list)
       {
-         ProfileKey key = resolver.resolve(null, requirement);
-         ps.activateProfile(key);
-         activated.add(key);
+         if(profile.getName().equals("test") == false)
+         {
+            ps.activateProfile(profile);
+         }
       }
+      
       // Check MainDeployer 
       assertNotNull(getBean("MainDeployer", MainDeployer.class));
       // Check the profile deployer plugin for MainDeployer
@@ -98,15 +107,18 @@
       {
          getLog().debug("active " + key);
       }
-      for(ProfileKey check : activated)
+      for(ProfileKey profile : list)
       {
-         ps.validateProfile(check);
+         if(profile.getName().equals("test") == false)
+         {
+            ps.validateProfile(profile);
+         }
       }
    }
    
    public void testWait() throws Exception
    {
-      Thread.currentThread().wait();
+      
    }   
    
 }

Modified: projects/profileservice/trunk/core/src/test/resources/metadata/domain/domain1.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/metadata/domain/domain1.xml	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/resources/metadata/domain/domain1.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -7,13 +7,15 @@
 	<!-- 
 		The required profiles for this configuration.
 	 -->
-	<profiles xmlns="urn:jboss:profileservice:profile:required:1.0">
+	<required-profiles xmlns="urn:jboss:profileservice:profile:required:1.0">
 		<requires name="jboss:profile=minimal" />
 		<requires name="jboss:profile=web" />
+		<requires name="jboss:profile=clustering" />
+		<requires name="jboss:profile=stack" />
 		<!-- 
-		<requires name="jboss:profile=stack1" />
+		
 		 -->
-	</profiles>
+	</required-profiles>
 	<!-- 
 		The library classpath configuration.
 	--> 
@@ -51,11 +53,11 @@
 	</hot-deployment>
 	<!-- 
 		The farming service.
-	 -->	
+	-->
 	<farming-deployment name="jboss:profile=application,flavor=farming"
 			xmlns="urn:jboss:profileservice:profile:farming:1.0">
 		<source path="${jboss.server.home.url}farm" />
 		<scan-period time-unit="MINUTES">1</scan-period>	
-	</farming-deployment>
+	</farming-deployment>	
 	<!--  The end -->
 </domain>

Added: projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/basic.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/basic.xml	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/basic.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,32 @@
+<profiles xmlns="urn:jboss:profileservice:profiles:1.0">
+
+	<profile name="test">
+		
+	</profile>
+
+	<profile name="test1">
+		<requires name="test" optional="true" />
+		<requires name="optional1" optional="true" />
+	</profile>
+
+	<profile name="test2">
+		<requires name="test1" />
+	</profile>
+
+	<profile name="optional1">
+		<requires name="optional2" optional="true" />
+	</profile>
+
+	<profile name="optional2">
+		<requires name="optional3" optional="true" />
+	</profile>
+
+	<profile name="optional3">
+		<requires name="optional4" optional="true" />	
+	</profile>
+
+	<profile name="optional4">
+		<requires name="test" />
+	</profile>
+
+</profiles>
\ No newline at end of file

Added: 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	                        (rev 0)
+++ projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,22 @@
+<profiles xmlns="urn:jboss:profileservice:profiles:1.0">
+
+	<profile name="activation-group1">
+		<requires  name="test" mode="activation-callback" />
+	</profile>
+
+	<profile name="test">
+		<requires name="other" />
+	</profile>
+
+	<profile name="test1">
+		<requires name="other" optional="true" />
+	</profile>
+
+	<profile name="test2">
+		<requires name="other" />
+		<requires name="test1" optional="true" />
+	</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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -14,7 +14,9 @@
 	</bean>
 	
 	<!-- A deployerPlugin registry - used when we have to swap the deployer -->
-	<bean name="ProfileDeployerPluginRegistry" class="org.jboss.profileservice.ProfileDeployerPluginRegistry" />
+	<bean name="ProfileDeployerPluginRegistry" class="org.jboss.profileservice.ProfileDeployerPluginRegistry">
+		<constructor factoryClass="org.jboss.profileservice.ProfileDeployerPluginRegistry" factoryMethod="getInstance"/>      
+	</bean>
 	
 	<!-- The bootstrap profile factory -->
 	<bean name="BootstrapProfileFactory" class="org.jboss.profileservice.profile.bootstrap.BootstrapProfileFactory">

Modified: projects/profileservice/trunk/core/src/test/resources/system/profiles/clustering-profiles.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/profiles/clustering-profiles.xml	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/resources/system/profiles/clustering-profiles.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -18,7 +18,7 @@
 		farming-profile is defined, as it sets a requirement on the
 		management namespace. 
 	 -->
-	<profile name="jboss:profile=deployment,flavor=farming">
+	<profile name="jboss:profile=deployment,flavor=farming" enable-on-demand="true">
 		<file-repository group="jboss.clustering" />
 		<deployment name="farming-jboss-beans.xml" />
 		<management namespace="urn:jboss:profileservice:profile:farming:1.0" />

Modified: projects/profileservice/trunk/core/src/test/resources/system/profiles/common-profiles.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/profiles/common-profiles.xml	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/resources/system/profiles/common-profiles.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,11 +1,15 @@
 <profiles xmlns="urn:jboss:profileservice:profiles:1.0">
 
-	<profile name="jboss:profile=common">
+	<profile-group name="jboss:profile=common">
+		<requires name="jboss:profile=minimal" mode="resolve" />
+		<requires name="jboss:profile=common,type=deployments" mode="resolve" />
+		<requires name="jboss:profile=naming" mode="resolve" />
+	</profile-group>
+
+	<profile name="jboss:profile=common,type=deployments">
 		<file-repository group="deployment" />
 		<deployment name="alias-deployers-jboss-beans.xml" />
-		<deployment name="ear-deployer-jboss-eabs.xml" />
-		<requires name="jboss:profile=minimal" />
-		<requires name="jboss:profile=naming" />
+		<deployment name="ear-deployer-jboss-beans.xml" />	
 	</profile>
 
 	<profile name="jboss:profile=naming">

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/resources/system/profiles/core-profiles.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,14 +1,13 @@
 <profiles xmlns="urn:jboss:profileservice:profiles:1.0">
 
-
 	<!-- 
 		Definition of the minimal jboss runtime.
 	-->
-	<profile name="jboss:profile=minimal">
-		<requires name="jboss:profile=bootstrap" />
-		<requires name="jboss:profile=logging" />
-		<requires name="jboss:profile=threads" />
-	</profile>
+	<profile-group name="jboss:profile=minimal">
+		<requires name="jboss:profile=bootstrap" mode="resolve" />
+		<requires name="jboss:profile=logging" mode="resolve" />
+		<requires name="jboss:profile=threads" mode="resolve" />
+	</profile-group>
 
 	<bootstrap name="jboss:profile=bootstrap">
 		<!--
@@ -31,7 +30,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">
+	<profile name="jboss:profile=deployment,flavor=hot-deployment" enable-on-demand="true" >
 		<file-repository group="deployment" />
 		<deployment name="hd-scanner-jboss-beans.xml" />
 		<requires name="jboss:profile=threads" />
@@ -48,7 +47,7 @@
 		<requires name="jboss:profile=logging,flavor=deployer" />
 	</profile>
 
-	<profile name="jboss:profile=logging,flavor=deployer">
+	<profile name="jboss:profile=logging,flavor=deployer" enable-on-demand="true" >
 		<file-repository group="logging" />
 		<virtual-deployment name="logging.deployer">
 			<meta-inf path="logmanager-jboss-beans.xml" />
@@ -66,7 +65,7 @@
 		<requires name="jboss:profile=threads,flavor=deployer" />
 	</profile>
 
-	<profile name="jboss:profile=threads,flavor=deployer">
+	<profile name="jboss:profile=threads,flavor=deployer" enable-on-demand="true" >
 		<file-repository group="threads" />
 		<virtual-deployment name="threads.deployer">
 			<meta-inf path="threads-deployer-jboss-beans.xml" />
@@ -77,7 +76,7 @@
 	<!--
 		Profiles should set an explicit requirement on the service binding manager. 
 	 -->
-	<profile name="jboss:profile=servicebindingmanager">
+	<profile name="jboss:profile=servicebindingmanager" enable-on-demand="true" >
 		<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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/resources/system/profiles/stack-profiles.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -5,11 +5,20 @@
 	when the stack is explicitly referenced in the domain model.
  -->
 <profiles xmlns="urn:jboss:profileservice:profiles:1.0">
+
+	<profile-group name="jboss:profile=stack">
+		<requires name="jboss:profile=stack1" mode="resolve" />
+		<!-- 
+			<requires name="jboss:profile=stack1" />
+		 -->	
+	</profile-group>
 	<!--
 		Stack one.
 	 -->
 	<profile name="jboss:profile=stack1">
+	<!-- TODO runtime alias ? 
 		<alias>jboss:profile=stack</alias>
+	-->
 		<file-repository group="stack1" />
 		<virtual-deployment name="stack1">
 			<meta-inf path="jboss-beans.xml" />
@@ -20,7 +29,9 @@
 		Stack two.
 	 -->
 	<profile name="jboss:profile=stack2">
+	<!-- TODO runtime alias ?
 		<alias>jboss:profile=stack</alias>
+		-->
 		<file-repository group="stack2" />
 		<virtual-deployment name="stack2">
 			<meta-inf path="jboss-beans.xml" />

Modified: projects/profileservice/trunk/core/src/test/resources/system/profiles/web-profiles.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/profiles/web-profiles.xml	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/resources/system/profiles/web-profiles.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,20 +1,20 @@
 <profiles xmlns="urn:jboss:profileservice:profiles:1.0">
 
-	<profile name="jboss:profile=web">
-		<requires name="jboss:profile=web,type=core" />
+	<profile-group name="jboss:profile=web">
+		<requires name="jboss:profile=web,type=core" mode="resolve" />
 		<!-- 
 			activation-policy=satisfied will install this profile
 			when it's requirements are satisfied (e.g. clustering installed)
 		 -->
 		<requires name="jboss:profile=web,type=clustering"
-			activation-policy="satisfied" />
+			mode="activation-callback" />
 		<!-- 
 			Depend on an alias of the web stack, which should get
 			activated either if stack1 or stack2 is installed
 		 -->
 		<requires name="jboss:profile=web,flavor=stack"
-			activation-policy="satisfied" />
-	</profile>
+			mode="activation-callback" />
+	</profile-group>
 
 	<profile name="jboss:profile=web,type=core">
 		<file-repository group="jboss.web" />

Modified: projects/profileservice/trunk/core/src/test/resources/system/static/bootstrap/profile.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/static/bootstrap/profile.xml	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/core/src/test/resources/system/static/bootstrap/profile.xml	2010-01-20 15:10:45 UTC (rev 99661)
@@ -10,9 +10,6 @@
  -->
 	<bean name="MainDeployerPlugin" class="org.jboss.profileservice.deployers.MainDeployerPlugin">
 		<constructor><parameter><inject bean="MainDeployer" /></parameter></constructor>
-		<install bean="ProfileDeployerPluginRegistry" method="addDefaultPlugin">
-			<parameter><this/></parameter>
-		</install>	
 	</bean>
 
 	<bean name="Basic Profile Factory" class="org.jboss.profileservice.profile.BasicProfileFactory">

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -22,12 +22,7 @@
 package org.jboss.profileservice.plugins.deploy;
 
 import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.profileservice.ProfileDeployerPlugin;
-import org.jboss.profileservice.dependency.LocalProfileServiceDomain;
-import org.jboss.profileservice.dependency.ProfileDependencyContext;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
 import org.jboss.profileservice.spi.ProfileService;
 
 /**
@@ -38,7 +33,7 @@
 {
 
    /** The local profile service domain. */
-   private LocalProfileServiceDomain domain;
+   private ProfileMetaDataRegistry domain;
    
    /** The ProfileService. */
    private ProfileService ps;
@@ -50,38 +45,12 @@
    
    protected void startDeployment(String deploymentName) throws Exception
    {
-      ProfileDependencyContext ctx = domain().getDeploymentProfile(deploymentName);
-      if(ctx == null)
-      {
-         throw new NoSuchDeploymentException(deploymentName);
-      }
-      ProfileDeployerPlugin deployer = ctx.getDeployer();
-      // Make sure the profile is active
-      Profile profile = ps.getActiveProfile(ctx.getKey());
-      
-      ProfileDeployment deployment = profile.getDeployment(deploymentName);
-      //
-      deployer.addDeployment(deployment);
-    
-      // TODO unlock deployment content
+
    }
    
    protected void stopDeployment(String deploymentName) throws Exception
    {
-      ProfileDependencyContext ctx = domain().getDeploymentProfile(deploymentName);
-      if(ctx == null)
-      {
-         throw new NoSuchDeploymentException(deploymentName);
-      }
-      ProfileDeployerPlugin deployer = ctx.getDeployer();
-      
-      Profile profile = ps.getActiveProfile(ctx.getKey());
-      
-      ProfileDeployment deployment = profile.getDeployment(deploymentName);
-      
-      // TODO lock deployment content
-    
-      deployer.removeDeployment(deployment);
+
    }
    
    protected void removeDeployment(String deploymentName) throws Exception
@@ -89,7 +58,7 @@
       
    }
    
-   LocalProfileServiceDomain domain()
+   ProfileMetaDataRegistry domain()
    {
       return this.domain;
    }

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKey.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKey.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKey.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -23,8 +23,6 @@
 
 import java.io.Serializable;
 
-import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
-
 /**
  * The key for a Profile. It consists of the domain, server and name.
  * 
@@ -51,20 +49,6 @@
    private String server;
    /** The profile name */
    private String name;
-
-   /**
-    * Create the profile key based on the meta data.
-    * 
-    * @param metaData the profile key meta data
-    * @return the profile key
-    */
-   public static ProfileKey createProfileKey(ProfileKeyMetaData metaData)
-   {
-      if(metaData == null)
-         throw new IllegalArgumentException("null meta data.");
-      
-      return new ProfileKey(metaData);
-   }
    
    /**
     * Calls this this(DEFAULT, DEFAULT, name)
@@ -95,16 +79,6 @@
          name = DEFAULT;
       this.name = name;
    }
-   
-   /**
-    * Build a profile key based on the profile key meta data.
-    * 
-    * @param metaData the meta data
-    */
-   public ProfileKey(ProfileKeyMetaData metaData)
-   {
-      this(metaData.getDomain(), metaData.getServer(), metaData.getName());
-   }
 
    public String getName()
    {

Copied: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java (from rev 99447, projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/Engine.java)
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.profileservice.spi.action.engine;
+
+import java.util.List;
+
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.action.ProfileModificationAction;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ActionController
+{
+
+   /**
+    * Perform a set of modification actions.
+    * 
+    * @param key the target profile key
+    * @param actions the modification actions
+    * @return the modification status
+    */
+   ModificationStatus perfom(ProfileKey key, List<ProfileModificationAction<?>> actions); 
+   
+}
+

Deleted: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/Engine.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/Engine.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/Engine.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -1,46 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.profileservice.spi.action.engine;
-
-import java.util.List;
-
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.action.ProfileModificationAction;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public interface Engine
-{
-
-   /**
-    * Perform a set of modification actions.
-    * 
-    * @param key the target profile key
-    * @param actions the modification actions
-    * @return the modification status
-    */
-   ModificationStatus perfom(ProfileKey key, List<ProfileModificationAction<?>> actions); 
-   
-}
-

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/DependencyMode.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/DependencyMode.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/DependencyMode.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,56 @@
+/*
+* 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.spi.dependency;
+
+import javax.xml.bind.annotation.XmlEnumValue;
+
+/**
+ * The dependency mode.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public enum DependencyMode
+{
+
+   /** Explicit requirement. */
+   EXPLICIT,
+   
+   /** Optional requirement. */
+   OPTIONAL,
+   
+   /** Try to resolve the requirement. */
+   @XmlEnumValue("resolve")
+   RESOLVE,
+   
+   /** Callback activation if the dependencies of the dependent profile are satisfied. */
+   @XmlEnumValue("activation-callback")
+   ACTIVATION_CALLBACK;
+   
+   
+   public static DependencyMode getDefault()
+   {
+      return EXPLICIT;
+   }
+   
+}
+

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileCapability.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileCapability.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileCapability.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -38,6 +38,17 @@
     * @return true if the capability resolves the given requirement, otherwise false.
     */
    boolean resolves(ProfileRequirement requirement);
+
+   /**
+    * Check whether this capability is consistent with another capability.<p>
+    *
+    * Since the capabilties are within one shared 'domain' capabilties have to 
+    * be unique.
+    * 
+    * @param other the other capability
+    * @return true when consistent, false when inconsistent
+    */
+   boolean isConsistent(ProfileCapability other);
    
 }
 

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirement.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirement.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirement.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -31,22 +31,18 @@
 {
    
    /**
-    * isOptional.
+    * Get the dependency mode.
     * 
-    * @return if this requirement is optional
+    * @return the mode
     */
-   boolean isOptional();
+   DependencyMode getDependencyMode();
    
    /**
-    * Check whether this requirement is consistent with another requirement.<p>
+    * isOptional.
     * 
-    * Typically they will be inconsistent if they are the same type,
-    * have the same name but a different version
-    * 
-    * @param other the other requirement
-    * @return true when consistent, false when inconsistent
+    * @return if this requirement is optional
     */
-   boolean isConsistent(ProfileRequirement other);
+   boolean isOptional();
    
 }
 

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolver.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolver.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolver.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,65 @@
+/*
+* 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.spi.dependency;
+
+import java.util.Collection;
+
+
+/**
+ * The ProfileService requirement resolver. 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ProfileRequirementResolver
+{
+
+   /**
+    * Get the unsatisfied requirements.
+    * 
+    * @return the  unsatisfied requirements
+    */
+   Collection<ProfileRequirement> getUnsatisfiedRequirements();
+   
+   /**
+    * Add a requirement.
+    * 
+    * @param requirement the requirement.
+    */
+   void addRequirement(ProfileRequirement requirement);
+   
+   /**
+    * Try to resolve the requirements.
+    * 
+    * @param requirements the requirements
+    */
+   boolean resolve();
+
+   /**
+    * Deploy the configuration.
+    * 
+    * @throws Exception
+    */
+   void deploy() throws Exception;
+   
+}
+

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolverFactory.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolverFactory.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolverFactory.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,42 @@
+/*
+* 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.spi.dependency;
+
+/**
+ * The profile requirement resolver factory.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ProfileRequirementResolverFactory
+{
+
+   /**
+    * Create a requirement resolver.
+    * 
+    * @param name a unique profile name
+    * @return the resolver
+    */
+   ProfileRequirementResolver createResolver(String name);
+   
+}
+

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileKeyMetaData.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileKeyMetaData.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileKeyMetaData.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -31,20 +31,6 @@
 {
 
    /**
-    * Get the profileKey domain attribute.
-    * 
-    * @return the domain
-    */
-   String getDomain();
-   
-   /**
-    * Get the profileKey server attribute.
-    * 
-    * @return the server
-    */
-   String getServer();
-
-   /**
     * Get the profile name.
     * 
     * @return the name

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-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/metadata/ProfileMetaDataVisitor.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -55,6 +55,13 @@
    void addRequirement(ProfileRequirement requirement);
    
    /**
+    * Enable on demand.
+    * 
+    * @param onDemand 
+    */
+   void enableOnDemand(boolean onDemand);
+   
+   /**
     * Visit a profile meta data node.
     * 
     * @param node the profile meta data node.

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactNotFoundHandler.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactNotFoundHandler.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactNotFoundHandler.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -0,0 +1,48 @@
+/*
+* 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.spi.repository;
+
+import java.io.IOException;
+
+/**
+ * A handler which is getting called, when a artifact cannot be found.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ArtifactNotFoundHandler<T extends ArtifactId>
+{
+
+   /**
+    * Handle if an artifact cannot be found. The default would be to throw an exception.
+    * Other implementations might want to check other locations for this artifact and
+    * provide it.
+    * 
+    * @param repsoitory the repository
+    * @param artifactId the artifact id
+    * @return artifact the resolved artifact
+    * @throws IOException for any error
+    */
+   Artifact<T> handleArtifactNotFound(ArtifactRepository<T> repsoitory, T artifactId) throws IOException;
+   
+}
+

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepository.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepository.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -41,7 +41,7 @@
     * 
     * @return the configuration
     */
-    ArtifactRepositoryConfiguration getConfiguration(); 
+    ArtifactRepositoryConfiguration<T> getConfiguration(); 
 
    /**
     * Checks whether this repository provides the specified

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryConfiguration.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryConfiguration.java	2010-01-20 14:49:31 UTC (rev 99660)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryConfiguration.java	2010-01-20 15:10:45 UTC (rev 99661)
@@ -29,7 +29,7 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public interface ArtifactRepositoryConfiguration
+public interface ArtifactRepositoryConfiguration<T extends ArtifactId>
 {
    
    /**
@@ -45,6 +45,13 @@
     * @return whether this repository is mutable or not
     */
    boolean isMutable();
+
+   /**
+    * Get the not found handler.
+    * 
+    * @return the not found handler.
+    */
+   ArtifactNotFoundHandler<T> getNotFoundHandler();
    
 }
 




More information about the jboss-cvs-commits mailing list