[jbossws-commits] JBossWS SVN: r13370 - stack/cxf/branches/jbossws-cxf-3.1.2/modules/server/src/main/java/org/jboss/wsf/stack/cxf.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Wed Dec 1 11:07:45 EST 2010
Author: darran.lofthouse at jboss.com
Date: 2010-12-01 11:07:44 -0500 (Wed, 01 Dec 2010)
New Revision: 13370
Modified:
stack/cxf/branches/jbossws-cxf-3.1.2/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
Log:
[JBPAPP-5488] CXF integration initialises endpoints multiple times.
Modified: stack/cxf/branches/jbossws-cxf-3.1.2/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-3.1.2/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2010-11-30 17:27:30 UTC (rev 13369)
+++ stack/cxf/branches/jbossws-cxf-3.1.2/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2010-12-01 16:07:44 UTC (rev 13370)
@@ -67,6 +67,10 @@
{
public static final String PARAM_CXF_BEANS_URL = "jbossws.cxf.beans.url";
+ private static final String CHILD_CONTEXT_ATTRIBUTE = "jbossws.cxf.childCtx";
+ private static final String BUS_ATTRIBUTE = "jbossws.cxf.bus";
+ private static final String CONTROLLER_ATTRIBUTE = "jbossws.cxf.controller";
+
private static Logger log = Logger.getLogger(CXFServletExt.class);
protected Endpoint endpoint;
@@ -78,7 +82,7 @@
{
super.init(servletConfig);
}
-
+
@Override
public ServletController createServletController(ServletConfig servletConfig)
{
@@ -89,24 +93,44 @@
@Override
public void loadBus(ServletConfig servletConfig) throws ServletException
{
- super.loadBus(servletConfig);
-
ServletContext svCtx = getServletContext();
- ApplicationContext appCtx = (ApplicationContext)svCtx.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
+ synchronized (svCtx)
+ {
+ Bus bus = (Bus)svCtx.getAttribute(BUS_ATTRIBUTE);
+ if (bus != null)
+ {
+ this.bus = bus;
+ controller = (ServletController)svCtx.getAttribute(CONTROLLER_ATTRIBUTE);
+ }
+ else
+ {
+ super.loadBus(servletConfig);
+ bus = getBus();
+ svCtx.setAttribute(BUS_ATTRIBUTE, bus);
+ svCtx.setAttribute(CONTROLLER_ATTRIBUTE, getController());
+ svCtx.setAttribute(ServletController.class.getName(), getController());
+ }
- Bus bus = getBus();
- //Install our SoapTransportFactory to allow for proper soap address rewrite
- DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
- SoapTransportFactory factory = new SoapTransportFactoryExt();
- factory.setBus(bus);
- dfm.registerDestinationFactory(Constants.NS_SOAP11, factory);
- dfm.registerDestinationFactory(Constants.NS_SOAP12, factory);
+ ApplicationContext appCtx = (ApplicationContext)svCtx.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
- //Init the Endpoint
- initEndpoint(servletConfig);
-
- //Load additional configurations
- loadAdditionalConfigExt(appCtx, servletConfig);
+ //Install our SoapTransportFactory to allow for proper soap address rewrite
+ DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+ SoapTransportFactory factory = new SoapTransportFactoryExt();
+ factory.setBus(bus);
+ dfm.registerDestinationFactory(Constants.NS_SOAP11, factory);
+ dfm.registerDestinationFactory(Constants.NS_SOAP12, factory);
+
+ //Init the Endpoint
+ initEndpoint(servletConfig);
+
+ childCtx = (GenericApplicationContext)svCtx.getAttribute(CHILD_CONTEXT_ATTRIBUTE);
+ if (childCtx == null)
+ {
+ //Load additional configurations
+ loadAdditionalConfigExt(appCtx, servletConfig);
+ svCtx.setAttribute(CHILD_CONTEXT_ATTRIBUTE, childCtx);
+ }
+ }
}
private void initEndpoint(ServletConfig servletConfig)
@@ -117,15 +141,13 @@
ServletContext context = servletConfig.getServletContext();
String contextPath = context.getContextPath();
endpoint = initServiceEndpoint(contextPath);
-
+
//Install the JBossWS resource resolver
ResourceResolver resourceResolver = endpoint.getAttachment(ResourceResolver.class);
if (resourceResolver != null)
{
bus.getExtension(ResourceManager.class).addResourceResolver(resourceResolver);
}
-
- context.setAttribute(ServletController.class.getName(), getController());
}
private void loadAdditionalConfigExt(ApplicationContext ctx, ServletConfig servletConfig) throws ServletException
@@ -151,7 +173,7 @@
childCtx.refresh();
}
}
-
+
@Override
protected void invoke(HttpServletRequest req, HttpServletResponse res) throws ServletException
{
@@ -177,7 +199,10 @@
public void destroy()
{
if (childCtx != null)
+ {
childCtx.destroy();
+ childCtx = null;
+ }
super.destroy();
}
More information about the jbossws-commits
mailing list