[jboss-cvs] JBossAS SVN: r87871 - in trunk: system/src/main/org/jboss/system/server/profileservice and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 27 10:58:27 EDT 2009


Author: emuckenhuber
Date: 2009-04-27 10:58:27 -0400 (Mon, 27 Apr 2009)
New Revision: 87871

Added:
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
Removed:
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java
Modified:
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
   trunk/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileStartAction.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/tests/org/jboss/test/server/profileservice/support/MavenProfileMetaData.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.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
   trunk/testsuite/src/resources/test-configs/embedded/conf/bootstrap/profile.xml
Log:
add propOrder and update the usage of DefaultSchemaResolver

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -30,7 +30,6 @@
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
 import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
@@ -46,7 +45,7 @@
 {
 
    /** The profile source. */
-   private ProfileSourceMetaData source;
+   private HotDeploymentProfileSourceMetaData source;
    
    public HotDeploymentProfileMetaData()
    {
@@ -64,12 +63,12 @@
    }
    
    @XmlElement(name = "profile-source", type = HotDeploymentProfileSourceMetaData.class)
-   public ProfileSourceMetaData getSource()
+   public HotDeploymentProfileSourceMetaData getSource()
    {
       return source;
    }
 
-   public void setSource(ProfileSourceMetaData source)
+   public void setSource(HotDeploymentProfileSourceMetaData source)
    {
       this.source = source;
    }

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -56,7 +56,7 @@
    /** The server. */
    private String server;
    
-   /** The doamin. */
+   /** The domain. */
    private String domain;
    
    /** The profiles. */

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -23,7 +23,6 @@
 package org.jboss.system.server.profileservice;
 
 import java.net.URI;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -46,14 +45,6 @@
  */
 public class StaticClusteredProfileFactory extends StaticProfileFactory
 {
-   /** The bootstrap profile name. */
-   private static final String BOOTSTRAP_NAME = "bootstrap";
-   
-   /** The deployers profile name. */
-   private static final String DEPLOYERS_NAME = "deployers";
-   
-   /** The deployers profile name. */
-   private static final String APPLICATIONS_NAME = "applications";
 
    /** The deploy-hasingleton profile name. */
    private static final String HASINGLETON_NAME = "deploy-hasingleton";
@@ -112,56 +103,30 @@
 //         }
 //      }
 //   }
-
+   
    /**
-    * Create the legacy profiles, based on the injected uris. 
+    * Create the cluster profiles, including the application profile from the
+    * StaticProfileFactory.
     * 
-    * @param rootKey the key for the root profile.
-    * @throws Exception
     */
    @Override
-   protected void createProfileMetaData(ProfileKey rootKey, URL url) throws Exception
-   {     
-      if(rootKey == null)
-         throw new IllegalArgumentException("Null root profile key.");
+   protected String[] createApplicationProfiles(String[] applicationsSubProfiles)
+   {
+      // Create the application profile
+      String applicationProfileName = super.createApplicationProfile(applicationsSubProfiles);
       
-      // Create bootstrap profile meta data
-      ProfileKey bootstrapKey = new ProfileKey(BOOTSTRAP_NAME);
-      ProfileMetaData bootstrap = createProfileMetaData(
-            BOOTSTRAP_NAME, false, new URI[] { getBootstrapURI() }, new String[0]);
-      addProfile(bootstrapKey, bootstrap);
-      
-      // Create deployers profile meta data
-      ProfileKey deployersKey = new ProfileKey(DEPLOYERS_NAME);
-      ProfileMetaData deployers = createProfileMetaData(
-            DEPLOYERS_NAME, false, new URI[] { getDeployersURI() }, new String[] { BOOTSTRAP_NAME });
-      addProfile(deployersKey, deployers);
-
-      // Create applications profile;
-      ProfileKey applicationsKey = new ProfileKey(APPLICATIONS_NAME);
-      URI[] deployURIs = getApplicationURIs().toArray(new URI[getApplicationURIs().size()]);
-      String[] applicationSubProfiles = new String[] { BOOTSTRAP_NAME, DEPLOYERS_NAME };
-      ProfileMetaData applications = createProfileMetaData(
-            APPLICATIONS_NAME, true, deployURIs, applicationSubProfiles);
-      addProfile(applicationsKey, applications);
-      
+      // Create the farm profile
       ProfileMetaData farm = null;
       if (getFarmURIs() != null)
       {
          ProfileKey farmKey = new ProfileKey(FARM_NAME);
          URI[] farmURIs = getFarmURIs().toArray(new URI[getFarmURIs().size()]);
-         String[] farmSubProfiles = new String[] { APPLICATIONS_NAME };
+         String[] farmSubProfiles = new String[] { applicationProfileName };
          farm = createClusteredProfileMetaData(
                FARM_NAME, true, farmURIs, farmSubProfiles);
          addProfile(farmKey, farm);         
       }
-      
-      String[] rootSubProfiles = farm == null ? new String[]{APPLICATIONS_NAME} 
-                                              : new String[] { FARM_NAME };
-      ProfileMetaData root = createProfileMetaData(
-            rootKey.getName(), true, new URI[0], rootSubProfiles);
-      addProfile(rootKey, root);
-      
+      // Create the hasingleton profile
       if (getHASingletonURIs() != null)
       {
          ProfileKey hasingletonKey = new ProfileKey(HASINGLETON_NAME);
@@ -173,6 +138,8 @@
                HASINGLETON_NAME, true, hasingletonURIs, hasingletonSubProfiles);
          addProfile(hasingletonKey, hasingletons);         
       }
+      // Return the dependencies for the root profile
+      return farm == null ? new String[] { applicationProfileName } : new String[] { FARM_NAME };
    }
 
    private ProfileMetaData createClusteredProfileMetaData(String name, boolean hotDeployment, URI[] uris, String[] subProfiles)

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-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -32,7 +32,7 @@
  * 
  * @author Scott.Stark at jboss.org
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision:$
+ * @version $Revision$
  */
 public abstract class AbstractFileAttachmentsSerializer
 {

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -23,6 +23,8 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import org.jboss.profileservice.spi.Profile;
 
@@ -31,7 +33,7 @@
  * TODO use jboss-reflect for this.
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision: 84894 $
+ * @version $Revision$
  */
 public abstract class AbstractProfileLifeCycleAction extends AbstractProfileAction
 {
@@ -72,15 +74,27 @@
       {
          return;
       }
-      boolean isAccessible = m.isAccessible();
-      try
+      invoke(profile, m);
+   }
+
+   private static void invoke(Profile profile, final Method method) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+         method.setAccessible(true);
+      else
       {
-         m.setAccessible(true);
-         m.invoke(profile, args);
+         AccessController.doPrivileged(new PrivilegedAction<Object>()
+         {
+            public Object run()
+            {
+               method.setAccessible(true);
+               return null;
+            }
+         });
       }
-      finally
-      {
-         m.setAccessible(isAccessible);
-      }
+      // invoke
+      method.invoke(profile, args);
    }
+   
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -35,6 +35,7 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
@@ -130,6 +131,13 @@
       updateLastModfied();
    }
    
+   /**
+    * Add a deployment to this profile source. 
+    * 
+    * @param vfsPath the deployment name
+    * @param d the deployment
+    * @throws Exception
+    */
    public void addDeployment(String vfsPath, ProfileDeployment d) throws Exception
    {
       if(d == null)
@@ -142,6 +150,12 @@
       updateLastModfied();
    }
    
+   /**
+    * Get the deployment
+    * 
+    * @param vfsPath the deployment
+    * @return the deployment or null if it does not exist
+    */
    public ProfileDeployment getDeployment(String vfsPath) throws NoSuchDeploymentException
    {
       if(vfsPath == null)
@@ -150,6 +164,13 @@
       return this.applicationCtxs.get(vfsPath);
    }
    
+   /**
+    * Remove a deployment from this source.
+    * 
+    * @param vfsPath the deployment name
+    * @return the deployment
+    * @throws NoSuchProfileException if the deployment does not exist
+    */
    public ProfileDeployment removeDeployment(String vfsPath) throws Exception
    {
       if(vfsPath == null)
@@ -183,6 +204,14 @@
       }
    }
    
+   /**
+    * Scan the children of the root for deployments.
+    * 
+    * @param list a list of virtual files, where new deployments are added to
+    * @param root the root to scan
+    * @throws IOException
+    * @throws URISyntaxException
+    */
    protected void addedDeployments(List<VirtualFile> list, VirtualFile root) throws IOException, URISyntaxException
    {
       if(root.isLeaf())
@@ -199,16 +228,25 @@
       }
    }
    
+   /**
+    * Scan a given virtualFile for deployments.
+    * 
+    * @param list a list of virtual files, where new deployments are added to
+    * @param component the root file
+    * @throws IOException
+    * @throws URISyntaxException
+    */
    protected void addedDeployment(List<VirtualFile> list, VirtualFile component) throws IOException, URISyntaxException
    {
       // Excluding files from scanning
-      if(deploymentFilter != null && ! this.deploymentFilter.accepts(component))
+      if(deploymentFilter != null && this.deploymentFilter.accepts(component) == false)
       {
          if(log.isTraceEnabled())
             log.trace("ignoring "+ component);
          return;
       }
       
+      // Check if we accept this deployment
       String key = component.toURI().toString();
       if(acceptsDeployment(key) == false)
          return;
@@ -233,14 +271,24 @@
       }
    }
    
+   /**
+    * Check if the deployment should be added.
+    * 
+    * @param name the deployment name
+    * @return  
+    */
    protected boolean acceptsDeployment(String name)
    {
-      if (applicationCtxs.containsKey(name) == true)
-         return false;
-      
-      return true;
+      return applicationCtxs.containsKey(name) == false;
    }
    
+   /**
+    * Try to find a deployment, based on the cached
+    * virtual roots of deployments we have.
+    * 
+    * @param name the deployment name
+    * @return a collection of matching names
+    */
    protected List<String> findDeploymentContent(String name)
    {
       if(this.applicationVFCache.containsKey(name))
@@ -263,11 +311,14 @@
       return contents;
    }
    
-   protected ProfileDeployment createDeployment(VirtualFile vf) throws Exception
-   {
-      return new AbstractProfileDeployment(vf);
-   }
-   
+   /**
+    * Add a virtualFile to the local virtualFileCache
+    * 
+    * @param vf the virtual file
+    * @return the name
+    * @throws MalformedURLException
+    * @throws URISyntaxException
+    */
    protected String addVirtualFileCache(VirtualFile vf) throws MalformedURLException, URISyntaxException
    {
       String uri = vf.toURI().toString();
@@ -275,11 +326,25 @@
       return uri;
    }
 
+   /**
+    * Get a cached virtual file.
+    * 
+    * @param name the name
+    * @return the virtual file or null, if it does not exist
+    */
    protected VirtualFile getCachedVirtualFile(String name)
    {
       return this.applicationVFCache.get(name);
    }
    
+   /**
+    * Get a cached virtual file. This will add the uri to the
+    * virtualFile if it does not exist.
+    * 
+    * @param uri the uri
+    * @return the virtual file
+    * @throws IOException
+    */
    protected VirtualFile getCachedVirtualFile(URI uri) throws IOException 
    {
       VirtualFile vf = getCachedVirtualFile(uri.toString());
@@ -291,6 +356,21 @@
       return vf;
    }
    
+   /**
+    * Create a ProfileDeployment, based on the virtual file.
+    * 
+    * @param vf the deployment root
+    * @return the profile deployment
+    * @throws Exception
+    */
+   protected static ProfileDeployment createDeployment(VirtualFile vf) throws Exception
+   {
+      return new AbstractProfileDeployment(vf);
+   }
+   
+   /**
+    * Internally update the lastModified timestamp.
+    */
    protected void updateLastModfied()
    {
       this.lastModified = System.currentTimeMillis();

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -21,6 +21,8 @@
  */ 
 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;
@@ -29,20 +31,19 @@
 import java.util.List;
 
 import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.ProfileFactory;
 import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
 import org.jboss.system.server.profile.repository.AbstractImmutableProfile;
 import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
+import org.jboss.virtual.VirtualFile;
 
 /**
- * A filtered profile factory. This should create a profile based on the 
- * deployments defined in the meta data.
- * Currently this only creates a immutable profile, based on it's source.
+ * A filtered profile factory.
  * 
- * @see {org.jboss.test.server.profileservice.support.FilteredProfileFactory}
- * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -66,6 +67,12 @@
    public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles)
          throws URISyntaxException
    {
+      // TODO this only should create a filtered profiles
+      if(metaData.getDeployments() != null && metaData.getDeployments().isEmpty() == false)
+      {
+         return new FilteredProfile(key, createURIs(metaData), subProfiles, getDeploymentNames(metaData));
+      }
+      // FIXME create a legacy profile which scans the folder
       return new AbstractImmutableProfile(key, createURIs(metaData), subProfiles);
    }
    
@@ -84,4 +91,80 @@
       return uris.toArray(new URI[uris.size()]);
    }
    
+   protected List<String> getDeploymentNames(ProfileMetaData metaData)
+   {
+      List<String> deploymentNames = new ArrayList<String>();
+      if(metaData.getDeployments() != null && metaData.getDeployments().isEmpty() == false)
+      {
+         for(ProfileDeploymentMetaData deployment : metaData.getDeployments())
+         {
+            deploymentNames.add(deployment.getName());
+         }
+      }
+      return deploymentNames;
+   }
+   
+   /**
+    * A filtered profile. 
+    * 
+    */
+   public static class FilteredProfile extends AbstractImmutableProfile
+   {
+
+      /** The profile deployments. */
+      private List<String> deploymentNames;
+      
+      public FilteredProfile(ProfileKey key, URI[] uris, List<String> deploymentNames)
+      {
+         this(key, uris, null, deploymentNames);
+      }
+      
+      public FilteredProfile(ProfileKey key, URI[] uris, List<ProfileKey> subprofiles, List<String> deploymentNames)
+      {
+         super(key, uris, subprofiles);
+         if(deploymentNames == null)
+            throw new IllegalArgumentException("Null profile deployments.");
+         
+         this.deploymentNames = deploymentNames;
+      }
+      
+      @Override
+      public void create() throws Exception
+      {
+         // Load deployment names
+         for(String deploymentName : deploymentNames)
+         {
+            // Get the deployment content
+            VirtualFile vf = resolveDeploymentName(deploymentName);
+            // Load the deployment
+            ProfileDeployment deployment = createDeployment(vf);
+            // Add the deployment
+            addDeployment(deployment.getName(), deployment);
+         }
+         updateLastModfied();
+      }
+
+      protected VirtualFile resolveDeploymentName(String deploymentName) throws IOException
+      {
+         List<VirtualFile> list = new ArrayList<VirtualFile>();
+         for(URI uri : getRepositoryURIs())
+         {
+            VirtualFile repo = getCachedVirtualFile(uri);
+            VirtualFile vf = repo.getChild(deploymentName);
+            if(vf != null)
+               list.add(vf);
+         }
+         if(list.size() == 0)
+         {
+            throw new FileNotFoundException("Unable to find name: " + deploymentName);
+         }
+         else if (list.size() > 1)
+         {
+            throw new FileNotFoundException("Multiple matching names: " + deploymentName + " available " + list);
+         }
+         return list.get(0);
+      }
+      
+   }
+   
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileStartAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileStartAction.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileStartAction.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -22,7 +22,7 @@
 package org.jboss.system.server.profileservice.repository;
 
 /**
- * Basic start/stop action.
+ * Basic profile start/stop action.
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -42,8 +42,8 @@
 
 /** 
  * A profile factory based on a static configuration.
- * This creates the legacy configuration: bootstrap, deployers, and the
- * root profile.  
+ * This creates the legacy configuration: bootstrap, deployers, applications 
+ * and the root profile.  
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
@@ -181,16 +181,9 @@
       addProfile(deployersKey, deployers);
 
       // Create applications profile meta data
-      ProfileKey applicationsKey = new ProfileKey(applicationsName);
-      URI[] applicationURIs = getApplicationURIs().toArray(new URI[getApplicationURIs().size()]);
-      String[] applicationsSubProfiles = new String[] { bootstrapName, deployersName };
-      ProfileMetaData applications = createProfileMetaData(
-            applicationsName, true, applicationURIs, applicationsSubProfiles);
-      // Add to profile map
-      addProfile(applicationsKey, applications);
+      String[] rootSubProfiles = createApplicationProfiles(new String[] { bootstrapName, deployersName });
       
       // Create empty root profile;
-      String[] rootSubProfiles = new String[] { applicationsName };
       ProfileMetaData root = new EmptyProfileMetaData(
             null, null, rootKey.getName(), createSubProfileMetaData(rootSubProfiles)); 
 
@@ -199,6 +192,34 @@
    }
    
    /**
+    * Create the application sub profiles.
+    * 
+    * @param applicationsSubProfiles
+    * @return the dependencies for the root profile
+    */
+   protected String[] createApplicationProfiles(String[] applicationsSubProfiles)
+   {
+      return new String[] { createApplicationProfile(applicationsSubProfiles) };
+   }
+   
+   /**
+    * Create the applications sub profile.
+    * 
+    * @param applicationsSubProfiles the dependencies for the application profile
+    * @return the application profile name
+    */
+   protected String createApplicationProfile(String[] applicationsSubProfiles)
+   {
+      ProfileKey applicationsKey = new ProfileKey(applicationsName);
+      URI[] applicationURIs = getApplicationURIs().toArray(new URI[getApplicationURIs().size()]);
+      ProfileMetaData applications = createProfileMetaData(
+            applicationsName, true, applicationURIs, applicationsSubProfiles);
+      // Add to profile map
+      addProfile(applicationsKey, applications);
+      return applicationsName;
+   }
+   
+   /**
     * Create a basic profile meta data. This profile will have it's own
     * DeploymentRepository and therefore exposed in the DeploymentManager
     * for deploy actions.

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -36,7 +36,7 @@
 /**
  * The profile repository.
  * 
- * This accepts any implementation of DeploymentRepositoryFactory and dispatches
+ * This accepts any implementation of DeploymentRepositoryFactory and delegates
  * the creation of the repository to one of the installed factories, based on
  * the exposed types. 
  * 

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java (from rev 87857, trunk/system/src/tests/org/jboss/test/server/profileservice/support/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-04-27 14:58:27 UTC (rev 87871)
@@ -0,0 +1,316 @@
+/*
+ * 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.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.ProfilesMetaData;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+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 parses the xml ProfileMetaData files.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class XmlProfileFactory extends AbstractBootstrapProfileFactory
+{
+   /** The profiles directory name. */
+   public final static String PROFILES_SUFFIX = ".profile";
+   
+   /** The attachment store uri. */
+   private File attachmentStoreRoot;
+   
+   /** Profile directories */
+   private Collection<VirtualFile> profileDirectories;
+   
+   /** The unmarshaller. */
+   private Unmarshaller unmarshaller;
+   
+   /** The parsed file list */
+   private Collection<ProfileKey> processedProfileKeys = new ArrayList<ProfileKey>();
+
+   /** The default schema resolver. */
+   private static final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+   
+   static
+   {
+      // Add schema bindings
+      resolver.addClassBinding("urn:jboss:profileservice:profiles:1.0", ProfilesMetaData.class);
+      resolver.addClassBinding("urn:jboss:profileservice:profile:filtered:1.0", FilteredProfileMetaData.class);
+      resolver.addClassBinding("urn:jboss:profileservice:profile:hotdeployment:1.0", HotDeploymentProfileMetaData.class);
+   }
+   
+   public XmlProfileFactory(URI[] profileDirectories) throws Exception
+   {
+      if(profileDirectories == null)
+         throw new IllegalArgumentException("Null directories");
+      this.profileDirectories = new ArrayList<VirtualFile>();
+      for(URI uri : profileDirectories)
+      {
+         VirtualFile vf = VFS.getRoot(uri);
+         if(vf == null)
+            throw new IllegalArgumentException("Could not find uri: " + vf);
+         if(vf.isLeaf())
+            throw new IllegalArgumentException("Not a directory: " + vf);
+         this.profileDirectories.add(vf);
+      }
+   }
+   
+   public Collection<VirtualFile> getProfileDirectories()
+   {
+      return profileDirectories;
+   }
+   
+   public void setProfileDirectories(Collection<VirtualFile> profileDirectories)
+   {
+      this.profileDirectories = profileDirectories;
+   }   
+   
+   public File getAttachmentStoreRoot()
+   {
+      return attachmentStoreRoot;
+   }
+
+   public void setAttachmentStoreRoot(File attachmentStoreRoot)
+   {
+      this.attachmentStoreRoot = attachmentStoreRoot;
+   }
+   
+   /**
+    * Create the profile meta data.
+    * 
+    * @param rootKey the key of the profile/
+    * @param the url pointing to the profile file.
+    * @throws Exception
+    */
+   @Override
+   protected void createProfileMetaData(ProfileKey rootKey, URL url) throws Exception
+   {
+      // Create the unmarshaller
+      this.unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+      // Get the root profile virtual file
+      VirtualFile vf = getProfileFile(rootKey, url);
+      // Parse
+      ProfilesMetaData rootProfiles = parse(vf);
+      // Process
+      processProfilesMetaData(rootProfiles);
+   }
+   
+   /**
+    * process the profile meta data.
+    * 
+    * @param metaData the profile meta data.
+    * @throws Exception
+    */
+   protected void processProfileMetaData(ProfileMetaData metaData) throws Exception
+   {
+      // Create profileKey
+      ProfileKey key = createProfileKey(metaData);      
+      processProfileMetaData(key, metaData);
+   }
+   
+   /**
+    * process the profile meta data
+    * 
+    * @param key the profile key.
+    * @param metaData the meta data.
+    * 
+    * @throws Exception
+    */
+   protected void processProfileMetaData(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {      
+      // Don't process the same key twice
+      if(this.processedProfileKeys.contains(key))
+         return;
+
+      // Add profile meta data
+      addProfile(key, metaData);
+      
+      // Process sub profiles
+      processSubProfiles(key, metaData);
+   }
+   
+   /**
+    * process the sub profiles.
+    * 
+    * @param key the profile key.
+    * @param metaData the profile meta data
+    * @throws Exception
+    */
+   protected void processSubProfiles(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {
+      if(metaData.getSubprofiles() != null && metaData.getSubprofiles().isEmpty() == false)
+      {
+         for(SubProfileMetaData subProfile : metaData.getSubprofiles())
+         {
+            ProfileKey subProfileKey = createProfileKey(subProfile);
+            processSubProfileMetaData(subProfileKey, subProfile);
+         }
+      }
+   }
+   
+   /**
+    * process the sub profile.
+    * 
+    * @param key the sub profile key.
+    * @param metaData the sub profile meta data.
+    * @throws Exception
+    */
+   protected void processSubProfileMetaData(ProfileKey key, SubProfileMetaData metaData) throws Exception
+   {
+      // get file
+      VirtualFile vf = getProfileFile(key, null);
+      // parse
+      ProfilesMetaData profiles = parse(vf);
+      // TODO maybe override the profiles key (as it should be the same - filename and profiles name
+      // processProfilesMetaData(key, profiles);
+      processProfilesMetaData(profiles);
+   }
+   
+   /**
+    * process the profiles meta data.
+    * 
+    * @param key the profiles key.
+    * @param metaData the profiles meta data.
+    * @throws Exception
+    */
+   protected void processProfilesMetaData(ProfileKey key, ProfilesMetaData metaData) throws Exception
+   {
+      if(metaData.getProfiles() != null && metaData.getProfiles().isEmpty() == false)
+      {
+         for(ProfileMetaData profile : metaData.getProfiles())
+         {
+            processProfileMetaData(profile);
+         }
+      }
+      // Add the profiles for later resolution
+      addProfiles(key, metaData.getProfiles());      
+   }
+   
+   /**
+    * Process the <profiles> meta data.
+    * This will add dependencies based on the ordering of the xml.
+    * 
+    * @param profilesMetaData the profiles meta data
+    */
+   protected void processProfilesMetaData(ProfilesMetaData profilesMetaData) throws Exception
+   {
+      // The <profiles> key
+      ProfileKey profilesKey = createProfileKey(profilesMetaData);
+      processProfilesMetaData(profilesKey, profilesMetaData);
+   }
+
+   /**
+    * get the virtual file of the profile.
+    * 
+    * @param key the profile key.
+    * @param url the url pointing to the file
+    * @return a resolved name if the url is null.
+    * 
+    * @throws Exception
+    */
+   protected VirtualFile getProfileFile(ProfileKey key, URL url) throws Exception
+   {
+      if(url != null)
+         return VFS.getRoot(url);
+      else
+         return resolveFile(key.getName());
+   }
+   
+   /**
+    * Try to resolve the profile name.
+    * 
+    * @param name the profile name.
+    * @return the virtual file
+    * @throws Exception
+    */
+   protected VirtualFile resolveFile(String name) throws Exception
+   {
+      // ProfileKey.getName() + .profile
+      if(name.endsWith(PROFILES_SUFFIX) == false)
+         name = name + PROFILES_SUFFIX;
+         
+      VirtualFile vf = null;
+      for(VirtualFile dir : profileDirectories)
+      {
+         vf = dir.getChild(name);
+         if(vf != null)
+            break;
+      }
+      if(vf == null)
+         throw new FileNotFoundException("Could not find profile configuration file for: " + name);
+      return vf;
+   }
+   
+   /**
+    * 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);
+   }
+   
+   @Override
+   protected void addProfile(ProfileKey key, ProfileMetaData metaData)
+   {
+      // Add to processed keys
+      processedProfileKeys.add(key);
+      // Add to parent
+      super.addProfile(key, metaData);
+   }
+   
+   @Override
+   protected void addProfiles(ProfileKey key, List<ProfileMetaData> metaData)
+   {
+      // Add to processed keys
+      processedProfileKeys.add(key);
+      // Add to pared
+      super.addProfiles(key, metaData);
+   }
+}
+

Deleted: trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -1,97 +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.support;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.system.server.profile.repository.AbstractImmutableProfile;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class FilteredProfile extends AbstractImmutableProfile
-{
-
-   /** The profile deployments. */
-   private List<String> deploymentNames;
-   
-   public FilteredProfile(ProfileKey key, URI[] uris, List<String> deploymentNames)
-   {
-      this(key, uris, null, deploymentNames);
-   }
-   
-   public FilteredProfile(ProfileKey key, URI[] uris, List<ProfileKey> subprofiles, List<String> deploymentNames)
-   {
-      super(key, uris, subprofiles);
-      if(deploymentNames == null)
-         throw new IllegalArgumentException("Null profile deployments.");
-      
-      this.deploymentNames = deploymentNames;
-   }
-   
-   @Override
-   public void create() throws Exception
-   {
-      // Load deployment names
-      for(String deploymentName : deploymentNames)
-      {
-         // Get the deployment content
-         VirtualFile vf = resolveDeploymentName(deploymentName);
-         // Load the deployment
-         ProfileDeployment deployment = createDeployment(vf);
-         // Add the deployment
-         addDeployment(deployment.getName(), deployment);
-      }
-      updateLastModfied();
-   }
-
-   protected VirtualFile resolveDeploymentName(String deploymentName) throws IOException
-   {
-      List<VirtualFile> list = new ArrayList<VirtualFile>();
-      for(URI uri : getRepositoryURIs())
-      {
-         VirtualFile repo = getCachedVirtualFile(uri);
-         VirtualFile vf = repo.getChild(deploymentName);
-         if(vf != null)
-            list.add(vf);
-      }
-      if(list.size() == 0)
-      {
-         throw new FileNotFoundException("Unable to find name: " + deploymentName);
-      }
-      else if (list.size() > 1)
-      {
-         throw new FileNotFoundException("Multiple matching names: " + deploymentName + " available " + list);
-      }
-      return list.get(0);
-   }
-   
-}
-

Deleted: trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -1,96 +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.support;
-
-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.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileFactory;
-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.system.server.profile.repository.metadata.FilteredProfileMetaData;
-import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class FilteredProfileFactory extends AbstractProfileFactory implements ProfileFactory
-{
-
-   /** The profile meta data types. */
-   public static final Collection<String> types;
-   
-   static
-   {
-      types = Arrays.asList(FilteredProfileMetaData.class.getName());
-   }
-   
-   public String[] getTypes()
-   {
-      return types.toArray(new String[types.size()]);
-   }
-   
-   @Override
-   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles)
-         throws URISyntaxException
-   {
-      return new FilteredProfile(key, createURIs(metaData), subProfiles, getDeploymentNames(metaData));
-   }
-   
-   protected URI[] createURIs(ProfileMetaData metaData) throws URISyntaxException
-   {
-      ProfileSourceMetaData profileSource = metaData.getSource();
-      if(profileSource == null)
-         throw new IllegalArgumentException("Null profile source.");
-      
-      List<URI> uris = new ArrayList<URI>();
-      for(String source : profileSource.getSources())
-      {
-         URI uri = new URI(source);
-         uris.add(uri);
-      }
-      return uris.toArray(new URI[uris.size()]);
-   }
- 
-   protected List<String> getDeploymentNames(ProfileMetaData metaData)
-   {
-      List<String> deploymentNames = new ArrayList<String>();
-      if(metaData.getDeployments() != null && metaData.getDeployments().isEmpty() == false)
-      {
-         for(ProfileDeploymentMetaData deployment : metaData.getDeployments())
-         {
-            deploymentNames.add(deployment.getName());
-         }
-      }
-      return deploymentNames;
-   }
-   
-}
-

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MavenProfileMetaData.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MavenProfileMetaData.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MavenProfileMetaData.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -23,6 +23,7 @@
 
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
 import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
 import org.jboss.xb.annotations.JBossXmlSchema;
@@ -33,6 +34,7 @@
  */
 @JBossXmlSchema(namespace="urn:jboss:profileservice:profile:maven:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
 @XmlRootElement(name = "maven-profile")
+ at XmlType(name = "profileType", propOrder = {"source", "subprofiles", "deployments"})
 public class MavenProfileMetaData extends BasicProfileMetaData
 {
 

Deleted: trunk/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -1,318 +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.support;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.ProfilesMetaData;
-import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-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;
-import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
-
-/**
- * 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 AbstractBootstrapProfileFactory
-{
-   /** The profiles directory name. */
-   public final static String PROFILES_SUFFIX = ".profile";
-   
-   /** The attachment store uri. */
-   private File attachmentStoreRoot;
-   
-   /** Profile directories */
-   private Collection<VirtualFile> profileDirectories;
-   
-   /** The unmarshaller. */
-   private Unmarshaller unmarshaller;
-   
-   /** The parsed file list */
-   private Collection<ProfileKey> processedProfileKeys = new ArrayList<ProfileKey>();
-
-   /** The default schema resolver. */
-   private static final DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
-   
-   static
-   {
-      // Add schema bindings
-      resolver.addClassBinding("urn:jboss:profileservice:profiles:1.0", ProfilesMetaData.class);
-      resolver.addClassBinding("urn:jboss:profileservice:profile:filtered:1.0", FilteredProfileMetaData.class);
-      resolver.addClassBinding("urn:jboss:profileservice:profile:hotdeployment:1.0", HotDeploymentProfileMetaData.class);
-   }
-   
-   public XmlProfileFactory(URI[] profileDirectories) throws Exception
-   {
-      if(profileDirectories == null)
-         throw new IllegalArgumentException("Null directories");
-      this.profileDirectories = new ArrayList<VirtualFile>();
-      for(URI uri : profileDirectories)
-      {
-         VirtualFile vf = VFS.getRoot(uri);
-         if(vf == null)
-            throw new IllegalArgumentException("Could not find uri: " + vf);
-         if(vf.isLeaf())
-            throw new IllegalArgumentException("Not a directory: " + vf);
-         this.profileDirectories.add(vf);
-      }
-   }
-   
-   public Collection<VirtualFile> getProfileDirectories()
-   {
-      return profileDirectories;
-   }
-   
-   public void setProfileDirectories(Collection<VirtualFile> profileDirectories)
-   {
-      this.profileDirectories = profileDirectories;
-   }   
-   
-   public File getAttachmentStoreRoot()
-   {
-      return attachmentStoreRoot;
-   }
-
-   public void setAttachmentStoreRoot(File attachmentStoreRoot)
-   {
-      this.attachmentStoreRoot = attachmentStoreRoot;
-   }
-   
-   /**
-    * Create the profile meta data.
-    * 
-    * @param rootKey the key of the profile/
-    * @param the url pointing to the profile file.
-    * @throws Exception
-    */
-   @Override
-   protected void createProfileMetaData(ProfileKey rootKey, URL url) throws Exception
-   {
-      // Create the unmarshaller
-      this.unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-
-      // Get the root profile virtual file
-      VirtualFile vf = getProfileFile(rootKey, url);
-      // Parse
-      ProfilesMetaData rootProfiles = parse(vf);
-      // Process
-      processProfilesMetaData(rootProfiles);
-   }
-   
-   /**
-    * process the profile meta data.
-    * 
-    * @param metaData the profile meta data.
-    * @throws Exception
-    */
-   protected void processProfileMetaData(ProfileMetaData metaData) throws Exception
-   {
-      // Create profileKey
-      ProfileKey key = createProfileKey(metaData);      
-      processProfileMetaData(key, metaData);
-   }
-   
-   /**
-    * process the profile meta data
-    * 
-    * @param key the profile key.
-    * @param metaData the meta data.
-    * 
-    * @throws Exception
-    */
-   protected void processProfileMetaData(ProfileKey key, ProfileMetaData metaData) throws Exception
-   {      
-      // Don't process the same key twice
-      if(this.processedProfileKeys.contains(key))
-         return;
-
-      // Add profile meta data
-      addProfile(key, metaData);
-      
-      // Process sub profiles
-      processSubProfiles(key, metaData);
-   }
-   
-   /**
-    * process the sub profiles.
-    * 
-    * @param key the profile key.
-    * @param metaData the profile meta data
-    * @throws Exception
-    */
-   protected void processSubProfiles(ProfileKey key, ProfileMetaData metaData) throws Exception
-   {
-      if(metaData.getSubprofiles() != null && metaData.getSubprofiles().isEmpty() == false)
-      {
-         for(SubProfileMetaData subProfile : metaData.getSubprofiles())
-         {
-            ProfileKey subProfileKey = createProfileKey(subProfile);
-            processSubProfileMetaData(subProfileKey, subProfile);
-         }
-      }
-   }
-   
-   /**
-    * process the sub profile.
-    * 
-    * @param key the sub profile key.
-    * @param metaData the sub profile meta data.
-    * @throws Exception
-    */
-   protected void processSubProfileMetaData(ProfileKey key, SubProfileMetaData metaData) throws Exception
-   {
-      // get file
-      VirtualFile vf = getProfileFile(key, null);
-      // parse
-      ProfilesMetaData profiles = parse(vf);
-      // TODO maybe override the profiles key (as it should be the same - filename and profiles name
-      // processProfilesMetaData(key, profiles);
-      processProfilesMetaData(profiles);
-   }
-   
-   /**
-    * process the profiles meta data.
-    * 
-    * @param key the profiles key.
-    * @param metaData the profiles meta data.
-    * @throws Exception
-    */
-   protected void processProfilesMetaData(ProfileKey key, ProfilesMetaData metaData) throws Exception
-   {
-      if(metaData.getProfiles() != null && metaData.getProfiles().isEmpty() == false)
-      {
-         for(ProfileMetaData profile : metaData.getProfiles())
-         {
-            processProfileMetaData(profile);
-         }
-      }
-      // Add the profiles for later resolution
-      addProfiles(key, metaData.getProfiles());      
-   }
-   
-   /**
-    * Process the <profiles> meta data.
-    * This will add dependencies based on the ordering of the xml.
-    * 
-    * @param profilesMetaData the profiles meta data
-    */
-   protected void processProfilesMetaData(ProfilesMetaData profilesMetaData) throws Exception
-   {
-      // The <profiles> key
-      ProfileKey profilesKey = createProfileKey(profilesMetaData);
-      processProfilesMetaData(profilesKey, profilesMetaData);
-   }
-
-   /**
-    * get the virtual file of the profile.
-    * 
-    * @param key the profile key.
-    * @param url the url pointing to the file
-    * @return a resolved name if the url is null.
-    * 
-    * @throws Exception
-    */
-   protected VirtualFile getProfileFile(ProfileKey key, URL url) throws Exception
-   {
-      if(url != null)
-         return VFS.getRoot(url);
-      else
-         return resolveFile(key.getName());
-   }
-   
-   /**
-    * Try to resolve the profile name.
-    * 
-    * @param name the profile name.
-    * @return the virtual file
-    * @throws Exception
-    */
-   protected VirtualFile resolveFile(String name) throws Exception
-   {
-      // ProfileKey.getName() + .profile
-      if(name.endsWith(PROFILES_SUFFIX) == false)
-         name = name + PROFILES_SUFFIX;
-         
-      VirtualFile vf = null;
-      for(VirtualFile dir : profileDirectories)
-      {
-         vf = dir.getChild(name);
-         if(vf != null)
-            break;
-      }
-      if(vf == null)
-         throw new FileNotFoundException("Could not find profile configuration file for: " + name);
-      return vf;
-   }
-   
-   /**
-    * 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);
-   }
-   
-   @Override
-   protected void addProfile(ProfileKey key, ProfileMetaData metaData)
-   {
-      // Add to processed keys
-      processedProfileKeys.add(key);
-      // Add to parent
-      super.addProfile(key, metaData);
-   }
-   
-   @Override
-   protected void addProfiles(ProfileKey key, List<ProfileMetaData> metaData)
-   {
-      // Add to processed keys
-      processedProfileKeys.add(key);
-      // Add to pared
-      super.addProfiles(key, metaData);
-   }
-}
-

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -29,8 +29,8 @@
 import org.jboss.bootstrap.spi.ServerConfig;
 import org.jboss.deployers.client.spi.main.MainDeployer;
 import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
+import org.jboss.system.server.profileservice.repository.FilteredProfileFactory;
 import org.jboss.test.BaseTestCase;
-import org.jboss.test.server.profileservice.support.FilteredProfileFactory;
 import org.jboss.test.server.profileservice.support.MockMainDeployer;
 import org.jboss.test.server.profileservice.support.MockServer;
 import org.jboss.test.server.profileservice.support.MockServerConfig;

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -33,7 +33,7 @@
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
-import org.jboss.test.server.profileservice.support.XmlProfileFactory;
+import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
 import org.jboss.virtual.plugins.context.jar.JarUtils;
 
 /**

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -31,7 +31,6 @@
 import org.jboss.xb.binding.Unmarshaller;
 import org.jboss.xb.binding.UnmarshallerFactory;
 import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
-import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
 
 
 /**
@@ -43,7 +42,7 @@
 public class ProfileParsingUnitTestCase extends AbstractProfileServiceTestBase
 {
 
-   private static final DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+   private static final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
    
    static
    {

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	2009-04-27 14:58:27 UTC (rev 87871)
@@ -35,9 +35,9 @@
 import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
 import org.jboss.system.server.profileservice.repository.AbstractProfileService;
 import org.jboss.system.server.profileservice.repository.MainDeployerAdapter;
+import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
 import org.jboss.test.server.profileservice.support.MockAttachmentStore;
 import org.jboss.test.server.profileservice.support.MockMainDeployer;
-import org.jboss.test.server.profileservice.support.XmlProfileFactory;
 import org.jboss.virtual.plugins.context.jar.JarUtils;
 
 /**

Modified: trunk/testsuite/src/resources/test-configs/embedded/conf/bootstrap/profile.xml
===================================================================
--- trunk/testsuite/src/resources/test-configs/embedded/conf/bootstrap/profile.xml	2009-04-27 14:57:47 UTC (rev 87870)
+++ trunk/testsuite/src/resources/test-configs/embedded/conf/bootstrap/profile.xml	2009-04-27 14:58:27 UTC (rev 87871)
@@ -21,25 +21,35 @@
 		<property name="attachmentStoreRoot">${jboss.server.data.dir}/attachments</property>
 		<property name="profileFactory"><inject bean="ProfileFactory" /></property>
 	</bean>
+	
+	<!--  The default profile key -->
+	<bean name="DefaultProfileKey" class="org.jboss.profileservice.spi.ProfileKey">
+		<constructor><parameter>${jboss.server.name}</parameter></constructor>
+	</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="ProfileServiceDeployer" /></property>
+		<property name="defaultProfile"><inject bean="DefaultProfileKey" /></property>
 	</bean>
 
 	<!-- The Bootstrap implementation that loads the Profile from the ProfileService -->
 	<bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
+		<property name="profileKey"><inject bean="DefaultProfileKey" /></property>
 		<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="bootstrapProfileFactory"><inject bean="BootstrapProfileFactory" /></property>
+		<property name="configurator"><inject bean="jboss.kernel:service=Kernel" property="configurator"/></property>
 	</bean>
 
 	<!-- The profile factory -->
-	<bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.AbstractProfileFactory">
-		<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+	<bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileFactory">
+		<!-- Accept any AbstractprofileFactory -->
+		<incallback method="addProfileFactory" />
+		<uncallback method="removeProfileFactory" />
 	</bean>
 
 	<!-- The profile repository factory -->
@@ -49,14 +59,36 @@
 		<uncallback method="removeRepositoryFactory" />
 	</bean>
 
+  <!-- The structure modification cache and checker -->
+  <bean name="StructureModCache" class="org.jboss.deployers.vfs.spi.structure.modified.DefaultStructureCache">
+    <destroy method="flush"/>
+  </bean>
+
+  <bean name="StructureModificationChecker" class="org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker">
+    <constructor>
+      <parameter><inject bean="MainDeployer" /></parameter>
+    </constructor>
+    <property name="cache"><inject bean="StructureModCache" /></property>
+    <property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
+  </bean>
+
+	<bean name="BasicProfileFactory" class="org.jboss.system.server.profileservice.repository.BasicProfileFactory">
+		<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+	</bean>
+	<bean name="FilteredProfileFactory" class="org.jboss.system.server.profileservice.repository.FilteredProfileFactory"/>
+
 	<!-- The default deployment repository factory -->
-	<bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory" />
+	<bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory">
+		<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
+		<property name="checker"><inject bean="StructureModificationChecker" /></property>
+	</bean>
 
 	<!-- The attachment store -->
 	<bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore">
 		<constructor><parameter><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
 		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
 		<property name="serializer"><inject bean="AttachmentsSerializer" /></property>
+		<property name="metaDataFilter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
 	</bean>
 
 	<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">




More information about the jboss-cvs-commits mailing list