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/11/07 22:27:54 UTC
svn commit: r712272 - in /cxf/trunk: api/src/main/java/org/apache/cxf/
rt/core/src/main/java/org/apache/cxf/bus/
rt/core/src/main/java/org/apache/cxf/bus/spring/
rt/core/src/main/java/org/apache/cxf/buslifecycle/
rt/core/src/main/resources/META-INF/cxf...
Author: dkulp
Date: Fri Nov 7 13:27:54 2008
New Revision: 712272
URL: http://svn.apache.org/viewvc?rev=712272&view=rev
Log:
For spring applications and such, make sure the bus lifecycle listeners are called.
Added:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java (with props)
cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java (contents, props changed)
- copied, changed from r712024, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/TestCrossSchemaImports.java
cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java (with props)
Removed:
cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/TestCrossSchemaImports.java
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManager.java
cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
cxf/trunk/systests/src/test/resources/crossSchemaBeans.xml
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java?rev=712272&r1=712271&r2=712272&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java Fri Nov 7 13:27:54 2008
@@ -25,7 +25,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.apache.cxf.buslifecycle.BusLifeCycleManager;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.logging.LogUtils;
@@ -173,10 +172,6 @@
}
protected void initializeBus(Bus bus) {
- BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
- if (null != lifeCycleManager) {
- lifeCycleManager.initComplete();
- }
}
private static String getBusFactoryClass(ClassLoader classLoader) {
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java?rev=712272&r1=712271&r2=712272&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java Fri Nov 7 13:27:54 2008
@@ -25,6 +25,7 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
public class CXFBusFactory extends BusFactory {
@@ -43,4 +44,12 @@
return bus;
}
+
+ protected void initializeBus(Bus bus) {
+ super.initializeBus(bus);
+ BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+ if (null != lifeCycleManager) {
+ lifeCycleManager.initComplete();
+ }
+ }
}
Added: 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=712272&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java (added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java Fri Nov 7 13:27:54 2008
@@ -0,0 +1,67 @@
+/**
+ * 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.bus.CXFBusImpl;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.support.AbstractApplicationContext;
+
+/**
+ *
+ */
+public class BusApplicationListener implements ApplicationListener, ApplicationContextAware {
+ AbstractApplicationContext ctx;
+
+ /** {@inheritDoc}*/
+ public void onApplicationEvent(ApplicationEvent event) {
+ if (ctx == null) {
+ return;
+ }
+ if (event instanceof ContextRefreshedEvent) {
+ Bus bus = (Bus)ctx.getBean("cxf");
+ ((CXFBusImpl)bus).initialize();
+ BusLifeCycleManager lcm = (BusLifeCycleManager)
+ ctx.getBean("org.apache.cxf.buslifecycle.BusLifeCycleManager",
+ BusLifeCycleManager.class);
+ lcm.initComplete();
+ } else if (event instanceof ContextClosedEvent) {
+ BusLifeCycleManager lcm = (BusLifeCycleManager)
+ ctx.getBean("org.apache.cxf.buslifecycle.BusLifeCycleManager",
+ BusLifeCycleManager.class);
+ lcm.postShutdown();
+ }
+ }
+
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ if (applicationContext instanceof AbstractApplicationContext) {
+ ctx = (AbstractApplicationContext)applicationContext;
+ ctx.addApplicationListener(this);
+ }
+ }
+
+}
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
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=712272&r1=712271&r2=712272&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 Fri Nov 7 13:27:54 2008
@@ -25,7 +25,6 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
-import org.apache.cxf.bus.CXFBusImpl;
import org.apache.cxf.buslifecycle.BusLifeCycleListener;
import org.apache.cxf.buslifecycle.BusLifeCycleManager;
import org.apache.cxf.common.logging.LogUtils;
@@ -139,12 +138,6 @@
throw new RuntimeException(ex);
}
}
-
- @Override
- protected void initializeBus(Bus bus) {
- ((CXFBusImpl)bus).initialize();
- super.initializeBus(bus);
- }
void registerApplicationContextLifeCycleListener(Bus bus, BusApplicationContext bac) {
BusLifeCycleManager lm = bus.getExtension(BusLifeCycleManager.class);
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManager.java?rev=712272&r1=712271&r2=712272&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManager.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManager.java Fri Nov 7 13:27:54 2008
@@ -31,6 +31,8 @@
private final List<BusLifeCycleListener> listeners;
private Bus bus;
+ private boolean preShutdownCalled;
+ private boolean postShutdownCalled;
public CXFBusLifeCycleManager() {
listeners = new ArrayList<BusLifeCycleListener>();
@@ -66,6 +68,8 @@
}
public void initComplete() {
+ preShutdownCalled = false;
+ postShutdownCalled = false;
for (BusLifeCycleListener listener : listeners) {
listener.initComplete();
}
@@ -73,15 +77,22 @@
public void preShutdown() {
// TODO inverse order of registration?
+ preShutdownCalled = true;
for (BusLifeCycleListener listener : listeners) {
listener.preShutdown();
}
}
public void postShutdown() {
- // TODO inverse order of registration?
- for (BusLifeCycleListener listener : listeners) {
- listener.postShutdown();
+ if (!preShutdownCalled) {
+ preShutdown();
+ }
+ if (!postShutdownCalled) {
+ postShutdownCalled = true;
+ // TODO inverse order of registration?
+ for (BusLifeCycleListener listener : listeners) {
+ listener.postShutdown();
+ }
}
}
Modified: cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml?rev=712272&r1=712271&r2=712272&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml (original)
+++ cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml Fri Nov 7 13:27:54 2008
@@ -24,6 +24,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>
+ <bean id="foo" class="org.apache.cxf.bus.spring.BusApplicationListener"/>
<bean id="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor" class="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor"/>
<bean id="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor" class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"/>
<bean id="org.apache.cxf.bus.spring.BusExtensionPostProcessor" class="org.apache.cxf.bus.spring.BusExtensionPostProcessor"/>
Modified: cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java?rev=712272&r1=712271&r2=712272&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java (original)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java Fri Nov 7 13:27:54 2008
@@ -230,6 +230,9 @@
static class TestFeature extends AbstractFeature {
boolean initialised;
+ public TestFeature() {
+ //nothing
+ }
@Override
public void initialize(Bus bus) {
Copied: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java (from r712024, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/TestCrossSchemaImports.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java?p2=cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java&p1=cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/TestCrossSchemaImports.java&r1=712024&r2=712272&rev=712272&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/TestCrossSchemaImports.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java Fri Nov 7 13:27:54 2008
@@ -29,17 +29,18 @@
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
-public class TestCrossSchemaImports extends AbstractDependencyInjectionSpringContextTests {
+public class CrossSchemaImportsTests extends AbstractDependencyInjectionSpringContextTests {
private TestUtilities testUtilities;
- public TestCrossSchemaImports() {
+ public CrossSchemaImportsTests() {
setAutowireMode(AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_NAME);
testUtilities = new TestUtilities(getClass());
}
@Test
public void testJaxbCrossSchemaImport() throws Exception {
+ System.out.println("TEst");
testUtilities.setBus((Bus)applicationContext.getBean("cxf"));
testUtilities.addDefaultNamespaces();
Server s = testUtilities.getServerForService(new QName("http://apache.org/type_test/doc",
@@ -48,6 +49,8 @@
testUtilities.
assertValid("//xsd:schema[@targetNamespace='http://apache.org/type_test/doc']/"
+ "xsd:import[@namespace='http://apache.org/type_test/types1']", wsdl);
+
+ assertEquals(1, LifeCycleListenerTester.getInitCount());
}
/*
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java
------------------------------------------------------------------------------
svn:mergeinfo =
Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java?rev=712272&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java Fri Nov 7 13:27:54 2008
@@ -0,0 +1,61 @@
+/**
+ * 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.systest.wsdl;
+
+import javax.annotation.Resource;
+
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+
+/**
+ *
+ */
+public class LifeCycleListenerTester implements BusLifeCycleListener {
+
+ static int initCount;
+
+ public LifeCycleListenerTester() {
+ }
+
+ @Resource(name = "org.apache.cxf.buslifecycle.BusLifeCycleManager")
+ public void setBusLifeCycleManager(BusLifeCycleManager mgr) {
+ mgr.registerLifeCycleListener(this);
+ }
+
+ public static int getInitCount() {
+ return initCount;
+ }
+
+ /** {@inheritDoc}*/
+ public void initComplete() {
+ initCount++;
+ }
+
+ /** {@inheritDoc}*/
+ public void postShutdown() {
+
+ }
+
+ /** {@inheritDoc}*/
+ public void preShutdown() {
+
+ }
+
+}
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/systests/src/test/resources/crossSchemaBeans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/crossSchemaBeans.xml?rev=712272&r1=712271&r2=712272&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/resources/crossSchemaBeans.xml (original)
+++ cxf/trunk/systests/src/test/resources/crossSchemaBeans.xml Fri Nov 7 13:27:54 2008
@@ -34,6 +34,8 @@
<import resource="classpath:META-INF/cxf/cxf-extension-local.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+ <bean class="org.apache.cxf.systest.wsdl.LifeCycleListenerTester" id="listenerTest"/>
+
<!-- Services -->
<jaxws:server id="JaxbTestServer"
serviceClass="org.apache.type_test.doc.TypeTestPortType"