geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1430511 - /geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
Date Tue, 08 Jan 2013 20:46:23 GMT
Author: gawor
Date: Tue Jan  8 20:46:23 2013
New Revision: 1430511

URL: http://svn.apache.org/viewvc?rev=1430511&view=rev
Log:
GERONIMO-6427: Avoid temporarily loading and unloading disabled modules

Modified:
    geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java

Modified: geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java?rev=1430511&r1=1430510&r2=1430511&view=diff
==============================================================================
--- geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
(original)
+++ geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
Tue Jan  8 20:46:23 2013
@@ -58,7 +58,6 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.management.geronimo.WebModule;
 import org.apache.geronimo.web.info.WebAppInfo;
 import org.apache.geronimo.aries.ApplicationGBean;
@@ -237,17 +236,11 @@ public class ConfigManagerPortlet extend
                     ModuleDetails details = new ModuleDetails(info.getConfigID(), info.getType(),
info.getState());
                     try {
                         AbstractName configObjName = Configuration.getConfigurationAbstractName(info.getConfigID());
-                        boolean loaded = loadModule(configManager, configObjName);
                         Configuration config = configManager.getConfiguration(info.getConfigID());
                         if (config != null) {
                             for(Map.Entry<AbstractName, GBeanData> entry : config.getGBeans().entrySet())
{
                                 if(entry.getKey().getNameProperty(NameFactory.J2EE_TYPE).equals(NameFactory.WEB_MODULE))
{
-                                    details.getContextPaths().add((String)entry.getValue().getAttribute("contextPath"));
-                                    details.setDisplayName(((WebAppInfo)entry.getValue().getAttribute("webAppInfo")).displayName);
-                                    if (null != entry.getValue().getAttribute("virtualServer")
-                                    		&& !"".equals(entry.getValue().getAttribute("virtualServer")))
{
-                                    	details.setVirtualServer((String)entry.getValue().getAttribute("virtualServer"));
-                                    }
+                                    setWebModuleDetails(details, entry.getValue());
                                 }
                             }
                         }
@@ -255,10 +248,6 @@ public class ConfigManagerPortlet extend
                         if (showDependencies) {
                             addDependencies(details, configObjName);
                         }
-
-                        if (loaded) {
-                            unloadModule(configManager, configObjName);
-                        }
                     } catch (InvalidConfigException ice) {
                         logger.error("Fail to load configuration", ice);
                     }
@@ -266,18 +255,14 @@ public class ConfigManagerPortlet extend
                 } else if (info.getType() == ConfigurationModuleType.EAR) {
                     try {
                         AbstractName configObjName = Configuration.getConfigurationAbstractName(info.getConfigID());
-                        boolean loaded = loadModule(configManager, configObjName);
-
                         Configuration config = configManager.getConfiguration(info.getConfigID());
                         if (config != null) {
                             for (Map.Entry<AbstractName, GBeanData> entry : config.getGBeans().entrySet())
{
                                 if (entry.getKey().getNameProperty(NameFactory.J2EE_TYPE).equals(NameFactory.WEB_MODULE))
{
                                     ModuleDetails childDetails = new ModuleDetails(info.getConfigID(),
ConfigurationModuleType.WAR, info.getState());
                                     AbstractName webModuleAbName = entry.getKey();
-                                    GBeanData webModuleGBeanData = entry.getValue();
                                     childDetails.setComponentName(webModuleAbName.getNameProperty("name"));
-                                    childDetails.getContextPaths().add((String) webModuleGBeanData.getAttribute("contextPath"));
-                                    childDetails.setDisplayName(((WebAppInfo)webModuleGBeanData.getAttribute("webAppInfo")).displayName);
+                                    setWebModuleDetails(childDetails, entry.getValue());
                                     if (showDependencies) {
                                         addDependencies(childDetails, configObjName);
                                     }
@@ -285,9 +270,6 @@ public class ConfigManagerPortlet extend
                                 }
                             }
                         }
-                        if (loaded) {
-                            unloadModule(configManager, configObjName);
-                        }
                     } catch (InvalidConfigException ice) {
                         logger.error("Fail to load configuration", ice);
                     }
@@ -297,15 +279,12 @@ public class ConfigManagerPortlet extend
                 ModuleDetails details = new ModuleDetails(info.getConfigID(), info.getType(),
getConfigurationState(info));
                 try {
                     AbstractName configObjName = Configuration.getConfigurationAbstractName(info.getConfigID());
-                    boolean loaded = loadModule(configManager, configObjName);
-
                     if (info.getType() == ConfigurationModuleType.EAR) {
                         Configuration config = configManager.getConfiguration(info.getConfigID());
                         if(config != null){
                             for(Map.Entry<AbstractName, GBeanData> entry : config.getGBeans().entrySet())
{
                                 if(entry.getKey().getNameProperty(NameFactory.J2EE_TYPE).equals(NameFactory.WEB_MODULE))
{
-                                    details.getContextPaths().add((String)entry.getValue().getAttribute("contextPath"));
-                                    details.setDisplayName(((WebAppInfo)entry.getValue().getAttribute("webAppInfo")).displayName);
+                                    setWebModuleDetails(details, entry.getValue());
                                 }
                             }
                         }
@@ -342,9 +321,6 @@ public class ConfigManagerPortlet extend
                     if (showDependencies) {
                         addDependencies(details, configObjName);
                     }
-                    if (loaded) {
-                        unloadModule(configManager, configObjName);
-                    }
                 } catch (InvalidConfigException ice) {
                     logger.error("Fail to load configuration", ice);
                 }
@@ -368,6 +344,15 @@ public class ConfigManagerPortlet extend
         }
     }
 
+    private void setWebModuleDetails(ModuleDetails details, GBeanData gbean) {
+        details.getContextPaths().add((String)gbean.getAttribute("contextPath"));
+        details.setDisplayName(((WebAppInfo)gbean.getAttribute("webAppInfo")).displayName);
+        String virtualServer = (String)gbean.getAttribute("virtualServer");
+        if (virtualServer != null && virtualServer.length() > 0) {
+            details.setVirtualServer(virtualServer);
+        }
+    }
+
     private State getConfigurationState(ConfigurationInfo configurationInfo) {
         State configurationState = configurationInfo.getState();
         if (configurationState.isRunning()) {
@@ -408,28 +393,6 @@ public class ConfigManagerPortlet extend
         return null;
     }
 
-    private boolean loadModule(ConfigurationManager configManager, AbstractName configObjName)
{
-        if(!kernel.isLoaded(configObjName)) {
-            try {
-                configManager.loadConfiguration(configObjName.getArtifact());
-                return true;
-            } catch (NoSuchConfigException e) {
-                // Should not occur
-                e.printStackTrace();
-            } catch (LifecycleException e) {
-                // config could not load because one or more of its dependencies
-                // has been removed. cannot load the configuration in this case,
-                // so don't rely on that technique to discover its parents or children
-                if (e.getCause() instanceof MissingDependencyException) {
-                    // do nothing
-                } else {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return false;
-    }
-
     private void addDependencies(ModuleDetails details, AbstractName configObjName) {
         DependencyManager depMgr = kernel.getDependencyManager();
         Set<AbstractName> parents = depMgr.getParents(configObjName);
@@ -447,16 +410,6 @@ public class ConfigManagerPortlet extend
         Collections.sort(details.getChildren());
     }
 
-    private void unloadModule(ConfigurationManager configManager, AbstractName configObjName)
{
-        try {
-            configManager.unloadConfiguration(configObjName.getArtifact());
-        } catch (NoSuchConfigException e) {
-            logger.error("Fail to unload module " + configObjName, e);
-        }  catch (LifecycleException e) {
-            logger.error("Fail to unload module " + configObjName, e);
-        }
-    }
-
     private boolean showWebInfo() {
         return ConfigurationModuleType.WAR.getName().equalsIgnoreCase(moduleType) ||
                ConfigurationModuleType.EAR.getName().equalsIgnoreCase(moduleType) ||



Mime
View raw message