You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/07/22 19:23:54 UTC
svn commit: r678811 - in /cxf/branches/2.0.x-fixes: ./
rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
Author: dkulp
Date: Tue Jul 22 10:23:54 2008
New Revision: 678811
URL: http://svn.apache.org/viewvc?rev=678811&view=rev
Log:
Merged revisions 678808 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r678808 | dkulp | 2008-07-22 13:16:49 -0400 (Tue, 22 Jul 2008) | 3 lines
[CXF-1709] Detect the application context refresh and make sure we update the bus and servlet controller.
........
Modified:
cxf/branches/2.0.x-fixes/ (props changed)
cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 22 10:23:54 2008
@@ -1 +1 @@
-/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629
+/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808
Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java?rev=678811&r1=678810&r2=678811&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java (original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java Tue Jul 22 10:23:54 2008
@@ -110,7 +110,7 @@
bus.getExtension(DestinationFactoryManager.class).registerDestinationFactory(namespace, factory);
}
- protected void replaceDestinationFactory() throws ServletException {
+ protected void replaceDestinationFactory() {
DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
try {
Modified: cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java?rev=678811&r1=678810&r2=678811&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java (original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java Tue Jul 22 10:23:54 2008
@@ -37,6 +37,10 @@
import org.apache.cxf.resource.URIResolver;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.InputStreamResource;
@@ -48,9 +52,11 @@
* to the {@link ServletController}.
*
*/
-public class CXFServlet extends AbstractCXFServlet {
+public class CXFServlet extends AbstractCXFServlet implements ApplicationListener {
private GenericApplicationContext childCtx;
+ private boolean inRefresh;
+
public static Logger getLogger() {
return LogUtils.getL7dLogger(CXFServlet.class);
@@ -91,7 +97,14 @@
}
}
- // This constructor works whether there is a context or not
+ updateContext(servletConfig, ctx);
+
+ if (ctx instanceof ConfigurableApplicationContext) {
+ ((ConfigurableApplicationContext)ctx).addApplicationListener(this);
+ }
+ }
+ private void updateContext(ServletConfig servletConfig, ApplicationContext ctx) {
+ // This constructor works whether there is a context or not
// If the ctx is null, we just start up the default bus
if (ctx == null) {
LOG.info("LOAD_BUS_WITHOUT_APPLICATION_CONTEXT");
@@ -99,7 +112,8 @@
} else {
LOG.info("LOAD_BUS_WITH_APPLICATION_CONTEXT");
bus = new SpringBusFactory(ctx).createBus();
- }
+ }
+
ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
resourceManager.addResourceResolver(new ServletContextResourceResolver(
servletConfig.getServletContext()));
@@ -114,7 +128,7 @@
}
private void loadAdditionalConfig(ApplicationContext ctx,
- ServletConfig servletConfig) throws ServletException {
+ ServletConfig servletConfig) {
String location = servletConfig.getInitParameter("config-location");
if (location == null) {
location = "/WEB-INF/cxf-servlet.xml";
@@ -153,5 +167,18 @@
super.destroy();
}
+ public void onApplicationEvent(ApplicationEvent event) {
+ if (!inRefresh && event instanceof ContextRefreshedEvent) {
+ //need to re-do the bus/controller stuff
+ try {
+ inRefresh = true;
+ updateContext(this.getServletConfig(),
+ ((ContextRefreshedEvent)event).getApplicationContext());
+ } finally {
+ inRefresh = false;
+ }
+ }
+ }
+
}