Author: ningjiang
Date: Wed Dec 22 08:45:42 2010
New Revision: 1051792
URL: http://svn.apache.org/viewvc?rev=1051792&view=rev
Log:
CXF-3213 BusApplicationListener should listen to the events of the
BusApplicationContext parent
Added:
cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
(with props)
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java?rev=1051792&r1=1051791&r2=1051792&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
Wed Dec 22 08:45:42 2010
@@ -49,6 +49,7 @@ public class BusApplicationListener impl
while (ac != null && !doIt) {
if (event.getSource() == ac) {
doIt = true;
+ break;
}
ac = ac.getParent();
}
@@ -74,6 +75,13 @@ public class BusApplicationListener impl
if (applicationContext instanceof AbstractApplicationContext) {
ctx = (AbstractApplicationContext)applicationContext;
ctx.addApplicationListener(this);
+ ApplicationContext ac = applicationContext.getParent();
+ while (ac != null) {
+ if (ac instanceof AbstractApplicationContext) {
+
((AbstractApplicationContext)ac).addApplicationListener(this);
+ }
+ ac = ac.getParent();
+ }
}
}
Added:
cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java?rev=1051792&view=auto
==============================================================================
---
cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
(added)
+++
cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
Wed Dec 22 08:45:42 2010
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.bus.spring;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.CXFBusLifeCycleManager;
+import org.easymock.classextension.EasyMock;
+import org.junit.Assert;
+import org.junit.Test;
+import
org.springframework.context.support.AbstractRefreshableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+
+public class BusApplicationListenerTest extends Assert {
+
+ @Test
+ public void testParentApplicationEvent() {
+ AbstractRefreshableApplicationContext parent = new
ClassPathXmlApplicationContext();
+ parent.refresh();
+ SpringBusFactory factory = new SpringBusFactory(parent);
+ Bus bus = factory.createBus();
+ CXFBusLifeCycleManager manager =
bus.getExtension(CXFBusLifeCycleManager.class);
+ BusLifeCycleListener listener =
EasyMock.createMock(BusLifeCycleListener.class);
+ manager.registerLifeCycleListener(listener);
+ EasyMock.reset(listener);
+ listener.preShutdown();
+ EasyMock.expectLastCall().times(1);
+ listener.postShutdown();
+ EasyMock.expectLastCall().times(1);
+ EasyMock.replay(listener);
+ parent.close();
+ EasyMock.verify(listener);
+ }
+
+}
Propchange:
cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date