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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jan 25 07:52:29 EST 2009


Author: emuckenhuber
Date: 2009-01-25 07:52:29 -0500 (Sun, 25 Jan 2009)
New Revision: 83398

Added:
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java
Modified:
   trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.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/ProfileServiceUnitTestCase.java
Log:
split to a bootstrap and a separate profile factory

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2009-01-25 12:02:11 UTC (rev 83397)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2009-01-25 12:52:29 UTC (rev 83398)
@@ -71,7 +71,7 @@
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.profileservice.spi.types.ControllerStateMetaType;
-import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
+import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
 
 /**
  * Bootstraps the profile service
@@ -103,8 +103,9 @@
    private ManagedObjectFactory mof;
    /** The ManagedDeployment map for the MCServer KernelDeployments */
    private Map<String, ManagedDeployment> bootstrapMDs = new HashMap<String, ManagedDeployment>();
-   /** The profile factory */
-   private AbstractProfileFactory profileFactory; 
+   
+   /** The profile bootstrap factory */
+   private AbstractBootstrapProfileFactory profileFactory; 
 
    /** Whether we are shutdown */
    private AtomicBoolean shutdown = new AtomicBoolean(false);
@@ -171,12 +172,12 @@
       this.mgtDeploymentCreator = mgtDeploymentCreator;
    }
 
-   public AbstractProfileFactory getProfileFactory()
+   public AbstractBootstrapProfileFactory getBootstrapProfileFactory()
    {
       return profileFactory;
    }
    
-   public void setProfileFactory(AbstractProfileFactory profileFactory)
+   public void setBootstrapProfileFactory(AbstractBootstrapProfileFactory profileFactory)
    {
       this.profileFactory = profileFactory;
    }

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java (from rev 83397, trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java	2009-01-25 12:52:29 UTC (rev 83398)
@@ -0,0 +1,262 @@
+/*
+ * 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.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+
+/**
+ * The abstract profile factory.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractBootstrapProfileFactory
+{
+   /** The profile map. */
+   private Map<ProfileKey, ProfileMetaData> profileMap = new HashMap<ProfileKey, ProfileMetaData>();
+   
+   /** The profiles map. */
+   private Map<ProfileKey, List<ProfileMetaData>> profilesMetaData = new HashMap<ProfileKey, List<ProfileMetaData>>();
+   
+   /** The profile factory. */
+   private AbstractProfileFactory profileFactory;
+   
+   /** The logger */
+   protected final Logger log = Logger.getLogger(getClass()); 
+
+   public AbstractProfileFactory getProfileFactory()
+   {
+      return profileFactory;
+   }
+   
+   public void setProfileFactory(AbstractProfileFactory profileFactory)
+   {
+      this.profileFactory = profileFactory;
+   }
+   
+   /**
+    * Create the meta data required for this profile.
+    * 
+    * @param key the root profile key.
+    * @throws Exception
+    */
+   protected abstract void createProfileMetaData(ProfileKey key, URL url) throws Exception;
+   
+   /**
+    * Create the profiles required for this profile. 
+    * 
+    * @param rootKey the root profile key.
+    * @param uri the profile root uri for parsing.
+    * @return a collection of profiles
+    * @throws Exception
+    */
+   public Collection<Profile> createProfiles(ProfileKey rootKey, URL url) throws Exception
+   {
+      if(rootKey == null)
+         throw new IllegalArgumentException("Null profile key");
+         
+      // Create the profile meta data.
+      createProfileMetaData(rootKey, url);
+      
+      Map<ProfileKey, Profile> profiles = new HashMap<ProfileKey, Profile>();
+      // Create the real profiles
+      createProfiles(profiles, rootKey);
+      
+      return profiles.values();
+   }
+
+   /**
+    * Create profiles
+    * 
+    * @param profiles the profiles map 
+    * @param key the ProfileKey
+    * @throws Exception
+    */
+   public void createProfiles(Map<ProfileKey, Profile> profiles, ProfileKey key) throws Exception
+   {
+      ProfileMetaData profileMetaData = this.profileMap.get(key);
+      if(profileMetaData == null)
+         throw new IllegalStateException("Could not find metaData for key: " + key);
+
+      List<ProfileKey> subProfiles = new ArrayList<ProfileKey>();
+      
+      // Create the profile
+      createProfile(profiles, subProfiles, key, profileMetaData);
+
+   }
+
+   /**
+    * Create a Profile with it's sub-profiles.
+    * 
+    * @param profiles the profiles map
+    * @param subProfiles the sub-profiles list
+    * @param key the ProfileKey
+    * @param profileMetaData the profile meta data
+    * @throws Exception
+    */
+   public void createProfile(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfiles, ProfileKey key, ProfileMetaData profileMetaData) throws Exception
+   {
+      // Don't process a profile twice
+      if(profiles.containsKey(key))
+         return;
+      
+      if(log.isTraceEnabled())
+         log.trace("Creating profile for key: " + key);
+      
+      // First recursively process the sub profiles
+      processSubProfiles(profiles, subProfiles, profileMetaData.getSubprofiles());
+      
+      // Create the profile
+      Profile profile = profileFactory.createProfile(key, profileMetaData, subProfiles);
+      
+      // Add to the profileMap
+      profiles.put(key, profile);
+      
+      // FIXME add a implicit dependency for the next
+      if(subProfiles.contains(key) == false)
+         subProfiles.add(key);
+   }
+   
+   /**
+    * Process the sub-profiles.
+    * 
+    * @param profiles the profiles map
+    * @param subProfileKeys the sub-profiles
+    * @param subProfilesMetaData a list of sub-profile metadata 
+    * @throws Exception
+    */
+   private void processSubProfiles(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfileKeys, List<SubProfileMetaData> subProfilesMetaData) throws Exception
+   {
+      if(subProfilesMetaData == null || subProfilesMetaData.isEmpty())
+         return;
+      
+      for(SubProfileMetaData subProfile : subProfilesMetaData)
+      {
+         ProfileKey subProfileKey = createProfileKey(subProfile);
+         if(this.profileMap.containsKey(subProfileKey))
+         {
+            createProfile(profiles, subProfileKeys, subProfileKey, this.profileMap.get(subProfileKey));
+         }
+         else if(this.profilesMetaData.containsKey(subProfileKey))
+         {
+            List<ProfileMetaData> subProfileAliases = this.profilesMetaData.get(subProfileKey);
+            processSubProfileAlias(profiles, subProfileKeys, subProfileAliases);
+         }
+         else
+         {
+            throw new IllegalStateException("Could not resolve profile meta data for key: " + subProfileKey);
+         }
+      }     
+   }
+   
+   /**
+    * Process the profiles alias for a sub-profile.
+    * 
+    * @param profiles the profiles map
+    * @param subProfileKeys the sub-profiles
+    * @param subprofileAliases the profile meta data for the sub-profiles
+    * @throws Exception
+    */
+   private void processSubProfileAlias(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfileKeys, List<ProfileMetaData> subprofileAliases) throws Exception
+   {
+      if(subprofileAliases == null || subprofileAliases.isEmpty())
+         return;
+      
+      for(ProfileMetaData metaData : subprofileAliases)
+      {
+         ProfileKey key = createProfileKey(metaData);
+         createProfile(profiles, subProfileKeys, key, metaData);
+      }
+   }
+   
+   /**
+    * Add a profile.
+    * 
+    * @param key the profile key.
+    * @param metaData the profile meta data.
+    */
+   protected void addProfile(ProfileKey key, ProfileMetaData metaData)
+   {
+      // The keys have be unique
+      if(this.profileMap.containsKey(key))
+         throw new IllegalStateException("Duplicate key: " + key);
+
+      if(this.profilesMetaData.containsKey(key))
+         throw new IllegalStateException("Duplicate key: " + key);
+      
+      this.profileMap.put(key, metaData);
+   }
+   
+   /**
+    * Add a list of profile meta data which make up a profiles reference.
+    * 
+    * @param key the profile key.
+    * @param metaData a list of profile meta data.
+    */
+   protected void addProfiles(ProfileKey key, List<ProfileMetaData> metaData)
+   {
+      if(this.profileMap.containsKey(key))
+      {
+         // Ignore the default key, which gets generated for <profiles/>
+         if(ProfileKey.DEFAULT.equals(key.getDomain())
+               && ProfileKey.DEFAULT.equals(key.getServer())
+               && ProfileKey.DEFAULT.equals(key.getName()))
+         {
+            return;
+         }
+         else
+         {
+            throw new IllegalStateException("Duplicate key: " + key);  
+         }
+      }
+
+      // Create a entry for <profiles>
+      List<ProfileMetaData> profileList = this.profilesMetaData.get(key);
+      if(profileList == null)
+      {
+         profileList = new ArrayList<ProfileMetaData>();
+         this.profilesMetaData.put(key, profileList);
+      }
+      
+      if(metaData != null && metaData.isEmpty() == false)
+      {
+         profileList.addAll(metaData);
+      }
+   }
+   
+   public static ProfileKey createProfileKey(ProfileKeyMetaData md)
+   {
+      return new ProfileKey(md.getDomain(), md.getServer(), md.getName());
+   }
+}
\ No newline at end of file


Property changes on: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + native

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java	2009-01-25 12:02:11 UTC (rev 83397)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java	2009-01-25 12:52:29 UTC (rev 83398)
@@ -21,42 +21,30 @@
  */ 
 package org.jboss.system.server.profileservice.repository;
 
-import java.net.URL;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
-import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileRepository;
-import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 import org.jboss.system.server.profile.repository.AbstractProfile;
 
 /**
  * The abstract profile factory.
+ * This does actually just creates a abstract profile for now!
  * 
+ * TODO maybe create put in spi ?
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public abstract class AbstractProfileFactory
-{
-   /** The profile map. */
-   private Map<ProfileKey, ProfileMetaData> profileMap = new HashMap<ProfileKey, ProfileMetaData>();
-   
-   /** The profiles map. */
-   private Map<ProfileKey, List<ProfileMetaData>> profilesMetaData = new HashMap<ProfileKey, List<ProfileMetaData>>();
-   
+public class AbstractProfileFactory
+{   
    /** The deployment repository factory. */
    private ProfileRepository profileRepository;
-   
-   /** The logger */
-   protected final Logger log = Logger.getLogger(getClass()); 
 
    public ProfileRepository getProfileRepository()
    {
@@ -68,80 +56,21 @@
       this.profileRepository = profileRepository;
    }
    
-   /**
-    * Create the meta data required for this profile.
-    * 
-    * @param key the root profile key.
-    * @throws Exception
-    */
-   protected abstract void createProfileMetaData(ProfileKey key, URL url) throws Exception;
-   
-   /**
-    * Create the profiles required for this profile. 
-    * 
-    * @param rootKey the root profile key.
-    * @param uri the profile root uri for parsing.
-    * @return a collection of profiles
-    * @throws Exception
-    */
-   public Collection<Profile> createProfiles(ProfileKey rootKey, URL url) throws Exception
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData) throws Exception
    {
-      if(rootKey == null)
-         throw new IllegalArgumentException("Null profile key");
-         
-      // Create the profile meta data.
-      createProfileMetaData(rootKey, url);
-      
-      Map<ProfileKey, Profile> profiles = new HashMap<ProfileKey, Profile>();
-      // Create the real profiles
-      createProfiles(profiles, rootKey);
-      
-      return profiles.values();
+      return createProfile(key, metaData, Collections.EMPTY_LIST);
    }
-
-   /**
-    * Create profiles
-    * 
-    * @param profiles the profiles map 
-    * @param key the ProfileKey
-    * @throws Exception
-    */
-   public void createProfiles(Map<ProfileKey, Profile> profiles, ProfileKey key) throws Exception
+   
+   
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception
    {
-      ProfileMetaData profileMetaData = this.profileMap.get(key);
-      if(profileMetaData == null)
-         throw new IllegalStateException("Could not find metaData for key: " + key);
-
-      List<ProfileKey> subProfiles = new ArrayList<ProfileKey>();
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(metaData == null)
+         throw new IllegalArgumentException("Null profile meta data.");
       
-      // Create the profile
-      createProfile(profiles, subProfiles, key, profileMetaData);
-
-   }
-
-   /**
-    * Create a Profile with it's sub-profiles.
-    * 
-    * @param profiles the profiles map
-    * @param subProfiles the sub-profiles list
-    * @param key the ProfileKey
-    * @param profileMetaData the profile meta data
-    * @throws Exception
-    */
-   public void createProfile(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfiles, ProfileKey key, ProfileMetaData profileMetaData) throws Exception
-   {
-      // Don't process a profile twice
-      if(profiles.containsKey(key))
-         return;
-      
-      if(log.isTraceEnabled())
-         log.trace("Creating profile for key: " + key);
-      
-      // First recursively process the sub profiles
-      processSubProfiles(profiles, subProfiles, profileMetaData.getSubprofiles());
-      
       // Start to create the profile
-      DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, profileMetaData);
+      DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, metaData);
       
       // Create the profile
       AbstractProfile profile = new AbstractProfile(repository, key);
@@ -149,123 +78,6 @@
       // Copy the sub-profile keys
       profile.setSubProfiles(new ArrayList<ProfileKey>(subProfiles));
       
-      // Add to the profileMap
-      profiles.put(key, profile);
-      
-      // FIXME add a implicit dependency for the next
-      if(subProfiles.contains(key) == false)
-         subProfiles.add(key);
+      return profile;
    }
-   
-   /**
-    * Process the sub-profiles.
-    * 
-    * @param profiles the profiles map
-    * @param subProfileKeys the sub-profiles
-    * @param subProfilesMetaData a list of sub-profile metadata 
-    * @throws Exception
-    */
-   private void processSubProfiles(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfileKeys, List<SubProfileMetaData> subProfilesMetaData) throws Exception
-   {
-      if(subProfilesMetaData == null || subProfilesMetaData.isEmpty())
-         return;
-      
-      for(SubProfileMetaData subProfile : subProfilesMetaData)
-      {
-         ProfileKey subProfileKey = createProfileKey(subProfile);
-         if(this.profileMap.containsKey(subProfileKey))
-         {
-            createProfile(profiles, subProfileKeys, subProfileKey, this.profileMap.get(subProfileKey));
-         }
-         else if(this.profilesMetaData.containsKey(subProfileKey))
-         {
-            List<ProfileMetaData> subProfileAliases = this.profilesMetaData.get(subProfileKey);
-            processSubProfileAlias(profiles, subProfileKeys, subProfileAliases);
-         }
-         else
-         {
-            throw new IllegalStateException("Could not resolve profile meta data for key: " + subProfileKey);
-         }
-      }     
-   }
-   
-   /**
-    * Process the profiles alias for a sub-profile.
-    * 
-    * @param profiles the profiles map
-    * @param subProfileKeys the sub-profiles
-    * @param subprofileAliases the profile meta data for the sub-profiles
-    * @throws Exception
-    */
-   private void processSubProfileAlias(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfileKeys, List<ProfileMetaData> subprofileAliases) throws Exception
-   {
-      if(subprofileAliases == null || subprofileAliases.isEmpty())
-         return;
-      
-      for(ProfileMetaData metaData : subprofileAliases)
-      {
-         ProfileKey key = createProfileKey(metaData);
-         createProfile(profiles, subProfileKeys, key, metaData);
-      }
-   }
-   
-   /**
-    * Add a profile.
-    * 
-    * @param key the profile key.
-    * @param metaData the profile meta data.
-    */
-   protected void addProfile(ProfileKey key, ProfileMetaData metaData)
-   {
-      // The keys have be unique
-      if(this.profileMap.containsKey(key))
-         throw new IllegalStateException("Duplicate key: " + key);
-
-      if(this.profilesMetaData.containsKey(key))
-         throw new IllegalStateException("Duplicate key: " + key);
-      
-      this.profileMap.put(key, metaData);
-   }
-   
-   /**
-    * Add a list of profile meta data which make up a profiles reference.
-    * 
-    * @param key the profile key.
-    * @param metaData a list of profile meta data.
-    */
-   protected void addProfiles(ProfileKey key, List<ProfileMetaData> metaData)
-   {
-      if(this.profileMap.containsKey(key))
-      {
-         // Ignore the default key, which gets generated for <profiles/>
-         if(ProfileKey.DEFAULT.equals(key.getDomain())
-               && ProfileKey.DEFAULT.equals(key.getServer())
-               && ProfileKey.DEFAULT.equals(key.getName()))
-         {
-            return;
-         }
-         else
-         {
-            throw new IllegalStateException("Duplicate key: " + key);  
-         }
-      }
-
-      // Create a entry for <profiles>
-      List<ProfileMetaData> profileList = this.profilesMetaData.get(key);
-      if(profileList == null)
-      {
-         profileList = new ArrayList<ProfileMetaData>();
-         this.profilesMetaData.put(key, profileList);
-      }
-      
-      if(metaData != null && metaData.isEmpty() == false)
-      {
-         profileList.addAll(metaData);
-      }
-   }
-   
-   public static ProfileKey createProfileKey(ProfileKeyMetaData md)
-   {
-      return new ProfileKey(md.getDomain(), md.getServer(), md.getName());
-   }
 }
\ No newline at end of file

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-01-25 12:02:11 UTC (rev 83397)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	2009-01-25 12:52:29 UTC (rev 83398)
@@ -43,7 +43,7 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class StaticProfileFactory extends AbstractProfileFactory
+public class StaticProfileFactory extends AbstractBootstrapProfileFactory
 {
 
    /** The bootstrap profile name. */

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java	2009-01-25 12:02:11 UTC (rev 83397)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java	2009-01-25 12:52:29 UTC (rev 83398)
@@ -49,7 +49,7 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class XmlProfileFactory extends AbstractProfileFactory
+public class XmlProfileFactory extends AbstractBootstrapProfileFactory
 {
    /** The profiles directory name. */
    public final static String PROFILES_SUFFIX = ".profile";

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-01-25 12:02:11 UTC (rev 83397)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	2009-01-25 12:52:29 UTC (rev 83398)
@@ -31,6 +31,7 @@
 import org.jboss.profileservice.spi.AttachmentStore;
 import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
 import org.jboss.profileservice.spi.ProfileRepository;
+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.MockMainDeployer;
@@ -83,7 +84,12 @@
       return new MockProfileRepository(factory);
    }   
 
+   protected AbstractProfileFactory createProfileFactory(DeploymentRepositoryFactory factory)
+   {
+      AbstractProfileFactory pf = new AbstractProfileFactory();
+      pf.setProfileRepository(createProfileRepository(factory));
+      return pf;
+   }
    
-   
 }
 

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-01-25 12:02:11 UTC (rev 83397)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java	2009-01-25 12:52:29 UTC (rev 83398)
@@ -31,7 +31,7 @@
 
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
+import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
 import org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory;
 import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
 import org.jboss.virtual.plugins.context.jar.JarUtils;
@@ -68,9 +68,9 @@
       FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
       repositoryFactory.setAttachmentStore(createAttachmentStore());
       // The xml profile factory
-      AbstractProfileFactory profileFactory = new XmlProfileFactory(
+      AbstractBootstrapProfileFactory profileFactory = new XmlProfileFactory(
             new URI[] { one.toURI(), two.toURI() });
-      profileFactory.setProfileRepository(createProfileRepository(repositoryFactory));
+      profileFactory.setProfileFactory(createProfileFactory(repositoryFactory));
       
       // Clear jar suffixes.
       JarUtils.clearSuffixes();

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-01-25 12:02:11 UTC (rev 83397)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	2009-01-25 12:52:29 UTC (rev 83398)
@@ -29,7 +29,7 @@
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
+import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
 import org.jboss.system.server.profileservice.repository.AbstractProfileService;
 import org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory;
 import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
@@ -77,9 +77,9 @@
       // 
       FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
       repositoryFactory.setAttachmentStore(createAttachmentStore());
-      AbstractProfileFactory profileFactory = new XmlProfileFactory(
+      AbstractBootstrapProfileFactory profileFactory = new XmlProfileFactory(
             new URI[] { one.toURI(), two.toURI() });
-      profileFactory.setProfileRepository(createProfileRepository(repositoryFactory));
+      profileFactory.setProfileFactory(createProfileFactory(repositoryFactory));
       
       // Clear jar suffixes.
       JarUtils.clearSuffixes();
@@ -87,13 +87,20 @@
       // Parse
       Collection<Profile> profiles = profileFactory.createProfiles(new ProfileKey("default"), null);
       for(Profile profile : profiles)
-      {        
+      {
          // Register
          profileService.registerProfile(profile);
       }
       
-      // Activate profile
-      profileService.activateProfile(new ProfileKey("default"));
+      try
+      {
+         // Activate profile
+         profileService.activateProfile(new ProfileKey("default"));
+      }
+      catch(Exception e)
+      {
+         getLog().error("failed to activate: ", e);
+      }
       
       // Assert default profile
       assertActive("default");
@@ -116,6 +123,18 @@
       // Assert metadata-deployers profile
       assertActive("metadata-deployers");
       
+      for(ProfileKey key : profileService.getActiveProfileKeys())
+      {
+         try
+         {
+            profileService.deactivateProfile(key);
+         }
+         catch(Exception e)
+         {
+            getLog().debug("error deactivating profile: " + key, e);
+         }
+      }
+      
    }
    
    protected void assertActive(String profile) throws Exception




More information about the jboss-cvs-commits mailing list