[jboss-cvs] JBossAS SVN: r84176 - trunk/profileservice/src/main/org/jboss/profileservice/management.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 13 10:17:58 EST 2009


Author: emuckenhuber
Date: 2009-02-13 10:17:58 -0500 (Fri, 13 Feb 2009)
New Revision: 84176

Modified:
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
Log:
update MgtView to handle multiple profiles

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-02-13 15:14:49 UTC (rev 84175)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-02-13 15:17:58 UTC (rev 84176)
@@ -168,25 +168,35 @@
     * @throws NoSuchProfileException
     */
    public void loadProfile(ProfileKey key)
-      throws Exception
+      throws NoSuchProfileException
    {
-      // If the profile is unmodified do nothing
-      if(activeProfile != null && activeProfile.getKey().equals(key))
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      
+      // Force reload
+      if(activeProfile != null)
       {
-         if(activeProfile.getLastModified() <= activeProfileLastModified)
-         {
-            log.debug("Not reloading profile: "+key+", "+activeProfileLastModified);
-            return;
-         }
+         if(activeProfile.getKey().equals(key) == false)
+            this.activeProfileLastModified = 0;
       }
+      
+      // If the profile is not modified do nothing
+      if(reload() == false)
+      {
+         log.debug("Not reloading profiles");
+         return;
+      }
 
-      activeProfile = ps.getProfile(key);
-      if( activeProfile == null )
+      try
       {
+         activeProfile = ps.getActiveProfile(key);
+      }
+      catch(NoSuchProfileException e)
+      {
          formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
          Object[] args = {key};
          String msg = formatter.format(args);
-         throw new NoSuchProfileException(msg);
+         throw new NoSuchProfileException(msg);         
       }
       // Cleanup
       this.compByCompType.clear();
@@ -197,19 +207,10 @@
 
       // Process the deployments
       boolean trace = log.isTraceEnabled();
-      Collection<ProfileDeployment> deployments = activeProfile.getDeployments();
-      for(ProfileDeployment deployment : deployments)
-      {
-         try
-         {
-            ManagedDeployment md = getManagedDeployment(deployment);
-            processManagedDeployment(md, 0, trace);
-         }
-         catch(Exception e)
-         {
-            log.warn("Failed to create ManagedDeployment for: " + deployment.getName(), e);
-         }
-      }
+      
+      // load the profiles
+      loadProfiles(trace);
+      
       // Process the bootstrap deployments
       for(ManagedDeployment md : bootstrapManagedDeployments.values())
       {
@@ -224,13 +225,63 @@
       }
       if(this.runtimeMOs.size() > 0)
          log.warn("Failed to merged the following runtime ManagedObjects: "+runtimeMOs);
-      activeProfileLastModified = activeProfile.getLastModified();
    }
+   
    public void reloadProfile() throws Exception
    {
       activeProfileLastModified = 0;
       loadProfile(activeProfile.getKey());
    }
+   
+   protected void loadProfiles(boolean trace)
+   {
+      for(ProfileKey key : this.ps.getActiveProfileKeys())
+      {
+         try
+         {
+            Profile profile = this.ps.getActiveProfile(key);
+            Collection<ProfileDeployment> deployments = profile.getDeployments();
+            for(ProfileDeployment deployment : deployments)
+            {
+               try
+               {
+                  ManagedDeployment md = getManagedDeployment(deployment);
+                  processManagedDeployment(md, 0, trace);
+               }
+               catch(Exception e)
+               {
+                  log.debug("Failed to create ManagedDeployment for: " + deployment.getName(), e);
+               }
+            }
+            long lastModified = profile.getLastModified();
+            if(activeProfileLastModified < lastModified)
+               this.activeProfileLastModified = lastModified;            
+         }
+         catch(Exception e)
+         {
+            log.debug("failed to load profile " + key, e);
+         }
+      }
+   }
+   
+   protected boolean reload()
+   {
+      boolean reload = false;
+      if(activeProfile == null)
+         return true;
+      for(ProfileKey key : this.ps.getActiveProfileKeys())
+      {
+         try
+         {
+            Profile profile = this.ps.getActiveProfile(key);
+            long lastModified = profile.getLastModified();
+            if(lastModified > this.activeProfileLastModified)
+               return true;
+         }
+         catch(Exception ignore) { /** . */ }
+      }
+      return reload;
+   }
 
    /**
     * Process managed deployment.
@@ -547,13 +598,7 @@
     */
    public Set<String> getDeploymentNames()
    {
-      Set<String> names = new HashSet<String>();
-      Set<String> profileNames = activeProfile.getDeploymentNames();
-      if(profileNames != null)
-         names.addAll(profileNames);
-      if(bootstrapManagedDeployments != null)
-         names.addAll(bootstrapManagedDeployments.keySet());
-      return names;
+      return new HashSet<String>(this.managedDeployments.keySet());
    }
 
    /**




More information about the jboss-cvs-commits mailing list