[jboss-cvs] JBossAS SVN: r82809 - in trunk: cluster/src/main/org/jboss/ha/singleton and 29 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 13 07:54:36 EST 2009


Author: emuckenhuber
Date: 2009-01-13 07:54:35 -0500 (Tue, 13 Jan 2009)
New Revision: 82809

Added:
   trunk/server/src/etc/conf/default/bootstrap/profile-service.xml
   trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileContext.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileCreateAction.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileDeployAction.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ScopedProfileServiceController.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
   trunk/system/src/resources/parsing-tests/
   trunk/system/src/resources/parsing-tests/common/
   trunk/system/src/resources/parsing-tests/common/profiles/
   trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml
   trunk/system/src/resources/parsing-tests/common/profiles/common.xml
   trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml
   trunk/system/src/resources/parsing-tests/common/profiles/web.xml
   trunk/system/src/resources/parsing-tests/config/
   trunk/system/src/resources/parsing-tests/config/profiles/
   trunk/system/src/resources/parsing-tests/config/profiles/default.xml
   trunk/system/src/resources/parsing-tests/config/profiles/seam.xml
   trunk/system/src/resources/server-root/
   trunk/system/src/resources/server-root/conf/
   trunk/system/src/resources/server-root/conf/jboss-service.xml
   trunk/system/src/resources/server-root/deploy/
   trunk/system/src/resources/server-root/deploy/ejb3-container-jboss-beans.xml
   trunk/system/src/resources/server-root/deploy/ejb3-interceptors-aop.xml
   trunk/system/src/resources/server-root/deploy/ejb3-timer-service.xml
   trunk/system/src/resources/server-root/deploy/httpha-invoker.sar
   trunk/system/src/resources/server-root/deploy/jbossweb.sar
   trunk/system/src/resources/server-root/deploy/myDeployment.jar
   trunk/system/src/resources/server-root/deploy2/
   trunk/system/src/resources/server-root/deploy2/myDeployment12.jar
   trunk/system/src/resources/server-root/deployers/
   trunk/system/src/resources/server-root/deployers/clustering-deployer-jboss-beans.xml
   trunk/system/src/resources/server-root/deployers/ejb3.deployer
   trunk/system/src/resources/server-root/deployers/jbossweb.deployer
   trunk/system/src/resources/server-root/deployers/metadata-deployer-jboss-beans.xml
   trunk/system/src/resources/server-root/deployers/seam.deployer
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockMainDeployer.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockServer.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockServerConfig.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
Removed:
   trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java
   trunk/server/src/etc/conf/default/bootstrap-norepo.xml
   trunk/server/src/etc/conf/default/bootstrap/profile-repository.xml
   trunk/server/src/etc/conf/default/bootstrap/profile.xml
   trunk/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java
   trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/VFSBootstrapScannerImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeployerScannerImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeploymentScannerImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/basic/
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/DeploymentRecord.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/FileProfileRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaBeanXmlAttachmentsSerializer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaSerializationAttachmentsSerializer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/TCLObjectInputStream.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/MainTestCase.java
Modified:
   trunk/build/build.xml
   trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java
   trunk/component-matrix/pom.xml
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
   trunk/profileservice/src/resources/profileservice-jboss-beans.xml
   trunk/server/src/etc/conf/default/bootstrap-minimal.xml
   trunk/server/src/etc/conf/default/bootstrap.xml
   trunk/system/.classpath
   trunk/system/src/main/org/jboss/system/server/profileservice/DeploymentPhaseVFSScanner.java
   trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
   trunk/system/src/main/org/jboss/system/server/profileservice/attachments/LazyPredeterminedManagedObjects.java
   trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java
Log:
initial sub-profiles prototype

Modified: trunk/build/build.xml
===================================================================
--- trunk/build/build.xml	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/build/build.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -770,7 +770,7 @@
         <include name="bootstrap/aop.xml"/>
         <include name="bootstrap/jmx.xml"/>
         <include name="bootstrap/deployers.xml"/>
-        <include name="bootstrap/profile.xml"/>
+        <include name="bootstrap/profile-service.xml"/>
         <include name="xmdesc/NamingBean-xmbean.xml"/>
         <include name="xmdesc/NamingService-xmbean.xml"/>
         <include name="xmdesc/Log4jService-xmbean.xml"/>          

Modified: trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -194,9 +194,9 @@
       VFSDeployment deployment = createDeployment(file);
       if (this.deploymentManager == null)
       {         
-         if(profile.hasDeployment(deployment.getName(), DEPLOYMENT_PHASE) == false)
+         if(profile.hasDeployment(deployment.getName()) == false)
          {
-            profile.addDeployment(deployment, DEPLOYMENT_PHASE);
+            profile.addDeployment(deployment);
             this.mainDeployer.addDeployment(deployment);
          }
       }
@@ -223,9 +223,9 @@
    @Override
    protected void remove(Profile profile, String name) throws Exception
    {
-      if(this.deploymentManager == null && profile.hasDeployment(name, DEPLOYMENT_PHASE))
+      if(this.deploymentManager == null && profile.hasDeployment(name))
       {
-         profile.removeDeployment(name, DEPLOYMENT_PHASE);
+         profile.removeDeployment(name);
          this.mainDeployer.removeDeployment(name);
       }
       // else we deal with everything at the end of undeploySingletons

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/component-matrix/pom.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -70,7 +70,7 @@
     <version.org.jboss.cluster>1.1.0.GA</version.org.jboss.cluster>
     <version.org.jboss.cluster.cache.spi>1.1.0.GA</version.org.jboss.cluster.cache.spi>
     <version.org.jboss.cluster.cache.jbc>1.1.0.GA</version.org.jboss.cluster.cache.jbc>
-    <version.org.jboss.integration>5.0.3.GA</version.org.jboss.integration>
+    <version.org.jboss.integration>6.0.0.Alpha1</version.org.jboss.integration>
     <version.org.jboss.jbossxb>2.0.0.GA</version.org.jboss.jbossxb>
     <version.org.jboss.metadata>1.0.0.CR11</version.org.jboss.metadata>
     <version.org.jboss.naming>5.0.0.SP1</version.org.jboss.naming>

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -21,7 +21,9 @@
  */
 package org.jboss.profileservice.management;
 
+import java.io.IOException;
 import java.lang.annotation.Annotation;
+import java.net.URI;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -84,6 +86,7 @@
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.remoting.InvokerLocator;
+import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -92,6 +95,7 @@
  * @author Scott.Stark at jboss.org
  * @author adrian at jboss.org
  * @author ales.justin at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
 @ManagementObject(name="ManagementView", componentType=@ManagementComponent(type="MCBean", subtype="*"))
@@ -138,9 +142,16 @@
    /** The dispatcher handles ManagedOperation dispatches */
    private RuntimeComponentDispatcher dispatcher;
    private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+   
+   /** The template root */
+   private VirtualFile templateRoot = null;
 
-   public ManagementViewImpl()
+   public ManagementViewImpl(URI uri) throws IOException
    {
+      if(uri == null)
+         throw new IllegalArgumentException("Null template root uri.");
+      this.templateRoot = VFS.getCachedFile(uri);
+      
       currentLocale = Locale.getDefault();
       formatter.setLocale(currentLocale);
       i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
@@ -648,7 +659,7 @@
       // Let the DeploymentRepository try to resolve the deployment (simpleName)
       if(md == null)
       {
-         Deployment ctx = activeProfile.getDeployment(name, phase);
+         Deployment ctx = activeProfile.getDeployment(name);
          md = this.managedDeployments.get(ctx.getName());
       }
       
@@ -673,7 +684,7 @@
       HashSet<ManagedDeployment> mds = new HashSet<ManagedDeployment>();
       for(String name : names)
       {
-         Deployment ctx = activeProfile.getDeployment(name, null);
+         Deployment ctx = activeProfile.getDeployment(name);
          ManagedDeployment md = getManagedDeployment(ctx);
          mds.add(md);
       }
@@ -775,12 +786,11 @@
       }
 
       // Create a deployment base from the template
-      VirtualFile root = activeProfile.getRootFile(phase);
       if( log.isTraceEnabled() )
          log.trace("applyTemplate, profile="+activeProfile+", deploymentBaseName="+deploymentBaseName+", phase="+phase+", info="+info);
-      VirtualFile vf = template.applyTemplate(root, deploymentBaseName, info);
+      VirtualFile vf = template.applyTemplate(templateRoot, deploymentBaseName, info);
       VFSDeployment ctx = deploymentFactory.createVFSDeployment(vf);
-      activeProfile.addDeployment(ctx, phase);
+      activeProfile.addDeployment(ctx);
       mainDeployer.addDeployment(ctx);
       // Seems useless, what was the original point of this?
       template.updateTemplateDeployment(ctx, info);
@@ -892,7 +902,7 @@
       throws NoSuchProfileException, NoSuchDeploymentException, Exception
    {
       log.debug("removeDeployment, "+deploymentName+", phase: "+phase);
-      Deployment ctx = activeProfile.removeDeployment(deploymentName, phase);
+      Deployment ctx = activeProfile.removeDeployment(deploymentName);
       if( ctx == null )
       {
          formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
@@ -960,7 +970,7 @@
          
       String name = md.getName();
       DeploymentPhase phase = md.getDeploymentPhase();
-      VFSDeployment compDeployment = activeProfile.getDeployment(name, phase);
+      VFSDeployment compDeployment = activeProfile.getDeployment(name);
       if( compDeployment == null )
       {
          formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
@@ -1042,7 +1052,7 @@
       
       
       // Update the repository deployment attachments
-      activeProfile.updateDeployment(compDeployment, phase, serverComp);
+      activeProfile.updateDeployment(compDeployment, serverComp);
    }
 
    /**

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -37,10 +37,10 @@
 import org.jboss.profileservice.management.upload.remoting.DeployHandler;
 import org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget;
 import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.remoting.InvokerLocator;
 
@@ -57,7 +57,7 @@
    private ProfileService ps;
    /** The currently loaded profile */
    private Profile activeProfile;
-   private DeploymentRepositoryFactory repositoryFactory;
+   private ProfileRepository profileRepository;
    private DeployHandler deployHandler;
 
    /** */
@@ -76,7 +76,6 @@
       i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
    }
 
-   
    public ProfileService getProfileService()
    {
       return ps;
@@ -86,13 +85,13 @@
       this.ps = ps;
    }
 
-   public DeploymentRepositoryFactory getRepositoryFactory()
+   public ProfileRepository getProfileRepository()
    {
-      return repositoryFactory;
+      return profileRepository;
    }
-   public void setRepositoryFactory(DeploymentRepositoryFactory repositoryFactory)
+   public void setProfileRepository(ProfileRepository repositoryFactory)
    {
-      this.repositoryFactory = repositoryFactory;
+      this.profileRepository = repositoryFactory;
    }
 
    public DeployHandler getDeployHandler()
@@ -171,7 +170,7 @@
       log.debug("Loading profile, key: "+key+", allowHotDeployments: "+allowHotDeployments);
       activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
       // Set the deployment repository on the handler
-      DeploymentRepository repository = repositoryFactory.getDeploymentRepository(key);
+      DeploymentRepository repository = profileRepository.getProfileDeploymentRepository(key);
       log.debug("DeploymentRepository for profile: "+repository);
       deployHandler.setDeploymentRepository(repository);
    }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -52,6 +52,7 @@
  * handler and used by the StreamingDeploymentTarget implementation.
  *
  * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision:$
  */
 public class DeployHandler extends AOPRemotingInvocationHandler
@@ -104,7 +105,7 @@
       deploymentTarget.setContentIS(contentIS);
       DeploymentPhase phase = deploymentTarget.getPhase();
       String[] names = deploymentTarget.getNames();
-      String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS, phase);
+      String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS);
       log.info("End handle stream, repositoryName: " + repositoryName);
       String[] rnames = {repositoryName};
       deploymentTarget.setRepositoryNames(rnames);
@@ -175,7 +176,8 @@
    protected String[] getRepositoryNames(String[] names, DeploymentPhase phase)
       throws IOException
    {
-      return deploymentRepository.getRepositoryNames(names, phase);
+//      return deploymentRepository.getRepositoryNames(names, phase);
+      return names;
    }
 
    protected String[] distribute(DeploymentID dtID) throws Exception
@@ -184,12 +186,12 @@
       DeploymentPhase phase = dtID.getPhase();
       log.info("Begin distribute, content url: " + contentURL + ", phase: " + phase);
       // Prevent hot deployment scans from seeing in transition deployments
-      deploymentRepository.acquireDeploymentContentLock();
+//      deploymentRepository.acquireDeploymentContentLock();
       try
       {
          VirtualFile vf = VFS.getRoot(contentURL);
          VFSDeployment vfsd = createDeployment(vf);
-         deploymentRepository.addDeployment(vfsd.getName(), vfsd, phase);
+         deploymentRepository.addDeployment(vfsd.getName(), vfsd);
          mainDeployer.addDeployment(vfsd);
          mainDeployer.process();
          mainDeployer.checkComplete();         
@@ -199,7 +201,7 @@
       }
       finally
       {
-         deploymentRepository.releaseDeploymentContentLock();
+//         deploymentRepository.releaseDeploymentContentLock();
       }
    }
 
@@ -209,15 +211,15 @@
       DeploymentPhase phase = dtID.getPhase();
       log.info("Begin start, "+Arrays.asList(names) + ", phase: " + phase);
       // Prevent hot deployment scans from seeing in transition deployments
-      deploymentRepository.acquireDeploymentContentLock();
+//      deploymentRepository.acquireDeploymentContentLock();
       try
       {
          for(String name : names)
          {
-            VirtualFile vf = deploymentRepository.getDeploymentContent(name, phase);
+            VirtualFile vf = deploymentRepository.getDeploymentContent(name);
             VFSDeployment vfsd = createDeployment(vf);
-            deploymentRepository.addDeployment(vfsd.getName(), vfsd, phase);
-            deploymentRepository.unlockDeploymentContent(vf.getPathName(), phase);
+            deploymentRepository.addDeployment(vfsd.getName(), vfsd);
+            deploymentRepository.unlockDeploymentContent(vf.getPathName());
             mainDeployer.addDeployment(vfsd);
             log.info("Scheduling start for: "+vfsd);
          }
@@ -226,7 +228,7 @@
       }
       finally
       {
-         deploymentRepository.releaseDeploymentContentLock();
+//         deploymentRepository.releaseDeploymentContentLock();
       }
       log.info("End start, "+Arrays.asList(names));
    }
@@ -235,16 +237,16 @@
    {
       String[] names = dtID.getNames();
       log.info("Stop, "+Arrays.asList(names));
-      deploymentRepository.acquireDeploymentContentLock();
+//      deploymentRepository.acquireDeploymentContentLock();
       try
       {
          for(String name : names)
          {
             // Obtain the 
-            VFSDeployment vfsd = deploymentRepository.getDeployment(name, dtID.getPhase());
+            VFSDeployment vfsd = deploymentRepository.getDeployment(name);
             // Lock the content to make it unavailable to the deployment scanner
             String path = vfsd.getRoot().getPathName();
-            deploymentRepository.lockDeploymentContent(path, dtID.getPhase());
+            deploymentRepository.lockDeploymentContent(path);
             mainDeployer.removeDeployment(vfsd);
             log.info("Scheduling stop for: "+vfsd);
          }
@@ -253,7 +255,7 @@
       }
       finally
       {
-         deploymentRepository.releaseDeploymentContentLock();
+//         deploymentRepository.releaseDeploymentContentLock();
       }
    }
 
@@ -261,18 +263,18 @@
    {
       String[] names = dtID.getNames();
       log.info("Undeploy, "+Arrays.asList(names));
-      deploymentRepository.acquireDeploymentContentLock();
+//      deploymentRepository.acquireDeploymentContentLock();
       try
       {
          for(String name : names)
          {
-            deploymentRepository.removeDeployment(name, dtID.getPhase());
+            deploymentRepository.removeDeployment(name);
             log.info("Undeployed: "+name);
          }
       }
       finally
       {
-         deploymentRepository.releaseDeploymentContentLock();
+//         deploymentRepository.releaseDeploymentContentLock();
       }
    }
 

Modified: trunk/profileservice/src/resources/profileservice-jboss-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-jboss-beans.xml	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/profileservice/src/resources/profileservice-jboss-beans.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -100,6 +100,7 @@
         The ManagementView plugin
     -->
     <bean name="ManagementView" class="org.jboss.profileservice.management.ManagementViewImpl">
+    	<constructor><parameter><inject bean="ProfileFactory" property="templateRoot" /></parameter></constructor>
         <install bean="ProfileService" method="setViewManager">
             <parameter>
                 <this/>
@@ -135,7 +136,7 @@
                 <null/>
             </parameter>
         </uninstall>
-        <property name="repositoryFactory"><inject bean="SerializableDeploymentRepositoryFactory" /></property>
+        <property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
         <property name="profileService"><inject bean="ProfileService"/></property>
         <property name="deployHandler"><inject bean="DeploymentInvocationHandler"/></property>
         <property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>

Deleted: trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java
===================================================================
--- trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,144 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.ps;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
-import org.jboss.profileservice.spi.DeploymentContentFlags;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.system.server.profileservice.repository.JavaSerializationAttachmentsSerializer;
-import org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository;
-
-
-/**
- * Tests of the SerializableDeploymentRepository implementation details.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class SerializableDeploymentRepositoryUnitTest
-   extends TestCase
-{
-   private static Logger log = Logger.getLogger(SerializableDeploymentRepositoryUnitTest.class);
-
-   public SerializableDeploymentRepositoryUnitTest(String name)
-   {
-      super(name);
-   }
-
-   /**
-    * Test the behavior of the {@link DeploymentContentFlags#LOCKED} flag
-    * @throws Exception
-    */
-   public void testDeploymentContentFlagsLocked()
-      throws Exception
-   {
-      File root = getServerRoot();
-      URI[] appURIs = {root.toURI().resolve("default/deploy")};
-      ProfileKey key = new ProfileKey("default");
-      log.info("Creating SDR with root: "+root+", appURI: "+appURIs[0]);
-      SerializableDeploymentRepository sdr = new SerializableDeploymentRepository(root, appURIs, key);
-      AttachmentsSerializer serializer = new JavaSerializationAttachmentsSerializer();
-      sdr.setSerializer(serializer);
-      sdr.load();
-
-      log.info("DeploymentNames: "+sdr.getDeploymentNames());
-      // Validate we can get the ROOT.war
-      VFSDeployment rootWar = sdr.getDeployment("ROOT.war", DeploymentPhase.APPLICATION);
-      assertNotNull("deploy/ROOT.war", rootWar);
-
-      // Modify the ROOT.war
-      URI warURI = rootWar.getRoot().toURI();
-      File warFile = new File(warURI.getPath());
-      warFile.setLastModified(System.currentTimeMillis());
-      // Check its flags
-      int flags = sdr.getDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION);
-      assertEquals("ROOT.war flags", 0, flags);
-
-      // Validate the ROOT.war is in the modified deployments
-      Collection<ModificationInfo> mods = sdr.getModifiedDeployments();
-      assertEquals("Collection<ModificationInfo> size is 1", 1, mods.size());
-      ModificationInfo warMods = mods.iterator().next();
-      assertEquals("ModificationInfo.status is MODIFIED", ModificationInfo.ModifyStatus.MODIFIED, warMods.getStatus());
-      assertEquals("ModificationInfo.name is ROOT.war", "ROOT.war", warMods.getDeployment().getSimpleName());
-
-      // lock the war
-      flags = sdr.setDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION,
-            DeploymentContentFlags.LOCKED);
-      assertEquals(flags, DeploymentContentFlags.LOCKED);
-      warFile.setLastModified(System.currentTimeMillis()+1000);
-      // It should be modified, but not show up in the mods
-      assertTrue("vfsfile ROOT.war hasBeenModified", rootWar.getRoot().hasBeenModified());
-      mods = sdr.getModifiedDeployments();
-      assertEquals("Collection<ModificationInfo> size is 0", 0, mods.size());
-
-      // Validate that the locked flag overrides the modified flag
-      assertFalse("vfsfile ROOT.war hasBeenModified", rootWar.getRoot().hasBeenModified());
-      flags = DeploymentContentFlags.LOCKED | DeploymentContentFlags.MODIFIED;
-      sdr.setDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION, flags);
-      mods = sdr.getModifiedDeployments();
-      assertEquals("Collection<ModificationInfo> size is 0", 0, mods.size());
-
-      // Validate that the modified flag allows it to show
-      flags = sdr.clearDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION,
-            DeploymentContentFlags.LOCKED);
-      assertEquals("ROOT.war has MODIFIED flag", flags, DeploymentContentFlags.MODIFIED);
-      mods = sdr.getModifiedDeployments();
-      assertEquals("Collection<ModificationInfo> size is 1", 1, mods.size());
-      warMods = mods.iterator().next();
-      assertEquals("ModificationInfo.status is MODIFIED", ModificationInfo.ModifyStatus.MODIFIED, warMods.getStatus());
-      assertEquals("ModificationInfo.name is ROOT.war", "ROOT.war", warMods.getDeployment().getSimpleName());
-   }
-
-   /**
-    * Get the file for the jboss server directory. Relies on one
-    * of the following variables to be set:
-    * JBOSS_HOME env variable
-    * jboss.home system property
-    * 
-    * @return
-    * @throws IOException 
-    */
-   protected File getServerRoot() throws IOException
-   {
-      String home = System.getenv("JBOSS_HOME");
-      if(home == null)
-      {
-         home = System.getProperty("jboss.home");
-      }
-      File defaultDir = new File(home, "server");
-      if(defaultDir.exists() == false)
-         throw new FileNotFoundException(defaultDir.getAbsolutePath()+", check the JBOSS_HOME env variable or jboss.home system property");
-      return defaultDir;
-   }
-}

Deleted: trunk/server/src/etc/conf/default/bootstrap/profile-repository.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap/profile-repository.xml	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/server/src/etc/conf/default/bootstrap/profile-repository.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-   The profile service
--->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
-   <classloader><inject bean="profile-classloader:0.0.0"/></classloader>
-
-   <classloader name="profile-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
-      <root>${jboss.lib.url}jboss-profileservice-spi.jar</root>
-   </classloader>
-    
-    <!-- 
-    	The file repository profile service which provides full
-        support ProfileService spi.
-    -->
-    <bean name="ProfileService" class="org.jboss.system.server.profileservice.repository.ProfileServiceImpl">
-        <constructor>
-            <parameter>${jboss.server.name}</parameter>
-        </constructor>
-        <property name="profileRepository"><inject bean="FileProfileRepository"/></property>
-    </bean>
-    <bean name="FileProfileRepository" class="org.jboss.system.server.profileservice.repository.FileProfileRepository">
-        <property name="storeRoot">${jboss.server.base.dir}</property>
-        <property name="repositoryFactory"><inject bean="SerializableDeploymentRepositoryFactory"/></property>
-    </bean>
-   <bean name="SerializableDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.SerializableDeploymentRepositoryFactory">
-      <property name="storeRoot">${jboss.server.base.dir}</property>
-      <property name="attachmentsRoot">${jboss.server.data.dir}/attachments</property>
-      <property name="applicationURIs">
-         <array elementClass="java.net.URI">
-            <value>${jboss.server.home.url}deploy</value>
-         </array>
-      </property>
-      <property name="serializer"><inject bean="AttachmentsSerializer"/></property>
-      <property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
-      <property name="hotDeploymentFilter">
-        <bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter"/>
-      </property>
-      <property name="mainDeployer"><inject bean="MainDeployer"/></property>
-      <depends>ProfileServicePersistenceDeployer</depends>
-   </bean>
-   <bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer" />
-
-   <!-- The Bootstrap implementation that loads the Profile from the ProfileService -->
-   <bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
-      <property name="mainDeployer"><inject bean="MainDeployer"/></property>
-      <property name="profileService"><inject bean="ProfileService"/></property>
-      <property name="mof"><inject bean="ManagedObjectFactory"/></property>
-      <property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator"/></property>
-   </bean>
-   
-   <bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer" />
-	
-   <!-- A filter for excluding files from the scanner -->
-   <bean name="DeploymentFilter" class="org.jboss.virtual.plugins.vfs.helpers.ExtensibleFilter">
-      <!-- Files starting with theses strings are ignored -->
-      <property name="prefixes">#,%,\,,.,_$</property>
-      <!-- Files ending with theses strings are ignored -->
-      <property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
-      <!-- Files matching with theses strings are ignored -->
-      <property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
-   </bean>
-   
-</deployment>

Added: trunk/server/src/etc/conf/default/bootstrap/profile-service.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap/profile-service.xml	                        (rev 0)
+++ trunk/server/src/etc/conf/default/bootstrap/profile-service.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- 
+	The ProfileService.
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+	<classloader><inject bean="profile-classloader:0.0.0" /></classloader>
+
+	<classloader name="profile-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
+		<root>${jboss.lib.url}jboss-profileservice-spi.jar</root>
+	</classloader>
+
+	<!-- The profile configuration -->
+	<bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.StaticProfileFactory">
+		<property name="bootstrapURI">${jboss.server.home.url}conf/jboss-service.xml</property>
+		<property name="deployersURI">${jboss.server.home.url}deployers</property>
+		<property name="applicationURIs">
+			<list elementClass="java.net.URI">
+				<value>${jboss.server.home.url}deploy</value>
+			</list>
+		</property>
+		<property name="attachmentStoreRoot">${jboss.server.data.dir}/attachments</property>
+		<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+	</bean>
+
+	<!-- The ProfileService -->
+	<bean name="ProfileService" class="org.jboss.system.server.profileservice.repository.AbstractProfileService">
+		<constructor><parameter><inject bean="jboss.kernel:service=KernelController" /></parameter></constructor>
+		<property name="deployer"><inject bean="MainDeployer" /></property>
+	</bean>
+
+	<!-- The Bootstrap implementation that loads the Profile from the ProfileService -->
+	<bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
+		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
+		<property name="profileService"><inject bean="ProfileService" /></property>
+		<property name="mof"><inject bean="ManagedObjectFactory" /></property>
+		<property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator" /></property>
+		<property name="profileFactory"><inject bean="ProfileFactory" /></property>
+	</bean>
+
+	<!-- The profile repository factory -->
+	<bean name="ProfileRepositoryFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileRepository">
+		<!-- Accept any DeploymentRepositoryFactory -->
+		<incallback method="addRepositoryFactory" />
+		<uncallback method="removeRepositoryFactory" />
+	</bean>
+
+	<!-- The default deployment repository factory -->
+	<bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory">
+		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
+		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
+		<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
+		<property name="hotDeploymentFilter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
+	</bean>
+
+	<!-- The attachment store -->
+	<bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore">
+		<constructor><parameter><inject bean="ProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
+		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
+		<property name="serializer"><inject bean="AttachmentsSerializer" /></property>
+	</bean>
+
+	<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">
+		<constructor><parameter><inject bean="ProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
+	</bean>
+
+   <bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer" />
+
+	<!-- A filter for excluding files from the scanner -->
+	<bean name="DeploymentFilter" class="org.jboss.virtual.plugins.vfs.helpers.ExtensibleFilter">
+		<!-- Files starting with theses strings are ignored -->
+		<property name="prefixes">#,%,\,,.,_$</property>
+		<!-- Files ending with theses strings are ignored -->
+		<property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
+		<!-- Files matching with theses strings are ignored -->
+		<property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
+	</bean>
+
+</deployment>
\ No newline at end of file

Deleted: trunk/server/src/etc/conf/default/bootstrap/profile.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap/profile.xml	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/server/src/etc/conf/default/bootstrap/profile.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-   The profile service
--->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
-   <classloader><inject bean="profile-classloader:0.0.0"/></classloader>
-
-   <classloader name="profile-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
-      <root>${jboss.lib.url}jboss-profileservice-spi.jar</root>
-   </classloader>
-
-   <!-- The basic profile service which relies on vfs scanners
-   to determine the profile deployments. This version does not
-   support the full ProfileService spi.
-   -->
-   <bean name="ProfileService" class="org.jboss.system.server.profileservice.basic.MetaDataAwareProfileService">
-      <constructor>
-         <parameter>${jboss.server.name}</parameter>
-      </constructor>
-      <property name="profileRoot">${jboss.server.home.dir}</property>
-      <property name="mainDeployer"><inject bean="MainDeployer"/></property>
-      <property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
-      <property name="filter">
-        <bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter"/>
-      </property>
-   </bean>
-
-   <bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
-      <property name="mainDeployer"><inject bean="MainDeployer"/></property>
-      <property name="profileService"><inject bean="ProfileService"/></property>
-      <property name="mof"><inject bean="ManagedObjectFactory"/></property>
-      <property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator"/></property>
-   </bean>
-
-   <!-- A filter for excluding files from the scanner -->
-   <bean name="DeploymentFilter" class="org.jboss.virtual.plugins.vfs.helpers.ExtensibleFilter">
-      <!-- Files starting with theses strings are ignored -->
-      <property name="prefixes">#,%,\,,.,_$</property>
-      <!-- Files ending with theses strings are ignored -->
-      <property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
-      <!-- Files matching with theses strings are ignored -->
-      <property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
-   </bean>
-
-   <!-- Scan for bootstraps -->
-   <bean name="VFSBootstrapScanner" class="org.jboss.system.server.profileservice.VFSBootstrapScannerImpl">
-      <property name="profileService"><inject bean="ProfileService"/></property>
-      <property name="filterInstance"><inject bean="DeploymentFilter"/></property>
-      <property name="URIList">
-         <list elementClass="java.net.URI">
-            <!-- Legacy static conf/jboss-service.xml -->
-            <value>${jboss.server.home.url}conf/jboss-service.xml</value>
-         </list>
-      </property>
-   </bean>
-
-   <!-- Scan for deployers -->
-   <bean name="VFSDeployerScanner" class="org.jboss.system.server.profileservice.VFSDeployerScannerImpl">
-      <property name="profileService"><inject bean="ProfileService"/></property>
-      <property name="filterInstance"><inject bean="DeploymentFilter"/></property>
-      <property name="URIList">
-         <list elementClass="java.net.URI">
-            <!-- Directory for deployers -->
-            <value>${jboss.server.home.url}deployers/</value>
-         </list>
-      </property>
-   </bean>
-
-   <!-- Scan for applications -->
-   <bean name="VFSDeploymentScanner" class="org.jboss.system.server.profileservice.VFSDeploymentScannerImpl">
-      <property name="profileService"><inject bean="ProfileService"/></property>
-      <property name="filterInstance"><inject bean="DeploymentFilter"/></property>
-      <property name="URIList">
-         <list elementClass="java.net.URI">
-            <!-- Standard hot deployment directory -->
-            <value>${jboss.server.home.url}deploy/</value>
-         </list>
-      </property>
-   </bean>
-
-</deployment>

Modified: trunk/server/src/etc/conf/default/bootstrap-minimal.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap-minimal.xml	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/server/src/etc/conf/default/bootstrap-minimal.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
    The list of URLs for mc beans to load during bootstrap.
-   $Id:$
+   $Id$
 -->
 <bootstrap xmlns="urn:jboss:bootstrap:1.0">
 
@@ -9,6 +9,6 @@
    <url>bootstrap/aop.xml</url>
    <url>bootstrap/jmx.xml</url>
    <url>bootstrap/deployers.xml</url>
-   <url>bootstrap/profile.xml</url>
+   <url>bootstrap/profile-service.xml</url>
 
 </bootstrap>

Deleted: trunk/server/src/etc/conf/default/bootstrap-norepo.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap-norepo.xml	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/server/src/etc/conf/default/bootstrap-norepo.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-   The list of URLs for mc beans to load during bootstrap.
-   $Id$
--->
-<bootstrap xmlns="urn:jboss:bootstrap:1.0">
-
-   <url>bootstrap/vfs.xml</url>
-   <url>bootstrap/classloader.xml</url>
-   <url>bootstrap/aop.xml</url>
-   <url>bootstrap/jmx.xml</url>
-   <url>bootstrap/deployers.xml</url>
-   <url>bootstrap/bindings.xml</url>
-   <url>bootstrap/profile.xml</url>
-
-</bootstrap>

Modified: trunk/server/src/etc/conf/default/bootstrap.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap.xml	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/server/src/etc/conf/default/bootstrap.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -11,6 +11,6 @@
    <url>bootstrap/jmx.xml</url>
    <url>bootstrap/deployers.xml</url>
    <url>bootstrap/bindings.xml</url>
-   <url>bootstrap/profile-repository.xml</url>
+   <url>bootstrap/profile-service.xml</url>
 
 </bootstrap>

Modified: trunk/system/.classpath
===================================================================
--- trunk/system/.classpath	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/.classpath	2009-01-13 12:54:35 UTC (rev 82809)
@@ -29,5 +29,6 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/main"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-core.jar" sourcepath="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-core-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/profileservice-spi/lib/jboss-profileservice-spi.jar" sourcepath="/thirdparty/jboss/profileservice-spi/lib/jboss-profileservice-spi-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client.jar" sourcepath="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client-sources.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Deleted: trunk/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,188 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.system.server.profile.basic;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.jboss.deployers.structure.spi.DeploymentContext;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-
-/**
- * Profile monitoring metadata changes.
- *
- * We need to cache files's last modifed timestamps,
- * since file.getChildren re-caches handlers,
- * hence hasBeenModified is useless.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class MetaDataAwareProfile extends ProfileImpl
-{
-   private MainDeployerStructure mainDeployer;
-   private VirtualFileFilter filter;
-   private Map<String, Long> lastModifiedCache;
-
-   public MetaDataAwareProfile(String profileRoot, ProfileKey key)
-   {
-      super(profileRoot, key);
-      lastModifiedCache = new ConcurrentHashMap<String, Long>();
-   }
-
-   /**
-    * Set main deployer structure.
-    *
-    * @param mainDeployer the main deployer structure
-    */
-   public void setMainDeployer(MainDeployerStructure mainDeployer)
-   {
-      this.mainDeployer = mainDeployer;
-   }
-
-   /**
-    * Set the metadata resources filter.
-    *
-    * @param filter the metadata resources filter
-    */
-   public void setFilter(VirtualFileFilter filter)
-   {
-      this.filter = filter;
-   }
-
-   protected boolean hasBeenModified(VirtualFile root) throws Exception
-   {
-      // get file:/ schema
-      URI uri = VFSUtils.getCompatibleURI(root);
-      File file = new File(uri);
-      // if root is file check its modification
-      if (file.isFile())
-         return root.hasBeenModified();
-
-      // else check metadata
-      String name = root.toURI().toString();
-      VFSDeploymentContext deploymentContext = getDeploymentContext(name);
-      if (deploymentContext != null)
-         return hasBeenModified(deploymentContext);
-
-      log.debug("Falling back to root name: " + root);
-      deploymentContext = getDeploymentContext(root.getName());
-      if (deploymentContext != null)
-         return hasBeenModified(deploymentContext);
-
-      return false;
-   }
-
-   /**
-    * Has vfs deployment context been modified.
-    *
-    * @param deploymentContext the vfs deployment context
-    * @return true if modified
-    * @throws IOException for any error
-    */
-   protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
-   {
-      List<VirtualFile> metadataLocations = deploymentContext.getMetaDataLocations();
-      if (metadataLocations != null && metadataLocations.isEmpty() == false)
-      {
-         for(VirtualFile metadataLocation : metadataLocations)
-         {
-            List<VirtualFile> children = metadataLocation.getChildren(filter);
-            if (children != null && children.isEmpty() == false)
-            {
-               for(VirtualFile child : children)
-               {
-                  String pathName = child.getPathName();
-                  Long timestamp = lastModifiedCache.get(pathName);
-                  long lastModified = child.getLastModified();
-                  lastModifiedCache.put(pathName, lastModified);
-                  if (timestamp != null && timestamp < lastModified)
-                  {
-                     if (log.isTraceEnabled())
-                        log.trace("Metadata location modified: " + child);
-                     return true;
-                  }
-               }
-            }
-         }
-      }
-      List<DeploymentContext> childContexts = deploymentContext.getChildren();
-      if (childContexts != null && childContexts.isEmpty() == false)
-      {
-         for (DeploymentContext childContext : childContexts)
-         {
-            if (childContext instanceof VFSDeploymentContext)
-            {
-               if (hasBeenModified((VFSDeploymentContext)childContext))
-                  return true;
-            }
-         }
-      }
-      return false;
-   }
-
-   // expecting all deployments from same context root
-   // so path name should group them per deployment unit
-   protected void postRemove(VFSDeployment deployment) throws Exception
-   {
-      VirtualFile root = deployment.getRoot();
-      String pathName = root.getPathName();
-      if (log.isTraceEnabled())
-         log.debug("Removing last modified cache info for: " + pathName);
-
-      Iterator<String> iter = lastModifiedCache.keySet().iterator();
-      while (iter.hasNext())
-      {
-         if (iter.next().startsWith(pathName))
-            iter.remove();
-      }
-   }
-
-   /**
-    * Get deployment context.
-    *
-    * @param name the deployment context name
-    * @return vfs deployment context or null if doesn't exist or not vfs based
-    */
-   @SuppressWarnings("deprecation")
-   protected VFSDeploymentContext getDeploymentContext(String name)
-   {
-      if (mainDeployer == null)
-         throw new IllegalArgumentException("Null main deployer");
-
-      DeploymentContext deploymentContext = mainDeployer.getDeploymentContext(name);
-      if (deploymentContext == null || deploymentContext instanceof VFSDeploymentContext == false)
-         return null;
-
-      return (VFSDeploymentContext)deploymentContext;
-   }
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,532 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.system.server.profile.basic;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
-import org.jboss.system.server.profileservice.VFSScanner;
-import org.jboss.util.JBossObject;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-
-/**
- * A basic profile implementation that uses in memory store for the applications.
- * This has to be populated by some other components.
- * 
- * @see VFSScanner and subclasses for an example usage.
- * 
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision$
- */
-public class ProfileImpl extends JBossObject implements Profile
-{
-   /** The deployment factory */
-   private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
-   
-   private ProfileKey key;
-   /** The directory containing the profiles */
-   private File profileRoot;
-   private LinkedHashMap<String, VFSDeployment> bootstraps = new LinkedHashMap<String, VFSDeployment>();
-   private LinkedHashMap<String, VFSDeployment> applications = new LinkedHashMap<String, VFSDeployment>();
-   private LinkedHashMap<String, VFSDeployment> deployers = new LinkedHashMap<String, VFSDeployment>();
-   /** Is hot deployment checking enabled */
-   private volatile boolean hotdeployEnabled;
-   /** The last time the profile was modified */
-   private long lastModified;
-   /** The deployment filter */
-   private VirtualFileFilter deploymentFilter;
-
-   public ProfileImpl(String profileRoot, ProfileKey key)
-   {
-      this.key = key;
-      this.profileRoot = new File(profileRoot);
-      log.info("Using profile root:"+this.profileRoot.getAbsolutePath());
-   }
-
-   public String getName()
-   {
-      return key.getName();
-   }
-
-   public ProfileKey getKey()
-   {
-      return key;
-   }
-
-   public String getVersion()
-   {
-      return null;
-   }
-
-   
-   public long getLastModified()
-   {
-      return this.lastModified;
-   }
-   
-   public VirtualFileFilter getDeploymentFilter()
-   {
-      return deploymentFilter;
-   }
-   
-   public void setDeploymentFilter(VirtualFileFilter deploymentFilter)
-   {
-      this.deploymentFilter = deploymentFilter;
-   }
-
-   /**
-    * Get the names of the applications in the profile
-    * @return names of applications
-    */
-   public Set<String> getDeploymentNames()
-   {
-      HashSet<String> names = new HashSet<String>();
-      names.addAll(this.bootstraps.keySet());
-      names.addAll(this.deployers.keySet());
-      names.addAll(this.applications.keySet());
-      return names;
-   }
-
-   public VirtualFile getRootFile(DeploymentPhase phase)
-      throws Exception
-   {
-      VirtualFile root = VFS.getRoot(profileRoot.toURI());
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            root = root.findChild("conf");
-            break;
-         case DEPLOYER:
-            root = root.findChild("deployers");
-            break;
-         case APPLICATION:
-            root = root.findChild("deploy");
-            break;
-      }      
-      return root;
-   }
-
-   public void addDeployment(VFSDeployment d, DeploymentPhase phase)
-      throws Exception
-   {
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            this.addBootstrap(d);
-            break;
-         case DEPLOYER:
-            this.addDeployer(d);
-            break;
-         case APPLICATION:
-            this.addApplication(d);
-            break;
-      }
-      this.lastModified = System.currentTimeMillis();
-   }
-   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
-         ManagedComponent comp)
-      throws Exception
-   {
-   
-   }
-
-   /**
-    * Find a deployment context from the basic profile service.
-    * 
-    * @param    name    the name of the deployment
-    * @param    phase   optionally a deployment phase, if null search all
-    * @return   the deployment or null if not found
-    */
-   private VFSDeployment findDeployment(String name, DeploymentPhase phase)
-   {
-      VFSDeployment d = null;
-      if( phase == null )
-      {
-         // Try all phases
-         d = this.getBootstrap(name);
-         if( d == null )
-            d = this.getDeployer(name);
-         if( d == null )
-            d = this.getApplication(name);
-      }
-      else
-      {
-         switch( phase )
-         {
-            case BOOTSTRAP:
-               d = this.getBootstrap(name);
-               break;
-            case DEPLOYER:
-               d = this.getDeployer(name);
-               break;
-            case APPLICATION:
-               d = this.getApplication(name);
-               break;
-         }
-      }
-      return d;
-   }
-   
-   /**
-    * Get a deployment context from the basic profile service.
-    * 
-    * @param    name    the name of the deployment
-    * @param    phase   optionally a deployment phase, if null search all
-    * @return   the deployment or NoSuchDeploymentException
-    * @throws   NoSuchDeploymentException   if the deployment can't be found
-    */
-   public VFSDeployment getDeployment(String name, DeploymentPhase phase)
-      throws NoSuchDeploymentException
-   {
-      VFSDeployment d = findDeployment(name, phase);
-      // Make sure we don't return null
-      if( d == null )
-         throw new NoSuchDeploymentException("name="+name+", phase="+phase);
-      return d;
-   }
-
-   /**
-    * Checks whether a deployment context is available in the basic profile service.
-    * 
-    * @param    name    the name of the deployment
-    * @param    phase   optionally a deployment phase, if null search all
-    * @return   true if the deployment is found or false otherwise
-    */
-   public boolean hasDeployment(String name, DeploymentPhase phase)
-   {
-      return findDeployment(name, phase) != null;
-   }
-   
-   public Set<String> getDeploymentNames(DeploymentPhase phase)
-   {
-      HashSet<String> names = new HashSet<String>();
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            names.addAll(this.bootstraps.keySet());
-            break;
-         case DEPLOYER:
-            names.addAll(this.deployers.keySet());
-            break;
-         case APPLICATION:
-            names.addAll(this.applications.keySet());
-            break;
-      }
-      return names;
-   }
-
-   public Set<String> getDeploymentNamesForType(String type)
-   {
-      throw new UnsupportedOperationException("getDeploymentNamesForType");
-      /** TODO Deployment.getTypes()
-      HashSet<String> names = new HashSet<String>();
-      for(VFSDeployment d : bootstraps.values())
-      {
-         if( d.getTypes().contains(type) )
-            names.add(d.getName());
-      }
-      for(VFSDeployment d : deployers.values())
-      {
-         if( d.getTypes().contains(type) )
-            names.add(d.getName());
-      }
-      for(VFSDeployment d : applications.values())
-      {
-         if( d.getTypes().contains(type) )
-            names.add(d.getName());
-      }
-      return names;
-      */
-   }
-
-   public Collection<VFSDeployment> getDeployments()
-   {
-      HashSet<VFSDeployment> deployments = new HashSet<VFSDeployment>();
-      deployments.addAll(this.bootstraps.values());
-      deployments.addAll(this.deployers.values());
-      deployments.addAll(this.applications.values());
-      return Collections.unmodifiableCollection(deployments);
-   }
-
-   /**
-    * Go through the applications looking for modifications. This also
-    * picks the last application parent directory as the basis for
-    * scanning for new deployments.
-    * TODO: to handle multiple application/hotdeployment directories a
-    * set of parent dirs needs to be built.
-    */
-   public Collection<ModificationInfo> getModifiedDeployments()
-      throws Exception
-   {
-      if( hotdeployEnabled == false )
-         return Collections.emptyList();
-
-      ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
-      Collection<VFSDeployment> apps = applications.values();
-      boolean trace = log.isTraceEnabled();
-      if( trace )
-         log.trace("Checking applications for modifications");
-      VirtualFile applicationDir = null;
-      if( apps != null )
-      {
-         Iterator<VFSDeployment> iter = apps.iterator();
-         while( iter.hasNext() )
-         {
-            VFSDeployment d = iter.next();
-            VirtualFile root = d.getRoot();
-            // Save the containing parent dir to scan for new deployments
-            VirtualFile parent = root.getParent();
-            if(parent != null && (applicationDir == null || parent.getPathName().compareTo(applicationDir.getPathName()) < 0 ))
-               applicationDir = parent;
-            // Check for removal
-            if( root.exists() == false )
-            {
-               long rootLastModified = root.getLastModified();
-               ModificationInfo info = new ModificationInfo(d, rootLastModified, ModifyStatus.REMOVED);
-               modified.add(info);
-               iter.remove();
-               if( trace )
-                  log.trace(root.getPathName() + " was removed");
-               postRemove(d);
-            }
-            // Check for modification
-            else if(hasBeenModified(root))
-            {
-               long rootLastModified = root.getLastModified();
-               if( trace )
-                  log.trace(root.getPathName() + " was modified: " + rootLastModified);
-               // Need to create a duplicate ctx
-               VFSDeployment deployment2 = deploymentFactory.createVFSDeployment(root);
-               ModificationInfo info = new ModificationInfo(deployment2, rootLastModified, ModifyStatus.MODIFIED);
-               modified.add(info);
-            }
-            // TODO: this could check metadata files modifications as well
-         }
-
-         // If there are no apps, use the default appplication root
-         if( applicationDir == null )
-            applicationDir = getRootFile(DeploymentPhase.APPLICATION);
-         // Now check for additions
-         ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
-         addDeployments(added, applicationDir);
-         for(VirtualFile vf : added)
-         {
-            VFSDeployment d = deploymentFactory.createVFSDeployment(vf);
-            ModificationInfo info = new ModificationInfo(d, vf.getLastModified(), ModifyStatus.ADDED);
-            modified.add(info);
-            applications.put(d.getName(), d);
-         }
-      }
-      if(modified.size() > 0)
-         lastModified = System.currentTimeMillis();
-      return modified;
-   }
-
-   /**
-    * Has the root been modified.
-    *
-    * @param root the virtual file root
-    * @return true if modifed
-    * @throws Exception for any error
-    */
-   protected boolean hasBeenModified(VirtualFile root) throws Exception
-   {
-      return root.hasBeenModified();
-   }
-
-   /**
-    * Apply post remove operation.
-    *
-    * @param deployment the vfs deployment
-    * @throws Exception for any error
-    */
-   protected void postRemove(VFSDeployment deployment) throws Exception
-   {
-      // noop here
-   }
-
-   /**
-    * Noop as basic profile does not support hot deployment currently
-    */
-   public void enableModifiedDeploymentChecks(boolean flag)
-   {
-      this.hotdeployEnabled = flag;
-   }
-
-   public Collection<VFSDeployment> getDeployments(DeploymentPhase phase)
-   {
-      Collection<VFSDeployment> deployments = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            deployments = this.getBootstraps();
-            break;
-         case DEPLOYER:
-            deployments = this.getDeployers();
-            break;
-         case APPLICATION:
-            deployments = this.getApplications();
-            break;
-      }
-      return deployments;
-   }
-
-   public VFSDeployment removeDeployment(String name, DeploymentPhase phase)
-      throws Exception
-   {
-      VFSDeployment d = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            d = this.removeBootstrap(name);
-            break;
-         case DEPLOYER:
-            d = this.removeDeployer(name);
-            break;
-         case APPLICATION:
-            d = this.removeApplication(name);
-            break;
-      }
-      return d;
-   }
-
-   public Map<String, Object> getConfig()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   protected void addBootstrap(VFSDeployment d)
-   {
-      bootstraps.put(d.getName(), d);
-   }
-
-   protected VFSDeployment removeBootstrap(String name)
-   {
-      return bootstraps.remove(name);
-   }
-
-   protected VFSDeployment getBootstrap(String name)
-   {
-      return bootstraps.get(name);
-   }
-
-   protected Collection<VFSDeployment> getBootstraps()
-   {
-      return Collections.unmodifiableCollection(bootstraps.values());
-   }
-
-   protected void addDeployer(VFSDeployment d)
-   {
-      deployers.put(d.getName(), d);
-   }
-
-   protected VFSDeployment removeDeployer(String name)
-   {
-      return deployers.remove(name);
-   }
-
-   protected VFSDeployment getDeployer(String name)
-   {
-      return deployers.get(name);
-   }
-
-   protected Collection<VFSDeployment> getDeployers()
-   {
-      return Collections.unmodifiableCollection(deployers.values());
-   }
-
-   protected void addApplication(VFSDeployment d)
-   {
-      applications.put(d.getName(), d);
-   }
-
-   protected VFSDeployment removeApplication(String name)
-   {
-      return applications.remove(name);
-   }
-
-   protected VFSDeployment getApplication(String name)
-   {
-      return applications.get(name);
-   }
-
-   protected Collection<VFSDeployment> getApplications()
-   {
-      return Collections.unmodifiableCollection(applications.values());
-   }
-
-   private void addDeployments(List<VirtualFile> list, VirtualFile root)
-      throws Exception
-   {
-      List<VirtualFile> components = root.getChildren();
-      
-      for (VirtualFile component : components)
-      {
-         // Excluding files from scanning
-         if(! this.deploymentFilter.accepts(component))
-         {
-            log.trace("ignoring "+ component);
-            continue;
-         }
-         
-         String key = component.toURI().toString();
-         if( applications.containsKey(key) == true )
-            continue;
-
-         if (component.isLeaf())
-         {
-            list.add(component);
-         }
-         else if (component.getName().indexOf('.') == -1)
-         {
-            // recurse if not '.' in name and recursive search is enabled
-            addDeployments(list, component);
-         }
-         else
-         {
-            list.add(component);
-         }
-      }
-   }
-
-}

Added: trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profile.repository;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * A basic profile implementation, which delegates all the deployment
+ * actions the a DeploymentRepository.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractProfile implements Profile
+{
+
+   /** TODO The version */
+   private String version;
+   
+   /** The profile key */
+   final private ProfileKey key;
+   
+   /** The repository containing the deployment contents */
+   final private DeploymentRepository repository;
+   
+   /** The profile dependencies */
+   private List<DependencyItem> dependencies;
+   
+   /** Is hot deployment checking enabled */
+   private volatile boolean hotdeployEnabled = false;
+   
+   public AbstractProfile(DeploymentRepository repository, ProfileKey key)
+   {
+      this(repository, key, null);
+   }
+   
+   public AbstractProfile(DeploymentRepository repository, ProfileKey key, List<DependencyItem> dependencies)
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(repository == null)
+         throw new IllegalArgumentException("Null deployment repository.");
+            
+      this.key = key;
+      this.repository = repository;
+      this.dependencies = dependencies;
+   }
+
+   public void addDeployment(VFSDeployment d) throws Exception
+   {
+      if(d == null)
+         throw new IllegalArgumentException("Null deployment");
+      this.repository.addDeployment(d.getName(), d);
+   }
+
+   public void enableModifiedDeploymentChecks(boolean flag)
+   {
+      this.hotdeployEnabled = flag;
+   }
+   
+   public VFSDeployment getDeployment(String name) throws Exception, NoSuchDeploymentException
+   {
+      if(name == null)
+         throw new IllegalArgumentException("Null name.");
+      return this.repository.getDeployment(name);
+   }
+
+   public Set<String> getDeploymentNames()
+   {
+      return this.repository.getDeploymentNames();
+   }
+
+   public Collection<VFSDeployment> getDeployments() throws Exception
+   {
+      return this.repository.getDeployments();
+   }
+
+   public ProfileKey getKey()
+   {
+      return this.key;
+   }
+
+   public long getLastModified()
+   {
+      return this.repository.getLastModified();
+   }
+
+   @SuppressWarnings("unchecked")
+   public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+   {
+      if(this.hotdeployEnabled == false)
+         return Collections.EMPTY_SET;
+      return this.repository.getModifiedDeployments();
+   }
+
+   public String getVersion()
+   {
+      return this.version;
+   }
+
+   public boolean hasDeployment(String name)
+   {
+      if(name == null)
+         throw new IllegalArgumentException("Null name.");
+      // FIXME
+      try
+      {
+         return this.repository.getDeployment(name) != null;
+      }
+      catch(Exception e)
+      {
+         return false;
+      }
+   }
+
+   public VFSDeployment removeDeployment(String name) throws Exception
+   {
+      if(name == null)
+         throw new IllegalArgumentException("Null name.");
+      return this.repository.removeDeployment(name);
+   }
+
+   public void updateDeployment(VFSDeployment d, ManagedComponent comp) throws Exception
+   {
+      if(d == null)
+         throw new IllegalArgumentException("Null deployment");
+      if(comp == null)
+         throw new IllegalArgumentException("Null managed component.");
+      this.repository.updateDeployment(d, comp);
+   }
+   
+   public void create() throws Exception
+   {
+      if(this.repository == null)
+         throw new IllegalStateException("Null deployment repository.");
+      // Load
+      this.repository.load();
+   }
+   
+   public void destroy()
+   {
+      // nothing here
+   }
+
+   public Collection<DependencyItem> getDependencies()
+   {
+      return this.dependencies;
+   }
+   
+   public void setDependencies(List<DependencyItem> dependencies)
+   {
+      this.dependencies = dependencies;
+   }
+   
+   public String toString()
+   {
+      StringBuilder builder = new StringBuilder();
+      builder.append(getClass().getSimpleName());
+      builder.append('@').append(Integer.toHexString(System.identityHashCode(this)));
+      builder.append("{key = ").append(getKey());
+      toString(builder);
+      builder.append("}");
+      return builder.toString();
+   }
+   
+   /**
+    * Additional information for toString().
+    * 
+    * @param builder the builder.
+    */
+   protected void toString(StringBuilder builder)
+   {
+      //
+   }
+}
+

Deleted: trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,198 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profile.repository;
-
-import java.net.URI;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.util.JBossObject;
-import org.jboss.util.JBossStringBuilder;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A profile implementation that uses the DeploymentRepository to store
- * deployments and admin metadata.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ProfileImpl extends JBossObject
-   implements Profile
-{
-   private ProfileKey key;
-   private String version;
-   /** The repository containing the deployment contents */
-   private DeploymentRepository repository;
-   /** Is hot deployment checking enabled */
-   private volatile boolean hotdeployEnabled;
-
-   /**
-    * 
-    * @param repository the repository
-    * @param key the key
-    */
-   public ProfileImpl(DeploymentRepository repository, ProfileKey key)
-   {
-      this.key = key;
-      this.repository = repository;
-      log.info("Using repository:"+repository);
-   }
-
-   public String getName()
-   {
-      return key.getName();
-   }
-
-   public ProfileKey getKey()
-   {
-      return key;
-   }
-
-   public String getVersion()
-   {
-      return version;
-   }
-
-   
-   public long getLastModified()
-   {
-      return repository.getLastModified();
-   }
-
-   /**
-    * Get the names of the deployments in the profile
-    * @return names of deployments
-    */
-   public Set<String> getDeploymentNames()
-   {
-      return repository.getDeploymentNames();
-   }
-   public Set<String> getDeploymentNames(DeploymentPhase phase)
-   {
-      return repository.getDeploymentNames(phase);
-   }
-
-   public VirtualFile getRootFile(DeploymentPhase phase)
-      throws Exception
-   {
-      URI uri = repository.getDeploymentURI(phase);
-      return VFS.getRoot(uri);
-   }
-
-   public Collection<VFSDeployment> getDeployments(DeploymentPhase phase)
-      throws Exception
-   {
-      return repository.getDeployments(phase);
-   }
-   public Collection<VFSDeployment> getDeployments()
-      throws Exception
-   {
-      return repository.getDeployments();
-   }
-
-   /**
-    * 
-    */
-   public Collection<ModificationInfo> getModifiedDeployments()
-      throws Exception
-   {
-      Collection<ModificationInfo> modified = Collections.emptyList();
-      if( hotdeployEnabled == true )
-         modified = repository.getModifiedDeployments();
-      return modified;
-   }
-   /**
-    * Enable/disable getModifiedDeployments results.
-    */
-   public synchronized void enableModifiedDeploymentChecks(boolean flag)
-   {
-      this.hotdeployEnabled = flag;
-   }
-
-   public void addDeployment(VFSDeployment d, DeploymentPhase phase)
-       throws Exception
-   {
-      String name = d.getName();
-      repository.addDeployment(name, d, phase);
-   }
-   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
-         ManagedComponent mo)
-       throws Exception
-   {
-      repository.updateDeployment(d, phase, mo);
-   }
-   public VFSDeployment getDeployment(String name, DeploymentPhase phase)
-       throws Exception, NoSuchDeploymentException
-   {
-      return repository.getDeployment(name, phase);
-   }
-   public VFSDeployment removeDeployment(String name, DeploymentPhase phase)
-      throws Exception
-   {
-      return repository.removeDeployment(name, phase);
-   }
-
-   public Map<String, Object> getConfig()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-   
-   public boolean hasDeployment(String name, DeploymentPhase phase)
-   {
-      // TODO: Wolf: needs refactoring / review
-      try
-      {
-         getDeployment(name, phase);
-         return true;
-      }
-      catch(NoSuchDeploymentException e)
-      {
-         return false;
-      }
-      catch(Exception e)
-      {
-         log.warn("getDeployment return exception", e);
-         return false;
-      }
-   }
-
-   @Override
-   protected void toString(JBossStringBuilder buffer)
-   {
-      buffer.append("key=");
-      buffer.append(this.key);
-   }
-   
-}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/DeploymentPhaseVFSScanner.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/DeploymentPhaseVFSScanner.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/DeploymentPhaseVFSScanner.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -31,6 +31,7 @@
  *
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  */
+ at Deprecated
 public abstract class DeploymentPhaseVFSScanner extends VFSScanner
 {
    private ManagedDeployment.DeploymentPhase phase;
@@ -45,13 +46,13 @@
    protected VFSDeployment add(Profile profile, VirtualFile file) throws Exception
    {
       VFSDeployment deployment = createDeployment(file);
-      if(profile.hasDeployment(deployment.getName(), phase) == false)
-         profile.addDeployment(deployment, phase);
+      if(profile.hasDeployment(deployment.getName()) == false)
+         profile.addDeployment(deployment);
       return deployment;
    }
 
    protected void remove(Profile profile, String name) throws Exception
    {
-      profile.removeDeployment(name, phase);
+      profile.removeDeployment(name);
    }
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -22,10 +22,10 @@
 package org.jboss.system.server.profileservice;
 
 import java.lang.annotation.Annotation;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -39,22 +39,18 @@
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.deployers.client.spi.IncompleteDeploymentException;
 import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.plugins.main.MainDeployerImpl;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.managed.ManagedDeploymentCreator;
 import org.jboss.deployers.spi.management.KnownComponentTypes;
-import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
 import org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer.KernelDeploymentVisitor;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.kernel.spi.deployment.KernelDeployment;
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.api.MutableManagedObject;
@@ -70,16 +66,19 @@
 import org.jboss.metatype.api.values.ArrayValueSupport;
 import org.jboss.metatype.api.values.EnumValue;
 import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.profileservice.spi.types.ControllerStateMetaType;
+import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
 
 /**
  * Bootstraps the profile service
  * 
  * @author Scott.Stark at jboss.org
  * @author adrian at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
 public class ProfileServiceBootstrap implements Bootstrap
@@ -89,6 +88,8 @@
    
    /** The name of the profile that is being booted */
    protected String profileName = "default";
+   
+   protected ProfileKey profileKey;
 
    /** The server MainDeployer */
    protected MainDeployer mainDeployer;
@@ -102,6 +103,8 @@
    private ManagedObjectFactory mof;
    /** The ManagedDeployment map for the MCServer KernelDeployments */
    private Map<String, ManagedDeployment> bootstrapMDs = new HashMap<String, ManagedDeployment>();
+   /** The profile factory */
+   private AbstractProfileFactory profileFactory; 
 
    /** Whether we are shutdown */
    private AtomicBoolean shutdown = new AtomicBoolean(false);
@@ -168,6 +171,16 @@
       this.mgtDeploymentCreator = mgtDeploymentCreator;
    }
 
+   public AbstractProfileFactory getProfileFactory()
+   {
+      return profileFactory;
+   }
+   
+   public void setProfileFactory(AbstractProfileFactory profileFactory)
+   {
+      this.profileFactory = profileFactory;
+   }
+   
    public Map<String, ManagedDeployment> getBootstrapMDs()
    {
       return bootstrapMDs;
@@ -198,11 +211,23 @@
       // Expose the bootstrap ManagedDeployments
       initBootstrapMDs(server);
 
-      // Load the profile beans
+      // Load the profile
+      profileName = server.getConfig().getServerName();
+      this.profileKey = new ProfileKey(profileName);
+      
+      List<Profile> bootstrapProfiles = profileFactory.createProfiles(server);
+      for(Profile profile : bootstrapProfiles)
+      {
+         profileService.registerProfile(profile);
+      }
+      
+      // Activate the root profile
+      profileService.activateProfile(this.profileKey);
+      
       try
       {
-         profileName = server.getConfig().getServerName();
-         loadProfile(profileName);
+         // Check if everything is complete
+         mainDeployer.checkComplete();
       }
       catch (IncompleteDeploymentException e)
       {
@@ -213,9 +238,9 @@
          log.error("Failed to load profile: ", e);
       }
       // Mark the profile as ready for hotdeployment if supported
-      Profile profile = profileService.getActiveProfile();
-      if( profile != null )
-         profile.enableModifiedDeploymentChecks(true);
+      Profile activeProfile = profileService.getActiveProfile(profileKey);
+      if( activeProfile != null )
+         activeProfile.enableModifiedDeploymentChecks(true);
    }
 
    public void prepareShutdown(Server server)
@@ -227,195 +252,62 @@
 
    public void shutdown(Server server)
    {
-      unloadProfile(profileName);
       try
       {
-         mainDeployer.shutdown();
+         // Release 
+         profileService.releaseProfile(profileKey);
       }
-      catch (Throwable t)
+      catch(Throwable t)
       {
-         log.warn("Error shutting down the main deployer", t);
+         log.warn("Error unloading profile: " + this.profileKey, t);
       }
-   }
-
-   /**
-    * Load the deployments associated with the named profile and deploy them
-    * using the MainDeployer.
-    * 
-    * @param name
-    * @throws Exception for any error
-    * @throws NullPointerException if either the MainDeployer or ProfileService
-    * have not been injected.
-    */
-   protected void loadProfile(String name) throws Exception
-   {
-      MainDeployer deployer = getMainDeployer();
-      if (deployer == null)
-         throw new NullPointerException("MainDeployer has not been set");
-      ProfileService ps = getProfileService();
-      if (ps == null)
-         throw new NullPointerException("ProfileService has not been set");
-
-      // Load the named profile
-      ProfileKey key = new ProfileKey(name);
-      Profile profile = ps.getProfile(key);
-
-      // HACK
-      VFSDeployment first = null;
-      
-      // Deploy the profile bootstrap deployments
-      Collection<VFSDeployment> boostraps = profile.getDeployments(DeploymentPhase.BOOTSTRAP);
-      for (VFSDeployment d : boostraps)
-      {
-         deployer.addDeployment(d);
-         if (first == null)
-            first = d;
-      }
-      deployer.process();
-      deployer.checkComplete();
-
-      Thread thread = Thread.currentThread();
-      ClassLoader old = thread.getContextClassLoader();
-      // FIXME remove this hack
-      MainDeployerStructure hack = (MainDeployerStructure) deployer;
-      ClassLoader cl = null;
-      if (first != null)
-      {
-         DeploymentContext ctx = hack.getDeploymentContext(first.getName());
-         if (ctx != null)
-            cl = ctx.getClassLoader();
-      }
-      //if (cl != null)
-      //   thread.setContextClassLoader(cl);
       try
       {
-         
-         // Deploy the profile deployers
-         Collection<VFSDeployment> profileDeployers = profile.getDeployments(DeploymentPhase.DEPLOYER);
-         for (VFSDeployment d : profileDeployers)
-            deployer.addDeployment(d);
-         deployer.process();
-         deployer.checkComplete();
-
-         // Deploy the profile applications
-         Collection<VFSDeployment> profileDeployments = profile.getDeployments(DeploymentPhase.APPLICATION);
-         for (VFSDeployment d : profileDeployments)
-            deployer.addDeployment(d);
-         deployer.process();
-         deployer.checkComplete();
+         // Unregister
+         Profile profile = profileService.getProfile(profileKey);
+         profileService.unregisterProfile(profile);
       }
-      finally
+      catch(Throwable t)
       {
-         thread.setContextClassLoader(old);
+         log.warn("Error unloading profile: " + this.profileKey, t);         
       }
-   }
-
-   /**
-    * Unload the deployments associated with the named profile and undeploy them
-    * using the MainDeployer in reverse phase order.
-    * 
-    * @param name the profile name
-    * @throws NullPointerException if either the MainDeployer or ProfileService
-    * have not been injected.
-    */
-   protected void unloadProfile(String name)
-   {
-      MainDeployer deployer = getMainDeployer();
-      if (deployer == null)
+      
+      // FIXME we should release other active profiles in the correct order
+      for(ProfileKey key : profileService.getActiveProfileKeys())
       {
-         log.warn("MainDeployer has not been set");
-         return;
-      }
-      ProfileService ps = getProfileService();
-      if (ps == null)
-      {
-         log.warn("ProfileService has not been set");
-         return;
-      }
-
-      try
-      {
-         // Load the named profile
-         ProfileKey key = new ProfileKey(name);
-         Profile profile = ps.getProfile(key);
-
-         // HACK
-         VFSDeployment first = null;
-         
-         // Deploy the bootstrap
-         Collection<VFSDeployment> boostraps = profile.getDeployments(DeploymentPhase.BOOTSTRAP);
-         for (VFSDeployment d : boostraps)
+         try
          {
-            if (first == null)
-            {
-               first = d;
-               break;
-            }
+            // Release
+            profileService.releaseProfile(key);
          }
-
-         Thread thread = Thread.currentThread();
-         ClassLoader old = thread.getContextClassLoader();
-         // FIXME remove this hack
-         MainDeployerImpl hack = (MainDeployerImpl) deployer;
-         ClassLoader cl = null;
-         if (first != null)
+         catch(NoSuchProfileException e)
          {
-            try
-            {
-               DeploymentContext ctx = hack.getDeploymentContext(first.getName());
-               if (ctx != null)
-                  cl = ctx.getClassLoader();
-            }
-            catch (Exception e)
-            {
-               log.debug("Unable to get first deployment", e);
-            }
+            // ignore
          }
-         //if (cl != null)
-         //   thread.setContextClassLoader(cl);
+         catch(Throwable t)
+         {
+            log.warn("Error unloading profile: " + this.profileKey, t);
+         }
          try
          {
-            // Undeploy the applications
-            unload(deployer, profile.getDeployments(DeploymentPhase.APPLICATION));
-            // Undeploy the deployers
-            unload(deployer, profile.getDeployments(DeploymentPhase.DEPLOYER));
-            // Undeploy the bootstrap
-            unload(deployer, profile.getDeployments(DeploymentPhase.BOOTSTRAP));
+            // Unregister
+            Profile profile = profileService.getProfile(key);
+            profileService.unregisterProfile(profile);
          }
-         finally
+         catch(Throwable t)
          {
-            thread.setContextClassLoader(old);
+            // Ignore
          }
       }
-      catch (Throwable t)
+      
+      try
       {
-         log.warn("Error unloading profile", t);
+         mainDeployer.shutdown();
       }
-   }
-
-   /**
-    * Unload a set of deployments
-    * 
-    * @param deployer the main deployer
-    * @param deployments the deployments
-    */
-   protected void unload(MainDeployer deployer, Collection<VFSDeployment> deployments)
-   {
-      if (deployments == null || deployments.isEmpty())
-         return;
-      
-      for (VFSDeployment d : deployments)
+      catch (Throwable t)
       {
-         try
-         {
-            deployer.removeDeployment(d);
-         }
-         catch (Exception e)
-         {
-            log.warn("Unable to remove deployment: " + d);
-         }
+         log.warn("Error shutting down the main deployer", t);
       }
-      deployer.process();
    }
 
    /**

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/VFSBootstrapScannerImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/VFSBootstrapScannerImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/VFSBootstrapScannerImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.system.server.profileservice;
-
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-
-/**
- * VFSBootstrapScannerImpl.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class VFSBootstrapScannerImpl extends DeploymentPhaseVFSScanner
-{
-   public VFSBootstrapScannerImpl()
-   {
-      super(DeploymentPhase.BOOTSTRAP);
-   }
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeployerScannerImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeployerScannerImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeployerScannerImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.system.server.profileservice;
-
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-
-/**
- * VFSDeployerScannerImpl.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class VFSDeployerScannerImpl extends DeploymentPhaseVFSScanner
-{
-   public VFSDeployerScannerImpl()
-   {
-      super(DeploymentPhase.DEPLOYER);
-   }
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeploymentScannerImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeploymentScannerImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeploymentScannerImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.system.server.profileservice;
-
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-
-/**
- * VFSDeploymentScannerImpl.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class VFSDeploymentScannerImpl extends DeploymentPhaseVFSScanner
-{
-   public VFSDeploymentScannerImpl()
-   {
-      super(DeploymentPhase.APPLICATION);
-   }
-}
-

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/attachments/LazyPredeterminedManagedObjects.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/attachments/LazyPredeterminedManagedObjects.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/attachments/LazyPredeterminedManagedObjects.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -27,9 +27,9 @@
 
 import org.jboss.deployers.spi.attachments.AttachmentsFactory;
 import org.jboss.deployers.spi.attachments.MutableAttachments;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
 import org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
 
 /**
  * Basic wrapper for MutableAttachmets. This maintains a list of associated
@@ -47,7 +47,7 @@
    private final MutableAttachments delegate;
    
    /** The attachmentsSerializer. */
-   private final AttachmentsSerializer serializer;
+   private final AbstractFileAttachmentsSerializer serializer;
    
    /** The relative path. */
    private final String relativePath;
@@ -55,7 +55,7 @@
    /** The available attachments. */
    private final Collection<String> attachments;
    
-   public LazyPredeterminedManagedObjects(AttachmentsSerializer serializer, String relativePath, Collection<String> attachments)
+   public LazyPredeterminedManagedObjects(AbstractFileAttachmentsSerializer serializer, String relativePath, Collection<String> attachments)
    {
       if(serializer == null)
          throw new IllegalArgumentException("serializer may not be null;");

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -34,9 +34,9 @@
 import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 
 /**
@@ -51,6 +51,7 @@
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  * @author Scott.Stark at jboss.org
  * @author adrian at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
 public class HDScanner
@@ -247,42 +248,62 @@
       if( trace )
          log.trace("Begin deployment scan");
 
-      
-      // Get the modified deployments
-      Profile activeProfile = profileService.getActiveProfile();
-      if( activeProfile == null )
+      // Get the active profiles
+      Collection<ProfileKey> activeProfiles = profileService.getActiveProfileKeys();
+      if(activeProfiles == null || activeProfiles.isEmpty())
       {
          if( trace )
-            log.trace("End deployment scan, no activeProfile");
+            log.trace("End deployment scan, no active profiles");
          return;
       }
+      // Current workaround for JBAS-4206
+      Profile firstProfile = null;
 
-      Collection<ModificationInfo> modified = activeProfile.getModifiedDeployments();
-      for(ModificationInfo info : modified)
+      // Get the modified deployments
+      boolean modified = false;
+      for(ProfileKey key : activeProfiles)
       {
-         VFSDeployment ctx = info.getDeployment();
-         switch( info.getStatus() )
+         Profile activeProfile = profileService.getActiveProfile(key);
+         if( activeProfile == null )
          {
-            case ADDED:
-               mainDeployer.addDeployment(ctx);
-               break;
-            case MODIFIED:
-               mainDeployer.addDeployment(ctx);
-               break;
-            case REMOVED:
-               mainDeployer.removeDeployment(ctx.getName());
-               break;
+            if( trace )
+               log.trace("End deployment scan, no activeProfile");
+            return;
          }
+         // Current workaround for JBAS-4206
+         if(firstProfile == null)
+            firstProfile = activeProfile;
+
+         Collection<ModificationInfo> modifiedDeployments = activeProfile.getModifiedDeployments();
+         for(ModificationInfo info : modifiedDeployments)
+         {
+            VFSDeployment ctx = info.getDeployment();
+            switch( info.getStatus() )
+            {
+               case ADDED:
+                  mainDeployer.addDeployment(ctx);
+                  break;
+               case MODIFIED:
+                  mainDeployer.addDeployment(ctx);
+                  break;
+               case REMOVED:
+                  mainDeployer.removeDeployment(ctx.getName());
+                  break;
+            }
+         }
+         
+         if(modifiedDeployments.size() > 0)
+            modified = true;
       }
 
       // Process the changes
       try
       {
-         if( modified.size() > 0 )
+         if( modified )
          {
             // Current workaround for JBAS-4206
             ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
-            ClassLoader tcl = getTCL(activeProfile);
+            ClassLoader tcl = getTCL(firstProfile);
             try
             {
                if (tcl != null)
@@ -304,6 +325,7 @@
          // TODO: somehow need to ignore bad deployments to avoid repeated errors
          return;
       }
+      
 
       if( trace )
          log.trace("End deployment scan");
@@ -328,7 +350,7 @@
       throws Exception
    {
       MainDeployerStructure structure = (MainDeployerStructure) mainDeployer;
-      Collection<VFSDeployment> ctxs = activeProfile.getDeployments(DeploymentPhase.BOOTSTRAP);
+      Collection<VFSDeployment> ctxs = activeProfile.getDeployments();
       if (ctxs != null && ctxs.isEmpty() == false)
       {
          for (VFSDeployment deployment : ctxs)

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -24,6 +24,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -47,8 +48,7 @@
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.profileservice.spi.AttachmentStore;
 import org.jboss.system.server.profileservice.attachments.AttachmentMetaData;
 import org.jboss.system.server.profileservice.attachments.DeploymentClassPathMetaData;
 import org.jboss.system.server.profileservice.attachments.DeploymentStructureMetaData;
@@ -65,11 +65,13 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public abstract class AbstractAttachmentStore
+public class AbstractAttachmentStore implements AttachmentStore
 {
+   /** The attachment store root. */
+   private final URI attatchmentStoreRoot;
 
    /** The attachment serializer. */
-   protected AttachmentsSerializer serializer;
+   protected AbstractFileAttachmentsSerializer serializer;
    
    /** The deployment factory. */
    protected VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
@@ -86,6 +88,18 @@
    /** The logger. */
    private static final Logger log = Logger.getLogger(AbstractAttachmentStore.class);
    
+   public AbstractAttachmentStore(URI uri)
+   {
+      if(uri == null)
+         throw new IllegalArgumentException("Null uri");
+      this.attatchmentStoreRoot = uri;
+   }
+   
+   public URI getAttachmentStoreRoot()
+   {
+      return this.attatchmentStoreRoot;
+   }
+   
    public VFSDeploymentFactory getDeploymentFactory()
    {
       return deploymentFactory;
@@ -106,12 +120,12 @@
       this.mainDeployer = mainDeployer;
    }
    
-   public AttachmentsSerializer getSerializer()
+   public AbstractFileAttachmentsSerializer getSerializer()
    {
       return serializer;
    }
    
-   public void setSerializer(AttachmentsSerializer serializer)
+   public void setSerializer(AbstractFileAttachmentsSerializer serializer)
    {
       this.serializer = serializer;
    }
@@ -123,7 +137,7 @@
     * @param phase the deployment phase
     * @return the VFSDeployment
     */
-   protected VFSDeployment loadDeploymentData(VirtualFile file, DeploymentPhase phase) throws Exception
+   public VFSDeployment loadDeploymentData(VirtualFile file) throws Exception
    {
       if(file == null)
          throw new IllegalArgumentException("Cannot create a deployment for a null file.");
@@ -205,7 +219,7 @@
     * @param comp the managed component.
     * @throws Exception
     */
-   protected void updateDeployment(VFSDeployment deployment, DeploymentPhase phase, ManagedComponent comp)
+   public void updateDeployment(VFSDeployment deployment, ManagedComponent comp)
       throws Exception
    {
       if(deployment ==  null)

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,372 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.profileservice.spi.AttachmentStore;
+import org.jboss.profileservice.spi.DeploymentContentFlags;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * A abstract VFS based deployment repository.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractDeploymentRepository implements DeploymentRepository
+{
+   
+   /** The associated profile key. */
+   private ProfileKey key;
+   
+   /** The repository uris. */
+   protected final Collection<URI> uris;
+
+   /** The VFSDeployments. */
+   private Map<String, VFSDeployment> applicationCtxs = new ConcurrentHashMap<String, VFSDeployment>();
+   
+   /** The content flags. */
+   private Map<String, Integer> contentFlags = new ConcurrentHashMap<String, Integer>();
+   
+   /** Allowed deployments filter. */
+   private VirtualFileFilter deploymentFilter;
+   
+   /** The application phase deployment files keyed by VirtualFile URI string. */
+   private final Map<String, VirtualFile> applicationVFCache = new HashMap<String, VirtualFile>();
+   
+   /** The attachmentStore. */
+   private AttachmentStore attachmentStore;
+
+   /** The last time the profile was modified. */
+   private volatile long lastModified;
+   
+   /** The logger. */
+   protected final Logger log = Logger.getLogger(getClass());
+   
+   public AbstractDeploymentRepository(ProfileKey key, URI[] uris)
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(uris == null)
+         throw new IllegalArgumentException("Null uris");
+      
+      this.key = key;
+      this.uris = new ArrayList<URI>();
+      for(URI uri : uris)
+      {
+         this.uris.add(uri);
+      }
+   }
+   
+   public ProfileKey getProfileKey()
+   {
+      return this.key;
+   }
+   
+   public AttachmentStore getAttachmentStore()
+   {
+      return attachmentStore;
+   }
+   
+   public void setAttachmentStore(AttachmentStore attachmentStore)
+   {
+      this.attachmentStore = attachmentStore;
+   }
+
+   public VirtualFileFilter getDeploymentFilter()
+   {
+      return deploymentFilter;
+   }
+   
+   public void setDeploymentFilter(VirtualFileFilter deploymentFilter)
+   {
+      this.deploymentFilter = deploymentFilter;
+   }
+   
+   public URI[] getRepositoryURIs()
+   {
+      return uris.toArray(new URI[uris.size()]);
+   }
+   
+   public void create() throws Exception
+   {
+      if(this.attachmentStore == null)
+         throw new IllegalStateException("Null attachment store.");
+   }
+   
+   public void addDeployment(String vfsPath, VFSDeployment d) throws Exception
+   {
+      this.applicationCtxs.put(vfsPath, d);
+      updateLastModfied();
+   }
+   
+   public VFSDeployment removeDeployment(String vfsPath) throws Exception
+   {
+      VFSDeployment deployment = this.applicationCtxs.remove(vfsPath);
+      if(deployment != null)
+         updateLastModfied();
+      return deployment;
+   }
+   
+   /**
+    * Load all the applications under the applicationDir.
+    * 
+    * @param applicationDir the application directory
+    * @throws IOException
+    */
+   protected void loadApplications(VirtualFile applicationDir) throws Exception
+   {
+      ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
+      addedDeployments(added, applicationDir);
+      for (VirtualFile vf : added)
+      {
+         VFSDeployment vfCtx = loadDeploymentData(vf);
+         addDeployment(vfCtx.getName(), vfCtx);
+      }
+   }
+   
+   protected void addedDeployments(List<VirtualFile> list, VirtualFile root) throws IOException, URISyntaxException
+   {
+      if(root.isLeaf())
+      {
+         addedDeployment(list, root);
+      }
+      else
+      {
+         List<VirtualFile> components = root.getChildren();
+         for (VirtualFile component : components)
+         {
+            addedDeployment(list, component);
+         }         
+      }
+   }
+   
+   protected void addedDeployment(List<VirtualFile> list, VirtualFile component) throws IOException, URISyntaxException
+   {
+      // Excluding files from scanning
+      if(deploymentFilter != null && ! this.deploymentFilter.accepts(component))
+      {
+         if(log.isTraceEnabled())
+            log.trace("ignoring "+ component);
+         return;
+      }
+      
+      String key = component.toURI().toString();
+      if (applicationCtxs.containsKey(key) == true)
+         return;
+
+      if (component.isLeaf())
+      {
+         list.add(component);
+      }
+      else if (component.getName().indexOf('.') == -1)
+      {
+         // recurse if not '.' in name and recursive search is enabled
+         addedDeployments(list, component);
+      }
+      else
+      {
+         list.add(component);
+      }      
+   }
+
+   public VFSDeployment getDeployment(String vfsPath) throws NoSuchDeploymentException
+   {
+      boolean trace = log.isTraceEnabled();
+      VFSDeployment ctx = this.applicationCtxs.get(vfsPath);
+      // TODO should a lookup of the simple name really be done here ? 
+      if(ctx == null)
+      {
+         // Try to find the simple name
+         if(trace)
+            log.trace("Failed to find application for: "+vfsPath+", scanning for simple name");
+         for(VFSDeployment deployment : applicationCtxs.values())
+         {
+            if(trace)
+               log.trace("Checking: "+deployment.getSimpleName());
+            if(deployment.getSimpleName().equals(vfsPath))
+            {
+               if(trace)
+                  log.trace("Matched to simple name of deployment:"+deployment);
+               ctx = deployment;
+               break;
+            }
+         }
+         if(ctx == null)
+         {
+            log.debug("Failed to find application for: "+vfsPath+", available: " + applicationCtxs.values());
+            throw new NoSuchDeploymentException(vfsPath);
+         }
+      }
+      return ctx;
+   }
+
+   public Set<String> getDeploymentNames()
+   {
+      return this.applicationCtxs.keySet();
+   }
+
+   public Collection<VFSDeployment> getDeployments()
+   {
+      return this.applicationCtxs.values();
+   }
+
+   public long getLastModified()
+   {
+      return this.lastModified;
+   }
+
+   public VirtualFile getDeploymentContent(String name) throws IOException, URISyntaxException
+   {
+      for(URI uri : this.uris)
+      {
+         VirtualFile root = getCachedVirtualFile(uri);
+         VirtualFile vf = root.getChild(name);
+         if(vf != null)
+            return vf;
+      }
+      throw new FileNotFoundException("Failed to content in profile: "+ key + " filename: " + name);
+   }
+   
+   public String[] getRepositoryNames(String[] names) throws IOException
+   {
+      if(names == null)
+         throw new IllegalArgumentException("Null names[]");
+      Collection<String> tmp = new HashSet<String>();
+      for(URI uri : this.uris)
+      {
+         VirtualFile root = getCachedVirtualFile(uri);
+         for(String name : names)
+         {
+            VirtualFile vf = root.getChild(name);
+            try
+            {
+               String content = vf.toURI().toString();
+               tmp.add(content);
+            }
+            catch(URISyntaxException e)
+            {
+               log.error("Should not happen", e);
+            }
+         }
+      }
+      return tmp.toArray(new String[tmp.size()]);
+   }
+
+   public int lockDeploymentContent(String vfsPath)
+   {
+      if( log.isTraceEnabled() )
+         log.trace("lockDeploymentContent, "+vfsPath);
+      return setDeploymentContentFlags(vfsPath, DeploymentContentFlags.LOCKED);
+   }
+
+   public int unlockDeploymentContent(String vfsPath)
+   {
+      if( log.isTraceEnabled() )
+         log.trace("unlockDeploymentContent, "+vfsPath);
+      return clearDeploymentContentFlags(vfsPath, DeploymentContentFlags.LOCKED);
+   }
+
+   public int getDeploymentContentFlags(String vfsPath)
+   {
+      Integer flags = contentFlags.get(vfsPath);
+      return flags != null ? flags : 0;
+   }
+   public synchronized int clearDeploymentContentFlags(String vfsPath, int flags)
+   {
+      Integer dflags = contentFlags.get(vfsPath);
+      if(dflags != null)
+      {
+         dflags &= ~flags;
+         contentFlags.put(vfsPath, dflags);
+      }
+      return dflags != null ? dflags : 0;
+   }
+   public boolean hasDeploymentContentFlags(String vfsPath, int flag)
+   {
+      Integer flags = contentFlags.get(vfsPath);
+      boolean hasFlag = false;
+      if(flags != null )
+         hasFlag = (flags & flag) != 0;
+      return hasFlag;
+   }
+   public int setDeploymentContentFlags(String vfsPath, int flags)
+   {
+      contentFlags.put(vfsPath, flags);
+      return flags;
+   }
+
+   protected VFSDeployment loadDeploymentData(VirtualFile vf) throws Exception
+   {
+      return attachmentStore.loadDeploymentData(vf);
+   }
+   
+   public void updateDeployment(VFSDeployment d, ManagedComponent comp) throws Exception
+   {
+      if(d == null)
+         throw new IllegalArgumentException("Null deployment");
+
+      if(comp != null)
+      {
+         // update component
+         attachmentStore.updateDeployment(d, comp);
+         // Update last modified
+         updateLastModfied();
+      }
+   }
+
+   protected VirtualFile getCachedVirtualFile(URI uri) throws IOException 
+   {
+      VirtualFile vf = this.applicationVFCache.get(uri.toString());
+      if(vf == null)
+      {
+         vf = VFS.getCachedFile(uri);
+         this.applicationVFCache.put(uri.toString(), vf);
+      }
+      return vf;
+   }
+   
+   protected void updateLastModfied()
+   {
+      this.lastModified = System.currentTimeMillis();
+   }
+}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -24,18 +24,18 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.NotSerializableException;
+import java.net.URI;
 
 import org.jboss.logging.Logger;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
 
 /**
  * A base AttachmentsSerializer that uses a file system based store.
  * 
  * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision:$
  */
 public abstract class AbstractFileAttachmentsSerializer
-   implements AttachmentsSerializer
 {
    private static final Logger log = Logger.getLogger(AbstractFileAttachmentsSerializer.class);
    
@@ -43,16 +43,19 @@
    private static final String ATTACHMENT_SUFFIX = ".attachment";
    
    /** The deployment pre-processed attachments store dir */
-   private File attachmentsStoreDir;
+   private final File attachmentsStoreDir;
 
+   public AbstractFileAttachmentsSerializer(URI uri)
+   {
+      if(uri == null)
+         throw new IllegalArgumentException("Null uri");
+      this.attachmentsStoreDir = new File(uri.toString());
+   }
+   
    public File getAttachmentsStoreDir()
    {
       return attachmentsStoreDir;
    }
-   public void setAttachmentsStoreDir(File attachmentsStoreDir)
-   {
-      this.attachmentsStoreDir = attachmentsStoreDir;
-   }
    
    public <T> T loadAttachment(String baseName, Class<T> expected)
       throws Exception

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,279 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+import org.jboss.system.server.profile.repository.AbstractProfile;
+
+/**
+ * The abstract profile factory.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractProfileFactory
+{
+
+   /** The profile map. */
+   private Map<ProfileKey, ProfileMetaData> profileMap = new HashMap<ProfileKey, ProfileMetaData>();
+   
+   /** The profiles map. */
+   private Map<ProfileKey, List<ProfileMetaData>> profilesMetaData = new HashMap<ProfileKey, List<ProfileMetaData>>();
+   
+   /** The deployment repository factory. */
+   private ProfileRepository profileRepository;
+
+   public ProfileRepository getProfileRepository()
+   {
+      return profileRepository;
+   }
+   
+   public void setProfileRepository(ProfileRepository profileRepository)
+   {
+      this.profileRepository = profileRepository;
+   }
+   
+   public ProfileMetaData getProfileMetaData(ProfileKey key)
+   {
+      return this.profileMap.get(key);
+   }
+   
+   /**
+    * Create the profile meta data.
+    * 
+    * @param server The Server.
+    * @throws Exception
+    */
+   protected abstract void createProfileMetaData(Server server) throws Exception;
+   
+   /**
+    * Create a list of profiles, based on the profile meta data.
+    * 
+    * @param server the Server.
+    * @return a list of profiles.
+    * @throws Exception
+    */
+   public List<Profile> createProfiles(Server server) throws Exception
+   {
+      // Create the metadata
+      createProfileMetaData(server);
+      List<Profile> profiles = new ArrayList<Profile>();
+
+      // Create profiles for all known stuff
+      // TODO should we maybe base this just on a profileKey ?
+      for(ProfileKey key : profileMap.keySet())
+      {
+         ProfileMetaData metaData = profileMap.get(key);
+         Profile profile = createProfile(key, metaData);
+         profiles.add(profile);
+      }      
+      return profiles;
+   }
+   
+   /**
+    * Create a single profile based on the profile meta data.
+    * All sub-profiles need to be registered previously as we try to resolve
+    * and generate all dependencies for this profile.
+    * 
+    * @param key the ProfileKey.
+    * @param metaData the profile meta data.
+    * @return the profile.
+    * @throws Exception
+    */
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(metaData == null)
+         throw new IllegalArgumentException("Null profile metaData");
+      
+      DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, metaData);
+      
+      // Create profile
+      AbstractProfile profile = new AbstractProfile(repository, key);
+      
+      // Create dependencies
+      List<DependencyItem> dependencies = new ArrayList<DependencyItem>();
+      // Profile dependencies
+      createSubProfileDependencies(dependencies, key, metaData);
+      // TODO other service dependencies ?
+      // createDependencies(dependencies, key, metaData);
+      profile.setDependencies(dependencies);
+
+      return profile;
+   }
+   
+   /**
+    * Create some dependencies to other profiles based on the sub profile meta data.
+    * 
+    * @param dependencies the dependency list.
+    * @param key the profile key.
+    * @param metaData the profile meta data.
+    */
+   protected void createSubProfileDependencies(List<DependencyItem> dependencies, ProfileKey key, ProfileMetaData metaData)
+   {
+      if(metaData.getSubprofiles() != null && ! metaData.getSubprofiles().isEmpty())
+      {
+         for(SubProfileMetaData subProfile : metaData.getSubprofiles())
+         {
+            ProfileKey IDependOn = new ProfileKey(subProfile.getDomain(), subProfile.getServer(), subProfile.getName());
+            // If it's a reference to a <profile>
+            if(this.profileMap.containsKey(IDependOn))
+            {
+               dependencies.add(createDependencyItem(key, IDependOn));
+            }
+            // Reference to <profiles> with more <profile>
+            else if(this.profilesMetaData.containsKey(IDependOn))
+            {
+               List<ProfileMetaData> subProfileList = this.profilesMetaData.get(IDependOn);
+               createSubProfilesDependencies(dependencies, key, subProfileList);
+            }
+            else
+            {
+               throw new IllegalStateException("Cannot not resolve profile: "+ IDependOn);
+            }
+         }
+      }
+   }
+   
+   /**
+    * Create dependencies based on the profile dependencies list.
+    * 
+    * @param dependencies the dependency list.
+    * @param key the profile key.
+    * @param metaData the profile meta data.
+    */
+   protected void createDependencies(List<DependencyItem> dependencies, ProfileKey key, ProfileMetaData metaData)
+   {
+      // TODO maybe service dependencies with ParentLookup ?
+      if(metaData.getDependencies() != null && metaData.getDependencies().isEmpty() == false)
+      {
+         for(Object dependency : metaData.getDependencies())
+         {
+            DependencyItem item = createDependencyItem(key, dependency);
+            dependencies.add(item);
+         }
+      }
+   }
+   
+   /**
+    * Create the dependencies if the sub-profile references to <profiles/>
+    * where it can contain more sub-profiles as a dependency. 
+    * 
+    * @param dependencies the dependency list.
+    * @param key the profile key.
+    * @param subProfileList a list of profiles.
+    */
+   protected void createSubProfilesDependencies(List<DependencyItem> dependencies, ProfileKey key, List<ProfileMetaData> subProfileList)
+   {
+      if(subProfileList != null && subProfileList.isEmpty() == false)
+      {
+         for(ProfileMetaData subProfile : subProfileList)
+         {
+            ProfileKey IDependOn = new ProfileKey(subProfile.getDomain(), subProfile.getServer(), subProfile.getName());
+            dependencies.add(createDependencyItem(key, IDependOn));
+         }
+      }
+   }
+   
+   /**
+    * Create a DependencyItem.
+    * 
+    * @param key the profile key.
+    * @param IDependOn the Object i depend on.
+    * @return the dependency item.
+    */
+   protected DependencyItem createDependencyItem(ProfileKey key, Object IDependOn)
+   {
+      return new AbstractDependencyItem(key, IDependOn, ControllerState.PRE_INSTALL, ControllerState.INSTALLED);
+   }
+   
+   /**
+    * Add a profile.
+    * 
+    * @param key the profile key.
+    * @param metaData the profile meta data.
+    */
+   protected void addProfile(ProfileKey key, ProfileMetaData metaData)
+   {
+      // The keys have be unique
+      if(this.profileMap.containsKey(key))
+         throw new IllegalStateException("Duplicate key: " + key);
+
+      if(this.profilesMetaData.containsKey(key))
+         throw new IllegalStateException("Duplicate key: " + key);
+      
+      this.profileMap.put(key, metaData);
+   }
+   
+   /**
+    * Add a list of profile meta data which make up a profiles reference.
+    * 
+    * @param key the profile key.
+    * @param metaData a list of profile meta data.
+    */
+   protected void addProfiles(ProfileKey key, List<ProfileMetaData> metaData)
+   {
+      if(this.profileMap.containsKey(key))
+      {
+         // Ignore the default key, which gets generated for <profiles/>
+         if(ProfileKey.DEFAULT.equals(key.getDomain())
+               && ProfileKey.DEFAULT.equals(key.getServer())
+               && ProfileKey.DEFAULT.equals(key.getName()))
+         {
+            return;
+         }
+         else
+         {
+            throw new IllegalStateException("Duplicate key: " + key);  
+         }
+      }
+
+      // Create a entry for <profiles>
+      List<ProfileMetaData> profileList = this.profilesMetaData.get(key);
+      if(profileList == null)
+      {
+         profileList = new ArrayList<ProfileMetaData>();
+         this.profilesMetaData.put(key, profileList);
+      }
+      
+      if(metaData != null && metaData.isEmpty() == false)
+      {
+         profileList.addAll(metaData);
+      }
+   }
+   
+}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.Profile;
+
+/**
+ * A abstract profile lifecycle action.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractProfileLifeCycleAction
+{
+
+   /** The logger. */
+   protected final Logger log = Logger.getLogger(getClass());
+   
+   public abstract void install(Profile profile) throws Exception;
+   
+   public abstract void uninstall(Profile profile) throws Exception;
+   
+   /**
+    * Install.
+    * 
+    * @param context the profile context.
+    * @throws Exception
+    */
+   public void install(ProfileContext context) throws Exception
+   {
+      Profile profile = context.getProfile();
+      if(profile == null)
+         return;
+      
+      // Install
+      install(profile);
+   }
+   
+   /**
+    * Uninstall.
+    * 
+    * @param context the profile context.
+    */
+   public void uninstall(ProfileContext context)
+   {
+      Profile profile = context.getProfile();
+      if(profile == null)
+         return;
+    
+      try
+      {
+         // Uninstall
+         uninstall(profile);
+      }
+      catch (Throwable t)
+      {
+         log.error("Error when uninstalling profile: " + profile, t);
+      }
+   }
+   
+}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,495 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerContextActions;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.ControllerStateModel;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * The ProfileService.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractProfileService implements ProfileService, ControllerContextActions
+{
+
+   /** The registered profiles. */
+   private Map<ProfileKey, ProfileContext> registeredProfiles = new ConcurrentHashMap<ProfileKey, ProfileContext>();
+   
+   /** The active profiles. */
+   private List<ProfileKey> activeProfiles = new CopyOnWriteArrayList<ProfileKey>();
+   
+   /** The deployment manager. */
+   private DeploymentManager deploymentManager;
+   
+   /** The management view. */
+   private ManagementView managementView;
+   
+   /** The main deployer. */
+   private MainDeployer deployer;
+   
+   /** The controller. */
+   private Controller controller;
+   
+   /** The profileActions. */
+   private Map<ControllerState, AbstractProfileLifeCycleAction> profileActions = new HashMap<ControllerState, AbstractProfileLifeCycleAction>();
+   
+   /** The Logger. */
+   private final static Logger log = Logger.getLogger(AbstractProfileService.class);
+   
+   public AbstractProfileService(AbstractController controller)
+   {
+      if(controller == null)
+         throw new IllegalArgumentException("Null controller.");
+      // Create a scoped controller
+      this.controller = new ScopedProfileServiceController(controller);
+   }
+   
+   public MainDeployer getDeployer()
+   {
+      return deployer;
+   }
+   
+   public void setDeployer(MainDeployer deployer)
+   {
+      this.deployer = deployer;
+   }
+
+   public DeploymentManager getDeploymentManager()
+   {
+      return this.deploymentManager;
+   }
+   
+   public void setDeploymentManager(DeploymentManager deploymentManager)
+   {
+      this.deploymentManager = deploymentManager;
+   }
+
+   public ManagementView getViewManager()
+   {
+      return this.managementView;
+   }
+
+   public void setViewManager(ManagementView managementView)
+   {
+      this.managementView = managementView;
+   }
+   
+   public String[] getDomains()
+   {
+      // TODO do we need that ? 
+      Collection<String> domains = new ArrayList<String>();
+      for(ProfileKey key : activeProfiles)
+         domains.add(key.getDomain());
+      return domains.toArray(new String[domains.size()]);
+   }
+   
+   public String[] getProfileDeploymentNames(ProfileKey key) throws NoSuchProfileException
+   {
+      Profile profile = getActiveProfile(key);
+      Collection<String> deploymentNames = profile.getDeploymentNames();
+      return deploymentNames.toArray(new String[deploymentNames.size()]);
+   }
+
+   public Collection<ProfileKey> getProfileKeys()
+   {
+      // Make it serializable
+      List<ProfileKey> copy = new ArrayList<ProfileKey>();
+      for(ProfileKey key : this.registeredProfiles.keySet())
+         copy.add(key);
+      return copy;
+   }
+   
+   /**
+    * Obtain the registered profile for the key.
+    * 
+    * @param key - the key for the profile
+    * @return the matching profile.
+    * @throws NoSuchProfileException if there is no such profile registered.
+    */
+   public Profile getProfile(ProfileKey key) throws NoSuchProfileException
+   {
+      if(key ==  null)
+         throw new IllegalArgumentException("Null profile key.");
+      
+      ProfileContext profile = this.registeredProfiles.get(key); 
+      if(profile == null)
+         throw new NoSuchProfileException("No such profile: " + key);
+      
+      return profile.getProfile();
+   }
+   
+   public Collection<ProfileKey> getActiveProfileKeys()
+   {
+      return Collections.unmodifiableCollection(this.activeProfiles);
+   }
+   
+   /**
+    * Obtain the active profile for the key.
+    * 
+    * @param key - the key for the profile
+    * @return the matching active profile.
+    * @throws NoSuchProfileException if there is no such profile active.
+    */
+   public Profile getActiveProfile(ProfileKey key) throws NoSuchProfileException
+   {
+      ProfileContext profile = null;
+      if(this.activeProfiles.contains(key))
+      {
+         profile = (ProfileContext) controller.getInstalledContext(key);
+      }
+      if(profile == null)
+         throw new NoSuchProfileException("Profile not installed: " + key);
+      return profile.getProfile();
+   }
+   
+   /**
+    * Create the profile service actions.
+    * 
+    * @throws Exception
+    */
+   public void create() throws Exception
+   {
+      if(this.controller == null)
+         throw new IllegalStateException("Null controller.");
+      if(this.deployer == null)
+         throw new IllegalStateException("Null main deployer.");
+      
+      // FIXME
+      this.profileActions.put(ControllerState.CREATE, new ProfileCreateAction());
+      this.profileActions.put(ControllerState.START, new ProfileDeployAction(deployer));
+      this.profileActions.put(ControllerState.INSTALLED, new ProfileInstallAction());
+   }
+   
+   /**
+    * Register a Profile.
+    * 
+    * @param profile the profile.
+    * @throws Exception
+    */
+   public void registerProfile(Profile profile) throws Exception
+   {
+      if(profile == null)
+         throw new IllegalArgumentException("Null profile.");
+      
+      ProfileKey key = profile.getKey();
+      if(key == null)
+         throw new IllegalStateException("Null profile key.");
+      if(registeredProfiles.get(profile.getKey()) != null)
+         return;
+      
+      if(controller.isShutdown())
+         throw new IllegalStateException("Controller is shutdown.");
+      
+      log.debug("registering profile: " + profile);
+      ProfileContext context = new ProfileContext(profile, this);
+      try
+      {
+         controller.install(context);
+         this.registeredProfiles.put(key, context);
+      }
+      catch(Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+   
+   /**
+    * Activate a registered profile.
+    * 
+    * @param key the profile key.
+    * @throws NoSuchProfileException if there is no such profile registered. 
+    * @throws Exception
+    */
+   public void activateProfile(ProfileKey key) throws Exception
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(controller.isShutdown())
+         throw new IllegalStateException("Controller is shutdown.");
+      if(this.activeProfiles.contains(key))
+         return;
+
+      ProfileContext context = this.registeredProfiles.get(key);
+      if(context == null)
+         throw new NoSuchProfileException("No such profile: "+ key);
+
+      try
+      {
+         log.info("Activating profile: " + context.getProfile());
+         controller.change(context, ControllerState.INSTALLED);         
+      }
+      catch(Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+      
+      // Check if the profile was activated successfully 
+      validate();
+   }
+   
+   /**
+    * Check if all dependencies are satisfied and the profile was installed successfully.
+    * 
+    * @throws Exception
+    */
+   public void validate() throws Exception
+   {
+      // TODO - this should basically just validate the activated profile with it's dependencies
+      internalValidate(((AbstractController)controller).getAllContexts());
+   }
+   
+   public void install(ControllerContext context, ControllerState fromState, ControllerState toState) throws Throwable
+   {
+      if(context instanceof ProfileContext == false)
+         return;
+      // TODO
+      AbstractProfileLifeCycleAction action = this.profileActions.get(toState);
+      if(action != null)
+      {
+         action.install((ProfileContext) context);
+      }
+   }
+   
+   public void uninstall(ControllerContext context, ControllerState fromState, ControllerState toState)
+   {
+      if(context instanceof ProfileContext == false)
+         return;
+      // TODO
+      AbstractProfileLifeCycleAction action = this.profileActions.get(fromState);
+      if(action != null)
+      {
+         action.uninstall((ProfileContext) context);
+      }
+   }
+
+   /**
+    * Release the profile.
+    * 
+    * @param key the profile key.
+    * @throws NoSuchProfileException if the profile is not active.
+    */
+   public void releaseProfile(ProfileKey key) throws NoSuchProfileException
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      
+      if(this.activeProfiles.contains(key) == false)
+         throw new NoSuchProfileException("No active profile for: " + key);
+
+      if(controller.isShutdown())
+         return;
+      
+      ControllerContext context = controller.getContext(key, ControllerState.INSTALLED);
+      if(context == null)
+         throw new IllegalStateException("Profile not installed: "+ key);
+      try
+      {
+         log.debug("releasing profile: " + key);
+         controller.change(context, ControllerState.NOT_INSTALLED);
+         
+         // TODO release other not needed contexts ? 
+      }
+      catch(Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+
+   /**
+    * Unregister a profile.
+    * 
+    * @param profile
+    * @throws NoSuchProfileException if the profile is not registered.
+    */
+   public void unregisterProfile(Profile profile) throws NoSuchProfileException
+   {
+      if(profile == null)
+         throw new IllegalArgumentException("Null profile.");
+      
+      ProfileKey key = profile.getKey();
+      if(key == null)
+         throw new IllegalStateException("Null profile key.");
+      
+      if(this.activeProfiles.contains(key))
+         throw new IllegalStateException("Cannot unregister active profile: "+ key);
+      
+      if(this.registeredProfiles.containsKey(key) == false)
+         throw new NoSuchProfileException("Profile not registered: " + key);
+      
+      log.debug("unregistering profile: " + key);
+      this.registeredProfiles.remove(key);
+
+      if(controller.isShutdown())
+         return;
+      
+      controller.uninstall(key);
+   }
+   
+   protected void internalValidate(Set<ControllerContext> notInstalled) throws Exception
+   {
+      // Validate from AbstractKernelDeployer
+      if (notInstalled.isEmpty() == false)
+      {
+         for (Iterator<ControllerContext> i = notInstalled.iterator(); i.hasNext();)
+         {
+            ControllerContext context = i.next();
+            if (context.getState().equals(context.getRequiredState()))
+               i.remove();
+         }
+         if (notInstalled.isEmpty() == false)
+         {
+            HashSet<ControllerContext> errors = new HashSet<ControllerContext>();
+            HashSet<ControllerContext> incomplete = new HashSet<ControllerContext>();
+            for (ControllerContext ctx : notInstalled)
+            {
+               if (ctx.getState().equals(ControllerState.ERROR))
+                  errors.add(ctx);
+               else
+                  incomplete.add(ctx);
+            }
+            JBossStringBuilder buffer = new JBossStringBuilder();
+            buffer.append("Incompletely deployed:\n");
+            if (errors.size() != 0)
+            {
+               buffer.append("\n*** PROFILES IN ERROR: Name -> Error\n");
+               for (ControllerContext ctx : errors)
+               {
+                  buffer.append(ctx.getName()).append(" -> ").append(ctx.getError().toString()).append('\n');
+               }
+            }
+            if (incomplete.size() != 0)
+            {
+               buffer.append("\n*** PROFILES MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}\n");
+               for (ControllerContext ctx : incomplete)
+               {
+                  Object name = ctx.getName();
+                  buffer.append(name).append(" -> ");
+                  DependencyInfo dependsInfo = ctx.getDependencyInfo();
+                  Set<DependencyItem> depends = dependsInfo.getIDependOn(null);
+                  boolean first = true;
+                  for (DependencyItem item : depends)
+                  {
+                     ControllerState dependentState = item.getDependentState();
+                     if (dependentState == null)
+                        dependentState = ControllerState.INSTALLED;
+                     
+                     ControllerState otherState = null;
+                     ControllerContext other = null; 
+                     Object iDependOn = item.getIDependOn();
+
+                     if (name.equals(iDependOn) == false)
+                     {
+                        if (iDependOn != null)
+                        {
+                           other = controller.getContext(iDependOn, null);
+                           if (other != null)
+                              otherState = other.getState();
+                        }
+
+                        boolean print = true;
+                        if (otherState != null && otherState.equals(ControllerState.ERROR) == false)
+                        {
+                           ControllerStateModel states = controller.getStates();
+                           if (states.isBeforeState(otherState, dependentState) == false)
+                              print = false;
+                        }
+
+                        if (print)
+                        {
+                           if (first)
+                              first = false;
+                           else
+                              buffer.append(", ");
+
+                           buffer.append(iDependOn).append('{').append(dependentState.getStateString());
+                           buffer.append(':');
+                           if (iDependOn == null)
+                           {
+                              buffer.append("** UNRESOLVED " + item.toHumanReadableString() + " **");
+                           }
+                           else
+                           {
+                              if (other == null)
+                                 buffer.append("** NOT FOUND **");
+                              else
+                                 buffer.append(otherState.getStateString());
+                           }
+                           buffer.append('}');
+                        }
+                     }
+                  }
+                  buffer.append('\n');
+               }
+            }
+            throw new IllegalStateException(buffer.toString());
+         }
+      }
+   }
+   
+   /**
+    * A simple lifecycle action to add/remove a profile to the activeProfiles.  
+    */
+   private class ProfileInstallAction extends AbstractProfileLifeCycleAction
+   {
+      public void install(Profile profile) throws Exception
+      {
+         // activate profile
+         activeProfiles.add(profile.getKey());
+         log.debug("profile activated: " + profile);
+      }
+      public void uninstall(Profile profile)
+      {
+         // release profile
+         activeProfiles.remove(profile.getKey());
+         log.debug("releasing profile: " + profile);
+      }
+   }
+}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,118 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.net.URI;
-import java.util.Collections;
-import java.util.Map;
-
-import org.jboss.deployers.spi.attachments.Attachments;
-import org.jboss.profileservice.spi.repository.Capability;
-import org.jboss.profileservice.spi.repository.Repository;
-import org.jboss.profileservice.spi.repository.Requirement;
-import org.jboss.profileservice.spi.repository.Resource;
-import org.jboss.profileservice.spi.repository.Version;
-
-/**
- * A Resource implementation for a VFSDeployment attachments.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class AttachmentsResource implements Resource
-{
-   private String vfsPath;
-   private Repository repository;
-   private String[] categories = {};
-   private Capability[] capabilities = {};
-   private Map<String, Object> props;
-
-   public AttachmentsResource(String vfsPath, Attachments edits, Repository repository)
-   {
-      this.vfsPath = vfsPath;
-      this.repository = repository;
-      this.props = Collections.singletonMap("attachments", (Object)edits);
-   }
-
-   public Capability[] getCapabilities()
-   {
-      return capabilities;
-   }
-
-   public String[] getCategories()
-   {
-      return categories;
-   }
-
-   public String getId()
-   {
-      return vfsPath;
-   }
-
-   public String getPresentationName()
-   {
-      return vfsPath;
-   }
-
-   public Map getProperties()
-   {
-      return props;
-   }
-
-   public Repository getRepository()
-   {
-      return repository;
-   }
-
-   public Requirement[] getRequirements()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   public String getSymbolicName()
-   {
-      return vfsPath;
-   }
-
-   public URI getURI()
-   {
-      URI repoURI = repository.getURI();
-      URI uri = null;
-      try
-      {
-         // TODO: this probably does not work
-         uri = repoURI.resolve(vfsPath);
-      }
-      catch(Exception e)
-      {
-         throw new IllegalStateException(e);
-      }
-      return uri;
-   }
-
-   public Version getVersion()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }  
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.jboss.profileservice.spi.repository.Capability;
-
-/**
- * Default Capability implementation
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class CapabilityImpl implements Capability
-{
-   private String name;
-   private Map<String, Object> props;
-
-   public CapabilityImpl(String name)
-   {
-      this(name, Collections.EMPTY_MAP);
-   }
-   public CapabilityImpl(String name, Map<String, Object> props)
-   {
-      this.name = name;
-      this.props = props;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public Map<String, Object> getProperties()
-   {
-      return props;
-   }
-   public void setProperties(Map<String, Object> props)
-   {
-      this.props = props;
-   }
-   public Object addProperty(String name, Object value)
-   {
-      return props.put(name, value);
-   }
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.profileservice.spi.AttachmentStore;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * The default repository factory for immutable and mutable repositories.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DefaultDeploymentRepositoryFactory implements DeploymentRepositoryFactory
+{
+   
+   /** The mutable type. */
+   public final static String MUTABLE_TYPE = "mutable";
+   
+   /** The immutable type. */
+   public final static String IMMUTABLE_TYPE = "immutable";
+  
+   /** The repository types. */
+   public final static Collection<String> types; 
+   
+   /** The attachment store. */
+   private AttachmentStore store;
+   
+   /** The main deployer. */
+   private MainDeployer mainDeployer;
+   
+   /** The deployment filter. */
+   private VirtualFileFilter deploymentFilter;
+   
+   /** The metadata include filter. */
+   private VirtualFileFilter hotDeploymentFilter;
+   
+   static
+   {
+      types = Arrays.asList(new String[] { MUTABLE_TYPE, IMMUTABLE_TYPE } );
+   }
+   
+   public String[] getTypes()
+   {
+      return types.toArray(new String[types.size()]);
+   }
+   
+   public AttachmentStore getAttachmentStore()
+   {
+      return store;
+   }
+   
+   public void setAttachmentStore(AttachmentStore store)
+   {
+      this.store = store;
+   }
+   
+   public VirtualFileFilter getDeploymentFilter()
+   {
+      return deploymentFilter;
+   }
+   
+   public void setDeploymentFilter(VirtualFileFilter deploymentFilter)
+   {
+      this.deploymentFilter = deploymentFilter;
+   }
+   
+   public VirtualFileFilter getHotDeploymentFilter()
+   {
+      return hotDeploymentFilter;
+   }
+   
+   public void setHotDeploymentFilter(VirtualFileFilter hotDeploymentFilter)
+   {
+      this.hotDeploymentFilter = hotDeploymentFilter;
+   }
+   
+   public MainDeployer getMainDeployer()
+   {
+      return mainDeployer;
+   }
+   
+   public void setMainDeployer(MainDeployer mainDeployer)
+   {
+      this.mainDeployer = mainDeployer;
+   }
+
+   public DeploymentRepository createDeploymentRepository(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {
+      if(metaData == null)
+         throw new IllegalArgumentException("Null metaData");
+      
+      String repositoryType = null;
+      if(metaData.getSources() != null && ! metaData.getSources().isEmpty())
+      {
+         for( ProfileSourceMetaData source : metaData.getSources())
+         {
+            // FIXME - check for different source types
+            if(repositoryType == null && source.getType() != null)
+            {
+               repositoryType = source.getType();
+               break;
+            }
+         }         
+      }
+      
+      if(repositoryType == null)
+         throw new IllegalArgumentException("Null repository type.");
+      if(types.contains(repositoryType) == false)
+         throw new IllegalArgumentException("Cannot handle type: " + repositoryType);
+      
+      boolean mutable = false;
+      if(repositoryType.equals(MUTABLE_TYPE))
+      {
+         mutable = true;
+      }
+      
+      // create a default deployment repository
+      return createDeploymentRepository(mutable, key, createUris(metaData));
+   }
+   
+   protected DeploymentRepository createDeploymentRepository(boolean mutable, ProfileKey key, URI[] uris) throws Exception
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(uris == null)
+         throw new IllegalArgumentException("Null uris");
+      
+      if(mutable)
+      {
+         MutableDeploymentRepository repository = new MutableDeploymentRepository(key, uris);
+         // Manually inject beans :)
+         repository.setAttachmentStore(store);
+         repository.setDeploymentFilter(deploymentFilter);
+         repository.setHotDeploymentFilter(hotDeploymentFilter);
+         repository.setMainDeployer((MainDeployerStructure) mainDeployer);
+         
+         return repository;
+      }
+      else
+      {
+         ImmutableDeploymentRepository repository = new ImmutableDeploymentRepository(key, uris);
+         // Manually inject beans :)
+         repository.setAttachmentStore(store);
+         repository.setDeploymentFilter(deploymentFilter);
+         
+         return repository;
+      }
+   }
+   
+   protected URI[] createUris(ProfileMetaData metaData) throws URISyntaxException
+   {
+      List<URI> uris = new ArrayList<URI>();
+      for(ProfileSourceMetaData source : metaData.getSources())
+      {
+         URI uri = new URI(source.getSource());
+         uris.add(uri);
+      }
+      return uris.toArray(new URI[uris.size()]);
+   }
+   
+}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/DeploymentRecord.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/DeploymentRecord.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/DeploymentRecord.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.io.Serializable;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class DeploymentRecord implements Serializable
-{
-   private static final long serialVersionUID = 1;
-   
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/FileProfileRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/FileProfileRepository.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/FileProfileRepository.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,146 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
-import org.jboss.profileservice.spi.NoSuchProfileException;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileRepository;
-
-/**
- * An implementation of ProfileRepository that uses the following
- * file system structure for storing deployments and admin
- * edits.
- * 
- * root-file
- * + server/{name}/bootstrap - bootstrap beans/services
- * + server/{name}/deployers - profile deployers
- * + server/{name}/deploy - installed deployments
- * + server/{name}/apps - post install deployments
- * + server/{name}/admin - admin edits to deployments
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class FileProfileRepository
-   implements ProfileRepository
-{
-   private File root;
-   DeploymentRepositoryFactory repositoryFactory;
-   private MainDeployer mainDeployer;
-
-   public FileProfileRepository()
-   {
-      this(null);
-   }
-   public FileProfileRepository(File root)
-   {
-      this.root = root;
-   }
-
-   public DeploymentRepositoryFactory getRepositoryFactory()
-   {
-      return repositoryFactory;
-   }
-   public void setRepositoryFactory(DeploymentRepositoryFactory repositoryFactory)
-   {
-      this.repositoryFactory = repositoryFactory;
-   }
-   public MainDeployer getMainDeployer()
-   {
-      return mainDeployer;
-   }
-   public void setMainDeployer(MainDeployer mainDeployer)
-   {
-      this.mainDeployer = mainDeployer;
-   }
-
-   /**
-    * Get the server profile store root directory.
-    * @return the server profile root directory containing the
-    * available profiles.
-    */
-   public File getStoreRoot()
-   {
-      return root;
-   }
-   /**
-    * Set the profiles store root.
-    * @param root - the server profile root directory containing the
-    * available profiles.
-    */
-   public void setStoreRoot(File root)
-   {
-      this.root = root;
-   }
-
-   /**
-    * Get the keys for all known profiles. This lists the root store to
-    * obtain the server profiles.
-    * @return keys for all known profiles
-    */
-   public Collection<ProfileKey> getProfileKeys()
-   {
-      Collection<ProfileKey> keys = new HashSet<ProfileKey>();
-      for(File profile : root.listFiles())
-      {
-         keys.add(new ProfileKey(profile.getName()));
-      }
-      return keys;
-   }
-
-   /**
-    * 
-    */
-   public DeploymentRepository createProfileDeploymentRepository(ProfileKey key)
-      throws Exception
-   {
-      DeploymentRepository repository = repositoryFactory.getDeploymentRepository(key);
-      repository.create();
-      return repository;
-   }
-
-   /**
-    * Load an existing profile deployment repository.
-    */
-   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key)
-      throws Exception, NoSuchProfileException
-   {
-      DeploymentRepository repository = repositoryFactory.getDeploymentRepository(key);
-      repository.load();
-      return repository;
-   }
-
-   public void removeProfileDeploymentRepository(ProfileKey key)
-      throws Exception, NoSuchProfileException
-   {      
-      DeploymentRepository repository = repositoryFactory.getDeploymentRepository(key);
-      repository.remove();  
-   }
-
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.profileservice.spi.AttachmentStore;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * TODO
+ * 
+ * Create a filtered deployment repository, based on the deployments
+ * of the profile meta data.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class FilteredDeploymentRepositoryFactory implements DeploymentRepositoryFactory
+{
+
+   /** The filtered immutable type. */
+   public final static String FILTERED_IMMUTABLE_TYPE = "filtered";
+   
+   /** The attachment store. */
+   private AttachmentStore store;
+   
+   public String[] getTypes()
+   {
+      return new String[] { FILTERED_IMMUTABLE_TYPE };
+   }
+   
+   public AttachmentStore getAttachmentStore()
+   {
+      return store;
+   }
+   
+   public void setAttachmentStore(AttachmentStore store)
+   {
+      this.store = store;
+   }
+
+   public DeploymentRepository createDeploymentRepository(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {
+      if(metaData == null)
+         throw new IllegalArgumentException("Null metadata");
+      
+      List<String> deploymentList = new ArrayList<String>();
+      if(metaData.getDeployments() != null && metaData.getDeployments().isEmpty() == false)
+      {
+         for(ProfileDeploymentMetaData deployment : metaData.getDeployments())
+         {
+            deploymentList.add(deployment.getName());
+         }
+      }
+      
+      // Create a filtered repository
+      FilteredRepository repository = new FilteredRepository(deploymentList, key, createUris(metaData) );
+      // Set attachment store
+      repository.setAttachmentStore(store);
+      
+      return repository; 
+   }
+   
+   protected URI[] createUris(ProfileMetaData metaData) throws URISyntaxException
+   {
+      List<URI> uris = new ArrayList<URI>();
+      for(ProfileSourceMetaData source : metaData.getSources())
+      {
+         URI uri = new URI(source.getSource());
+         uris.add(uri);
+      }
+      return uris.toArray(new URI[uris.size()]);
+   }
+   
+   /**
+    * A filtered deployment repository.
+    */
+   private class FilteredRepository extends AbstractDeploymentRepository
+   {
+      private List<String> deploymentNames;
+
+      public FilteredRepository(List<String> deploymentNames, ProfileKey key, URI[] uris)
+      {
+         super(key, uris);
+         this.deploymentNames = deploymentNames;
+      }
+      
+      public void load() throws Exception
+      {
+         // Load deployment names
+         for(String deploymentName : deploymentNames)
+         {
+            VirtualFile vf = getDeploymentContent(deploymentName);
+            loadApplications(vf);
+         }
+         updateLastModfied();
+      }
+
+      public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
+      {
+         throw new RuntimeException("Cannot add deployment content to an immutable repository.");
+      }
+
+      @SuppressWarnings("unchecked")
+      public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+      {
+         return Collections.EMPTY_LIST;
+      }
+
+      public void remove() throws Exception
+      {
+         // nothing
+      }
+   }
+   
+}

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

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -22,6 +22,7 @@
 package org.jboss.system.server.profileservice.repository;
 
 import java.io.File;
+import java.net.URI;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
@@ -53,6 +54,11 @@
    /** The attachment suffix. */
    private static final String ATTACHMENT_SUFFIX = ".attachment.xml";
    
+   public JAXBAttachmentSerializer(URI uri)
+   {
+      super(uri);
+   }
+   
    @SuppressWarnings("unchecked")
    protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
    {

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaBeanXmlAttachmentsSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaBeanXmlAttachmentsSerializer.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaBeanXmlAttachmentsSerializer.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-
-import org.jboss.logging.Logger;
-
-/**
- * An AttachmentsSerializer that uses the java bean long term xml serialization
- * format.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class JavaBeanXmlAttachmentsSerializer extends AbstractFileAttachmentsSerializer
-{
-   private static final Logger log = Logger.getLogger(JavaBeanXmlAttachmentsSerializer.class);
-
-   @Override
-   @SuppressWarnings("unchecked")
-   protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
-   {
-      T object = null;
-      FileInputStream fis = new FileInputStream(attachmentsStore);
-      XMLDecoder ois = new XMLDecoder(fis);
-      try
-      {
-         object = (T) ois.readObject();
-      }
-      finally
-      {
-         try
-         {
-            ois.close();
-         }
-         catch(Exception igore)
-         {            
-         }
-         try
-         {
-            fis.close();
-         }
-         catch(Exception igore)
-         {            
-         }
-      }
-      return object;
-   }
-
-   @Override
-   protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
-   {
-      log.trace("saveAttachments, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
-      FileOutputStream fos = new FileOutputStream(attachmentsStore);
-      XMLEncoder oos = new XMLEncoder(fos);
-      try
-      {
-         oos.writeObject(attachment);
-      }
-      finally
-      {
-         try
-         {
-            oos.close();
-         }
-         catch(Exception igore)
-         {            
-         }
-         try
-         {
-            fos.close();
-         }
-         catch(Exception igore)
-         {            
-         }
-      }
-   }
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaSerializationAttachmentsSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaSerializationAttachmentsSerializer.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaSerializationAttachmentsSerializer.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,174 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Arrays;
-
-import org.jboss.logging.Logger;
-
-/**
- * Standard java serialization to a file.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class JavaSerializationAttachmentsSerializer
-   extends AbstractFileAttachmentsSerializer
-{
-   private static final Logger log = Logger.getLogger(JavaSerializationAttachmentsSerializer.class);
-   
-   @Override
-   @SuppressWarnings("unchecked")
-   protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
-   {
-      FileInputStream fis = new FileInputStream(attachmentsStore);
-      ObjectInputStream ois = new ObjectInputStream(fis);
-      T object = null;
-      try
-      {
-         object = (T) ois.readObject();
-      }
-      catch(ClassNotFoundException e)
-      {
-         URL[] path = getClassLoaderURLs(Thread.currentThread().getContextClassLoader());
-         log.debug("ClassNotFoundException: "+e.getMessage()+", path: "+Arrays.asList(path));
-      }
-      finally
-      {
-         try
-         {
-            ois.close();
-         }
-         catch(Exception igore)
-         {            
-         }
-         try
-         {
-            fis.close();
-         }
-         catch(Exception igore)
-         {            
-         }
-      }
-      return object;
-   }
-
-   @Override
-   protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
-   {
-      log.trace("saveAttachments, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
-      FileOutputStream fos = new FileOutputStream(attachmentsStore);
-      ObjectOutputStream oos = new ObjectOutputStream(fos);
-      try
-      {
-         oos.writeObject(attachment);
-      }
-      finally
-      {
-         try
-         {
-            oos.close();
-         }
-         catch(Exception igore)
-         {            
-         }
-         try
-         {
-            fos.close();
-         }
-         catch(Exception igore)
-         {            
-         }
-      }
-   }
-
-   /** Use reflection to access a URL[] getURLs or URL[] getClasspath method so
-   that non-URLClassLoader class loaders, or class loaders that override
-   getURLs to return null or empty, can provide the true classpath info.
-   */
-   @SuppressWarnings("unchecked")
-  private static URL[] getClassLoaderURLs(ClassLoader cl)
-  {
-     URL[] urls = {};
-     try
-     {
-        Class returnType = urls.getClass();
-        Class[] parameterTypes = {};
-        Class clClass = cl.getClass();
-        Method getURLs = clClass.getMethod("getURLs", parameterTypes);
-        if( returnType.isAssignableFrom(getURLs.getReturnType()) )
-        {
-           Object[] args = {};
-           urls = (URL[]) getURLs.invoke(cl, args);
-        }
-     }
-     catch(Exception ignore)
-     {
-     }
-     if( urls == null || urls.length == 0 )
-     {
-        try
-        {
-           Class returnType = urls.getClass();
-           Class[] parameterTypes = {};
-           Class clClass = cl.getClass();
-           Method getURLs = clClass.getMethod("getAllURLs", parameterTypes);
-           if( returnType.isAssignableFrom(getURLs.getReturnType()) )
-           {
-              Object[] args = {};
-              urls = (URL[]) getURLs.invoke(cl, args);
-           }
-        }
-        catch(Exception ignore)
-        {
-        }
-     }
-     if( urls == null || urls.length == 0 )
-     {
-        try
-        {
-           Class returnType = urls.getClass();
-           Class[] parameterTypes = {};
-           Class clClass = cl.getClass();
-           Method getURLs = clClass.getMethod("getClasspath", parameterTypes);
-           if( returnType.isAssignableFrom(getURLs.getReturnType()) )
-           {
-              Object[] args = {};
-              urls = (URL[]) getURLs.invoke(cl, args);
-           }
-        }
-        catch(Exception ignore)
-        {
-        }
-     }
-     
-     return urls;
-  }
-
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,374 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.SyncFailedException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.zip.ZipInputStream;
+
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.profileservice.spi.DeploymentContentFlags;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * A mutable deployment repository, with hot deployment capabilities.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MutableDeploymentRepository extends AbstractDeploymentRepository
+{
+   
+   /** Should an attempt to overwrite existing content fail in {@link #addDeploymentContent(String, ZipInputStream)}*/
+   private boolean failIfAlreadyExists = false;
+   
+   /** The main deployer structure. */
+   private MainDeployerStructure mainDeployer;
+   
+   /** The metadata include filter. */
+   private VirtualFileFilter hotDeploymentFilter;
+   
+   /** The last modified cache. */
+   private Map<String, Long> lastModifiedCache = new ConcurrentHashMap<String, Long>();
+   
+   /** A lock for the hot deployment/{@link #getModifiedDeployments()} */
+   private ReentrantReadWriteLock contentLock = new ReentrantReadWriteLock(true);
+   
+   public MutableDeploymentRepository(ProfileKey key, URI[] uris)
+   {
+      super(key, uris);
+   }
+   
+   public VirtualFileFilter getHotDeploymentFilter()
+   {
+      return hotDeploymentFilter;
+   }
+   
+   public void setHotDeploymentFilter(VirtualFileFilter hotDeploymentFilter)
+   {
+      this.hotDeploymentFilter = hotDeploymentFilter;
+   }
+   
+   public MainDeployerStructure getMainDeployer()
+   {
+      return mainDeployer;
+   }
+   
+   public void setMainDeployer(MainDeployerStructure mainDeployer)
+   {
+      this.mainDeployer = mainDeployer;
+   }
+
+   public void load() throws Exception
+   {
+      for(URI uri : uris)
+      {
+         VirtualFile root = getCachedVirtualFile(uri);
+         loadApplications(root);
+      }
+      updateLastModfied();
+   }
+   
+   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
+   {
+      boolean trace = log.isTraceEnabled();
+      // Suspend hot deployment checking
+      if( trace )
+         log.trace("Aquiring content read lock");
+      contentLock.writeLock().lock();
+      String repositoryName = null;
+      try
+      {
+         if(getRepositoryURIs().length == 0)
+            throw new IllegalStateException("No uris associated with this repository.");
+         
+         // FIXME, this is writing the content to the first URI
+         // Write the content out
+         File contentRoot = new File(getRepositoryURIs()[0]); 
+         if(contentRoot == null)
+            throw new FileNotFoundException("Failed to obtain content dir for phase: "+vfsPath);
+         File contentFile = new File(contentRoot, vfsPath);
+         
+         if(failIfAlreadyExists && contentFile.exists())
+            throw new SyncFailedException("Deployment content already exists: "+contentFile.getAbsolutePath());
+         FileOutputStream fos = new FileOutputStream(contentFile);
+         try
+         {
+            byte[] tmp = new byte[4096];
+            int read;
+            while((read = contentIS.read(tmp)) > 0)
+            {
+               if (trace)
+                  log.trace("write, " + read);
+               fos.write(tmp, 0, read);
+            }
+            fos.flush();
+            // Get the vfs uri for the content as the repository name
+            VirtualFile contentVF = VFS.getVirtualFile(contentRoot.toURI(), vfsPath);
+            repositoryName = contentVF.getName();
+         }
+         finally
+         {
+            try
+            {
+               fos.close();
+            }
+            catch (IOException ignored)
+            {
+            }
+         }
+
+         // Lock the content
+         lockDeploymentContent(vfsPath);
+      }
+      finally
+      {
+         // Allow hot deployment checking
+         contentLock.writeLock().unlock();
+         if(trace)
+            log.trace("Released content write lock");
+      }
+      return repositoryName;
+   }
+
+   public synchronized Collection<ModificationInfo> getModifiedDeployments() throws Exception
+   {
+      ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
+      Collection<VFSDeployment> apps = getDeployments();
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+         log.trace("Checking applications for modifications");
+      if (trace)
+         log.trace("Aquiring content read lock");
+      contentLock.readLock().lock();
+      try
+      {
+         if (apps != null)
+         {
+            Iterator<VFSDeployment> iter = apps.iterator();
+            int ignoreFlags = DeploymentContentFlags.LOCKED | DeploymentContentFlags.DISABLED;
+            while (iter.hasNext())
+            {
+               VFSDeployment ctx = iter.next();
+               VirtualFile root = ctx.getRoot();
+               String name = root.getPathName();
+               // Ignore locked or disabled applications
+               if (this.hasDeploymentContentFlags(name, ignoreFlags))
+               {
+                  if (trace)
+                     log.trace("Ignoring locked application: " + root);
+                  continue;
+               }
+               // Check for removal
+               if (root.exists() == false)
+               {
+                  long rootLastModified = root.getLastModified();
+                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.REMOVED);
+                  modified.add(info);
+                  iter.remove();
+                  // Remove last modified cache
+                  this.lastModifiedCache.remove(root.getPathName());
+                  if (trace)
+                     log.trace(name + " was removed");
+               }
+               // Check for modification
+               else if (hasBeenModified(root)
+                     || hasDeploymentContentFlags(root.getPathName(), DeploymentContentFlags.MODIFIED))
+               {
+                  long rootLastModified = root.getLastModified();
+                  if (trace)
+                     log.trace(name + " was modified: " + rootLastModified);
+                  // Need to create a duplicate ctx
+                  VFSDeployment ctx2 = loadDeploymentData(root);
+                  ModificationInfo info = new ModificationInfo(ctx2, rootLastModified, ModifyStatus.MODIFIED);
+                  modified.add(info);
+               }
+               // TODO: this could check metadata files modifications as well
+            }
+            // Now check for additions
+            for (URI applicationDir : uris)
+            {
+               VirtualFile deployDir = getCachedVirtualFile(applicationDir);
+               ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
+               addedDeployments(added, deployDir);
+               for (VirtualFile vf : added)
+               {
+                  if (this.hasDeploymentContentFlags(vf.getPathName(), ignoreFlags))
+                  {
+                     if (trace)
+                        log.trace("Ignoring locked application: " + vf);
+                     continue;
+                  }
+                  VFSDeployment ctx = loadDeploymentData(vf);
+                  ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
+                  modified.add(info);
+                  addDeployment(ctx.getName(), ctx);
+               }
+            }
+         }
+      }
+      finally
+      {
+         contentLock.readLock().unlock();
+         if (trace)
+            log.trace("Released content read lock");
+      }
+
+      if (modified.size() > 0)
+         updateLastModfied();
+      return modified;
+   }
+
+   /**
+    * Check if the deployment has been modified.
+    *
+    * @param root the virtual file root
+    * @return true if modifed
+    * @throws Exception for any error
+    */
+   protected boolean hasBeenModified(VirtualFile root) throws Exception
+   {
+      // get file:/ schema
+      URI uri = VFSUtils.getCompatibleURI(root);
+      File file = new File(uri);
+      // if root is file check its modification
+      if (file.isFile())
+         return root.hasBeenModified();
+
+      // else check metadata
+      String name = root.toURI().toString();
+      VFSDeploymentContext deploymentContext = getDeploymentContext(name);
+      if (deploymentContext != null)
+         return hasBeenModified(deploymentContext);
+
+      log.trace("Falling back to root name: " + root);
+      deploymentContext = getDeploymentContext(root.getName());
+      if (deploymentContext != null)
+         return hasBeenModified(deploymentContext);
+
+      return false;
+   }
+   
+   /**
+    * Check for modifications.
+    * 
+    * @param deploymentContext
+    * @return
+    * @throws IOException
+    */
+   protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
+   {
+      List<VirtualFile> metadataLocations = deploymentContext.getMetaDataLocations();
+      if (metadataLocations != null && metadataLocations.isEmpty() == false)
+      {
+         for(VirtualFile metadataLocation : metadataLocations)
+         {
+            List<VirtualFile> children = metadataLocation.getChildren(hotDeploymentFilter);
+            if (children != null && children.isEmpty() == false)
+            {
+               for(VirtualFile child : children)
+               {
+                  // TODO JBAS-6360 - check if we already deployed a deployment containing the changes
+                  String pathName = child.getPathName();
+                  Long timestamp = lastModifiedCache.get(pathName);
+                  long lastModified = child.getLastModified();
+                  lastModifiedCache.put(pathName, lastModified);
+                  if (timestamp != null && timestamp < lastModified)
+                  {
+                     if (log.isTraceEnabled())
+                        log.trace("Metadata location modified: " + child);
+                     return true;
+                  }
+               }
+            }
+         }
+      }
+      List<DeploymentContext> childContexts = deploymentContext.getChildren();
+      if (childContexts != null && childContexts.isEmpty() == false)
+      {
+         for (DeploymentContext childContext : childContexts)
+         {
+            if (childContext instanceof VFSDeploymentContext)
+            {
+               if (hasBeenModified((VFSDeploymentContext)childContext))
+                  return true;
+            }
+         }
+      }
+      return false;
+   }
+
+   public VFSDeployment removeDeployment(String vfsPath) throws Exception
+   {
+      VFSDeployment vfsDeployment = getDeployment(vfsPath);
+      VirtualFile root = vfsDeployment.getRoot();
+      if(root.delete() == false)
+         throw new IOException("Failed to delete: " + root);
+      return super.removeDeployment(vfsPath);
+   }
+   
+   public void remove() throws Exception
+   {
+      // FIXME remove
+   }
+   
+   /**
+    * Get deployment context.
+    *
+    * @param name the deployment context name
+    * @return vfs deployment context or null if doesn't exist or not vfs based
+    */
+   @SuppressWarnings("deprecation")
+   protected VFSDeploymentContext getDeploymentContext(String name)
+   {
+      if (mainDeployer == null)
+         throw new IllegalStateException("Null main deployer.");
+
+      DeploymentContext deploymentContext = mainDeployer.getDeploymentContext(name);
+      if (deploymentContext == null || deploymentContext instanceof VFSDeploymentContext == false)
+         return null;
+
+      return (VFSDeploymentContext)deploymentContext;
+   }
+
+}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileContext.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileContext.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileContext.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.util.Collection;
+
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.spi.ControllerContextActions;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * The ProfileServiceContext.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileContext extends AbstractControllerContext
+{
+
+   /** The profile. */
+   private Profile profile;
+   
+   protected static ProfileKey getProfileKey(Profile profile)
+   {
+      if(profile == null)
+         throw new IllegalArgumentException("Null profile.");
+      return profile.getKey();
+   }
+   
+   public ProfileContext(Profile profile, ControllerContextActions actions)
+   {
+      super(getProfileKey(profile), actions);
+      setMode(ControllerMode.ON_DEMAND);
+      addDependencies(profile.getDependencies());
+      this.profile = profile;
+   }
+
+   public Profile getProfile()
+   {
+      return this.profile;
+   }
+   
+   private void addDependencies(Collection<DependencyItem> dependencies)
+   {
+      if(dependencies != null && dependencies.isEmpty() == false)
+      {
+         for(DependencyItem dependency : dependencies)
+            getDependencyInfo().addIDependOn(dependency);
+      }
+   }
+ 
+   @Override
+   public String toString()
+   {
+      // FIXME
+      return this.profile.toString();
+   }
+   
+}
+

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileCreateAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileCreateAction.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileCreateAction.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import org.jboss.profileservice.spi.Profile;
+
+/**
+ * Basic profile create/destroy action.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileCreateAction extends AbstractProfileLifeCycleAction
+{
+
+   @Override
+   public void install(Profile profile) throws Exception 
+   {
+      // Internally create a profile
+      if(log.isTraceEnabled())
+         log.trace("creating profile: " + profile);
+      profile.create();
+   }
+
+   @Override
+   public void uninstall(Profile profile)
+   {
+      // Internally destroy a profile
+      if(log.isTraceEnabled())
+         log.trace("destroying profile: " + profile);
+      profile.destroy();
+   }
+
+}
+

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileDeployAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileDeployAction.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileDeployAction.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.repository;
+
+import java.util.Collection;
+
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.profileservice.spi.Profile;
+
+/**
+ * deploy/undeploy action. This deploys/undeploys the profile deployments
+ * based on the lifecycle of the profile.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileDeployAction extends AbstractProfileLifeCycleAction
+{
+
+   /** The mainDeployer. */
+   private MainDeployer deployer;
+   
+   public ProfileDeployAction(MainDeployer deployer)
+   {
+      if(deployer == null)
+         throw new IllegalArgumentException("Null deployer");
+      this.deployer = deployer;
+   }
+   
+   @Override
+   public void install(Profile profile) throws Exception
+   {
+      Collection<VFSDeployment> deployments = profile.getDeployments();
+      if (deployments != null && !deployments.isEmpty())
+      {
+         // Add deployments
+         for (VFSDeployment deployment : profile.getDeployments())
+            deployer.addDeployment(deployment);
+         // deploy
+         deployer.process();
+         // TODO do we need some additional meta data to do e.g.: ?
+         // deployer.checkComplete();
+      }
+   }
+
+   @Override
+   public void uninstall(Profile profile) throws Exception
+   {
+      // Handle deployments
+      Collection<VFSDeployment> deployments = profile.getDeployments();
+      if (deployments != null && !deployments.isEmpty())
+      {
+         // remove deployments
+         for (VFSDeployment deployment : profile.getDeployments())
+         {
+            try
+            {
+               // remove deployments
+               deployer.removeDeployment(deployment);
+            }
+            catch(Throwable t)
+            {
+               log.warn("failed to  undeploy: " + t);
+            }
+         }
+         // undeploy
+         try
+         {
+            deployer.process();
+         }
+         catch (Throwable t)
+         {
+            log.warn("Error on releasing profile: ", t);
+         }
+      }
+   }
+}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,216 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.logging.Logger;
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.NoSuchProfileException;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileRepository;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.system.server.profile.repository.ProfileImpl;
-
-
-/**
- * A ProfileService impl that uses a ProfileRepository/DeploymentRepository
- * based Profile implementation.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ProfileServiceImpl
-   implements ProfileService
-{
-   private static final Logger log = Logger.getLogger(ProfileServiceImpl.class);
-   /** The name of the profile to use */
-   private String name;
-   /** The profile repository plugin */
-   private ProfileRepository profileRepository;
-   /** The deployment repository plugin for the current profile */
-   private DeploymentRepository deploymentRepository;
-   /** The active profile */
-   private Profile profile;
-   /** The management view for the active profile */
-   private ManagementView mgtView;
-   /** The profiles DeploymentManager */
-   private DeploymentManager deployMgr;
-   /** The version of the profile to use */
-   private String version;
-
-   public ProfileServiceImpl(String name) throws IOException
-   {
-      this.name = name;
-   }
-   // Properties ------------------------
-
-   public String getName()
-   {
-      return this.name;
-   }
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public String getVersion()
-   {
-      return version;
-   }
-
-   public void setVersion(String version)
-   {
-      this.version = version;
-   }
-
-   public ProfileRepository getProfileRepository()
-   {
-      return profileRepository;
-   }
-
-   public void setProfileRepository(ProfileRepository profileRepository)
-   {
-      this.profileRepository = profileRepository;
-   }
-
-   public DeploymentRepository getDeploymentRepository()
-   {
-      return deploymentRepository;
-   }
-
-   public void setDeploymentRepository(DeploymentRepository repository)
-   {
-      this.deploymentRepository = repository;
-   }
-
-   public void start()
-      throws Exception
-   {
-      if( profileRepository == null )
-         throw new IllegalStateException("No profileRepository specified");
-      // Obtain the deployment repository for the profile
-      ProfileKey key = new ProfileKey(name);
-      Profile profile = this.getProfile(key);
-      log.info("Loaded profile: "+profile);
-   }
-
-   // ProfileService implementation --------------------
-   /**
-    * There is only the default domain (ProfileKey.DEFAULT)
-    */
-   public String[] getDomains()
-   {
-      String[] domains = {ProfileKey.DEFAULT};
-      return domains;
-   }
-
-   /**
-    * Get the keys for all known profiles
-    * @return keys for all known profiles
-    */
-   public Collection<ProfileKey> getProfileKeys()
-   {
-      Collection<ProfileKey> keys = profileRepository.getProfileKeys();
-      return keys;
-   }
-
-   /**
-    * Always returns the default profile.
-    */
-   public Profile getProfile(ProfileKey key)
-      throws NoSuchProfileException
-   {
-      if( profileRepository == null )
-         throw new IllegalStateException("No profileRepository specified");
-      if(profile != null)
-      {
-         if(key.isDefaultKey() || profile.getKey().equals(key))
-            return profile;
-      }
-
-      // Obtain the deployment repository for the profile
-      try
-      {
-         deploymentRepository = profileRepository.getProfileDeploymentRepository(key);
-      }
-      catch(NoSuchProfileException e)
-      {
-         throw e;
-      }
-      catch(Exception e)
-      {
-         throw new NoSuchProfileException("Failed to obtain deployment repository for: "+key, e);
-      }
-      log.info("Loading profile: "+name+" from: "+deploymentRepository);
-      profile = new ProfileImpl(deploymentRepository, key);
-      return profile;
-   }
-   public Profile getActiveProfile()
-      throws NoSuchProfileException
-   {
-      return profile;   
-   }
-
-   public String[] getProfileDeploymentNames(ProfileKey key)
-      throws NoSuchProfileException
-   {
-      String[] names = {"default"};
-      return names;
-   }
-
-   public ManagementView getViewManager()
-   {
-      return mgtView;
-   }
-   public void setViewManager(ManagementView mgtView)
-   {
-      this.mgtView = mgtView;
-   }
-
-   public DeploymentManager getDeploymentManager()
-   {
-      return deployMgr;
-   }
-   public void setDeploymentManager(DeploymentManager deployMgr)
-   {
-      this.deployMgr = deployMgr;
-   }
-
-   public Profile newProfile(ProfileKey key)
-      throws Exception
-   {
-      DeploymentRepository repo = profileRepository.createProfileDeploymentRepository(key);
-      return new ProfileImpl(repo, key);
-   }
-
-   public void removeProfile(ProfileKey key)
-      throws Exception, NoSuchProfileException
-   {
-      profileRepository.removeProfileDeploymentRepository(key);
-   }
-}
-

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,602 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.deployers.spi.attachments.Attachments;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
-import org.jboss.profileservice.spi.repository.MutableRepository;
-import org.jboss.profileservice.spi.repository.Repository;
-import org.jboss.profileservice.spi.repository.RepositoryAdmin;
-import org.jboss.profileservice.spi.repository.Resource;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A bridge between the DeploymentRepository and the OBR RepositoryAdmin
- * to validate that the OBR api can be used for the profile service.
- * 
- * TODO: may need separate deployment phase maps for the OBR id to vfspath to
- * track deployments by phase.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class RepositoryAdminAdaptor
-   implements DeploymentRepository
-{
-   private static Logger log = Logger.getLogger(RepositoryAdminAdaptor.class);
-
-   /** The OBR repository interface */
-   private RepositoryAdmin delegate;
-   /** The server root container the deployments */
-   private File root;
-   /** The bootstrap jboss-service.xml dir */
-   private File bootstrapDir;
-   /** The server static libraries */
-   private File libDir;
-   /** The deployers phase deployments dir */
-   private File deployersDir;
-   /** The application phase deployments dir */
-   private File[] applicationDirs;
-   /** The deployment post edit */
-   private File adminEditsRoot;
-   /** The profile key this repository is associated with */
-   private ProfileKey key;
-   /** The last time the profile was modified */
-   private long lastModified;
-
-   
-   public String getAttachmentsRoot()
-   {
-      String path = null;
-      if(adminEditsRoot != null)
-         path = adminEditsRoot.getAbsolutePath();
-      return path;
-   }
-
-   public void setAttachmentsRoot(String root)
-   {
-      adminEditsRoot = new File(root);
-   }
-
-   public void addDeployment(String vfsPath, VFSDeployment d, DeploymentPhase phase)
-      throws Exception
-   {
-      MutableRepository mrepo = getRepository(d.getRoot().toURI());
-      VFSDeploymentResource dres = new VFSDeploymentResource(d, phase, mrepo);
-      mrepo.addResource(dres);
-   }
-
-   public String addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
-      throws IOException
-   {
-      // TODO
-      throw new IOException("Not yet implemented");
-   }
-
-   public String[] getRepositoryNames(String[] names, DeploymentPhase phase)
-         throws IOException
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   public VirtualFile getDeploymentContent(String vfsPath, DeploymentPhase phase)
-         throws IOException
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   public int lockDeploymentContent(String vfsPath, DeploymentPhase phase)
-   {
-      // TODO Auto-generated method stub
-      return 0;
-   }
-   public int unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
-   {
-      // TODO Auto-generated method stub
-      return 0;
-   }
-
-   
-   public int getDeploymentContentFlags(String vfsPath, DeploymentPhase phase)
-   {
-      // TODO Auto-generated method stub
-      return 0;
-   }
-
-   public int clearDeploymentContentFlags(String vfsPath,
-         DeploymentPhase phase, int flags)
-   {
-      // TODO Auto-generated method stub
-      return 0;
-   }
-
-   public boolean hasDeploymentContentFlags(String vfsPath,
-         DeploymentPhase phase, int flag)
-   {
-      // TODO Auto-generated method stub
-      return false;
-   }
-
-   public int setDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
-         int flags)
-   {
-      // TODO Auto-generated method stub
-      return 0;      
-   }
-
-   public void acquireDeploymentContentLock()
-   {
-      // TODO Auto-generated method stub
-   }
-
-   public void releaseDeploymentContentLock()
-   {
-      // TODO Auto-generated method stub
-   }
-
-
-   public void addManagedObject(String vfsPath, Attachments edits) throws Exception
-   {
-      MutableRepository repo = this.getRepository(adminEditsRoot.toURI());
-      AttachmentsResource attachments = new AttachmentsResource(vfsPath, edits, repo);
-      repo.addResource(attachments);
-      lastModified = System.currentTimeMillis();
-   }
-   
-   public long getLastModified()
-   {
-      return this.lastModified;
-   }
-
-   public void create() throws Exception
-   {
-      File profileRoot = new File(root, key.getName());
-      if( profileRoot.exists() == true )
-         throw new IOException("Profile root already exists: "+profileRoot);
-      if( profileRoot.mkdirs() == false )
-         throw new IOException("Failed to create profile root: "+profileRoot);
-      // server/{name}/bootstrap
-      bootstrapDir = new File(profileRoot, "bootstrap");
-      if( bootstrapDir.mkdirs() == false )
-         throw new IOException("Failed to create profile bootstrap dir: "+bootstrapDir);
-      delegate.addRepository(bootstrapDir.toURI());
-
-      // server/{name}/deployers
-      deployersDir = new File(profileRoot, "deployers");
-      if( deployersDir.mkdirs() == false )
-         throw new IOException("Failed to create profile deployers dir: "+deployersDir);
-      delegate.addRepository(deployersDir.toURI());
-
-      // server/{name}/deploy dirs
-      for (File applicationDir : applicationDirs)
-      {
-         if( applicationDir.mkdirs() == false )
-            throw new IOException("Failed to create profile deploy dir: "+applicationDir);
-         delegate.addRepository(applicationDir.toURI());
-      }
-
-      // server/{name}/lib
-      libDir = new File(profileRoot, "lib");
-      if( libDir.mkdirs() == false )
-         throw new IOException("Failed to create profile lib dir: "+libDir);
-      delegate.addRepository(libDir.toURI());
-
-      if(adminEditsRoot == null)
-         setAttachmentsRoot(profileRoot.getAbsolutePath()+"/attachments");
-      if( adminEditsRoot.exists() == false && adminEditsRoot.mkdirs() == false )
-         throw new IOException("Failed to create profile adminEdits dir: "+adminEditsRoot);
-      delegate.addRepository(adminEditsRoot.toURI());
-      lastModified = System.currentTimeMillis();
-   }
-
-   public VFSDeployment getDeployment(String name, DeploymentPhase phase)
-      throws Exception, NoSuchDeploymentException
-   {
-      VFSDeployment ctx = null;
-      if( phase == null )
-      {
-         // Try all phases
-         try
-         {
-            ctx = this.getBootstrap(name);
-         }
-         catch(NoSuchDeploymentException ignore)
-         {
-         }
-         try
-         {
-            if( ctx == null )
-               ctx = this.getDeployer(name);
-         }
-         catch(NoSuchDeploymentException ignore)
-         {
-         }
-         try
-         {
-            if( ctx == null )
-               ctx = this.getApplication(name);
-         }
-         catch(NoSuchDeploymentException ignore)
-         {
-         }
-      }
-      else
-      {
-         switch( phase )
-         {
-            case BOOTSTRAP:
-               ctx = this.getBootstrap(name);
-               break;
-            case DEPLOYER:
-               ctx = this.getDeployer(name);
-               break;
-            case APPLICATION:
-               ctx = this.getApplication(name);
-               break;
-         }
-      }
-      // Make sure we don't return null
-      if( ctx == null )
-         throw new NoSuchDeploymentException("name="+name+", phase="+phase);
-      return ctx;
-   }
-
-   /**
-    * Obtain the VFSDeploymentResource SymbolicName from all
-    * repositories.
-    */
-   public Set<String> getDeploymentNames()
-   {
-      HashSet<String> names = new HashSet<String>();
-      Repository[] repositories = delegate.listRepositories();
-      for(Repository repo : repositories)
-      {
-         Resource[] resources = repo.getResources();
-         for(Resource res : resources)
-         {
-            if(res instanceof VFSDeploymentResource)
-            {
-               VFSDeploymentResource vfsres = (VFSDeploymentResource) res;
-               names.add(vfsres.getSymbolicName());
-            }
-         }
-      }
-      return names;
-   }
-
-   /**
-    * Obtain the VFSDeploymentResource SymbolicName from the
-    * repository associated with the getDeploymentURI(phase) URI.
-    */
-   public Set<String> getDeploymentNames(DeploymentPhase phase)
-   {
-      HashSet<String> names = new HashSet<String>();
-      URI uri = getDeploymentURI(phase);
-      try
-      {
-         Repository repo = delegate.getRepository(uri);
-         Resource[] resources = repo.getResources();
-         for(Resource res : resources)
-         {
-            if(res instanceof VFSDeploymentResource)
-            {
-               VFSDeploymentResource vfsres = (VFSDeploymentResource) res;
-               names.add(vfsres.getSymbolicName());
-            }
-         }
-      }
-      catch(Exception e)
-      {
-         throw new IllegalStateException(e);
-      }
-      return names;
-   }
-
-   /**
-    * TODO: should be a resolver query for matching types via
-    * discoverResources(String).
-    */
-   public Set<String> getDeploymentNamesForType(String type)
-   {
-      return null;
-   }
-
-   /**
-    * Obtain the VFSDeploymentResource deployment property from all
-    * repositories.
-    */
-   public Collection<VFSDeployment> getDeployments() throws Exception
-   {
-      HashSet<VFSDeployment> deployments = new HashSet<VFSDeployment>();
-      Repository[] repositories = delegate.listRepositories();
-      for(Repository repo : repositories)
-      {
-         Resource[] resources = repo.getResources();
-         for(Resource res : resources)
-         {
-            if(res instanceof VFSDeploymentResource)
-            {
-               VFSDeploymentResource vfsres = (VFSDeploymentResource) res;
-               VFSDeployment deployment = (VFSDeployment) vfsres.getProperties().get("deployment");
-               if(deployment != null)
-                  deployments.add(deployment);
-            }
-         }
-      }
-      return deployments;
-   }
-
-   /**
-    * Obtain the VFSDeploymentResource deployment property from the
-    * repository
-    */
-   public Collection<VFSDeployment> getDeployments(DeploymentPhase phase)
-      throws Exception
-   {
-      URI uri = getDeploymentURI(phase);
-      Repository repo = delegate.getRepository(uri);
-      Resource[] resources = repo.getResources();
-      HashSet<VFSDeployment> deployments = new HashSet<VFSDeployment>();
-      for(Resource res : resources)
-      {
-         if(res instanceof VFSDeploymentResource)
-         {
-            VFSDeploymentResource vfsres = (VFSDeploymentResource) res;
-            VFSDeployment deployment = (VFSDeployment) vfsres.getProperties().get("deployment");
-            if(deployment != null)
-               deployments.add(deployment);
-         }
-      }
-      return deployments;
-   }
-
-   public URI getDeploymentURI(DeploymentPhase phase)
-   {
-      URI uri = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            uri = this.getBootstrapURI();
-            break;
-         case DEPLOYER:
-            uri = this.getDeployersURI();
-            break;
-         case APPLICATION:
-            uri = this.getApplicationURI();
-            break;
-      }
-      return uri;
-   }
-
-   public Collection<ModificationInfo> getModifiedDeployments() throws Exception
-   {
-      ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
-      URI appURI = getApplicationURI();
-      MutableRepository repo = getRepository(appURI);
-      Collection<Resource> resources = repo.getModifiedResources();
-      boolean trace = log.isTraceEnabled();
-      if( trace )
-         log.trace("Checking applications for modifications");
-      if( resources != null )
-      {
-         for(Resource res : resources)
-         {
-            VFSDeployment ctx = (VFSDeployment) res.getProperties().get("deployment");
-            if( ctx == null )
-               continue;
-            MutableRepository.ModifyStatus status = (MutableRepository.ModifyStatus) res.getProperties().get("modifyStatus");
-            Long lastModified = (Long) res.getProperties().get("lastModified");
-            VirtualFile root = ctx.getRoot();
-            String name = root.getPathName();
-            // Check for removal
-            if(status == MutableRepository.ModifyStatus.REMOVED)
-            {
-               ModificationInfo info = new ModificationInfo(ctx, lastModified, ModifyStatus.REMOVED);
-               modified.add(info);
-               if( trace )
-                  log.trace(name+" was removed");
-            }
-            // Check for modification
-            else if(status == MutableRepository.ModifyStatus.MODIFIED)
-            {
-               if( trace )
-                  log.trace(name+" was modified: "+lastModified);
-               ModificationInfo info = new ModificationInfo(ctx, lastModified, ModifyStatus.MODIFIED);
-               modified.add(info);
-            }
-            // Check for additions
-            else if(status == MutableRepository.ModifyStatus.ADDED)
-            {
-               if( trace )
-                  log.trace(name+" was added: "+lastModified);
-               ModificationInfo info = new ModificationInfo(ctx, lastModified, ModifyStatus.ADDED);
-               modified.add(info);               
-            }
-         }
-      }
-      if(modified.size() > 0)
-         lastModified = System.currentTimeMillis();
-      return modified;
-   }
-
-   public void load() throws Exception
-   {
-   }
-
-   public void remove() throws Exception
-   {
-      Repository[] repositories = delegate.listRepositories();
-      for(Repository repo : repositories)
-      {
-         delegate.removeRepository(repo.getURI());
-      }
-   }
-
-   public VFSDeployment removeDeployment(String name, DeploymentPhase phase)
-      throws Exception
-   {
-      URI uri = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            uri = getBootstrapURI();
-            break;
-         case DEPLOYER:
-            uri = getDeployersURI();
-            break;
-         case APPLICATION:
-            uri = getApplicationURI();
-            break;
-      }
-      VFSDeployment ctx = removeDeployment(name, uri);
-      return ctx;
-   }
-
-   public void setDeploymentURI(URI uri, DeploymentPhase phase)
-   {
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            this.setBootstrapURI(uri);
-            break;
-         case DEPLOYER:
-            this.setDeployersURI(uri);
-            break;
-         case APPLICATION:
-            this.setApplicationURIs(new URI[]{uri});
-            break;
-      }      
-   }
-
-   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
-         ManagedComponent comp)
-      throws Exception
-   {      
-   }
-
-   /** This requires that the RepositoryAdmin be able to walk up the
-      deployment URI to a matching repository URI
-      @param uri a URI pointing to a resource under a repository
-   */
-   protected MutableRepository getRepository(URI uri)
-      throws Exception
-   {
-      Repository repo = delegate.getRepository(uri);
-      if ( (repo instanceof MutableRepository) == false )
-         throw new IllegalStateException("Repository does not support MutableRepository");
-      MutableRepository mrepo = (MutableRepository) repo;
-      return mrepo;
-   }
-
-   protected VFSDeployment getBootstrap(String vfsPath)
-      throws Exception
-   {
-      Resource res = delegate.getResource(vfsPath);
-      if (res == null || (res instanceof VFSDeploymentResource) == false)
-         throw new NoSuchDeploymentException(vfsPath);
-      VFSDeploymentResource vfsres = (VFSDeploymentResource) res;
-      VFSDeployment deployment = (VFSDeployment) vfsres.getProperties().get("deployment");
-      return deployment;
-   }
-   
-   protected VFSDeployment getDeployer(String vfsPath)
-      throws Exception
-   {
-      Resource res = delegate.getResource(vfsPath);
-      if (res == null || (res instanceof VFSDeploymentResource) == false)
-         throw new NoSuchDeploymentException(vfsPath);
-      VFSDeploymentResource vfsres = (VFSDeploymentResource) res;
-      VFSDeployment deployment = (VFSDeployment) vfsres.getProperties().get("deployment");
-      return deployment;
-   }
-
-   protected VFSDeployment getApplication(String vfsPath)
-      throws Exception
-   {
-      Resource res = delegate.getResource(vfsPath);
-      if (res == null || (res instanceof VFSDeploymentResource) == false)
-         throw new NoSuchDeploymentException(vfsPath);
-      VFSDeploymentResource vfsres = (VFSDeploymentResource) res;
-      VFSDeployment deployment = (VFSDeployment) vfsres.getProperties().get("deployment");
-      return deployment;
-   }
-
-   protected URI getBootstrapURI()
-   {
-      return bootstrapDir.toURI();
-   }
-   protected URI getDeployersURI()
-   {
-      return deployersDir.toURI();
-   }
-   protected URI getApplicationURI()
-   {
-      File applicationDir = applicationDirs[0];
-      return applicationDir.toURI();
-   }
-
-   protected void setBootstrapURI(URI uri)
-   {
-      bootstrapDir = new File(uri);
-   }
-   protected void setDeployersURI(URI uri)
-   {
-      deployersDir = new File(uri);
-   }
-   public void setApplicationURIs(URI[] uris)
-   {
-      applicationDirs = new File[uris.length];
-      for (int n = 0; n < uris.length; n ++)
-      {
-         URI uri = uris[n];
-         applicationDirs[n] = new File(uri);
-      }
-   }
-
-   protected VFSDeployment removeDeployment(String name, URI uri) throws Exception
-   {
-      MutableRepository mrepo = getRepository(uri);
-      Resource res = mrepo.removeResource(name);
-      VFSDeploymentResource vfsres = (VFSDeploymentResource) res;
-      VFSDeployment deployment = (VFSDeployment) vfsres.getProperties().get("deployment");
-      return deployment;
-   }
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ScopedProfileServiceController.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ScopedProfileServiceController.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ScopedProfileServiceController.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.plugins.ScopedController;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.ScopeKey;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ScopedProfileServiceController extends ScopedController
+{
+   
+   public ScopedProfileServiceController(AbstractController parentController)
+   {
+      setScopeKey(new ScopeKey(CommonLevels.SUBSYSTEM, "Profile"));
+      setParentController(parentController);
+      setUnderlyingController(this);
+   }
+
+}
+

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,1198 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.SyncFailedException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.zip.ZipInputStream;
-
-import org.jboss.deployers.spi.attachments.Attachments;
-import org.jboss.deployers.structure.spi.DeploymentContext;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.DeploymentContentFlags;
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.NoSuchProfileException;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
-import org.jboss.util.file.Files;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-
-/**
- * An implementation of DeploymentRepository that relies on java
- * serialization to store contents on the file system.
- * 
- * + root/{name}/bootstrap - the bootstrap beans
- * + root/{name}/deployers - profile deployers
- * + root/{name}/deploy - installed deployments
- * + root/{name}/apps - post install deployments
- * + root/{name}/attachments - pre-processed attachments + admin edits to deployments
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class SerializableDeploymentRepository extends AbstractAttachmentStore
-   implements DeploymentRepository
-{
-   private static final Logger log = Logger.getLogger(SerializableDeploymentRepository.class);
-
-   /** The server root container the deployments */
-   private File root;
-   /** The bootstrap descriptor dir */
-   private File bootstrapDir;
-   /** The server static libraries */
-   private File libDir;
-   /** The deployers phase deployments dir */
-   private File deployersDir;
-   /** The application phase deployments dir */
-   private File[] applicationDirs;
-   /** The application phase deployment files keyed by VirtualFile URI string */
-   private final Map<String, VirtualFile> applicationVFCache = new HashMap<String, VirtualFile>();
-   /** The deployment post edit root location */
-   private File adminEditsRoot;
-   /** The profile key this repository is associated with */
-   private ProfileKey key;
-   /** The bootstrap VFSDeployments */
-   private LinkedHashMap<String,VFSDeployment> bootstrapCtxs = new LinkedHashMap<String,VFSDeployment>();
-   /** The deployer VFSDeployments */
-   private LinkedHashMap<String,VFSDeployment> deployerCtxs = new LinkedHashMap<String,VFSDeployment>();
-   /** The application VFSDeployments */
-   private LinkedHashMap<String,VFSDeployment> applicationCtxs = new LinkedHashMap<String,VFSDeployment>();
-
-   private Map<String, Integer> contentFlags = new ConcurrentHashMap<String, Integer>();
-   /** The last time the profile was modified */
-   private long lastModified;
-   /** A lock for the hot deployment/{@link #getModifiedDeployments()} */
-   private ReentrantReadWriteLock contentLock = new ReentrantReadWriteLock(true);
-   /** Should an attempt to overwrite existing content fail in {@link #addDeploymentContent(String, ZipInputStream, DeploymentPhase)}*/
-   private boolean failIfAlreadyExists = false;
-   
-   /** Allowed deployments filter */
-   private VirtualFileFilter deploymentFilter;
-   /** The metadata include filter */
-   private VirtualFileFilter hotDeploymentFilter;
-   /** The last modified cache */
-   private Map<String, Long> lastModifiedCache;
-
-   public SerializableDeploymentRepository(File root, URI[] appURIs, ProfileKey key)
-   {
-      this.root = root;
-      this.key = key;
-      this.setApplicationURIs(appURIs);
-      this.lastModifiedCache = new ConcurrentHashMap<String, Long>();
-   }
-
-   public URI[] getApplicationURIs()
-   {
-      URI[] appURIs = new URI[applicationDirs.length];
-      for (int n = 0; n < applicationDirs.length; n ++)
-      {
-         File applicationDir = applicationDirs[n];
-         appURIs[n] = applicationDir.toURI();
-      }
-      return appURIs;
-   }
-   public void setApplicationURIs(URI[] uris)
-   {
-      applicationDirs = new File[uris.length];
-      for (int n = 0; n < uris.length; n ++)
-      {
-         URI uri = uris[n];
-         applicationDirs[n] = new File(uri);
-      }
-   }
-
-   public boolean exists()
-   {
-      File profileRoot = new File(root, key.getName());
-      return profileRoot.exists();
-   }
-
-   public String getAttachmentsRoot()
-   {
-      String path = null;
-      if(adminEditsRoot != null)
-         path = adminEditsRoot.getAbsolutePath();
-      return path;
-   }
-   public void setAttachmentsRoot(String root)
-   {
-      adminEditsRoot = new File(root);
-   }
-   
-   public VirtualFileFilter getDeploymentFilter()
-   {
-      return deploymentFilter;
-   }
-   
-   public void setDeploymentFilter(VirtualFileFilter deploymentFilter)
-   {
-      this.deploymentFilter = deploymentFilter;
-   }
-   
-   public VirtualFileFilter getHotDeploymentFilter()
-   {
-      return hotDeploymentFilter;
-   }
-   
-   public void setHotDeploymentFilter(VirtualFileFilter hotDeploymentFilter)
-   {
-      this.hotDeploymentFilter = hotDeploymentFilter;
-   }
-
-   public long getLastModified()
-   {
-      return this.lastModified;
-   }
-
-   public URI getDeploymentURI(DeploymentPhase phase)
-   {
-      URI uri = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            uri = this.getBootstrapURI();
-            break;
-         case DEPLOYER:
-            uri = this.getDeployersURI();
-            break;
-         case APPLICATION:
-            uri = this.getApplicationURI();
-            break;
-      }
-      return uri;
-   }
-
-   public void setDeploymentURI(URI uri, DeploymentPhase phase)
-   {
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            this.setBootstrapURI(uri);
-            break;
-         case DEPLOYER:
-            this.setDeployersURI(uri);
-            break;
-         case APPLICATION:
-            this.setApplicationURIs(new URI[]{uri});
-            break;
-      }
-   }
-   public Set<String> getDeploymentNames()
-   {
-      HashSet<String> names = new HashSet<String>();
-      names.addAll(bootstrapCtxs.keySet());
-      names.addAll(deployerCtxs.keySet());
-      names.addAll(applicationCtxs.keySet());
-      return names;
-   }
-   public Set<String> getDeploymentNames(DeploymentPhase phase)
-   {
-      HashSet<String> names = new HashSet<String>();
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            names.addAll(this.bootstrapCtxs.keySet());
-            break;
-         case DEPLOYER:
-            names.addAll(this.deployerCtxs.keySet());
-            break;
-         case APPLICATION:
-            names.addAll(this.applicationCtxs.keySet());
-            break;
-      }
-      return names;      
-   }
-
-   /**
-    * 
-    */
-   public String addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
-      throws IOException
-   {
-      boolean trace = log.isTraceEnabled();
-      // Suspend hot deployment checking
-      if( trace )
-         log.trace("Aquiring content read lock");
-      contentLock.writeLock().lock();
-      String repositoryName = null;
-      try
-      {
-         // Write the content out
-         File contentRoot = getPhaseDir(phase);
-         if(contentRoot == null)
-            throw new FileNotFoundException("Failed to obtain content dir for phase: "+phase);
-         File contentFile = new File(contentRoot, name);
-         // TODO do we need to create the parent directory if the name is myDeployments/myRealDeployment.jar ?
-         
-         if(failIfAlreadyExists && contentFile.exists())
-            throw new SyncFailedException("Deployment content already exists: "+contentFile.getAbsolutePath());
-         FileOutputStream fos = new FileOutputStream(contentFile);
-         try
-         {
-            byte[] tmp = new byte[4096];
-            int read;
-            while((read = contentIS.read(tmp)) > 0)
-            {
-               if (trace)
-                  log.trace("write, " + read);
-               fos.write(tmp, 0, read);
-            }
-            fos.flush();
-            // Get the vfs uri for the content as the repository name
-            VirtualFile contentVF = VFS.getVirtualFile(contentRoot.toURI(), name);
-            repositoryName = contentVF.getName();
-         }
-         finally
-         {
-            try
-            {
-               fos.close();
-            }
-            catch (IOException ignored)
-            {
-            }
-         }
-
-         // Lock the content
-         lockDeploymentContent(name, phase);
-      }
-      finally
-      {
-         // Allow hot deployment checking
-         contentLock.writeLock().unlock();
-         if(trace)
-            log.trace("Released content write lock");
-      }
-      return repositoryName;
-   }
-
-   /**
-    * @throws URISyntaxException 
-    * 
-    */
-   public VirtualFile getDeploymentContent(String name, DeploymentPhase phase)
-         throws IOException, URISyntaxException
-   {
-      // find the cached root
-      switch( phase )
-      {
-         case BOOTSTRAP:
-         case DEPLOYER:
-            throw new IOException(phase+" content access not supported");
-         case APPLICATION:
-         case APPLICATION_TRANSIENT:
-            break;
-      }
-      // get cached version
-      File contentRoot = getPhaseDir(phase);
-      if(contentRoot == null)
-         throw new FileNotFoundException("Failed to obtain content dir for phase: "+phase);
-      File contentFile = new File(contentRoot, name);
-      VirtualFile content = getCachedApplicationVF(contentFile);
-      if(content == null || content.exists() == false)
-         throw new FileNotFoundException("Failed to find content for: "+name);
-      return content;
-   }
-
-   public String[] getRepositoryNames(String[] names, DeploymentPhase phase) throws IOException
-   {
-      List<String> tmp = new ArrayList<String>();
-      URI rootURI = getDeploymentURI(phase);
-      VirtualFile root = VFS.getRoot(rootURI);
-      for(String name : names)
-      {
-         VirtualFile content = root.getChild(name);
-         try
-         {
-            String rname = content.toURI().toString();
-            tmp.add(rname);
-         }
-         catch (URISyntaxException e)
-         {
-            log.error("Should not happen", e);
-         }
-      }
-      String[] rnames = new String[tmp.size()];
-      tmp.toArray(rnames);
-      return rnames;
-   }
-
-   public int lockDeploymentContent(String vfsPath, DeploymentPhase phase)
-   {
-      if( log.isTraceEnabled() )
-         log.trace("lockDeploymentContent, "+vfsPath);
-      return setDeploymentContentFlags(vfsPath, phase, DeploymentContentFlags.LOCKED);
-   }
-
-   public int unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
-   {
-      if( log.isTraceEnabled() )
-         log.trace("unlockDeploymentContent, "+vfsPath);
-      return clearDeploymentContentFlags(vfsPath, phase, DeploymentContentFlags.LOCKED);
-   }
-
-   public int getDeploymentContentFlags(String vfsPath, DeploymentPhase phase)
-   {
-      Integer flags = contentFlags.get(vfsPath);
-      return flags != null ? flags : 0;
-   }
-   public synchronized int clearDeploymentContentFlags(String vfsPath,
-         DeploymentPhase phase,
-         int flags)
-   {
-      Integer dflags = contentFlags.get(vfsPath);
-      if(dflags != null)
-      {
-         dflags &= ~flags;
-         contentFlags.put(vfsPath, dflags);
-      }
-      return dflags != null ? dflags : 0;
-   }
-   public boolean hasDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
-         int flag)
-   {
-      Integer flags = contentFlags.get(vfsPath);
-      boolean hasFlag = false;
-      if(flags != null )
-         hasFlag = (flags & flag) != 0;
-      return hasFlag;
-   }
-   public int setDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
-         int flags)
-   {
-      contentFlags.put(vfsPath, flags);
-      return flags;
-   }
-
-   public void acquireDeploymentContentLock()
-   {
-      contentLock.writeLock().lock();
-      if( log.isTraceEnabled() )
-         log.trace("acquireDeploymentContentLock, have write lock"); 
-   }
-   public void releaseDeploymentContentLock()
-   {
-      contentLock.writeLock().unlock();
-      if( log.isTraceEnabled() )
-         log.trace("releaseDeploymentContentLock, gave up write lock");       
-   }
-
-   public void addDeployment(String vfsPath, VFSDeployment d, DeploymentPhase phase)
-      throws Exception
-   {
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            this.addBootstrap(vfsPath, d);
-            break;
-         case DEPLOYER:
-            this.addDeployer(vfsPath, d);
-            break;
-         case APPLICATION:
-            this.addApplication(vfsPath, d);
-            break;
-         case APPLICATION_TRANSIENT:
-            this.addApplication(vfsPath, d);
-            break;
-      }
-      lastModified = System.currentTimeMillis();
-   }
-
-   public VFSDeployment getDeployment(String name, DeploymentPhase phase)
-      throws Exception, NoSuchDeploymentException
-   {
-      VFSDeployment ctx = null;
-      if( phase == null )
-      {
-         // Try all phases
-         try
-         {
-            ctx = this.getBootstrap(name);
-         }
-         catch(NoSuchDeploymentException ignore)
-         {
-         }
-         try
-         {
-            if( ctx == null )
-               ctx = this.getDeployer(name);
-         }
-         catch(NoSuchDeploymentException ignore)
-         {
-         }
-         try
-         {
-            if( ctx == null )
-               ctx = this.getApplication(name);
-         }
-         catch(NoSuchDeploymentException ignore)
-         {
-         }
-      }
-      else
-      {
-         switch( phase )
-         {
-            case BOOTSTRAP:
-               ctx = this.getBootstrap(name);
-               break;
-            case DEPLOYER:
-               ctx = this.getDeployer(name);
-               break;
-            case APPLICATION:
-               ctx = this.getApplication(name);
-               break;
-         }
-      }
-      // Make sure we don't return null
-      if( ctx == null )
-         throw new NoSuchDeploymentException("name="+name+", phase="+phase);
-      return ctx;
-   }
-
-   public Collection<VFSDeployment> getDeployments()
-   {
-      HashSet<VFSDeployment> deployments = new HashSet<VFSDeployment>();
-      deployments.addAll(this.bootstrapCtxs.values());
-      deployments.addAll(this.deployerCtxs.values());
-      deployments.addAll(this.applicationCtxs.values());
-      return Collections.unmodifiableCollection(deployments);
-   }
-
-   /**
-    * Scan the applications for changes.
-    */
-   public synchronized Collection<ModificationInfo> getModifiedDeployments()
-      throws Exception
-   {
-      ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
-      Collection<VFSDeployment> apps = getApplications();
-      boolean trace = log.isTraceEnabled();
-      if( trace )
-         log.trace("Checking applications for modifications");
-      if( trace )
-         log.trace("Aquiring content read lock");
-      contentLock.readLock().lock();
-      try
-      {
-         if( apps != null )
-         {
-            Iterator<VFSDeployment> iter = apps.iterator();
-            int ignoreFlags = DeploymentContentFlags.LOCKED | DeploymentContentFlags.DISABLED;
-            while( iter.hasNext() )
-            {
-               VFSDeployment ctx = iter.next();
-               VirtualFile root = ctx.getRoot();
-               String name = root.getPathName();
-               // Ignore locked or disabled applications
-               if(this.hasDeploymentContentFlags(name, DeploymentPhase.APPLICATION, ignoreFlags))
-               {
-                  if(trace)
-                     log.trace("Ignoring locked application: "+root);
-                  continue;
-               }
-               // Check for removal
-               if( root.exists() == false )
-               {
-                  long rootLastModified = root.getLastModified();
-                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.REMOVED);
-                  modified.add(info);
-                  iter.remove();
-                  // Remove last modified cache
-                  this.lastModifiedCache.remove(root.getPathName());
-                  if( trace )
-                     log.trace(name + " was removed");
-               }
-               // Check for modification
-               else if( hasBeenModified(root) || 
-                     hasDeploymentContentFlags(root.getPathName(), DeploymentPhase.APPLICATION, DeploymentContentFlags.MODIFIED) )
-               {
-                  long rootLastModified = root.getLastModified();
-                  if( trace )
-                     log.trace(name + " was modified: " + rootLastModified);
-                  // Need to create a duplicate ctx
-                  VFSDeployment ctx2 = loadDeploymentData(root, DeploymentPhase.APPLICATION);
-                  ModificationInfo info = new ModificationInfo(ctx2, rootLastModified, ModifyStatus.MODIFIED);
-                  modified.add(info);
-               }
-               // TODO: this could check metadata files modifications as well
-            }
-            // Now check for additions
-            for (File applicationDir : applicationDirs)
-            {
-               VirtualFile deployDir = getCachedApplicationVF(applicationDir);
-               ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
-               addedDeployments(added, deployDir);
-               for(VirtualFile vf : added)
-               {
-                  if(this.hasDeploymentContentFlags(vf.getPathName(), DeploymentPhase.APPLICATION, ignoreFlags))
-                  {
-                     if(trace)
-                        log.trace("Ignoring locked application: "+ vf);
-                     continue;
-                  }
-                  VFSDeployment ctx = loadDeploymentData(vf, DeploymentPhase.APPLICATION);
-                  ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
-                  modified.add(info);
-                  applicationCtxs.put(ctx.getName(), ctx);
-               }
-            }
-         }
-      }
-      finally
-      {
-         contentLock.readLock().unlock();
-         if( trace )
-            log.trace("Released content read lock");
-      }
-
-      if(modified.size() > 0)
-         lastModified = System.currentTimeMillis();
-      return modified;
-   }
-   
-   /**
-    * Check if the deployment has been modified.
-    *
-    * @param root the virtual file root
-    * @return true if modifed
-    * @throws Exception for any error
-    */
-   protected boolean hasBeenModified(VirtualFile root) throws Exception
-   {
-      // get file:/ schema
-      URI uri = VFSUtils.getCompatibleURI(root);
-      File file = new File(uri);
-      // if root is file check its modification
-      if (file.isFile())
-         return root.hasBeenModified();
-
-      // else check metadata
-      String name = root.toURI().toString();
-      VFSDeploymentContext deploymentContext = getDeploymentContext(name);
-      if (deploymentContext != null)
-         return hasBeenModified(deploymentContext);
-
-      log.trace("Falling back to root name: " + root);
-      deploymentContext = getDeploymentContext(root.getName());
-      if (deploymentContext != null)
-         return hasBeenModified(deploymentContext);
-
-      return false;
-   }
-   
-   /**
-    * Check for modifications.
-    * 
-    * @param deploymentContext
-    * @return
-    * @throws IOException
-    */
-   protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
-   {
-      List<VirtualFile> metadataLocations = deploymentContext.getMetaDataLocations();
-      if (metadataLocations != null && metadataLocations.isEmpty() == false)
-      {
-         for(VirtualFile metadataLocation : metadataLocations)
-         {
-            List<VirtualFile> children = metadataLocation.getChildren(hotDeploymentFilter);
-            if (children != null && children.isEmpty() == false)
-            {
-               for(VirtualFile child : children)
-               {
-                  String pathName = child.getPathName();
-                  Long timestamp = lastModifiedCache.get(pathName);
-                  long lastModified = child.getLastModified();
-                  lastModifiedCache.put(pathName, lastModified);
-                  if (timestamp != null && timestamp < lastModified)
-                  {
-                     if (log.isTraceEnabled())
-                        log.trace("Metadata location modified: " + child);
-                     return true;
-                  }
-               }
-            }
-         }
-      }
-      List<DeploymentContext> childContexts = deploymentContext.getChildren();
-      if (childContexts != null && childContexts.isEmpty() == false)
-      {
-         for (DeploymentContext childContext : childContexts)
-         {
-            if (childContext instanceof VFSDeploymentContext)
-            {
-               if (hasBeenModified((VFSDeploymentContext)childContext))
-                  return true;
-            }
-         }
-      }
-      return false;
-   }
-   
-
-   public Collection<VFSDeployment> getDeployments(DeploymentPhase phase)
-      throws Exception
-   {
-      Collection<VFSDeployment> ctxs = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            ctxs = this.getBootstraps();
-            break;
-         case DEPLOYER:
-            ctxs = this.getDeployers();
-            break;
-         case APPLICATION:
-            ctxs = this.getApplications();
-            break;
-      }
-      return ctxs;
-   }
-
-   public VFSDeployment removeDeployment(String name, DeploymentPhase phase)
-      throws Exception
-   {
-      VFSDeployment ctx = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            ctx = this.removeBootstrap(name);
-            break;
-         case DEPLOYER:
-            ctx = this.removeDeployer(name);
-            break;
-         case APPLICATION:
-            ctx = this.removeApplication(name);
-            break;
-      }
-      if(ctx != null)
-         lastModified = System.currentTimeMillis();
-      return ctx;
-   }
-   
-   public String toString()
-   {
-      StringBuilder tmp = new StringBuilder(super.toString());
-      tmp.append("(root=");
-      tmp.append(root);
-      tmp.append(", key=");
-      tmp.append(key);
-      tmp.append(")");
-      return tmp.toString();
-   }
-
-   /**
-    * Create a profile deployment repository
-    * 
-    * @throws IOException
-    */
-   public void create() throws Exception
-   {
-      File profileRoot = new File(root, key.getName());
-      if( profileRoot.exists() == true )
-         throw new IOException("Profile root already exists: "+profileRoot);
-      if( profileRoot.mkdirs() == false )
-         throw new IOException("Failed to create profile root: "+profileRoot);
-      // server/{name}/bootstrap
-      bootstrapDir = new File(profileRoot, "bootstrap");
-      if( bootstrapDir.mkdirs() == false )
-         throw new IOException("Failed to create profile bootstrap dir: "+bootstrapDir);
-
-      // server/{name}/deployers
-      deployersDir = new File(profileRoot, "deployers");
-      if( deployersDir.mkdirs() == false )
-         throw new IOException("Failed to create profile deployers dir: "+deployersDir);
-
-      // server/{name}/deploy
-      for (File applicationDir : applicationDirs)
-      {
-         if( applicationDir.mkdirs() == false )
-            throw new IOException("Failed to create profile deploy dir: "+applicationDir);
-      }
-      // server/{name}/lib
-      libDir = new File(profileRoot, "lib");
-      if( libDir.mkdirs() == false )
-         throw new IOException("Failed to create profile lib dir: "+libDir);
-
-      if( adminEditsRoot.exists() == false && adminEditsRoot.mkdirs() == false )
-         throw new IOException("Failed to create profile adminEdits dir: "+adminEditsRoot);
-   }
-
-   /**
-    * Load the profile deployments
-    * 
-    * @throws IOException
-    * @throws NoSuchProfileException
-    */
-   public void load() throws Exception, NoSuchProfileException
-   {
-      if( serializer == null )
-         throw new IllegalStateException("serializer has not been set");
-
-      File profileRoot = new File(root, key.getName());
-      if( profileRoot.exists() == false )
-         throw new NoSuchProfileException("Profile root does not exists: "+profileRoot);
-      // server/{name}/bootstrap
-      bootstrapDir = new File(profileRoot, "bootstrap");
-      if( bootstrapDir.exists() == false )
-      {
-         //throw new FileNotFoundException("Profile contains no bootstrap dir: "+bootstrapDir);
-         // fallback to conf/jboss-service.xml for now
-         bootstrapDir = null;
-      }
-
-      // server/{name}/deployers
-      deployersDir = new File(profileRoot, "deployers");
-      if( deployersDir.exists() == false )
-         throw new FileNotFoundException("Profile contains no deployers dir: "+deployersDir);
-
-      // server/{name}/deploy
-      for (File applicationDir : applicationDirs)
-      {
-         if( applicationDir.exists() == false )
-            throw new FileNotFoundException("Profile contains no deploy dir: "+applicationDir);
-      }
-
-      if(this.serializer instanceof AbstractFileAttachmentsSerializer)
-         ((AbstractFileAttachmentsSerializer) this.serializer).setAttachmentsStoreDir(adminEditsRoot);
-
-      if( bootstrapDir != null )
-      {
-         VFS bootstrapVFS = VFS.getVFS(bootstrapDir.toURI());
-         loadBootstraps(bootstrapVFS.getRoot());
-      }
-      else
-      {
-         // hack to load conf/jboss-service.xml until its removed
-         loadBootstraps(null);         
-      }
-      VFS deployersVFS = VFS.getVFS(deployersDir.toURI());
-      loadDeployers(deployersVFS.getRoot());
-      for (File applicationDir : applicationDirs)
-      {
-         VirtualFile dirVF = getCachedApplicationVF(applicationDir);
-         loadApplications(dirVF);
-      }
-
-      this.lastModified = System.currentTimeMillis();
-   }
-
-   /**
-    * Get virtual file for app dir.
-    *
-    * @param applicationDir the app dir
-    * @return virtual file representing app dir
-    * @throws IOException for any error
-    */
-   protected VirtualFile getCachedApplicationVF(File applicationDir) throws IOException
-   {
-      URI uri = applicationDir.toURI();
-      return getCachedApplicationVF(uri);
-   }
-
-   /**
-    * Get virtual file for app uri.
-    *
-    * @param uri the app uri
-    * @return virtual file representing app uri
-    * @throws IOException for any error
-    */
-   protected VirtualFile getCachedApplicationVF(URI uri) throws IOException   
-   {
-      String uriString = uri.toString();
-      VirtualFile dir;
-      synchronized (applicationVFCache)
-      {
-         dir = applicationVFCache.get(uriString);
-         if (dir == null)
-         {
-            dir = VFS.getCachedFile(uri);
-            applicationVFCache.put(uriString, dir);
-         }
-      }
-      return dir;
-   }
-
-   /**
-    * Remove the contents of the profile repository
-    * @throws IOException
-    * @throws NoSuchProfileException
-    */
-   public void remove() throws IOException, NoSuchProfileException
-   {
-      File profileRoot = new File(root, key.getName());
-      Files.delete(profileRoot);
-   }
-
-   protected void addBootstrap(String vfsPath, VFSDeployment ctx)
-      throws Exception
-   {
-      this.bootstrapCtxs.put(vfsPath, ctx);
-   }
-
-   // Managed object attachments for a deployment
-   public void addManagedObject(String vfsPath, Attachments edits)
-      throws IOException
-   {
-      // TODO what should this do ?
-      throw new UnsupportedOperationException("addManagedObject");
-//      Map<String, Object> map = edits.getAttachments();
-//      File attachments = new File(adminEditsRoot, vfsPath+".edits");
-//      ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(attachments));
-//      try
-//      {
-//         oos.writeObject(map);
-//      }
-//      finally
-//      {
-//         try
-//         {
-//            oos.close();
-//         }
-//         catch (IOException ignore)
-//         {
-//         }
-//      }
-//      lastModified = System.currentTimeMillis();
-   }
-
-   protected void addDeployer(String vfsPath, VFSDeployment ctx)
-      throws Exception
-   {
-      this.deployerCtxs.put(vfsPath, ctx);
-   }
-
-   protected void addApplication(String vfsPath, VFSDeployment ctx) throws Exception
-   {
-      log.info("Adding application: " + vfsPath + " / " + ctx);
-      this.applicationCtxs.put(vfsPath, ctx);
-   }
-
-   protected VFSDeployment getBootstrap(String vfsPath) throws Exception
-   {
-      VFSDeployment ctx = bootstrapCtxs.get(vfsPath);
-      if( ctx == null )
-         throw new NoSuchDeploymentException(vfsPath);
-      return ctx;
-   }
-
-   protected Collection<VFSDeployment> getBootstraps() throws Exception
-   {
-      return bootstrapCtxs.values();
-   }
-
-   protected File getPhaseDir(DeploymentPhase phase)
-   {
-      File dir = null;
-      switch( phase )
-      {
-         case BOOTSTRAP:
-            dir = bootstrapDir;
-            break;
-         case DEPLOYER:
-            dir = deployersDir;
-            break;
-         case APPLICATION:
-            dir = applicationDirs[0];
-            break;
-         case APPLICATION_TRANSIENT:
-            // TODO
-            break;
-      }
-      return dir;
-   }
-
-   protected URI getBootstrapURI()
-   {
-      return bootstrapDir.toURI();
-   }
-   protected URI getDeployersURI()
-   {
-      return deployersDir.toURI();
-   }
-   protected URI getApplicationURI()
-   {
-      File applicationDir = applicationDirs[0];
-      return applicationDir.toURI();
-   }
-   protected VFSDeployment getDeployer(String vfsPath)
-      throws Exception
-   {
-      VFSDeployment ctx = deployerCtxs.get(vfsPath);
-      if( ctx == null )
-         throw new NoSuchDeploymentException(vfsPath);
-      return ctx;
-   }
-
-   protected Collection<VFSDeployment> getDeployers()
-      throws Exception
-   {
-      return deployerCtxs.values();
-   }
-
-   protected VFSDeployment getApplication(String vfsPath) throws Exception
-   {
-      boolean trace = log.isTraceEnabled();
-      VFSDeployment ctx = applicationCtxs.get(vfsPath);
-      if( ctx == null )
-      {
-         // Try to find the simple name
-         if(trace)
-            log.trace("Failed to find application for: "+vfsPath+", scanning for simple name");
-         for(VFSDeployment deployment : applicationCtxs.values())
-         {
-            if(trace)
-               log.trace("Checking: "+deployment.getSimpleName());
-            if(deployment.getSimpleName().equals(vfsPath))
-            {
-               if(trace)
-                  log.trace("Matched to simple name of deployment:"+deployment);
-               ctx = deployment;
-               break;
-            }
-         }
-         if(ctx == null)
-         {
-            log.debug("Failed to find application for: "+vfsPath+", available: " + applicationCtxs.values());
-            throw new NoSuchDeploymentException(vfsPath);
-         }
-      }
-      return ctx;
-   }
-
-   protected Collection<VFSDeployment> getApplications()
-      throws Exception
-   {
-      return applicationCtxs.values();
-   }
-
-   protected VFSDeployment removeBootstrap(String vfsPath) throws IOException
-   {
-      VFSDeployment vfsDeployment = bootstrapCtxs.get(vfsPath);
-      if(vfsDeployment == null)
-         throw new IllegalStateException("Deployment not found: " + vfsPath + ", available: " + bootstrapCtxs.values());
-      VirtualFile root = vfsDeployment.getRoot();
-      if(root.delete() == false)
-         throw new IOException("Failed to delete: " + root);
-      return bootstrapCtxs.remove(vfsPath);
-   }
-
-   // this is an infinite loop
-   protected VFSDeployment removeDeployer(String vfsPath) throws IOException
-   {
-      VFSDeployment vfsDeployment = deployerCtxs.get(vfsPath);
-      if(vfsDeployment == null)
-         throw new IllegalStateException("Deployment not found: " + vfsPath + ", available: " + deployerCtxs.values());
-      VirtualFile root = vfsDeployment.getRoot();
-      if(root.delete() == false)
-         throw new IOException("Failed to delete: " + root);
-      return deployerCtxs.remove(vfsPath);
-   }
-   protected VFSDeployment removeApplication(String vfsPath) throws Exception
-   {
-      VFSDeployment vfsDeployment = getApplication(vfsPath);
-      VirtualFile root = vfsDeployment.getRoot();
-      if(root.delete() == false)
-         throw new IOException("Failed to delete: " + root);
-      return this.applicationCtxs.remove(vfsPath);
-   }
-   protected void setBootstrapURI(URI uri)
-   {
-      bootstrapDir = new File(uri);
-   }
-   protected void setDeployersURI(URI uri)
-   {
-      deployersDir = new File(uri);
-   }
-
-   /**
-    * Load the bootstrap descriptors under bootstrapDir:
-    * 
-    * @param bootstrapDir
-    * @throws IOException
-    */
-   private void loadBootstraps(VirtualFile bootstrapDir)
-      throws IOException
-   {
-      if( bootstrapDir != null )
-      {
-         List<VirtualFile> children = bootstrapDir.getChildren();
-         for(VirtualFile vf : children)
-         {
-            VFSDeployment vfCtx = loadDeploymentData(vf, DeploymentPhase.BOOTSTRAP);
-            bootstrapCtxs.put(vfCtx.getName(), vfCtx);       
-         }
-      }
-      else
-      {
-         // fallback to conf/jboss-service.xml for now
-         File profileRoot = new File(root, key.getName());
-         File confDir = new File(profileRoot, "conf");
-         VirtualFile confVF = VFS.getCachedFile(confDir.toURI());
-         VirtualFile jbossServiceVF = confVF.getChild("jboss-service.xml");
-         if(jbossServiceVF == null)
-            throw new FileNotFoundException("Failed to find jboss-service.xml under conf");
-         VFSDeployment vfCtx = loadDeploymentData(jbossServiceVF, DeploymentPhase.BOOTSTRAP);
-         bootstrapCtxs.put(vfCtx.getName(), vfCtx);                
-      }
-   }
-
-   /**
-    * Load all the deployments under the deployersDir.
-    * 
-    * @param deployersDir
-    * @throws IOException
-    */
-   private void loadDeployers(VirtualFile deployersDir)
-      throws IOException
-   {
-      List<VirtualFile> children = deployersDir.getChildren();
-      for(VirtualFile vf : children)
-      {
-         VFSDeployment vfCtx = loadDeploymentData(vf, DeploymentPhase.DEPLOYER);
-         deployerCtxs.put(vfCtx.getName(), vfCtx);       
-      }
-   }
-
-   /**
-    * Load all the applications under the applicationDir.
-    * 
-    * @param applicationDir
-    * @throws IOException
-    */
-   private void loadApplications(VirtualFile applicationDir)
-      throws Exception
-   {
-      ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
-      addedDeployments(added, applicationDir);
-      for (VirtualFile vf : added)
-      {
-         VFSDeployment vfCtx = loadDeploymentData(vf, DeploymentPhase.APPLICATION);
-         applicationCtxs.put(vfCtx.getName(), vfCtx);
-      }
-   }
-
-   /**
-    * Added deployments for DeploymentPhase.APPLICATION.
-    * 
-    * @param list
-    * @param root
-    * @throws Exception
-    */
-   private void addedDeployments(List<VirtualFile> list, VirtualFile root)
-      throws Exception
-   {
-      List<VirtualFile> components = root.getChildren();
-
-      for (VirtualFile component : components)
-      {
-         // Excluding files from scanning
-         if(! this.deploymentFilter.accepts(component))
-         {
-            log.trace("ignoring "+ component);
-            continue;
-         }
-         
-         String key = component.toURI().toString();
-         if (applicationCtxs.containsKey(key) == true)
-            continue;
-
-         if (component.isLeaf())
-         {
-            list.add(component);
-         }
-         else if (component.getName().indexOf('.') == -1)
-         {
-            // recurse if not '.' in name and recursive search is enabled
-            addedDeployments(list, component);
-         }
-         else
-         {
-            list.add(component);
-         }
-      }
-   }
-
-   /**
-    * Update a deployment.
-    * 
-    * @param d the deployment
-    * @param phase the deployment phase
-    * @param comp the managed component
-    * @throws Exception
-    */
-   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
-         ManagedComponent comp) throws Exception
-   {
-      if(comp != null)
-      {
-         // update component
-         super.updateDeployment(d, phase, comp);
-         // Update last modified
-         this.lastModified = System.currentTimeMillis();
-      }
-      else
-      {
-         log.error("no metadata attached.");
-      }
-   }
-   
-   protected VFSDeployment loadDeploymentData(VirtualFile file, DeploymentPhase phase)
-   {
-      try
-      {
-         return super.loadDeploymentData(file, phase);
-      }
-      catch(Exception e)
-      {
-         throw new RuntimeException("Could not load deployment data: "+ file, e);
-      }
-   }
-
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,159 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.io.File;
-import java.net.URI;
-import java.util.HashMap;
-
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.virtual.VirtualFileFilter;
-
-/**
- * Factory for SerializableDeploymentRepository
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class SerializableDeploymentRepositoryFactory
-   implements DeploymentRepositoryFactory
-{
-   /** The server root containing the deployments */
-   private File root;
-   /** The root location for admin edits */
-   private String attachmentsRoot;
-   /** The URIs for the application deployments */
-   private URI[] appURIs = {};
-   /** The attachment serializer */
-   private AttachmentsSerializer serializer;
-   /** The main deployer structure */
-   private MainDeployerStructure mainDeployer;
-   /** The deployment filter */
-   private VirtualFileFilter deploymentFilter;
-   /** The HotDeployment filter */
-   private VirtualFileFilter hotDeploymentFilter;
-   
-   /** The profile repositories */
-   private HashMap<ProfileKey, DeploymentRepository> profileRepositories
-      = new HashMap<ProfileKey, DeploymentRepository>();
-   
-   /**
-    * Get the server profile store root directory.
-    * @return the server profile root directory containing the
-    * available profiles.
-    */
-   public File getStoreRoot()
-   {
-      return root;
-   }
-   /**
-    * Set the profiles store root.
-    * @param root - the server profile root directory containing the
-    * available profiles.
-    */
-   public void setStoreRoot(File root)
-   {
-      this.root = root;
-   }
-   public String getAttachmentsRoot()
-   {
-      return attachmentsRoot;
-   }
-   public void setAttachmentsRoot(String attachmentsRoot)
-   {
-      this.attachmentsRoot = attachmentsRoot;
-   }
-   public URI[] getApplicationURIs()
-   {
-      return appURIs;
-   }
-   public void setApplicationURIs(URI[] appURIs)
-   {
-      this.appURIs = appURIs;
-   }
-
-   public AttachmentsSerializer getSerializer()
-   {
-      return serializer;
-   }
-
-   public void setSerializer(AttachmentsSerializer serializer)
-   {
-      this.serializer = serializer;
-   }
-   
-   public VirtualFileFilter getDeploymentFilter()
-   {
-      return deploymentFilter;
-   }
-   
-   public void setDeploymentFilter(VirtualFileFilter deploymentFilter)
-   {
-      this.deploymentFilter = deploymentFilter;
-   }
-   
-   public VirtualFileFilter getHotDeploymentFilter()
-   {
-      return hotDeploymentFilter;
-   }
-   
-   public void setHotDeploymentFilter(VirtualFileFilter hotDeploymentFilter)
-   {
-      this.hotDeploymentFilter = hotDeploymentFilter;
-   }
-   
-   public MainDeployerStructure getMainDeployer()
-   {
-      return mainDeployer;
-   }
-   
-   public void setMainDeployer(MainDeployerStructure mainDeployer)
-   {
-      this.mainDeployer = mainDeployer;
-   }
-
-   public synchronized DeploymentRepository getDeploymentRepository(ProfileKey key)
-   {
-      if (appURIs == null || appURIs.length == 0)
-      {
-         File deployDir = new File(root, key.getName()+"/deploy");
-         appURIs = new URI[]{deployDir.toURI()};
-      }
-      DeploymentRepository dr = profileRepositories.get(key);
-      if(dr == null)
-      {
-         SerializableDeploymentRepository repo = new SerializableDeploymentRepository(root, appURIs, key);
-         repo.setAttachmentsRoot(attachmentsRoot);
-         repo.setSerializer(serializer);
-         repo.setDeploymentFilter(deploymentFilter);
-         repo.setHotDeploymentFilter(hotDeploymentFilter);
-         repo.setMainDeployer(mainDeployer);
-         profileRepositories.put(key, repo);
-         dr = repo;
-      }
-      return dr;
-   }
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,188 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+
+/** 
+ * A profile factory based on a static configuration. 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class StaticProfileFactory extends AbstractProfileFactory
+{
+
+   /** The bootstrap profile name. */
+   private static final String BOOTSTRAP_NAME = "bootstrap";
+   
+   /** The deployers profile name. */
+   private static final String DEPLOYERS_NAME = "deployers";
+   
+   /** The bootstrap uri. */
+   private URI bootstrapURI;
+   
+   /** The deployers uri. */
+   private URI deployersURI;
+   
+   /** The attachment store uri. */
+   private URI attachmentStoreRoot;
+   
+   /** The application uris. */
+   private List<URI> applicationURIs;
+
+   public URI getBootstrapURI()
+   {
+      return bootstrapURI;
+   }
+
+   public void setBootstrapURI(URI bootstrapURI)
+   {
+      this.bootstrapURI = bootstrapURI;
+   }
+
+   public URI getDeployersURI()
+   {
+      return deployersURI;
+   }
+
+   public void setDeployersURI(URI deployersURI)
+   {
+      this.deployersURI = deployersURI;
+   }
+
+   public URI getAttachmentStoreRoot()
+   {
+      return attachmentStoreRoot;
+   }
+
+   public void setAttachmentStoreRoot(URI attachmentStoreRoot)
+   {
+      this.attachmentStoreRoot = attachmentStoreRoot;
+   }
+
+   public List<URI> getApplicationURIs()
+   {
+      return applicationURIs;
+   }
+   
+   public void setApplicationURIs(List<URI> applicationURIs)
+   {
+      this.applicationURIs = applicationURIs;
+   }
+   
+   public URI getTemplateRoot()
+   {
+      // Used for the management view
+      return this.applicationURIs.get(0);
+   }
+
+   /**
+    * Create the legacy profiles, based on the injected uris. 
+    * 
+    * @param server The Server.
+    * @throws Exception
+    */
+   @Override
+   protected void createProfileMetaData(Server server) throws Exception
+   {
+      if(server == null)
+         throw new IllegalArgumentException("Null server");
+      
+      // Create bootstrap profile meta data
+      ProfileKey bootstrapKey = new ProfileKey(BOOTSTRAP_NAME);
+      ProfileMetaData bootstrap = createProfileMetaData(
+            BOOTSTRAP_NAME, DefaultDeploymentRepositoryFactory.IMMUTABLE_TYPE, new URI[] { bootstrapURI }, new String[0]);
+      addProfile(bootstrapKey, bootstrap);
+      
+      // Create deployers profile meta data
+      ProfileKey deployersKey = new ProfileKey(DEPLOYERS_NAME);
+      ProfileMetaData deployers = createProfileMetaData(
+            DEPLOYERS_NAME, DefaultDeploymentRepositoryFactory.IMMUTABLE_TYPE, new URI[] { deployersURI }, new String[] { BOOTSTRAP_NAME });
+      addProfile(deployersKey, deployers);
+
+      // Create ${serverName} profile meta data
+      String rootName = server.getConfig().getServerName();
+      ProfileKey rootKey = new ProfileKey(rootName);
+      URI[] rootURIs = applicationURIs.toArray(new URI[applicationURIs.size()]);
+      String[] rootSubProfiles = new String[] { BOOTSTRAP_NAME, DEPLOYERS_NAME };
+      ProfileMetaData root = createProfileMetaData(
+            rootName, DefaultDeploymentRepositoryFactory.MUTABLE_TYPE, rootURIs, rootSubProfiles);
+      // Add to profile map
+      addProfile(rootKey, root);
+   }
+   
+   /**
+    * Create a profile meta data.
+    * 
+    * @param name the profile name.
+    * @param repositoryType the repository type.
+    * @param uris the repository uris.
+    * @param subProfiles a list of profile dependencies.
+    * @return the profile meta data.
+    */
+   protected ProfileMetaData createProfileMetaData(String name, String repositoryType, URI[] uris, String[] subProfiles)
+   {
+      // Create profile
+      ProfileMetaData metaData = new ProfileMetaData();
+      metaData.setName(name);
+      // Create profile sources
+      List<ProfileSourceMetaData> sources = new ArrayList<ProfileSourceMetaData>();
+      for(URI uri : uris)
+         sources.add(createSource(repositoryType, uri));
+      metaData.setSources(sources);
+      
+      List<SubProfileMetaData> profileList = new ArrayList<SubProfileMetaData>();
+      for(String subProfile : subProfiles)
+      {
+         SubProfileMetaData md = new SubProfileMetaData();
+         md.setName(subProfile);
+         profileList.add(md);
+      }
+      metaData.setSubprofiles(profileList);
+      
+      return metaData;
+   }
+   
+   /**
+    * Create a profile repository source meta data.
+    * 
+    * @param type the repository type.
+    * @param uri the uri
+    * @return the profile source meta data.
+    */
+   protected ProfileSourceMetaData createSource(String type, URI uri)
+   {
+      ProfileSourceMetaData source = new ProfileSourceMetaData();
+      source.setType(type);
+      source.setSource(uri.toString());
+      return source;
+   }
+}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/TCLObjectInputStream.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/TCLObjectInputStream.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/TCLObjectInputStream.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.system.server.profileservice.repository;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectStreamClass;
-
-import org.jboss.logging.Logger;
-
-/**
- * Use the TCL to load a class on a CNFE as the ObjectInputStream
- * fails to use the TCL one would expect it to.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class TCLObjectInputStream
-   extends ObjectInputStream
-{
-   private static Logger log = Logger.getLogger(TCLObjectInputStream.class);
-   private ClassLoader loader;
-
-   public TCLObjectInputStream(InputStream in, ClassLoader loader)
-      throws IOException
-   {
-      super(in);
-      this.loader = loader;
-   }
-
-   @Override
-   protected Class<?> resolveClass(ObjectStreamClass desc)
-      throws IOException, ClassNotFoundException
-   {
-      String name = desc.getName();
-      try
-      {
-         return super.resolveClass(desc);
-      }
-      catch(ClassNotFoundException e)
-      {
-         log.debug("ClassNotFoundException for name="+name+", retrying using TCL");
-         return Class.forName(name, false, loader);
-      }
-   }
-
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+
+/**
+ * The profile repository.
+ * 
+ * This accepts any implementation of DeploymentRepositoryFactory and dispatches
+ * the creation of the repository to one of the installed factories, based on
+ * the exposed types. 
+ * 
+ * TODO reuse DeploymentRepositories with the same sources ?
+ * TODO handle different profileSources in one Profile
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TypedProfileRepository implements ProfileRepository
+{
+   /** The default repository type. */
+   private static final String DEFAULT_REPOSITORY_TYPE = DefaultDeploymentRepositoryFactory.IMMUTABLE_TYPE;
+   
+   /** The repository factories. */
+   private Map<String, DeploymentRepositoryFactory> repositoryFactories = new ConcurrentHashMap<String, DeploymentRepositoryFactory>();
+
+   /** The created repositories. */
+   private Map<ProfileKey, DeploymentRepository> repositories = new ConcurrentHashMap<ProfileKey, DeploymentRepository>();
+   
+   public Collection<ProfileKey> getProfileKeys()
+   {
+      return this.repositories.keySet();
+   }
+
+   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
+   {
+      return this.repositories.get(key);
+   }
+   
+   public DeploymentRepository createProfileDeploymentRepository(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {
+      if(metaData == null)
+         throw new IllegalArgumentException("Null metaData");
+      if(metaData.getName() == null)
+         throw new IllegalArgumentException("Null metaData name");
+      
+      DeploymentRepository repository = this.repositories.get(key);
+      if(repository == null)
+      {
+         String type = null;
+         if(metaData.getSources() == null || metaData.getSources().isEmpty())
+            throw new IllegalStateException("No profile sources.");
+         
+         for(ProfileSourceMetaData source : metaData.getSources())
+         {
+            if(type == null && source.getType() != null)
+            {
+               // TODO handle different source types.
+               type = source.getType();
+               break;
+            }
+         }
+         if( type == null )
+            type = DEFAULT_REPOSITORY_TYPE;
+
+         // TODO maybe reuse already created repositories
+         repository = createProfileDeploymentRepository(key, type , metaData);
+         if(repository != null)
+         {
+            this.repositories.put(key, repository);
+         }
+      }
+      return repository;
+   }
+   
+   protected DeploymentRepository createProfileDeploymentRepository(ProfileKey key, String repositoryType, ProfileMetaData metaData) throws Exception
+   {
+      DeploymentRepositoryFactory factory = this.repositoryFactories.get(repositoryType);
+      if(factory ==  null)
+         throw new IllegalStateException("No registered factory for repository type: "+ repositoryType);
+      
+      return factory.createDeploymentRepository(key, metaData);
+   }
+
+   public void removeProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
+   {
+      DeploymentRepository repository = this.repositories.remove(key);
+      if(repository == null)
+         throw new NoSuchProfileException("No such profile: "  + key);
+      if(repository != null)
+      {
+         repository.remove();
+      }
+   }
+   
+   public void addRepositoryFactory(DeploymentRepositoryFactory factory)
+   {
+      if(factory == null)
+         throw new IllegalArgumentException("Null factory.");
+      if(factory.getTypes() == null)
+         throw new IllegalArgumentException("Empty factory type.");
+      
+      for(String type : factory.getTypes())
+         this.repositoryFactories.put(type, factory);
+   }
+   
+   public void removeRepositoryFactory(DeploymentRepositoryFactory factory)
+   {
+      if(factory == null)
+         throw new IllegalArgumentException("Null factory.");
+      if(factory.getTypes() == null)
+         throw new IllegalArgumentException("Empty factory type.");
+      
+      for(String type : factory.getTypes())
+         this.repositoryFactories.remove(type);
+   }
+}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,123 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.system.server.profileservice.repository;
-
-import java.net.URI;
-import java.util.Collections;
-import java.util.Map;
-
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.repository.Capability;
-import org.jboss.profileservice.spi.repository.Repository;
-import org.jboss.profileservice.spi.repository.Requirement;
-import org.jboss.profileservice.spi.repository.Resource;
-import org.jboss.profileservice.spi.repository.Version;
-
-/**
- * TODO: scan deployment for manifest with osgi header info like
- * the version, requirements.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class VFSDeploymentResource
-   implements Resource
-{
-   private VFSDeployment deployment;
-   private Repository repository;
-   private String[] categories = {};
-   private Capability[] capabilities;
-   private Map<String, Object> props;
-
-   public VFSDeploymentResource(VFSDeployment deployment, DeploymentPhase phase,
-         Repository repository)
-   {
-      this.deployment = deployment;
-      this.repository = repository;
-      CapabilityImpl ci = new CapabilityImpl("deployment");
-      ci.addProperty("phase", phase);
-      this.capabilities = new Capability[]{ci};
-      this.props = Collections.singletonMap("deployment", (Object)deployment);
-   }
-
-   public Capability[] getCapabilities()
-   {
-      return capabilities;
-   }
-
-   public String[] getCategories()
-   {
-      return categories;
-   }
-
-   public String getId()
-   {
-      return deployment.getName();
-   }
-
-   public String getPresentationName()
-   {
-      return deployment.getSimpleName();
-   }
-
-   public Map getProperties()
-   {
-      return props;
-   }
-
-   public Repository getRepository()
-   {
-      return repository;
-   }
-
-   public Requirement[] getRequirements()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   public String getSymbolicName()
-   {
-      return deployment.getName();
-   }
-
-   public URI getURI()
-   {
-      URI uri = null;
-      try
-      {
-         uri = deployment.getRoot().toURI();
-      }
-      catch(Exception e)
-      {
-         throw new IllegalStateException(e);
-      }
-      return uri;
-   }
-
-   public Version getVersion()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }  
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfilesMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+
+/**
+ * A profile factory based which generates the ProfileMetaData based on .xml files.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class XmlProfileFactory extends AbstractProfileFactory
+{
+   /** The profiles directory name. */
+   public final static String PROFILES_DIRECTORY = "profiles";
+
+   /** The schema resolver. */
+   private static final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+   
+   /** A xml include filter. */
+   private final static VirtualFileFilter xmlIncludeFilter = new XmlIncludeFilter();
+   
+   /** The unmarshaller. */
+   private Unmarshaller unmarshaller;
+   
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(XmlProfileFactory.class);
+   
+   static
+   {
+      // TODO namespace and xsd.
+      resolver.addClassBinding("", ProfilesMetaData.class);
+   }
+   
+   /**
+    * Create the profile meta data based on the .xml files found in the folders:
+    * - server/${config}/conf/profiles
+    * - common/profiles
+    * 
+    * @param server The Server.
+    * @throws Exception
+    */
+   @Override
+   protected void createProfileMetaData(Server server) throws Exception
+   {
+      // Setup the profile directories
+      VirtualFile serverConfig = VFS.getCachedFile(server.getConfig().getServerConfigURL());
+      VirtualFile commonDir = VFS.getCachedFile(server.getConfig().getCommonBaseURL());
+      
+      /** The server/${config}/conf/profiles directory */
+      VirtualFile profilesDir = serverConfig.getChild(PROFILES_DIRECTORY);
+      /** The common/profiles directory */
+      VirtualFile commonProfilesDir = commonDir.getChild(PROFILES_DIRECTORY);
+      
+      // Create the unmarshaller
+      this.unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+      
+      // Parse the conf/profiles dir
+      if(profilesDir != null && profilesDir.exists())
+      {
+         parseProfiles(profilesDir);
+      }
+      // Parse the common/profiles dir
+      if(commonProfilesDir != null && commonProfilesDir.exists())
+      {
+         parseProfiles(commonProfilesDir);
+      }
+      if(profilesDir == null
+            && profilesDir.exists() == false 
+            && commonDir == null
+            && commonDir.exists() == false)
+         throw new IllegalArgumentException("No profile directories found.");
+   }
+
+   /**
+    * Parse all .xml files in a directory.
+    * 
+    * @param profileDirectory the directory
+    * @throws IOException
+    * @throws JBossXBException
+    */
+   protected void parseProfiles(VirtualFile profileDirectory) throws IOException, JBossXBException
+   {
+      List<VirtualFile> fileList = profileDirectory.getChildren(xmlIncludeFilter);
+      if(fileList != null && fileList.isEmpty() == false)
+      {
+         for(VirtualFile vf : fileList)
+         {
+            ProfilesMetaData profilesMetaData = parse(vf);
+            if(profilesMetaData == null)
+               throw new IllegalStateException("Parsing returned for file: "+ vf.getPathName());
+            
+            processProfilesMetaData(profilesMetaData);
+         }
+      }
+   }
+   
+   /**
+    * Process the <profiles> meta data.
+    * FIXME this sets some additional dependencies based on the ordering of xml. 
+    * 
+    * @param profilesMetaData the profiles meta data
+    */
+   protected void processProfilesMetaData(ProfilesMetaData profilesMetaData)
+   {
+      // The <profiles> key
+      ProfileKey profilesKey = new ProfileKey(profilesMetaData.getDomain(), profilesMetaData.getServer(), profilesMetaData.getName());
+      if(profilesMetaData.getProfiles() != null && profilesMetaData.getProfiles().isEmpty() == false)
+      {
+         ProfileKey profileDependencyHack = null;
+         for(ProfileMetaData profile : profilesMetaData.getProfiles())
+         {
+            // The <profile> key
+            ProfileKey profileKey = new ProfileKey(profile.getDomain(), profile.getServer(), profile.getName());
+          
+            // FIXME Add a dependency as subprofile to the profile based on the xml ordering
+            if(profileDependencyHack != null)
+            {
+               addDependency(profileDependencyHack, profile);
+            }
+            
+            addProfile(profileKey, profile);
+            profileDependencyHack = profileKey;
+         }
+      }
+      // Add the profiles for later resolution
+      addProfiles(profilesKey, profilesMetaData.getProfiles());
+   }
+   
+   /**
+    * Add a dependency to another profile as sub-profile, based on the
+    * ProfileKey
+    * 
+    * @param key the profile key.
+    * @param metaData the profile meta data.
+    */
+   protected void addDependency(ProfileKey key, ProfileMetaData metaData)
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null key.");
+      if(metaData == null)
+         throw new IllegalArgumentException("Null metaData");
+
+      if(log.isTraceEnabled())
+         log.trace("Adding sub-profile dependency (" + key + ") for profile: " + metaData.getName());
+      
+      SubProfileMetaData subProfileDependency = new SubProfileMetaData();
+      subProfileDependency.setDomain(key.getDomain());
+      subProfileDependency.setServer(key.getServer());
+      subProfileDependency.setName(key.getName());
+      
+      List<SubProfileMetaData> subProfiles = metaData.getSubprofiles();
+      if(subProfiles == null)
+      {
+         subProfiles = new ArrayList<SubProfileMetaData>();
+         metaData.setSubprofiles(subProfiles);
+      }
+      subProfiles.add(subProfileDependency);
+   }
+   
+   /**
+    * Parse a profile file.
+    * 
+    * @param vf the virtual file.
+    * @return the <profiles> meta data
+    * @throws JBossXBException
+    * @throws IOException
+    */
+   protected ProfilesMetaData parse(VirtualFile vf) throws JBossXBException, IOException
+   {
+      if(log.isTraceEnabled())
+         log.trace("parsing file: " + vf.getPathName());
+      return (ProfilesMetaData) unmarshaller.unmarshal(vf.openStream(), resolver);
+   }
+   
+   private static final class XmlIncludeFilter implements VirtualFileFilter
+   {
+      public boolean accepts(VirtualFile file)
+      {
+         return file.getName().endsWith(".xml");
+      }
+   }
+}
+

Added: trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml	                        (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,13 @@
+<profiles name="clustering">
+
+	<profile name="clustering-deployers">
+		<source>${jboss.server.base.url}deployers</source>
+		<deployment>clustering-deployer-jboss-beans.xml</deployment>
+	</profile>
+
+	<profile name="clustering-runtime">
+		<source type="mutable">${jboss.server.base.url}deploy</source>
+		<deployment>httpha-invoker.sar</deployment>
+	</profile>
+
+</profiles>
\ No newline at end of file

Added: trunk/system/src/resources/parsing-tests/common/profiles/common.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/common.xml	                        (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/common.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,8 @@
+<profiles>
+
+	<profile name="metadata-deployers">
+		<source>${jboss.server.base.url}deployers</source>
+		<deployment>metadata-deployer-jboss-beans.xml</deployment>
+	</profile>
+
+</profiles>
\ No newline at end of file

Added: trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml	                        (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,16 @@
+<profiles name="ejb3">
+
+	<profile name="ejb3-deployers">
+		<source>${jboss.server.base.url}deployers</source>
+		<sub-profile>metadata-deployers</sub-profile>
+		<deployment>ejb3.deployer</deployment>
+	</profile>
+
+	<profile name="ejb3-runtime">
+		<source>${jboss.server.base.url}deploy</source>
+		<deployment>ejb3-container-jboss-beans.xml</deployment>
+		<deployment>ejb3-interceptors-aop.xml</deployment>
+		<deployment>ejb3-timer-service.xml</deployment>
+	</profile>
+
+</profiles>
\ No newline at end of file

Added: trunk/system/src/resources/parsing-tests/common/profiles/web.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/web.xml	                        (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/web.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,14 @@
+<profiles name="jboss-web">
+
+	<profile name="jboss-web-deployers">
+		<source>${jboss.server.base.url}deployers</source>
+		<sub-profile>metadata-deployers</sub-profile>
+		<deployment>jbossweb.deployer</deployment>
+	</profile>
+	
+	<profile name="jboss-web-runtime">
+		<source>${jboss.server.base.url}deploy</source>
+		<deployment>jbossweb.sar</deployment>
+	</profile>
+
+</profiles>
\ No newline at end of file

Added: trunk/system/src/resources/parsing-tests/config/profiles/default.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/config/profiles/default.xml	                        (rev 0)
+++ trunk/system/src/resources/parsing-tests/config/profiles/default.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,18 @@
+<profiles>
+
+	<profile name="bootstrap">
+		<source>${jboss.server.base.url}conf</source>	
+		<deployment>jboss-service.xml</deployment>
+	</profile>
+
+	<profile name="default">
+		<source>${jboss.server.base.url}deploy</source>
+		<source>${jboss.server.base.url}deploy2</source>
+		<sub-profile>seam</sub-profile>
+		<sub-profile>jboss-web</sub-profile>
+		<sub-profile>clustering</sub-profile>
+		<deployment>myDeployment.jar</deployment>
+		<deployment>myDeployment12.jar</deployment>
+	</profile>
+
+</profiles>
\ No newline at end of file

Added: trunk/system/src/resources/parsing-tests/config/profiles/seam.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/config/profiles/seam.xml	                        (rev 0)
+++ trunk/system/src/resources/parsing-tests/config/profiles/seam.xml	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,9 @@
+<profiles name="seam">
+
+	<profile name="seam-deployers">
+		<source>${jboss.server.base.url}deployers</source>
+		<sub-profile>ejb3</sub-profile>
+		<deployment>seam.deployer</deployment>
+	</profile>
+
+</profiles>
\ No newline at end of file

Added: trunk/system/src/resources/server-root/conf/jboss-service.xml
===================================================================

Added: trunk/system/src/resources/server-root/deploy/ejb3-container-jboss-beans.xml
===================================================================

Added: trunk/system/src/resources/server-root/deploy/ejb3-interceptors-aop.xml
===================================================================

Added: trunk/system/src/resources/server-root/deploy/ejb3-timer-service.xml
===================================================================

Added: trunk/system/src/resources/server-root/deploy/httpha-invoker.sar
===================================================================

Added: trunk/system/src/resources/server-root/deploy/jbossweb.sar
===================================================================

Added: trunk/system/src/resources/server-root/deploy/myDeployment.jar
===================================================================

Added: trunk/system/src/resources/server-root/deploy2/myDeployment12.jar
===================================================================

Added: trunk/system/src/resources/server-root/deployers/clustering-deployer-jboss-beans.xml
===================================================================

Added: trunk/system/src/resources/server-root/deployers/ejb3.deployer
===================================================================

Added: trunk/system/src/resources/server-root/deployers/jbossweb.deployer
===================================================================

Added: trunk/system/src/resources/server-root/deployers/metadata-deployer-jboss-beans.xml
===================================================================

Added: trunk/system/src/resources/server-root/deployers/seam.deployer
===================================================================

Deleted: trunk/system/src/tests/org/jboss/test/server/profileservice/MainTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/MainTestCase.java	2009-01-13 12:51:17 UTC (rev 82808)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/MainTestCase.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -1,147 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.server.profileservice;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-
-import org.jboss.Main;
-import org.jboss.bootstrap.microcontainer.ServerImpl;
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.test.BaseTestCase;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Test of the jboss main loading a configuration via the ProfileService.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class MainTestCase extends BaseTestCase
-{
-   public MainTestCase(String name)
-   {
-      super(name);
-   }
-
-   // Public --------------------------------------------------------
-
-   public void testCreateDefaultProfile() throws Throwable
-   {
-      // Set the jboss.server.home.url property to the system/src/resources dir
-      URL bootstrapDir = super.getResource("/bootstrap");
-      log.info("bootstrapDir: "+bootstrapDir);
-      URL resourcesDir = new URL(bootstrapDir, "..");
-      log.info("resourcesDir: "+resourcesDir);
-      System.setProperty("jboss.server.home.url", resourcesDir.toString());
-      System.setProperty(ServerConfig.EXIT_ON_SHUTDOWN, "false");
-      URL bootstrapURL = new URL(bootstrapDir, "bootstrap/default/deployer-beans.xml");
-      System.setProperty(ServerConfig.BOOTSTRAP_URL, bootstrapURL.toString());
-      
-      //
-      ServerImpl server = new ServerImpl();
-      server.init(System.getProperties());
-      server.start();
-      try
-      {
-         Kernel kernel = server.getKernel();
-         ProfileService ps = getBean(kernel, "ProfileService", ProfileService.class);
-         ProfileKey defaultKey = new ProfileKey("default");
-         Profile profile = ps.getProfile(defaultKey);
-         VFSDeployment testBeans = profile.getDeployment("test-beans.xml", DeploymentPhase.APPLICATION);
-         if( testBeans == null )
-         {
-            if( profile == null )
-               profile = ps.newProfile(defaultKey);
-            MainDeployer deployer = getBean(kernel, "MainDeployer", MainDeployer.class);
-            VFS vfs = VFS.getVFS(resourcesDir);
-            VirtualFile file = vfs.findChild("deploy/beans/test-beans.xml");
-            testBeans = createDeployment(file);
-            deployer.addDeployment(testBeans);
-            profile.addDeployment(testBeans, DeploymentPhase.APPLICATION);
-         }
-         // Validate the deployment
-         testBeans = profile.getDeployment("test-beans.xml", DeploymentPhase.APPLICATION);
-         assertNotNull(testBeans);
-         // TODO String type = testBeans.getType();
-         // assertEquals("Deployment type is beans", "beans", type);
-      }
-      finally
-      {
-         server.shutdown();
-      }
-   }
-   
-   /**
-    * Test the startup of the org.jboss.Main entry point using the "default"
-    * profile.
-    * @throws Exception
-    */
-   public void testDefaultStartup() throws Exception
-   {
-      // Set the jboss.server.home.url property to the system/src/resources dir
-      URL bootstrapDir = super.getResource("/bootstrap");
-      log.info("bootstrapDir: "+bootstrapDir);
-      URL resourcesDir = new URL(bootstrapDir, "..");
-      log.info("resourcesDir: "+resourcesDir);
-      System.setProperty("jboss.server.home.url", resourcesDir.toString());
-      // Set the jbosstest.support.dir to output/tests-support
-      File supportDir = new File("output/tests-support");
-      System.setProperty("jbosstest.support.dir", supportDir.toString());
-      System.setProperty(ServerConfig.EXIT_ON_SHUTDOWN, "false");
-      URL bootstrapURL = new URL(bootstrapDir, "bootstrap/default/deployer-beans.xml");
-      System.setProperty(ServerConfig.BOOTSTRAP_URL, bootstrapURL.toString());
-
-      ArrayList<String> args = new ArrayList<String>();
-      String[] tmp = {};
-      Main main = new Main();
-      main.boot(args.toArray(tmp));
-      main.shutdown();
-   }
-
-   protected <T> T getBean(Kernel kernel, String name, Class<T> expectedType)
-   {
-      KernelController controller = kernel.getController();
-      ControllerContext context = controller.getInstalledContext(name);
-      if (context == null)
-         fail("Context not installed " + name);
-      Object result = context.getTarget();
-      return expectedType.cast(result);
-   }
-
-   protected VFSDeployment createDeployment(VirtualFile file)
-   {
-      return VFSDeploymentFactory.getInstance().createVFSDeployment(file);
-   }
-}

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.support;
+
+import java.net.URI;
+
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.profileservice.spi.AttachmentStore;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MockAttachmentStore implements AttachmentStore
+{
+
+   private final static VFSDeploymentFactory factory = VFSDeploymentFactory.getInstance();
+   
+   public URI getAttachmentStoreRoot()
+   {
+      return null;
+   }
+
+   public VFSDeployment loadDeploymentData(VirtualFile vfsPath) throws Exception
+   {
+      return factory.createVFSDeployment(vfsPath);
+   }
+
+   public void updateDeployment(VFSDeployment deployment, ManagedComponent comp) throws Exception
+   {
+      // nothing
+   }
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockMainDeployer.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockMainDeployer.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockMainDeployer.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.support;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.DeploymentState;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.util.graph.Graph;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MockMainDeployer implements MainDeployer, MainDeployerStructure
+{
+
+   private Map<String, Deployment> deployments = new HashMap<String, Deployment>();
+   
+   private static final Logger log = Logger.getLogger(MockMainDeployer.class);
+   
+   public void prepareShutdown()
+   {
+      // FIXME prepareShutdown
+      
+   }
+
+   public void shutdown()
+   {
+      // FIXME shutdown
+      
+   }
+
+   public void addDeployment(Deployment deployment) throws DeploymentException
+   {
+      log.debug("add deployment: " + deployment);
+      deployments.put(deployment.getName(), deployment);
+   }
+
+   public void change(String deploymentName, DeploymentStage stage) throws DeploymentException
+   {
+      // FIXME change
+      
+   }
+
+   public void checkComplete() throws DeploymentException
+   {
+      // FIXME checkComplete
+      
+   }
+
+   public void checkComplete(Deployment... deployment) throws DeploymentException
+   {
+      // FIXME checkComplete
+      
+   }
+
+   public void checkComplete(String... names) throws DeploymentException
+   {
+      // FIXME checkComplete
+      
+   }
+
+   public void checkStructureComplete(Deployment... deployments) throws DeploymentException
+   {
+      // FIXME checkStructureComplete
+      
+   }
+
+   public void checkStructureComplete(String... names) throws DeploymentException
+   {
+      // FIXME checkStructureComplete
+      
+   }
+
+   public void deploy(Deployment... deployments) throws DeploymentException
+   {
+      // FIXME deploy
+      
+   }
+
+   public Graph<Map<String, ManagedObject>> getDeepManagedObjects(String name) throws DeploymentException
+   {
+      // FIXME getDeepManagedObjects
+      return null;
+   }
+
+   public Deployment getDeployment(String name)
+   {
+      return this.deployments.get(name);
+   }
+
+   public DeploymentStage getDeploymentStage(String deploymentName) throws DeploymentException
+   {
+      // FIXME getDeploymentStage
+      return null;
+   }
+
+   public DeploymentState getDeploymentState(String name)
+   {
+      // FIXME getDeploymentState
+      return null;
+   }
+
+   public ManagedDeployment getManagedDeployment(String name) throws DeploymentException
+   {
+      // FIXME getManagedDeployment
+      return null;
+   }
+
+   public Map<String, ManagedObject> getManagedObjects(String name) throws DeploymentException
+   {
+      // FIXME getManagedObjects
+      return null;
+   }
+
+   public Collection<Deployment> getTopLevel()
+   {
+      // FIXME getTopLevel
+      return null;
+   }
+
+   public void process()
+   {
+      log.debug("process");      
+   }
+
+   public boolean removeDeployment(Deployment deployment) throws DeploymentException
+   {
+      log.debug("remove deployment: " + deployment);
+      return this.deployments.remove(deployment.getName()) != null;
+   }
+
+   public boolean removeDeployment(String name) throws DeploymentException
+   {
+      // FIXME removeDeployment
+      return false;
+   }
+
+   public void undeploy(Deployment... deployments) throws DeploymentException
+   {
+      // FIXME undeploy
+      
+   }
+
+   public void undeploy(String... names) throws DeploymentException
+   {
+      // FIXME undeploy
+      
+   }
+
+   public DeploymentContext getDeploymentContext(String name)
+   {
+      // FIXME getDeploymentContext
+      return null;
+   }
+
+   public DeploymentContext getDeploymentContext(String name, boolean errorNotFound) throws DeploymentException
+   {
+      // FIXME getDeploymentContext
+      return null;
+   }
+
+   public DeploymentUnit getDeploymentUnit(String name)
+   {
+      // FIXME getDeploymentUnit
+      return null;
+   }
+
+   public DeploymentUnit getDeploymentUnit(String name, boolean errorNotFound) throws DeploymentException
+   {
+      // FIXME getDeploymentUnit
+      return null;
+   }
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.support;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MockProfileRepository implements ProfileRepository
+{
+
+   /** The deployment repository factory. */
+   DeploymentRepositoryFactory repository;
+   
+   public MockProfileRepository(DeploymentRepositoryFactory factory)
+   {
+      this.repository = factory;
+   }
+   
+   public DeploymentRepository createProfileDeploymentRepository(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {
+      return repository.createDeploymentRepository(key, metaData);
+   }
+
+   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
+   {
+      // FIXME
+      return null;
+   }
+
+   public Collection<ProfileKey> getProfileKeys()
+   {
+      return Collections.EMPTY_LIST;
+   }
+
+   public void removeProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
+   {
+      // nothing      
+   }
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockServer.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockServer.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockServer.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.support;
+
+import java.util.Date;
+import java.util.Properties;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.bootstrap.spi.ServerConfig;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MockServer implements Server
+{
+
+   public ServerConfig config;
+   
+   public MockServer(ServerConfig config)
+   {
+      this.config = config;
+   }
+   
+   public ServerConfig getConfig() throws IllegalStateException
+   {
+      return this.config;
+   }
+   
+   public String getBuildDate()
+   {
+      // FIXME getBuildDate
+      return null;
+   }
+
+   public String getBuildID()
+   {
+      // FIXME getBuildID
+      return null;
+   }
+
+   public String getBuildJVM()
+   {
+      // FIXME getBuildJVM
+      return null;
+   }
+
+   public String getBuildNumber()
+   {
+      // FIXME getBuildNumber
+      return null;
+   }
+
+   public String getBuildOS()
+   {
+      // FIXME getBuildOS
+      return null;
+   }
+
+   public Date getStartDate()
+   {
+      // FIXME getStartDate
+      return null;
+   }
+
+   public String getVersion()
+   {
+      // FIXME getVersion
+      return null;
+   }
+
+   public String getVersionName()
+   {
+      // FIXME getVersionName
+      return null;
+   }
+
+   public String getVersionNumber()
+   {
+      // FIXME getVersionNumber
+      return null;
+   }
+
+   public void init(Properties props) throws IllegalStateException, Exception
+   {
+      // FIXME init
+      
+   }
+
+   public boolean isInShutdown()
+   {
+      // FIXME isInShutdown
+      return false;
+   }
+
+   public boolean isStarted()
+   {
+      // FIXME isStarted
+      return false;
+   }
+
+   public void shutdown() throws IllegalStateException
+   {
+      // FIXME shutdown
+      
+   }
+
+   public void start() throws IllegalStateException, Exception
+   {
+      // FIXME start
+      
+   }
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockServerConfig.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockServerConfig.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockServerConfig.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,232 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.support;
+
+import java.io.File;
+import java.net.URL;
+
+import org.jboss.bootstrap.spi.ServerConfig;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MockServerConfig implements ServerConfig
+{
+   String serverName;
+   URL configURL;
+   URL commonBaseURL;
+   
+   public MockServerConfig(String serverName, URL configURL, URL commonBaseURL)
+   {
+      if(serverName == null)
+         throw new IllegalArgumentException("Null serverName");
+      if(configURL == null)
+         throw new IllegalArgumentException("Null configURL");
+      if(commonBaseURL == null)
+         throw new IllegalArgumentException("Null commonBaseURL");
+      
+      this.serverName = serverName;
+      this.configURL = configURL;
+      this.commonBaseURL = commonBaseURL;
+   }
+   
+   public URL getServerConfigURL()
+   {
+      return this.configURL;
+   }
+   
+   public URL getCommonBaseURL()
+   {
+      return this.commonBaseURL;
+   }
+   
+   public String getServerName()
+   {
+      return this.serverName;
+   }
+   
+   public boolean getBlockingShutdown()
+   {
+      // FIXME getBlockingShutdown
+      return false;
+   }
+
+   public URL getBootstrapURL()
+   {
+      // FIXME getBootstrapURL
+      return null;
+   }
+
+   public URL getCommonLibraryURL()
+   {
+      // FIXME getCommonLibraryURL
+      return null;
+   }
+
+   
+   public boolean getExitOnShutdown()
+   {
+      // FIXME getExitOnShutdown
+      return false;
+   }
+
+   public File getHomeDir()
+   {
+      // FIXME getHomeDir
+      return null;
+   }
+
+   public URL getHomeURL()
+   {
+      // FIXME getHomeURL
+      return null;
+   }
+
+   public URL getLibraryURL()
+   {
+      // FIXME getLibraryURL
+      return null;
+   }
+
+   public URL getPatchURL()
+   {
+      // FIXME getPatchURL
+      return null;
+   }
+
+   public boolean getPlatformMBeanServer()
+   {
+      // FIXME getPlatformMBeanServer
+      return false;
+   }
+
+   public boolean getRequireJBossURLStreamHandlerFactory()
+   {
+      // FIXME getRequireJBossURLStreamHandlerFactory
+      return false;
+   }
+
+   public String getRootDeploymentFilename()
+   {
+      // FIXME getRootDeploymentFilename
+      return null;
+   }
+
+   public File getServerBaseDir()
+   {
+      // FIXME getServerBaseDir
+      return null;
+   }
+
+   public URL getServerBaseURL()
+   {
+      // FIXME getServerBaseURL
+      return null;
+   }
+
+   public File getServerDataDir()
+   {
+      // FIXME getServerDataDir
+      return null;
+   }
+
+   public File getServerHomeDir()
+   {
+      // FIXME getServerHomeDir
+      return null;
+   }
+
+   public URL getServerHomeURL()
+   {
+      // FIXME getServerHomeURL
+      return null;
+   }
+
+   public URL getServerLibraryURL()
+   {
+      // FIXME getServerLibraryURL
+      return null;
+   }
+
+   public File getServerLogDir()
+   {
+      // FIXME getServerLogDir
+      return null;
+   }
+
+   public File getServerNativeDir()
+   {
+      // FIXME getServerNativeDir
+      return null;
+   }
+
+   public File getServerTempDeployDir()
+   {
+      // FIXME getServerTempDeployDir
+      return null;
+   }
+
+   public File getServerTempDir()
+   {
+      // FIXME getServerTempDir
+      return null;
+   }
+
+   public String getSpecificationVersion()
+   {
+      // FIXME getSpecificationVersion
+      return null;
+   }
+
+   public boolean isInstallLifeThread()
+   {
+      // FIXME isInstallLifeThread
+      return false;
+   }
+
+   public void setBlockingShutdown(boolean blockingShutdown)
+   {
+      // FIXME setBlockingShutdown
+      
+   }
+
+   public void setExitOnShutdown(boolean flag)
+   {
+      // FIXME setExitOnShutdown
+      
+   }
+
+   public void setRequireJBossURLStreamHandlerFactory(boolean requireJBossURLStreamHandlerFactory)
+   {
+      // FIXME setRequireJBossURLStreamHandlerFactory
+      
+   }
+
+   public void setRootDeploymentFilename(String filename)
+   {
+      // FIXME setRootDeploymentFilename
+      
+   }
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.test;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.profileservice.spi.AttachmentStore;
+import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
+import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.test.BaseTestCase;
+import org.jboss.test.server.profileservice.support.MockAttachmentStore;
+import org.jboss.test.server.profileservice.support.MockMainDeployer;
+import org.jboss.test.server.profileservice.support.MockProfileRepository;
+import org.jboss.test.server.profileservice.support.MockServer;
+import org.jboss.test.server.profileservice.support.MockServerConfig;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractProfileServiceTestBase extends BaseTestCase
+{
+
+   public AbstractProfileServiceTestBase(String name)
+   {
+      super(name);
+   }
+   
+   protected Server createDefaultServer(String name) throws MalformedURLException
+   {
+      File configDir = new File("src/resources/parsing-tests/config/");
+      File commonDir = new File("src/resources/parsing-tests/common/");
+      return createServer(name, configDir.toURL(), commonDir.toURL());
+   }
+
+   protected Server createServer(String name, URL configDir, URL commonDir)
+   {
+      ServerConfig config = new MockServerConfig(name, configDir, commonDir);
+      return createServer(config);
+   }
+   
+   protected Server createServer(ServerConfig config)
+   {
+      return new MockServer(config);
+   }
+   
+   protected MainDeployer createMainDeployer()
+   {
+      return new MockMainDeployer();
+   }
+   
+   protected AttachmentStore createAttachmentStore()
+   {
+      return new MockAttachmentStore();
+   }
+   
+   protected ProfileRepository createProfileRepository(DeploymentRepositoryFactory factory)
+   {
+      return new MockProfileRepository(factory);
+   }   
+
+   
+   
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
+import org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory;
+import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileParsingUnitTestCase extends AbstractProfileServiceTestBase
+{
+
+   /** The profiles */
+   Map<String, Profile> profileMap;
+   
+   public ProfileParsingUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testParsing() throws Exception
+   {
+      enableTrace("org.jboss.system.server.profileservice.repository");
+      
+      // Set the server base url as system property for the repository generation.
+      File serverBaseDir = new File("src/resources/server-root/");
+      System.setProperty("jboss.server.base.url", serverBaseDir.toURL().toExternalForm());
+      
+      // 
+      FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
+      repositoryFactory.setAttachmentStore(createAttachmentStore());
+      AbstractProfileFactory profileFactory = new XmlProfileFactory();
+      profileFactory.setProfileRepository(createProfileRepository(repositoryFactory));
+      
+      // Clear jar suffixes.
+      JarUtils.clearSuffixes();
+      
+      // Parse
+      List<Profile> profiles = profileFactory.createProfiles(createDefaultServer("default"));
+      assertNotNull(profiles);
+      
+      // 2 profiles in default.xml
+      // 1 profile in seam.xml
+      // 2 profiles in clustering.xml
+      // 2 profiles in ejb3.xml
+      // 2 profiles in web.xml
+      assertEquals(10, profiles.size());
+      
+      this.profileMap = new HashMap<String, Profile>();
+      for(Profile profile : profiles)
+      {
+         assertNotNull(profile.getKey());
+         String name = profile.getKey().getName();
+         assertNotNull(name);
+         this.profileMap.put(name, profile);
+      }
+      
+      // Assert Profiles
+      assertProfiles();
+      
+      // Try to load the profiles, this will try to resolve the deploymentNames 
+      // when loading the filtered repository in serverBaseDir.
+      for(Profile profile : profiles)
+      {
+         profile.create();
+      }
+
+      // TODO assert metadata
+   }
+   
+   protected void assertProfiles()
+   {
+      // Assert bootstrap profile
+      assertProfile("bootstrap", 0);
+      
+      // Assert default profile
+      assertProfile("default", 6, new String[] {
+               "bootstrap",
+               "seam-deployers",
+               "jboss-web-deployers",
+               "jboss-web-runtime",
+               "clustering-deployers",
+               "clustering-runtime"});
+      
+      // Assert seam profile
+      assertProfile("seam-deployers", 2,
+            new String[] { "ejb3-deployers", "ejb3-runtime" });
+      
+      // Assert ejb3-deployers profile
+      assertProfile("ejb3-deployers", 1,
+            new String[] { "metadata-deployers" } );
+      
+      // Assert ejb3-runtime profile
+      assertProfile("ejb3-runtime", 1,
+            new String[] { "ejb3-deployers" } );
+    
+      // Assert web-deployers profile
+      assertProfile("jboss-web-deployers", 1,
+            new String[] { "metadata-deployers" } );
+      
+      // Assert web-runtime profile
+      assertProfile("jboss-web-runtime", 1,
+            new String[] { "jboss-web-deployers" } );
+      
+      // Assert clustering-deployers
+      assertProfile("clustering-deployers", 0);
+      
+      // Assert hasingleton
+      assertProfile("clustering-runtime", 1,
+            new String[] { "clustering-deployers" } );
+   }
+   
+   protected void assertProfile(String name, int dependencySize, String[] dependencyNames)
+   {
+      Profile profile = profileMap.get(name);
+      assertNotNull("Null profile: " + name, profile);
+      assertNotNull("Null dependencies for profile: " + name, profile.getDependencies());
+      assertDependenciesSize(dependencySize, profile);
+      assertDependencies(dependencyNames, profile.getDependencies());
+   }
+   
+   protected void assertProfile(String name, int dependencySize)
+   {
+      assertProfile(name, dependencySize, new String[0]);
+   }
+   
+   protected void assertDependenciesSize(int size, Profile profile)
+   {
+      assertEquals("dependency size for profile: " + profile.getKey(), size, profile.getDependencies().size());
+   }
+
+   protected void assertDependencies(String[] dependencyNames, Collection<DependencyItem> dependencies)
+   {
+      if(dependencyNames == null || dependencyNames.length == 0)
+         return;
+      
+      List<String> idependon = new ArrayList<String>();
+      for(DependencyItem item : dependencies)
+      {
+         ProfileKey key = (ProfileKey) item.getIDependOn();
+         assertNotNull(key);
+         idependon.add(key.getName());
+      }
+      
+      // Assert dependency keys
+      for(String name : dependencyNames)
+      {
+         assertTrue("contains name: " + name, idependon.contains(name));
+      }
+   }
+   
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	2009-01-13 12:54:35 UTC (rev 82809)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.test;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
+import org.jboss.system.server.profileservice.repository.AbstractProfileService;
+import org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory;
+import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
+import org.jboss.test.server.profileservice.support.MockMainDeployer;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileServiceUnitTestCase extends AbstractProfileServiceTestBase
+{
+
+   private ProfileService profileService;
+   
+   public ProfileServiceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      // Create profile service
+      MockMainDeployer mainDeployer = new MockMainDeployer();
+      AbstractController parentController = new AbstractController();
+      AbstractProfileService profileService = new AbstractProfileService(parentController);
+      profileService.setDeployer(mainDeployer);
+      // 
+      profileService.create();
+      this.profileService = profileService;
+   }
+   
+   public void testProfileService() throws Exception
+   {
+      // Set the server base url as system property for the repository generation.
+      File serverBaseDir = new File("src/resources/server-root/");
+      System.setProperty("jboss.server.base.url", serverBaseDir.toURL().toExternalForm());
+      
+      // 
+      FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
+      repositoryFactory.setAttachmentStore(createAttachmentStore());
+      AbstractProfileFactory profileFactory = new XmlProfileFactory();
+      profileFactory.setProfileRepository(createProfileRepository(repositoryFactory));
+      
+      // Clear jar suffixes.
+      JarUtils.clearSuffixes();
+      
+      // Parse
+      List<Profile> profiles = profileFactory.createProfiles(createDefaultServer("default"));
+      for(Profile profile : profiles)
+      {        
+         // Register
+         profileService.registerProfile(profile);
+      }
+      
+      // Activate profile
+      profileService.activateProfile(new ProfileKey("default"));
+      
+      // Assert default profile
+      assertActive("default");
+      // Assert bootstrap profile
+      assertActive("bootstrap");
+      // Assert seam profile
+      assertActive("seam-deployers");
+      // Assert ejb3-deployers profile
+      assertActive("ejb3-deployers");
+      // Assert ejb3-runtime profile
+      assertActive("ejb3-runtime");
+      // Assert web-deployers profile
+      assertActive("jboss-web-deployers");
+      // Assert web-runtime profile
+      assertActive("jboss-web-runtime");
+      // Assert clustering-deployers
+      assertActive("clustering-deployers");
+      // Assert hasingleton
+      assertActive("clustering-runtime");
+      // Assert metadata-deployers profile
+      assertActive("metadata-deployers");
+      
+   }
+   
+   protected void assertActive(String profile) throws Exception
+   {
+      assertNotNull(profileService.getActiveProfile(new ProfileKey(profile)));
+   }
+
+}
+




More information about the jboss-cvs-commits mailing list