cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1244652 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/bus/spring/ systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/
Date Wed, 15 Feb 2012 19:13:06 GMT
Author: dkulp
Date: Wed Feb 15 19:13:05 2012
New Revision: 1244652

URL: http://svn.apache.org/viewvc?rev=1244652&view=rev
Log:
[CXF-4094] Put a guard around the closing of the context.

Added:
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/basic.xml  
(with props)
Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java?rev=1244652&r1=1244651&r2=1244652&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java Wed Feb 15 19:13:05
2012
@@ -47,7 +47,7 @@ public class SpringBus extends Extension
     implements ApplicationContextAware, ApplicationListener<ApplicationEvent> {
 
     AbstractApplicationContext ctx;
-
+    boolean closeContext;
     
     public SpringBus() {
     }
@@ -115,7 +115,6 @@ public class SpringBus extends Extension
             }
             ac = ac.getParent();
         }
-        
         if (doIt) {
             if (event instanceof ContextRefreshedEvent) {
                 if (getState() != BusState.RUNNING) {
@@ -128,7 +127,9 @@ public class SpringBus extends Extension
     }
     
     public void destroyBeans() {
-        ctx.close();
+        if (closeContext) {
+            ctx.close();
+        }
         super.destroyBeans();
     }
     
@@ -148,4 +149,8 @@ public class SpringBus extends Extension
         return id;
     }
 
+    public void setCloseContext(boolean b) {
+        closeContext = b;
+    }
+
 }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java?rev=1244652&r1=1244651&r2=1244652&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java Wed Feb
15 19:13:05 2012
@@ -83,6 +83,10 @@ public class SpringBusFactory extends Bu
         initializeBus(bus);        
         
         registerApplicationContextLifeCycleListener(bus, bac);
+        
+        if (bus instanceof SpringBus && defaultBusNotExists()) {
+            ((SpringBus)bus).setCloseContext(true);
+        }
         return bus;
     }
     

Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java?rev=1244652&r1=1244651&r2=1244652&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
Wed Feb 15 19:13:05 2012
@@ -64,6 +64,19 @@ public class SpringBusFactoryTest extend
         checkBindingExtensions(bus);
         checkHTTPTransportFactories(bus);
         checkOtherCoreExtensions(bus);
+        ctx.destroy();
+    }
+    @Test
+    public void testLoadBusWithApplicationContext() throws BusException {
+        ClassPathXmlApplicationContext ctx = 
+            new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/systest/bus/basic.xml"});
+        Bus bus = ctx.getBean("cxf", Bus.class);
+        ctx.refresh();
+        bus = ctx.getBean("cxf", Bus.class);
+        checkBindingExtensions(bus);
+        checkHTTPTransportFactories(bus);
+        checkOtherCoreExtensions(bus);
+        ctx.destroy();
     }
     
     private void checkBindingExtensions(Bus bus) throws BusException {

Added: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/basic.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/basic.xml?rev=1244652&view=auto
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/basic.xml (added)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/basic.xml Wed
Feb 15 19:13:05 2012
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns:jaxws="http://cxf.apache.org/jaxws"
+      xmlns:cxf="http://cxf.apache.org/core"
+      xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
+
+  <import resource="classpath*:META-INF/cxf/cxf.xml"/>
+
+
+   <cxf:bus>
+   </cxf:bus>  
+</beans>
\ No newline at end of file

Propchange: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/basic.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/basic.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/basic.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message