Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 70760 invoked from network); 13 Apr 2010 00:53:30 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Apr 2010 00:53:30 -0000 Received: (qmail 51514 invoked by uid 500); 13 Apr 2010 00:53:30 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 51465 invoked by uid 500); 13 Apr 2010 00:53:30 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 51458 invoked by uid 99); 13 Apr 2010 00:53:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Apr 2010 00:53:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Apr 2010 00:53:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 545EF238899B; Tue, 13 Apr 2010 00:53:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r933452 - in /geronimo/server/trunk: framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ framework/modules/geronimo-kernel/sr... Date: Tue, 13 Apr 2010 00:53:03 -0000 To: scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100413005303.545EF238899B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: xuhaihong Date: Tue Apr 13 00:53:02 2010 New Revision: 933452 URL: http://svn.apache.org/viewvc?rev=933452&view=rev Log: GERONIMO-4909 The changes just remove the bundle if we unload the car from ConfigurationManager Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationManager.java geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java?rev=933452&r1=933451&r2=933452&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java Tue Apr 13 00:53:02 2010 @@ -168,11 +168,11 @@ public class DeploymentConfigurationMana // UNLOAD // - public synchronized LifecycleResults unloadConfiguration(Artifact id) throws NoSuchConfigException { + public synchronized LifecycleResults unloadConfiguration(Artifact id) throws NoSuchConfigException, LifecycleException { return super.unloadConfiguration(id); } - public synchronized LifecycleResults unloadConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException { + public synchronized LifecycleResults unloadConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException { return super.unloadConfiguration(id, monitor); } Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java?rev=933452&r1=933451&r2=933452&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java Tue Apr 13 00:53:02 2010 @@ -34,6 +34,7 @@ import org.apache.geronimo.kernel.config import org.apache.geronimo.kernel.config.ConfigurationManager; import org.apache.geronimo.kernel.config.ConfigurationStore; import org.apache.geronimo.kernel.config.InvalidConfigException; +import org.apache.geronimo.kernel.config.LifecycleException; import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.ArtifactResolver; @@ -117,6 +118,8 @@ public class SingleFileHotDeployer { configurationManager.unloadConfiguration(existingConfigurationId); } catch (NoSuchConfigException e) { throw new DeploymentException("Unable to unload existing configuration " + existingConfigurationId); + } catch (LifecycleException e) { + throw new DeploymentException("Unable to unload existing configuration " + existingConfigurationId); } } Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationManager.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationManager.java?rev=933452&r1=933451&r2=933452&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationManager.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationManager.java Tue Apr 13 00:53:02 2010 @@ -53,7 +53,7 @@ import org.osgi.framework.Bundle; * classes needed by the GBeanDatas in the configuration. Once the * configuration has been loaded, it's ClassLoader is available so the * GBeanDatas can be loaded and inspected. But the GBean instances are not - * instantiated and started until the configuration is started. + * instantiated and started until the configuration is started. * * @version $Rev$ $Date$ */ @@ -275,8 +275,9 @@ public interface ConfigurationManager ex * @return the results of the operation * * @throws NoSuchConfigException if the configuration is not loaded + * @throws LifecycleException */ - LifecycleResults unloadConfiguration(Artifact configurationId) throws NoSuchConfigException; + LifecycleResults unloadConfiguration(Artifact configurationId) throws NoSuchConfigException, LifecycleException; /** * Stops and unloads the configuration. This causes all contained gbeans @@ -293,8 +294,9 @@ public interface ConfigurationManager ex * @return the results of the operation * * @throws NoSuchConfigException if the configuration is not loaded + * @throws LifecycleException */ - LifecycleResults unloadConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException; + LifecycleResults unloadConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException; /** * Loads and starts all of the gbeans contained within the configuration. @@ -480,11 +482,12 @@ public interface ConfigurationManager ex * * @param configurationId the configuration identifier, which must be fully * resolved (isResolved() == true) - * + * * @throws IOException if there was a problem removing the configuration * @throws NoSuchConfigException if the configuration is not loaded + * @throws LifecycleException */ - void uninstallConfiguration(Artifact configurationId) throws IOException, NoSuchConfigException; + void uninstallConfiguration(Artifact configurationId) throws IOException, NoSuchConfigException, LifecycleException; /** * Gets the common ArtifactResolver in case the caller wants to use this Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=933452&r1=933451&r2=933452&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Tue Apr 13 00:53:02 2010 @@ -43,10 +43,11 @@ import org.apache.geronimo.kernel.reposi import org.apache.geronimo.kernel.repository.MissingDependencyException; import org.apache.geronimo.kernel.repository.Repository; import org.apache.geronimo.kernel.repository.Version; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @version $Rev$ $Date$ @@ -348,26 +349,6 @@ public class SimpleConfigurationManager actuallyLoaded = new LinkedHashMap(resolvedParents.size()); } try { -// for (Artifact configurationId : resolvedParents) { -// -// monitor.loading(configurationId); -// String bundleId = locateBundle(configurationId, monitor); -// try { -// Bundle parent = bundleContext.installBundle(bundleId); -// if (parent.getSymbolicName() != null) { -// try { -// parent.start(); -// bundles.put(configurationId, parent); -// } catch (BundleException e) { -// log.info("failed to start bundle: " + parent, e); -// } -// } -// } catch (BundleException e) { -// log.info("failed to install bundle " + configurationId + ", message: " + e.getMessage()); -// } -// monitor.succeeded(configurationId); -// -// } // update the status of the loaded configurations Configuration configuration = load(configurationData, resolvedParents, actuallyLoaded); actuallyLoaded.put(configurationData.getId(), configuration); @@ -849,11 +830,11 @@ public class SimpleConfigurationManager return results; } - public synchronized LifecycleResults unloadConfiguration(Artifact id) throws NoSuchConfigException { + public synchronized LifecycleResults unloadConfiguration(Artifact id) throws NoSuchConfigException, LifecycleException { return unloadConfiguration(id, NullLifecycleMonitor.INSTANCE); } - public synchronized LifecycleResults unloadConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException { + public synchronized LifecycleResults unloadConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException { if (!id.isResolved()) { throw new IllegalArgumentException("Artifact " + id + " is not fully resolved"); } @@ -885,6 +866,21 @@ public class SimpleConfigurationManager // clean up the model removeConfigurationFromModel(configurationId); + + try { + Bundle bundle = bundles.remove(configurationId); + if (bundle != null) { + if (BundleUtils.canStop(bundle)) { + bundle.stop(Bundle.STOP_TRANSIENT); + } + if (BundleUtils.canUninstall(bundle)) { + bundle.uninstall(); + } + } + } catch (BundleException e) { + monitor.finished(); + throw new LifecycleException("unload", configurationId, e); + } } monitor.finished(); return results; @@ -1389,7 +1385,7 @@ public class SimpleConfigurationManager return configuration.getDependencyNode().getParents(); } - public synchronized void uninstallConfiguration(Artifact configurationId) throws IOException, NoSuchConfigException { + public synchronized void uninstallConfiguration(Artifact configurationId) throws IOException, NoSuchConfigException, LifecycleException { if (!configurationId.isResolved()) { throw new IllegalArgumentException("Artifact " + configurationId + " is not fully resolved"); } @@ -1403,6 +1399,7 @@ public class SimpleConfigurationManager } uninstall(configurationId); + for (ConfigurationStore store : getStoreList()) { if (store.containsConfiguration(configurationId)) { store.uninstall(configurationId); Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java?rev=933452&r1=933451&r2=933452&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java Tue Apr 13 00:53:02 2010 @@ -37,22 +37,30 @@ import org.osgi.service.packageadmin.Pac * @version $Rev$ $Date$ */ public class BundleUtils { - + public static boolean canStart(Bundle bundle) { - return (bundle.getState() != Bundle.STARTING) && (!isFragment(bundle)); + return (bundle.getState() != Bundle.UNINSTALLED) && (bundle.getState() != Bundle.STARTING) && (!isFragment(bundle)); + } + + public static boolean canStop(Bundle bundle) { + return (bundle.getState() != Bundle.UNINSTALLED) && (bundle.getState() != Bundle.STOPPING) && (!isFragment(bundle)); } - + + public static boolean canUninstall(Bundle bundle) { + return bundle.getState() != Bundle.UNINSTALLED; + } + public static boolean isFragment(Bundle bundle) { Dictionary headers = bundle.getHeaders(); return (headers != null && headers.get(Constants.FRAGMENT_HOST) != null); } - + /** * Returns bundle (if any) associated with current thread's context classloader. - * - * @param unwrap if true and if the bundle associated with the context classloader is a - * {@link DelegatingBundle}, this function will return the main application bundle - * backing with the {@link DelegatingBundle}. Otherwise, the bundle associated with + * + * @param unwrap if true and if the bundle associated with the context classloader is a + * {@link DelegatingBundle}, this function will return the main application bundle + * backing with the {@link DelegatingBundle}. Otherwise, the bundle associated with * the context classloader is returned as is. See {@link BundleClassLoader#getBundle(boolean)} * for more information. * @return The bundle associated with the current thread's context classloader. Might be null. @@ -60,18 +68,18 @@ public class BundleUtils { public static Bundle getContextBundle(boolean unwrap) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader instanceof BundleClassLoader) { - return ((BundleClassLoader) classLoader).getBundle(unwrap); + return ((BundleClassLoader) classLoader).getBundle(unwrap); } else if (classLoader instanceof BundleReference) { return ((BundleReference) classLoader).getBundle(); } else { return null; } } - + /** * Works like {@link Bundle#getEntryPaths(String)} but also returns paths * in attached fragment bundles. - * + * * @param bundle * @param name * @return @@ -92,11 +100,11 @@ public class BundleUtils { } return Collections.enumeration(paths); } - + /** * Works like {@link Bundle#getEntry(String)} but also checks * attached fragment bundles for the given entry. - * + * * @param bundle * @param name * @return @@ -105,7 +113,7 @@ public class BundleUtils { if (name.equals("/")) { return bundle.getEntry(name); } else if (name.endsWith("/")) { - name = name.substring(0, name.length() - 1); + name = name.substring(0, name.length() - 1); } String path; String pattern; @@ -127,20 +135,19 @@ public class BundleUtils { return null; } } - + public static LinkedHashSet getWiredBundles(Bundle bundle) { ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName()); - PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference); + PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference); try { return getWiredBundles(packageAdmin, bundle); } finally { bundle.getBundleContext().ungetService(reference); } } - + public static LinkedHashSet getWiredBundles(PackageAdmin packageAdmin, Bundle bundle) { BundleDescription description = new BundleDescription(bundle.getHeaders()); - // handle static wire via Import-Package List imports = description.getExternalImports(); LinkedHashSet wiredBundles = new LinkedHashSet(); @@ -151,23 +158,21 @@ public class BundleUtils { wiredBundles.add(wiredBundle); } } - // handle dynamic wire via DynamicImport-Package if (!description.getDynamicImportPackage().isEmpty()) { for (Bundle b : bundle.getBundleContext().getBundles()) { if (!wiredBundles.contains(b)) { ExportedPackage[] exports = packageAdmin.getExportedPackages(b); - Bundle wiredBundle = getWiredBundle(bundle, exports); + Bundle wiredBundle = getWiredBundle(bundle, exports); if (wiredBundle != null) { wiredBundles.add(wiredBundle); } } } } - return wiredBundles; } - + private static Bundle getWiredBundle(Bundle bundle, ExportedPackage[] exports) { if (exports != null) { for (ExportedPackage exportedPackage : exports) { @@ -183,5 +188,4 @@ public class BundleUtils { } return null; } - } Modified: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java?rev=933452&r1=933451&r2=933452&view=diff ============================================================================== --- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java (original) +++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java Tue Apr 13 00:53:02 2010 @@ -39,6 +39,7 @@ import org.apache.geronimo.gbean.annotat import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; import org.apache.geronimo.kernel.config.ConfigurationManager; import org.apache.geronimo.kernel.config.NoSuchConfigException; +import org.apache.geronimo.kernel.config.LifecycleException; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.persistence.PersistenceUnitGBean; import org.apache.geronimo.system.plugin.DownloadResults; @@ -248,6 +249,8 @@ public class FarmGBean implements NodeLi downloadResults.setFailure(e); } catch (NoSuchConfigException e) { downloadResults.setFailure(e); + } catch (LifecycleException e) { + downloadResults.setFailure(e); } return downloadResults; } Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java?rev=933452&r1=933451&r2=933452&view=diff ============================================================================== --- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java (original) +++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java Tue Apr 13 00:53:02 2010 @@ -64,7 +64,7 @@ import org.slf4j.LoggerFactory; public class ConfigManagerPortlet extends BasePortlet { private static final Logger logger = LoggerFactory.getLogger(ConfigManagerPortlet.class); - + private static final String START_ACTION = "start"; private static final String STOP_ACTION = "stop"; @@ -76,7 +76,7 @@ public class ConfigManagerPortlet extend private static final String CONFIG_INIT_PARAM = "config-type"; private static final String SHOW_DEPENDENCIES_COOKIE = "org.apache.geronimo.configmanager.showDependencies"; - + private Kernel kernel; private PortletRequestDispatcher normalView; @@ -84,9 +84,9 @@ public class ConfigManagerPortlet extend private PortletRequestDispatcher maximizedView; private PortletRequestDispatcher helpView; - + private boolean showDisplayName; - + private String moduleType; private static List loadChildren(Kernel kernel, String configName) { @@ -203,14 +203,14 @@ public class ConfigManagerPortlet extend if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) { return; } - + String cookies = renderRequest.getProperty("cookie"); - boolean showDependencies = (cookies != null && cookies.indexOf(SHOW_DEPENDENCIES_COOKIE + "=true") > 0); - + boolean showDependencies = (cookies != null && cookies.indexOf(SHOW_DEPENDENCIES_COOKIE + "=true") > 0); + List moduleDetails = new ArrayList(); ConfigurationManager configManager = PortletManager.getConfigurationManager(); List infos = configManager.listConfigurations(); - for (ConfigurationInfo info : infos) { + for (ConfigurationInfo info : infos) { if (ConfigurationModuleType.WAR.getName().equalsIgnoreCase(moduleType)) { if (info.getType().getValue() == ConfigurationModuleType.WAR.getValue()) { @@ -219,7 +219,7 @@ public class ConfigManagerPortlet extend AbstractName configObjName = Configuration.getConfigurationAbstractName(info.getConfigID()); boolean loaded = loadModule(configManager, configObjName); - WebModule webModule = (WebModule) PortletManager.getModule(renderRequest, info.getConfigID()); + WebModule webModule = (WebModule) PortletManager.getModule(renderRequest, info.getConfigID()); if (webModule != null) { details.getContextPaths().add(webModule.getContextPath()); @@ -229,7 +229,7 @@ public class ConfigManagerPortlet extend if (showDependencies) { addDependencies(details, configObjName); } - + if (loaded) { unloadModule(configManager, configObjName); } @@ -249,7 +249,7 @@ public class ConfigManagerPortlet extend if (child.getModuleType().getValue() == ConfigurationModuleType.WAR.getValue()) { ModuleDetails childDetails = new ModuleDetails(info.getConfigID(), child.getModuleType(), info.getState()); childDetails.setComponentName(child.getId().toString()); - WebModule webModule = getWebModule(config, child); + WebModule webModule = getWebModule(config, child); if (webModule != null) { childDetails.getContextPaths().add(webModule.getContextPath()); childDetails.setDisplayName(webModule.getDisplayName()); @@ -289,7 +289,7 @@ public class ConfigManagerPortlet extend details.getContextPaths().add(webModule.getContextPath()); } } - } + } } } else if (info.getType().equals(ConfigurationModuleType.CAR)) { Configuration config = configManager.getConfiguration(info.getConfigID()); @@ -357,12 +357,12 @@ public class ConfigManagerPortlet extend AbstractName childName = new AbstractName(config.getAbstractName().getArtifact(), query1); return (WebModule)kernel.getGBean(childName); } catch(Exception h){ - // No gbean found, will not happen + // No gbean found, will not happen // Except if module not started, ignored } return null; } - + private boolean loadModule(ConfigurationManager configManager, AbstractName configObjName) { if(!kernel.isLoaded(configObjName)) { try { @@ -384,7 +384,7 @@ public class ConfigManagerPortlet extend } return false; } - + private void addDependencies(ModuleDetails details, AbstractName configObjName) { DependencyManager depMgr = kernel.getDependencyManager(); Set parents = depMgr.getParents(configObjName); @@ -401,21 +401,22 @@ public class ConfigManagerPortlet extend Collections.sort(details.getParents()); Collections.sort(details.getChildren()); } - + private void unloadModule(ConfigurationManager configManager, AbstractName configObjName) { try { configManager.unloadConfiguration(configObjName.getArtifact()); } catch (NoSuchConfigException e) { - // Should not occur - e.printStackTrace(); - } + logger.error("Fail to unload module " + configObjName, e); + } catch (LifecycleException e) { + logger.error("Fail to unload module " + configObjName, e); + } } - - private boolean showWebInfo() { + + private boolean showWebInfo() { return ConfigurationModuleType.WAR.getName().equalsIgnoreCase(moduleType) || ConfigurationModuleType.EAR.getName().equalsIgnoreCase(moduleType); - } - + } + protected void doHelp(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { helpView.include(renderRequest, renderResponse); } @@ -496,27 +497,27 @@ public class ConfigManagerPortlet extend public List getChildren() { return children; } - + public List getContextPaths() { return contextPaths; - } - + } + public String getComponentName(){ return componentName; } - + public void setComponentName(String name){ componentName = name; - } - + } + public String getDisplayName(){ return displayName; } - + public void setDisplayName(String name){ displayName = name; } - + public void setClientAppServerSide(boolean clientAppServerSide) { this.clientAppServerSide = clientAppServerSide; } Modified: geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java?rev=933452&r1=933451&r2=933452&view=diff ============================================================================== --- geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java (original) +++ geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java Tue Apr 13 00:53:02 2010 @@ -43,6 +43,7 @@ import org.apache.geronimo.kernel.Naming import org.apache.geronimo.kernel.config.ConfigurationData; import org.apache.geronimo.kernel.config.ConfigurationManager; import org.apache.geronimo.kernel.config.ConfigurationUtil; +import org.apache.geronimo.kernel.config.LifecycleException; import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.repository.Artifact; import org.osgi.framework.Bundle; @@ -52,7 +53,7 @@ import org.slf4j.LoggerFactory; /** * An instance of a WAB deployed to an available Web Container * instance. - * + * * @version $Rev$, $Date$ */ public class WebApplication implements Runnable { @@ -64,12 +65,12 @@ public class WebApplication implements R private final Bundle bundle; // the deployed context path from the bundle headers private final String contextPath; - + private final AtomicBoolean scheduled = new AtomicBoolean(); private final AtomicBoolean running = new AtomicBoolean(); - + private boolean destroyed; - + private Artifact deployedArtifact; /** @@ -83,13 +84,13 @@ public class WebApplication implements R public WebApplication(WebContainerExtender extender, Bundle bundle, String contextPath) { this.extender = extender; this.bundle = bundle; - this.contextPath = contextPath; + this.contextPath = contextPath; } public String getContextPath() { - return contextPath; + return contextPath; } - + /** * Provide access to the bundle where the application resides. * @@ -146,7 +147,7 @@ public class WebApplication implements R private void failed(Throwable cause) { extender.getEventDispatcher().failed(bundle, contextPath, cause); } - + /** * This method must be called inside a synchronized block to ensure this method is not run concurrently */ @@ -158,13 +159,13 @@ public class WebApplication implements R try { // send out a broadcast alert that we're going to do this deploying(); - + ConfigurationManager configurationManager = extender.getConfigurationManager(); - + File configSer = bundle.getBundleContext().getDataFile("config.ser"); if (configSer.exists() && configSer.lastModified() == bundle.getLastModified()) { LOGGER.info("Redeploying WAB {} at {}", new Object[] {bundle, contextPath}); - + FileInputStream in = new FileInputStream(configSer); try { configurationData = ConfigurationUtil.readConfigurationData(in); @@ -173,17 +174,17 @@ public class WebApplication implements R } } else { LOGGER.info("Deploying WAB {} at {}", new Object[] {bundle, contextPath}); - + ModuleIDBuilder idBuilder = new ModuleIDBuilder(); Kernel kernel = extender.getKernel(); Naming naming = kernel.getNaming(); - ModuleBuilder webModuleBuilder = extender.getWebModuleBuilder(); + ModuleBuilder webModuleBuilder = extender.getWebModuleBuilder(); if (webModuleBuilder == null) { throw new DeploymentException("Unable to deploy " + bundle + " WAB. No web module builders found."); } WebModule webModule = (WebModule) webModuleBuilder.createModule(bundle, naming, idBuilder); - BundleDeploymentContext deploymentContext = + BundleDeploymentContext deploymentContext = new BundleDeploymentContext( webModule.getEnvironment(), webModule.getType(), @@ -204,11 +205,11 @@ public class WebApplication implements R deploymentContext.initializeConfiguration(); webModuleBuilder.initContext(deploymentContext, webModule, bundle); - + AbstractName appJndiName = naming.createChildName(deploymentContext.getModuleName(), "ApplicationJndi", "ApplicationJndi"); deploymentContext.getGeneralData().put(EARContext.APPLICATION_JNDI_NAME_KEY, appJndiName); - - webModuleBuilder.addGBeans(deploymentContext, webModule, bundle, extender.getRepositories()); + + webModuleBuilder.addGBeans(deploymentContext, webModule, bundle, extender.getRepositories()); Map> contexts = NamingBuilder.JNDI_KEY.get(deploymentContext.getGeneralData()); GBeanData appContexts = new GBeanData(appJndiName, ApplicationJndi.class); @@ -216,7 +217,7 @@ public class WebApplication implements R appContexts.setAttribute("applicationContextMap", contexts.get(JndiScope.application)); appContexts.setReferencePattern("GlobalContext", extender.getGlobalContextAbstractName()); deploymentContext.addGBean(appContexts); - + configurationData = deploymentContext.getConfigurationData(); FileOutputStream out = new FileOutputStream(configSer); try { @@ -230,17 +231,17 @@ public class WebApplication implements R // set config.ser last modified time to be of the bundle configSer.setLastModified(bundle.getLastModified()); } - - configurationData.setUseEnvironment(true); + + configurationData.setUseEnvironment(true); configurationData.setBundleContext(bundle.getBundleContext()); - + configurationManager.loadConfiguration(configurationData); configurationManager.startConfiguration(configurationData.getId()); deployedArtifact = configurationData.getId(); - + LOGGER.info("Deployed WAB {} at {}", new Object[] {bundle, contextPath}); - + // send out the deployed event deployed(); } catch (Throwable exception) { @@ -255,7 +256,7 @@ public class WebApplication implements R extender.unregisterWebApplication(this); } } - + private void undeploy(Artifact artifact) { ConfigurationManager configurationManager = extender.getConfigurationManager(); try { @@ -264,15 +265,16 @@ public class WebApplication implements R e.printStackTrace(); } catch (NoSuchConfigException e) { // ignore + } catch (LifecycleException e) { } } - + /** * Undeploy a web application. */ public void undeploy() { destroyed = true; - + synchronized (running) { while (running.get()) { try { @@ -282,21 +284,21 @@ public class WebApplication implements R } } } - + // send the undeploying event undeploying(); - + if (deployedArtifact != null) { LOGGER.info("Undeploying WAB {} at {}", new Object[] {bundle, contextPath}); undeploy(deployedArtifact); LOGGER.info("Undeployed WAB {} at {}", new Object[] {bundle, contextPath}); } - + // finished with the undeploy operation undeployed(); - + // unregister the application and possibly let other WABs with the same ContextPath to deploy - extender.unregisterWebApplication(this); + extender.unregisterWebApplication(this); } }