From 6aeb3566cde641802342a196fab4e339451eb9b1 Mon Sep 17 00:00:00 2001 From: slaws Date: Sat, 18 Jul 2009 13:32:22 +0000 Subject: TUSCANY-3149 - Generally be more careful about removing object references in host-webapp. Specifically there is a problem with the axis ws binding (JIRA 3732 in the Axis project) where a shutdown hook is registered but not removed. This is fixed in Axis2 1.5 but as we are still in 1.4.1 I've worked round it here. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@795364 13f79535-47bb-0310-9956-ffa450edef68 --- .../ws/axis2/Axis2BindingProviderFactory.java | 14 ++- .../sca/binding/ws/axis2/Axis2ServiceProvider.java | 2 + .../sca/binding/ws/axis2/Axis2ServiceServlet.java | 65 ++++++++++++- .../binding/ws/axis2/TuscanyListenerManager.java | 107 +++++++++++++++++++++ .../sca/host/embedded/impl/DefaultSCADomain.java | 7 +- .../sca/host/webapp/TuscanyServletFilter.java | 1 + .../sca/host/webapp/WebAppModuleActivator.java | 6 ++ .../tuscany/sca/host/webapp/WebAppServletHost.java | 17 +++- 8 files changed, 210 insertions(+), 9 deletions(-) create mode 100644 branches/sca-java-1.x/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java (limited to 'branches') diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java index e6ca8e20a8..b1923bdf3c 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java @@ -46,17 +46,15 @@ import org.apache.tuscany.sca.work.WorkScheduler; public class Axis2BindingProviderFactory implements BindingProviderFactory { private ModelFactoryExtensionPoint modelFactories; - private ServletHost servletHost; + private List hosts; private List policyHandlerClassnames = null; private DataBindingExtensionPoint dataBindings; private WorkScheduler workScheduler; public Axis2BindingProviderFactory(ExtensionPointRegistry extensionPoints) { ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); - List hosts = servletHosts.getServletHosts(); - if (!hosts.isEmpty()) { - this.servletHost = hosts.get(0); - } + hosts = servletHosts.getServletHosts(); + modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); policyHandlerClassnames = PolicyHandlerDefinitionsLoader.loadPolicyHandlerClassnames(); dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class); @@ -74,6 +72,12 @@ public class Axis2BindingProviderFactory implements BindingProviderFactory hosts = servletHosts.getServletHosts(); + hosts.clear(); } /** diff --git a/branches/sca-java-1.x/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java b/branches/sca-java-1.x/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java index 26114ab8b2..045cae4e75 100644 --- a/branches/sca-java-1.x/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java +++ b/branches/sca-java-1.x/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java @@ -19,7 +19,9 @@ package org.apache.tuscany.sca.host.webapp; +import java.beans.Introspector; import java.io.File; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.MalformedURLException; @@ -28,6 +30,7 @@ import java.net.URL; import java.net.UnknownHostException; import java.util.Collections; import java.util.HashMap; +import java.util.IdentityHashMap; import java.util.Map; import java.util.logging.Logger; @@ -39,6 +42,7 @@ import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import org.apache.commons.logging.LogFactory; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.apache.tuscany.sca.host.http.SecurityContext; import org.apache.tuscany.sca.host.http.ServletHost; @@ -57,7 +61,7 @@ public class WebAppServletHost implements ServletHost { public static final String SCA_DOMAIN_ATTRIBUTE = "org.apache.tuscany.sca.SCADomain"; - private static final WebAppServletHost instance = new WebAppServletHost(); + private static WebAppServletHost instance = null; private Map servlets; private SCADomain scaDomain; @@ -210,6 +214,9 @@ public class WebAppServletHost implements ServletHost { } public static WebAppServletHost getInstance() { + if (instance == null){ + instance = new WebAppServletHost(); + } return instance; } @@ -309,7 +316,15 @@ public class WebAppServletHost implements ServletHost { if (scaDomain instanceof WebSCADomain) { ((WebSCADomain)scaDomain).destroy(); } + servletContext.setAttribute(SCA_DOMAIN_ATTRIBUTE, null); + scaDomain = null; } + + servletContext = null; + instance = null; + servlets.clear(); + LogFactory.release(this.getClass().getClassLoader()); + Introspector.flushCaches(); } public String getContextPath() { -- cgit v1.2.3