[jboss-cvs] JBossAS SVN: r86174 - in branches/Branch_5_x: system/src/main/org/jboss/system/server/profile/repository and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Mar 21 11:18:12 EDT 2009


Author: emuckenhuber
Date: 2009-03-21 11:18:12 -0400 (Sat, 21 Mar 2009)
New Revision: 86174

Added:
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java
   branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java
   branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java
Removed:
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileMetaData.java
   branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredDeploymentRepositoryFactory.java
   branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
Modified:
   branches/Branch_5_x/server/src/etc/conf/default/bootstrap/profile.xml
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/AbstractImmutableProfile.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
   branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java
   branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java
   branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
Log:
[JBAS-6648] add different profile implementations.

Modified: branches/Branch_5_x/server/src/etc/conf/default/bootstrap/profile.xml
===================================================================
--- branches/Branch_5_x/server/src/etc/conf/default/bootstrap/profile.xml	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/server/src/etc/conf/default/bootstrap/profile.xml	2009-03-21 15:18:12 UTC (rev 86174)
@@ -53,8 +53,10 @@
 	</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 -->
@@ -65,7 +67,6 @@
 	</bean>
 
   <!-- The structure modification cache and checker -->
-
   <bean name="StructureModCache" class="org.jboss.deployers.vfs.spi.structure.modified.DefaultStructureCache">
     <destroy method="flush"/>
   </bean>
@@ -78,6 +79,11 @@
     <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.DefaultDeploymentRepositoryFactory">
 		<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/AbstractImmutableProfile.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/AbstractImmutableProfile.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/AbstractImmutableProfile.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -134,5 +134,26 @@
    {
       return false;
    }
+   
+   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)
+   {
+      //
+   }
 
 }

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -50,7 +50,7 @@
    final private DeploymentRepository repository;
    
    /** The profile dependencies */
-   List<ProfileKey> subProfiles;
+   private List<ProfileKey> subProfiles;
    
    /** Is hot deployment checking enabled */
    private volatile boolean hotdeployEnabled = false;
@@ -132,7 +132,7 @@
    {
       if(name == null)
          throw new IllegalArgumentException("Null name.");
-      // FIXME
+
       try
       {
          return this.repository.getDeployment(name) != null;

Added: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -0,0 +1,126 @@
+/*
+ * 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.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * A empty profile, which does not contain any deployments. This profile
+ * basically just has a key and dependencies on other profiles.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NoopProfile implements Profile
+{
+   
+   private final ProfileKey key;
+   private final long lastModified;
+   private List<ProfileKey> subProfiles;
+   
+   public NoopProfile(ProfileKey key)
+   {
+      this(key, null);
+   }
+   
+   public NoopProfile(ProfileKey key, List<ProfileKey> subProfiles)
+   {
+      this.key = key;
+      this.subProfiles = subProfiles;
+      this.lastModified = System.currentTimeMillis();
+   }
+
+   public ProfileKey getKey()
+   {
+      return this.key;
+   }
+
+   public long getLastModified()
+   {
+      return this.lastModified;
+   }
+
+   public Collection<ProfileKey> getSubProfiles()
+   {
+      return this.subProfiles;
+   }
+   
+   public void setSubProfiles(List<ProfileKey> subProfiles)
+   {
+      this.subProfiles = subProfiles;
+   }
+   
+   public Set<String> getDeploymentNames()
+   {
+      return Collections.emptySet();
+   }
+
+   public Collection<ProfileDeployment> getDeployments()
+   {
+      return Collections.emptySet();
+   }
+   
+   public ProfileDeployment getDeployment(String name) throws NoSuchDeploymentException
+   {
+      throw new NoSuchDeploymentException("This profiles does not contain any deployments.");
+   }
+
+   public boolean hasDeployment(String name)
+   {
+      return false;
+   }
+
+   public boolean isMutable()
+   {
+      return false;
+   }
+   
+   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)
+   {
+      //
+   }
+
+}

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -27,7 +27,6 @@
 import javax.xml.bind.annotation.XmlElement;
 
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
 import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 
 /**
@@ -48,11 +47,26 @@
    /** The doamin. */
    private String domain;
    
-   /** The profile sources. */
-   private ProfileSourceMetaData source;
-   
    /** The sub profiles. */
    private List<SubProfileMetaData> subprofiles;
+   
+   public AbstractProfileMetaData()
+   {
+      //
+   }
+   
+   public AbstractProfileMetaData(String domain, String server, String name)
+   {
+      this(domain, server, name, null);
+   }
+   
+   public AbstractProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      this.domain = domain;
+      this.server = server;
+      this.name = name;
+      this.subprofiles = subProfiles;
+   }
 
    @XmlAttribute(name = "name")
    public String getName()
@@ -87,17 +101,6 @@
       this.domain = domain;
    }
 
-   @XmlElement(name = "profile-source", type = FilteredProfileSourceMetaData.class)
-   public ProfileSourceMetaData getSource()
-   {
-      return source;
-   }
-
-   public void setSource(ProfileSourceMetaData source)
-   {
-      this.source = source;
-   }
-
    @XmlElement(name = "sub-profile", type = BasicSubProfileMetaData.class)
    public List<SubProfileMetaData> getSubprofiles()
    {

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -41,6 +41,16 @@
    /** The source. */
    private List<String> sources;
    
+   public AbstractProfileSourceMetaData()
+   {
+      //
+   }
+   
+   public AbstractProfileSourceMetaData(List<String> sources)
+   {
+      this.sources = sources;
+   }
+   
    @XmlTransient
    public String getType()
    {

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -26,6 +26,8 @@
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
 
 /**
+ * A basic ProfileDeployment meta data implementation.
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -35,6 +37,16 @@
    /** The deployment name. */
    private String name;
    
+   public BasicProfileDeploymentMetaData()
+   {
+      //
+   }
+   
+   public BasicProfileDeploymentMetaData(String name)
+   {
+      this.name = name;
+   }
+   
    @XmlValue
    public String getName()
    {
@@ -45,5 +57,6 @@
    {
       this.name = name;
    }
+   
 }
 

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -26,6 +26,8 @@
 import javax.xml.bind.annotation.XmlElement;
 
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -34,9 +36,38 @@
 public class BasicProfileMetaData extends AbstractProfileMetaData
 {
    
+   /** The profile source. */
+   private ProfileSourceMetaData source;
+   
    /** The deployments. */
    private List<ProfileDeploymentMetaData> deployments;
+   
+   public BasicProfileMetaData()
+   {
+      super();
+   }
+   
+   public BasicProfileMetaData(String domain, String server, String name)
+   {
+      super(domain, server, name, null);
+   }
+   
+   public BasicProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      super(domain, server, name, subProfiles);
+   }
+   
+   @XmlElement(name = "profile-source", type = ImmutableProfileSourceMetaData.class)
+   public ProfileSourceMetaData getSource()
+   {
+      return source;
+   }
 
+   public void setSource(ProfileSourceMetaData source)
+   {
+      this.source = source;
+   }   
+
    @XmlElement(name = "deployment", type = BasicProfileDeploymentMetaData.class)
    public List<ProfileDeploymentMetaData> getDeployments()
    {

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -41,6 +41,18 @@
    
    /** The doamin. */
    private String domain;
+   
+   public BasicSubProfileMetaData()
+   {
+      //
+   }
+   
+   public BasicSubProfileMetaData(String domain, String server, String name)
+   {
+      this.domain = domain;
+      this.server = server;
+      this.name = name;
+   }
 
    @XmlValue
    public String getName()

Added: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -0,0 +1,72 @@
+/*
+ * 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.metadata;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+
+/**
+ * A empty profile meta meta, which only has a name and dependencies 
+ * to other profiles.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class EmptyProfileMetaData extends AbstractProfileMetaData implements ProfileMetaData
+{
+   
+   public EmptyProfileMetaData()
+   {
+      super();
+   }
+   
+   public EmptyProfileMetaData(String domain, String server, String name)
+   {
+      super(domain, server, name, null);
+   }
+   
+   public EmptyProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      super(domain, server, name, subProfiles);
+   }
+   
+   @XmlTransient
+   public List<ProfileDeploymentMetaData> getDeployments()
+   {
+      return Collections.emptyList();
+   }
+
+   @XmlTransient
+   public ProfileSourceMetaData getSource()
+   {
+      return null;
+   }
+   
+}
+

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -21,9 +21,12 @@
  */ 
 package org.jboss.system.server.profile.repository.metadata;
 
+import java.util.List;
+
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
 /**
@@ -38,5 +41,20 @@
 public class FilteredProfileMetaData extends BasicProfileMetaData
 {
 
+   public FilteredProfileMetaData()
+   {
+      super();
+   }
+   
+   public FilteredProfileMetaData(String domain, String server, String name)
+   {
+      super(domain, server, name, null);
+   }
+   
+   public FilteredProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      super(domain, server, name, subProfiles);
+   }
+   
 }
 

Deleted: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -1,61 +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.repository.metadata;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-
-import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
-import org.jboss.xb.annotations.JBossXmlSchema;
-
-/**
- * A filtered profile source meta data. 
- * This is a workaround that we can a filtered deploymentRepository 
- * on this metadata only, based on the deployments list.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
- at JBossXmlSchema(namespace="urn:jboss:profileservice:source:filtered:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
- at XmlRootElement(name = "profile-source")
-public class FilteredProfileSourceMetaData extends AbstractProfileSourceMetaData
-{
-   
-   /** The deployments */
-   List<ProfileDeploymentMetaData> deployments;
-
-   @XmlTransient
-   public List<ProfileDeploymentMetaData> getDeployments()
-   {
-      return deployments;
-   }
-   
-   public void setDeployments(List<ProfileDeploymentMetaData> deployments)
-   {
-      this.deployments = deployments;
-   }
-   
-}
-

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -24,10 +24,14 @@
 import java.util.Collections;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.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;
 
 /**
@@ -41,10 +45,40 @@
 public class HotDeploymentProfileMetaData extends AbstractProfileMetaData
 {
 
+   /** The profile source. */
+   private ProfileSourceMetaData source;
+   
+   public HotDeploymentProfileMetaData()
+   {
+      super();
+   }
+   
+   public HotDeploymentProfileMetaData(String domain, String server, String name)
+   {
+      super(domain, server, name, null);
+   }
+   
+   public HotDeploymentProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      super(domain, server, name, subProfiles);
+   }
+   
+   @XmlElement(name = "profile-source", type = HotDeploymentProfileSourceMetaData.class)
+   public ProfileSourceMetaData getSource()
+   {
+      return source;
+   }
+
+   public void setSource(ProfileSourceMetaData source)
+   {
+      this.source = source;
+   }
+
    /**
     * There cannot be any specific deployments for a
     * hot deployment profile, as it will scan the folders.  
     */
+   @XmlTransient
    public List<ProfileDeploymentMetaData> getDeployments()
    {
       return Collections.emptyList();

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -21,6 +21,8 @@
  */ 
 package org.jboss.system.server.profile.repository.metadata;
 
+import java.util.List;
+
 /**
  * A hot deployment profile source meta data.
  * 
@@ -30,5 +32,14 @@
 public class HotDeploymentProfileSourceMetaData extends AbstractProfileSourceMetaData
 {
 
+   public HotDeploymentProfileSourceMetaData()
+   {
+      super();
+   }
+   
+   public HotDeploymentProfileSourceMetaData(List<String> sources)
+   {
+      super(sources);
+   }
 }
 

Deleted: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -1,49 +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.repository.metadata;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
-
-
-/**
- * The meta data defining a immutable profile.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ImmutableProfileMetaData extends AbstractProfileMetaData
-{
-
-   /**
-    * There cannot be any specific deployments for a
-    * immutable profile, as it will scan the folders.
-    */
-   public List<ProfileDeploymentMetaData> getDeployments()
-   {
-      return Collections.emptyList();
-   }
-
-}
-

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -21,6 +21,8 @@
  */ 
 package org.jboss.system.server.profile.repository.metadata;
 
+import java.util.List;
+
 /**
  * A immutable profile source meta data.
  * 
@@ -29,6 +31,16 @@
  */
 public class ImmutableProfileSourceMetaData extends AbstractProfileSourceMetaData
 {
+   
+   public ImmutableProfileSourceMetaData()
+   {
+      super();
+   }
+   
+   public ImmutableProfileSourceMetaData(List<String> sources)
+   {
+      super(sources);
+   }
 
 }
 

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -138,7 +138,8 @@
       processSubProfiles(profiles, subProfiles, profileMetaData.getSubprofiles());
       
       // Create the profile
-      Profile profile = profileFactory.createProfile(key, profileMetaData, subProfiles);
+      // Provide a new copy of the keys
+      Profile profile = profileFactory.createProfile(key, profileMetaData, new ArrayList<ProfileKey>(subProfiles));
       
       // Add to the profileMap
       profiles.put(key, profile);

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -22,70 +22,61 @@
 package org.jboss.system.server.profileservice.repository;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
-import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileFactory;
 import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.system.server.profile.repository.AbstractProfile;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 
 /**
- * The abstract profile factory.
+ * A abstract profile factory.
  * 
- * TODO this should create the profile based on the meta data,
- * as it only creates a AbstractProfile with it's DeploymentRepository
- * at the moment. 
- * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class AbstractProfileFactory implements ProfileFactory
+public abstract class AbstractProfileFactory implements ProfileFactory
 {   
-   /** The deployment repository factory. */
-   private ProfileRepository profileRepository;
-
-   public String[] getTypes()
-   {
-      // For further use
-      return null;
-   }
+   /**
+    * This is used by the BoostrapProfileFactory, as it already created the
+    * subProfiles list. 
+    * 
+    * @param key the profile key
+    * @param metaData the profile meta data
+    * @param subProfiles the sub profiles list
+    * @return the profile
+    * @throws Exception
+    */
+   public abstract Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception;
    
-   public ProfileRepository getProfileRepository()
-   {
-      return profileRepository;
-   }
-   
-   public void setProfileRepository(ProfileRepository profileRepository)
-   {
-      this.profileRepository = profileRepository;
-   }
-   
    public Profile createProfile(ProfileKey key, ProfileMetaData metaData) throws Exception
    {
-      return createProfile(key, metaData, Collections.EMPTY_LIST);
-   }
-   
-   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception
-   {
       if(key == null)
          throw new IllegalArgumentException("Null profile key.");
       if(metaData == null)
          throw new IllegalArgumentException("Null profile meta data.");
       
-      // Start to create the profile
-      DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, metaData);
-      
-      // Create the profile
-      AbstractProfile profile = new AbstractProfile(repository, key);
-      
-      // Copy the sub-profile keys
-      profile.setSubProfiles(new ArrayList<ProfileKey>(subProfiles));
-      
-      return profile;
+      // 
+      return createProfile(key, metaData, createSubProfiles(metaData));
    }
-
-}
\ No newline at end of file
+   
+   protected List<ProfileKey> createSubProfiles(ProfileMetaData metaData)
+   {
+      List<ProfileKey> subProfiles = new ArrayList<ProfileKey>();
+      if(metaData.getSubprofiles() != null && metaData.getSubprofiles().isEmpty() == false)
+      {
+         for(SubProfileMetaData subProfile : metaData.getSubprofiles())
+         {
+            subProfiles.add(createKey(subProfile));
+         }
+      }
+      return subProfiles;
+   }
+   
+   protected ProfileKey createKey(ProfileKeyMetaData metaData)
+   {
+      return new ProfileKey(metaData.getDomain(), metaData.getServer(), metaData.getName());
+   }   
+}

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -29,7 +29,6 @@
 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;
@@ -63,7 +62,7 @@
    private ProfileKey defaultProfile;
    
    /** The registered profiles. */
-   private Map<ProfileKey, ProfileContext> registeredProfiles = new ConcurrentHashMap<ProfileKey, ProfileContext>();
+   private List<ProfileKey> profiles = new CopyOnWriteArrayList<ProfileKey>();
    
    /** The active profiles. */
    private List<ProfileKey> activeProfiles = new CopyOnWriteArrayList<ProfileKey>();
@@ -155,7 +154,7 @@
 
    public Collection<ProfileKey> getProfileKeys()
    {
-      return new ArrayList<ProfileKey>(this.registeredProfiles.keySet());
+      return Collections.unmodifiableCollection(this.profiles);
    }
    
    /**
@@ -169,8 +168,16 @@
    {
       if(key ==  null)
          throw new IllegalArgumentException("Null profile key.");
+
+      // Get the profile
+      ProfileContext profile = null;
+      if(this.profiles.contains(key))
+         profile = (ProfileContext) this.controller.getContext(key, null);
       
-      ProfileContext profile = this.registeredProfiles.get(key); 
+      // If the key is the default, fallback to the injected default key
+      if(profile == null && key.isDefaultKey() && this.defaultProfile != null)
+         profile = (ProfileContext) controller.getContext(this.defaultProfile, null);   
+         
       if(profile == null)
          throw new NoSuchProfileException("No such profile: " + key);
       
@@ -191,19 +198,21 @@
     */
    public Profile getActiveProfile(ProfileKey key) throws NoSuchProfileException
    {
-      if(key == null)
+      if(key ==  null)
          throw new IllegalArgumentException("Null profile key.");
-      
+
+      // Get the profile
       ProfileContext profile = null;
       if(this.activeProfiles.contains(key))
-         profile = (ProfileContext) controller.getInstalledContext(key);
+         profile = (ProfileContext) this.controller.getInstalledContext(key);
       
-      // If the key is a default key, fallback to the injected default key
-      if(key.isDefaultKey() && this.defaultProfile != null)
-         profile = (ProfileContext) controller.getInstalledContext(this.defaultProfile);
+      // If the key is the default, fallback to the injected default key
+      if(profile == null && key.isDefaultKey() && this.defaultProfile != null)
+         profile = (ProfileContext) controller.getInstalledContext(this.defaultProfile);   
+         
+      if(profile == null)
+         throw new NoSuchProfileException("No such profile: " + key);
       
-      if(profile == null)
-         throw new NoSuchProfileException("Profile not installed: " + key);
       return profile.getProfile();
    }
    
@@ -217,7 +226,7 @@
       if(this.controller == null)
          throw new IllegalStateException("Null controller.");
       if(this.deployer == null)
-         throw new IllegalStateException("Null main deployer.");
+         throw new IllegalStateException("Null deployer.");
       
       // FIXME this should be moved to static actions
       this.profileActions.put(ControllerState.CREATE, new ProfileCreateAction());
@@ -265,8 +274,11 @@
       ProfileKey key = profile.getKey();
       if(key == null)
          throw new IllegalArgumentException("Null profile key.");
-      if(registeredProfiles.get(profile.getKey()) != null)
+      if(this.profiles.contains(key))
+      {
+         log.debug("Profile already registered: " + profile);
          return;
+      }
       
       if(controller.isShutdown())
          throw new IllegalStateException("Controller is shutdown.");
@@ -276,7 +288,7 @@
       try
       {
          controller.install(context);
-         this.registeredProfiles.put(key, context);
+         this.profiles.add(key);
       }
       catch(Throwable t)
       {
@@ -300,7 +312,7 @@
       if(this.activeProfiles.contains(key))
          return;
 
-      ProfileContext context = this.registeredProfiles.get(key);
+      ProfileContext context = (ProfileContext) this.controller.getContext(key, null);
       if(context == null)
          throw new NoSuchProfileException("No such profile: "+ key);
 
@@ -321,9 +333,20 @@
    
    public void validateProfile(ProfileKey key) throws Exception
    {
-      ProfileContext profile = this.registeredProfiles.get(key);
+      if(key ==  null)
+         throw new IllegalArgumentException("Null profile key.");
+
+      // Get the profile
+      ProfileContext profile = null;
+      if(this.profiles.contains(key))
+         profile = (ProfileContext) this.controller.getContext(key, null);
+      
+      // If the key is the default, fallback to the injected default key
+      if(profile == null && key.isDefaultKey() && this.defaultProfile != null)
+         profile = (ProfileContext) controller.getContext(this.defaultProfile, null);   
+         
       if(profile == null)
-         throw new NoSuchProfileException("No such profile registered: "+ key);
+         throw new NoSuchProfileException("No such profile: " + key);
       
       validate(profile);
    }
@@ -382,7 +405,7 @@
       if(controller.isShutdown())
          return;
       
-      ControllerContext context = controller.getContext(key, ControllerState.INSTALLED);
+      ControllerContext context = controller.getInstalledContext(key);
       if(context == null)
          throw new IllegalStateException("Profile not installed: "+ key);
       try
@@ -412,12 +435,10 @@
       if(this.activeProfiles.contains(key))
          throw new IllegalStateException("Cannot unregister active profile: "+ key);
       
-      if(this.registeredProfiles.containsKey(key) == false)
+      if(this.profiles.contains(key) == false)
          throw new NoSuchProfileException("Profile not registered: " + key);
       
       log.debug("unregistering profile: " + key);
-      this.registeredProfiles.remove(key);
-
       if(controller.isShutdown())
          return;
       

Added: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -0,0 +1,88 @@
+/*
+ * 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.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.system.server.profile.repository.AbstractProfile;
+import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicProfileFactory extends AbstractProfileFactory implements ProfileFactory
+{
+   /** The deployment repository factory. */
+   private ProfileRepository profileRepository;
+   
+   /** The handled meta data types. */
+   public static final Collection<String> types;
+   
+   static
+   {
+      types = Arrays.asList(BasicProfileMetaData.class.getName());
+   }
+
+   public String[] getTypes()
+   {
+      return types.toArray(new String[types.size()]);
+   }
+   
+   public ProfileRepository getProfileRepository()
+   {
+      return profileRepository;
+   }
+   
+   public void setProfileRepository(ProfileRepository profileRepository)
+   {
+      this.profileRepository = profileRepository;
+   }
+   
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(metaData == null)
+         throw new IllegalArgumentException("Null profile meta data.");
+      
+      // Start to create the profile
+      DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, metaData);
+      
+      // Create the profile
+      AbstractProfile profile = new AbstractProfile(repository, key);
+      
+      // Copy the sub-profile keys
+      profile.setSubProfiles(subProfiles);
+      
+      return profile;
+   }
+}
+

Added: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -0,0 +1,87 @@
+/*
+ * 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.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+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;
+
+/**
+ * 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.
+ * 
+ * @see {org.jboss.test.server.profileservice.support.FilteredProfileFactory}
+ * 
+ * @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 AbstractImmutableProfile(key, createURIs(metaData), subProfiles);
+   }
+   
+   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()]);
+   }
+   
+}

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -35,6 +35,8 @@
 import org.jboss.system.server.profile.repository.metadata.AbstractProfileSourceMetaData;
 import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
 import org.jboss.system.server.profile.repository.metadata.BasicSubProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.EmptyProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
 import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileSourceMetaData;
 import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
 
@@ -167,8 +169,9 @@
       
       // Create bootstrap profile meta data
       ProfileKey bootstrapKey = new ProfileKey(bootstrapName);
-      ProfileMetaData bootstrap = createProfileMetaData(
-            bootstrapName, false, new URI[] { bootstrapURI }, new String[0]);
+      BasicProfileMetaData bootstrap = new FilteredProfileMetaData(
+            null, null, bootstrapName);
+      bootstrap.setSource(createSource(new URI[]{ bootstrapURI }, false));
       addProfile(bootstrapKey, bootstrap);
       
       // Create deployers profile meta data
@@ -188,55 +191,65 @@
       
       // Create empty root profile;
       String[] rootSubProfiles = new String[] { applicationsName };
-      ProfileMetaData root = createProfileMetaData(
-            rootKey.getName(), false, new URI[0], rootSubProfiles);
+      ProfileMetaData root = new EmptyProfileMetaData(
+            null, null, rootKey.getName(), createSubProfileMetaData(rootSubProfiles)); 
+
       // Add to profile map
       addProfile(rootKey, root);
    }
    
    /**
-    * Create a profile meta data.
+    * Create a basic profile meta data. This profile will have it's own
+    * DeploymentRepository and therefore exposed in the DeploymentManager
+    * for deploy actions.
     * 
     * @param name the profile name.
-    * @param hotDeployment if it's a hotDeployment profile
+    * @param isHotDeployment if hotDeployment is enabled.
     * @param uris the repository uris.
     * @param subProfiles a list of profile dependencies.
     * 
     * @return the profile meta data.
     */
-   protected ProfileMetaData createProfileMetaData(String name, boolean hotDeployment, URI[] uris, String[] subProfiles)
+   protected ProfileMetaData createProfileMetaData(String name, boolean isHotDeployment, URI[] uris, String[] subProfiles)
    {
       // Create profile
-      BasicProfileMetaData metaData = new BasicProfileMetaData();
-      metaData.setName(name);
+      BasicProfileMetaData metaData = new BasicProfileMetaData(null, null, name);
+      
       // Create profile sources
-      ProfileSourceMetaData source = createSource(uris, hotDeployment);
-      metaData.setSource(source);
+      metaData.setSource(createSource(uris, isHotDeployment));
       
-      List<SubProfileMetaData> profileList = new ArrayList<SubProfileMetaData>();
-      for(String subProfile : subProfiles)
-      {
-         BasicSubProfileMetaData md = new BasicSubProfileMetaData();
-         md.setName(subProfile);
-         profileList.add(md);
-      }
-      metaData.setSubprofiles(profileList);
+      // Set subProfiles
+      metaData.setSubprofiles(createSubProfileMetaData(subProfiles));
       
       return metaData;
    }
    
+   protected List<SubProfileMetaData> createSubProfileMetaData(String[] subProfiles)
+   {
+      List<SubProfileMetaData> subProfileList = new ArrayList<SubProfileMetaData>();
+      if(subProfiles != null && subProfiles.length > 0)
+      {
+         for(String profileName : subProfiles)
+         {
+            subProfileList.add(new BasicSubProfileMetaData(null, null, profileName));
+         }
+      }
+      return subProfileList;
+   }
+   
+   
    /**
     * Create a profile repository source meta data.
     * 
     * @param uris the uris for the repository
-    * @param hotDeployment to create a hotDeployment profile
+    * @param isHotDeployment to create a hotDeployment profile
     * 
     * @return the profile source meta data.
     */
-   protected ProfileSourceMetaData createSource(URI[] uris, boolean hotDeployment)
+   protected ProfileSourceMetaData createSource(URI[] uris, boolean isHotDeployment)
    {
       AbstractProfileSourceMetaData source = null;
-      if(hotDeployment)
+      if(isHotDeployment)
       {
          source = new HotDeploymentProfileSourceMetaData();
       }

Added: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -0,0 +1,146 @@
+/*
+ * 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.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.system.server.profile.repository.NoopProfile;
+import org.jboss.system.server.profile.repository.metadata.EmptyProfileMetaData;
+
+/**
+ * A typed profile factory. This delegates the creation of profiles to 
+ * the registered factories, based on the class name of the profile meta data. 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TypedProfileFactory extends AbstractProfileFactory implements ProfileFactory
+{
+
+   /** The profile factories. */
+   private Map<String, AbstractProfileFactory> factories = new ConcurrentHashMap<String, AbstractProfileFactory>();
+   
+   /** The locally handled types. */
+   public static final Collection<String> types;
+   
+   static
+   {
+      types = Arrays.asList(EmptyProfileMetaData.class.getName());
+   }
+   
+   public String[] getTypes()
+   {
+      return types.toArray(new String[types.size()]);
+   }
+   
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(metaData == null)
+         throw new IllegalArgumentException("Null profile meta data");
+      
+      String profileType = metaData.getClass().getName();
+      if(types.contains(profileType))
+      {
+         return createNoopProfile(key, metaData, subProfiles);
+      }
+      // Delegate to registered factories
+      return delegateCreateProfile(profileType, key, metaData, subProfiles);
+   }
+   
+   /**
+    * Delegate the creation of the profile to one of the registered
+    * profile factories.
+    * 
+    * @param type the meta data type
+    * @param key the profile key
+    * @param metaData the profile meta data
+    * @param subProfiles the sub profiles
+    * @return the profile
+    * @throws IllegalArgumentException if there is no factory registered for the meta data type
+    * @throws Exception for any error
+    */
+   protected Profile delegateCreateProfile(String type, ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws IllegalArgumentException, Exception
+   {
+      AbstractProfileFactory factory = this.factories.get(type);
+      if(factory == null)
+         throw new IllegalArgumentException("Unrecognized meta data type: " + type);
+      
+      return factory.createProfile(key, metaData, subProfiles);
+   }
+   
+   /**
+    * Create a empty profile. 
+    * 
+    * @param key the profile key
+    * @param metaData the profile meta data
+    * @param subProfiles the sub profiles
+    * @return the profile
+    */
+   protected Profile createNoopProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles)
+   {
+      return new NoopProfile(key, subProfiles);
+   }
+   
+   /**
+    * Add a profile factory.
+    * 
+    * @param factory the abstract profile factory to add
+    */
+   public void addProfileFactory(AbstractProfileFactory factory)
+   {
+      if(factory == null)
+         throw new IllegalArgumentException("Null profile factory.");
+      if(factory.getTypes() == null)
+         throw new IllegalArgumentException("Null factory types.");
+      
+      for(String type : factory.getTypes())
+         this.factories.put(type, factory);
+   }
+   
+   /**
+    * Remove a profile factory.
+    * 
+    * @param factory the abstract profile factory to remove
+    */
+   public void removeProfileFactory(AbstractProfileFactory factory)
+   {
+      if(factory == null)
+         throw new IllegalArgumentException("Null profile factory.");
+      if(factory.getTypes() == null)
+         throw new IllegalArgumentException("Null factory types.");
+      
+      for(String type : factory.getTypes())
+         this.factories.remove(type);
+   }
+
+}
+

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -32,7 +32,6 @@
 import org.jboss.profileservice.spi.ProfileRepository;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
 
 /**
  * The profile repository.
@@ -90,12 +89,6 @@
    
          ProfileSourceMetaData source = metaData.getSource();
          
-         // FIXME the filtering should be done by the profile itself!
-         if(source instanceof FilteredProfileSourceMetaData)
-         {
-            ((FilteredProfileSourceMetaData) source).setDeployments(metaData.getDeployments());
-         }
-         
          // TODO check if there is a conflict with hotdeployment repositories
          repository = createProfileDeploymentRepository(key, type , source);
          if(repository != null)

Deleted: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredDeploymentRepositoryFactory.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredDeploymentRepositoryFactory.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredDeploymentRepositoryFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -1,168 +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.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.DeploymentRepository;
-import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
-import org.jboss.system.server.profileservice.repository.AbstractDeploymentRepository;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * TODO
- * 
- * Create a filtered deployment repository, based on the deployments
- * of the filtered profile source 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[] FACTORY_TYPE = new String[] { FilteredProfileSourceMetaData.class.getName() };
-   
-   public String[] getTypes()
-   {
-      return FACTORY_TYPE;
-   }
-
-   public DeploymentRepository createDeploymentRepository(ProfileKey key, ProfileSourceMetaData metaData)
-   throws Exception
-   {
-      if(metaData instanceof FilteredProfileSourceMetaData == false)
-         throw new IllegalArgumentException("Wrong profileSource meta data");
-      
-      return internalCreateRepository(key, (FilteredProfileSourceMetaData) metaData); 
-   }
-   
-   protected DeploymentRepository internalCreateRepository(ProfileKey key, FilteredProfileSourceMetaData 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())
-         {
-            String deploymentName = deployment.getName();
-            if(deploymentName != null)
-               deploymentList.add(deploymentName);
-         }
-      }
-      return new FilteredRepository(deploymentList, key, createUris(metaData)); 
-   }
-   
-   protected URI[] createUris(ProfileSourceMetaData metaData) throws URISyntaxException
-   {
-      List<URI> uris = new ArrayList<URI>();
-      for(String source : metaData.getSources())
-      {
-         URI uri = new URI(source);
-         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)
-         {
-            // Get the deployment content
-            VirtualFile vf = resolveDeploymentName(deploymentName);
-            // Load the deployment
-            ProfileDeployment deployment = createDeployment(vf);
-            // Add the deployment
-            addDeployment(deployment.getName(), deployment);
-         }
-         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
-      }
-      
-      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);
-      }
-   }   
-}

Added: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -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.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);
+   }
+   
+}
+

Added: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -0,0 +1,96 @@
+/*
+ * 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;
+   }
+   
+}
+

Deleted: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -1,78 +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.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;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
-
-/**
- * Create a filtered deployment repository
- * 
- * @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
-   {
-      // Fill the filtered source with deployments
-      FilteredProfileSourceMetaData source = (FilteredProfileSourceMetaData) metaData.getSource();
-      source.setDeployments(metaData.getDeployments());
-      
-      return repository.createDeploymentRepository(key, source);
-   }
-
-   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws NoSuchProfileException
-   {
-      // FIXME
-      return null;
-   }
-
-   public Collection<ProfileKey> getProfileKeys()
-   {
-      return Collections.EMPTY_LIST;
-   }
-
-   public void removeProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
-   {
-      // nothing      
-   }
-
-}
-

Modified: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -28,14 +28,10 @@
 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.DeploymentRepositoryFactory;
-import org.jboss.profileservice.spi.ProfileRepository;
-import org.jboss.system.server.profileservice.attachments.AttachmentStore;
 import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
 import org.jboss.test.BaseTestCase;
-import org.jboss.test.server.profileservice.support.MockAttachmentStore;
+import org.jboss.test.server.profileservice.support.FilteredProfileFactory;
 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;
 
@@ -72,23 +68,11 @@
    protected MainDeployer createMainDeployer()
    {
       return new MockMainDeployer();
-   }
-   
-   protected AttachmentStore createAttachmentStore()
-   {
-      return new MockAttachmentStore();
-   }
-   
-   protected ProfileRepository createProfileRepository(DeploymentRepositoryFactory factory)
-   {
-      return new MockProfileRepository(factory);
-   }   
+   }  
 
-   protected AbstractProfileFactory createProfileFactory(DeploymentRepositoryFactory factory)
+   protected AbstractProfileFactory createProfileFactory()
    {
-      AbstractProfileFactory pf = new AbstractProfileFactory();
-      pf.setProfileRepository(createProfileRepository(factory));
-      return pf;
+      return new FilteredProfileFactory();
    }
    
 }

Modified: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -33,7 +33,6 @@
 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.FilteredDeploymentRepositoryFactory;
 import org.jboss.test.server.profileservice.support.XmlProfileFactory;
 import org.jboss.virtual.plugins.context.jar.JarUtils;
 
@@ -65,12 +64,10 @@
       File one = new File(f, "config/profiles");
       File two = new File(f, "common/profiles");
       
-      // A filtered deployment factory
-      FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
       // The xml profile factory
       AbstractBootstrapProfileFactory profileFactory = new XmlProfileFactory(
             new URI[] { one.toURI(), two.toURI() });
-      profileFactory.setProfileFactory(createProfileFactory(repositoryFactory));
+      profileFactory.setProfileFactory(createProfileFactory());
       
       // Clear jar suffixes.
       JarUtils.clearSuffixes();

Modified: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	2009-03-21 12:04:35 UTC (rev 86173)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	2009-03-21 15:18:12 UTC (rev 86174)
@@ -32,7 +32,6 @@
 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.test.server.profileservice.support.FilteredDeploymentRepositoryFactory;
 import org.jboss.test.server.profileservice.support.MockAttachmentStore;
 import org.jboss.test.server.profileservice.support.MockMainDeployer;
 import org.jboss.test.server.profileservice.support.XmlProfileFactory;
@@ -80,10 +79,9 @@
       File two = new File(f, "common/profiles");
       
       // 
-      FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
       AbstractBootstrapProfileFactory profileFactory = new XmlProfileFactory(
             new URI[] { one.toURI(), two.toURI() });
-      profileFactory.setProfileFactory(createProfileFactory(repositoryFactory));
+      profileFactory.setProfileFactory(createProfileFactory());
       
       // Clear jar suffixes.
       JarUtils.clearSuffixes();




More information about the jboss-cvs-commits mailing list