cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r561807 - in /incubator/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/resources/META-INF/cxf/ rt/core/src/test/java/org/apache/cxf/bu...
Date Wed, 01 Aug 2007 14:14:07 GMT
Author: andreasmyth
Date: Wed Aug  1 07:14:06 2007
New Revision: 561807

URL: http://svn.apache.org/viewvc?view=rev&rev=561807
Log:
Ensure that BusLifeCycleListener's initComplete methods are called (this is currently not
the case)
Apply features to the bus only after bus construction is complete (i.e. after the application
context has been created).

Added:
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/init.xml   (with props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
    incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java?view=diff&rev=561807&r1=561806&r2=561807
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java Wed Aug  1 07:14:06
2007
@@ -25,6 +25,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.common.logging.LogUtils;
 
 public abstract class BusFactory {
@@ -152,6 +153,13 @@
             throw new RuntimeException(ex);
         }
         return instance;
+    }
+
+    protected void initializeBus(Bus bus) {
+        BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+        if (null != lifeCycleManager) {
+            lifeCycleManager.initComplete();
+        }
     }
     
     private static String getBusFactoryClass(ClassLoader classLoader) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java?view=diff&rev=561807&r1=561806&r2=561807
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java Wed Aug
 1 07:14:06 2007
@@ -39,7 +39,8 @@
     public Bus createBus(Map<Class, Object> e, Map<String, Object> properties)
{
         Bus bus = new ExtensionManagerBus(e, properties);
         possiblySetDefaultBus(bus);
+        initializeBus(bus);
         return bus;
     }
-    
+ 
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java?view=diff&rev=561807&r1=561806&r2=561807
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java Wed Aug 
1 07:14:06 2007
@@ -49,10 +49,6 @@
         this.extensions = extensions;
         
         state = BusState.INITIAL;
-        BusLifeCycleManager lifeCycleManager = this.getExtension(BusLifeCycleManager.class);
-        if (null != lifeCycleManager) {
-            lifeCycleManager.initComplete();
-        }
         
         CXFBusFactory.possiblySetDefaultBus(this);
     }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java?view=diff&rev=561807&r1=561806&r2=561807
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
Wed Aug  1 07:14:06 2007
@@ -38,13 +38,6 @@
     }
 
     @Override
-    protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean)
{
-        bean.setInitMethodName("initialize");
-        
-        super.doParse(element, ctx, bean);
-    }
-
-    @Override
     protected void mapElement(ParserContext ctx, 
                               BeanDefinitionBuilder bean, 
                               Element e, 

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java?view=diff&rev=561807&r1=561806&r2=561807
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
Wed Aug  1 07:14:06 2007
@@ -25,6 +25,7 @@
 
 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;
@@ -70,6 +71,9 @@
         bus.setExtension(new ConfigurerImpl(bac), Configurer.class);
 
         possiblySetDefaultBus(bus);
+        
+        initializeBus(bus);
+        
         registerApplicationContextLifeCycleListener(bus, bac);
         return bus;
     }
@@ -95,8 +99,13 @@
             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);
         if (null != lm) {

Modified: incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml?view=diff&rev=561807&r1=561806&r2=561807
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml (original)
+++ incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml Wed Aug  1 07:14:06
2007
@@ -23,7 +23,7 @@
        xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-    <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl" init-method="initialize"/>
+    <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>
     <bean class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"/>
     <bean class="org.apache.cxf.bus.spring.BusExtensionPostProcessor">
        <property name="bus" ref="cxf"/>

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java?view=diff&rev=561807&r1=561806&r2=561807
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
Wed Aug  1 07:14:06 2007
@@ -20,19 +20,23 @@
 package org.apache.cxf.bus.spring;
 
 import java.net.URL;
+import java.util.Collection;
 import java.util.List;
 import java.util.SortedSet;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.bus.CXFBusImpl;
 import org.apache.cxf.buslifecycle.BusLifeCycleListener;
 import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Message;
@@ -162,6 +166,12 @@
         
     }
 
+    @Test
+    public void testInitialisation() {
+        Bus bus = new SpringBusFactory().createBus("org/apache/cxf/bus/spring/init.xml");
+        assertNotNull(bus.getExtension(TestListener.class));        
+    }
+
     
     static class TestInterceptor implements Interceptor {
 
@@ -210,5 +220,43 @@
         }
     }
      
+    static class TestFeature extends AbstractFeature {
+        boolean initialised;
+
+        @Override
+        public void initialize(Bus bus) {
+            initialised = true;
+        }   
+    }
     
+    static class TestListener implements BusLifeCycleListener {
+
+        Bus bus;
+ 
+        @Resource
+        public void setBus(Bus b) {        
+            bus = b;        
+        }
+        
+        @PostConstruct
+        public void register() {
+            bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(this);
           
+        }
+        
+        public void initComplete() {
+            assertNull(bus.getExtension(TestFeature.class));
+            Collection<AbstractFeature> features = ((CXFBusImpl)bus).getFeatures();
+            assertEquals(1, features.size());
+            TestFeature tf = (TestFeature)features.iterator().next();
+            assertTrue(tf.initialised);
+            bus.setExtension(this, TestListener.class);          
+        }
+
+        public void postShutdown() {
+        }
+
+        public void preShutdown() {
+        }
+        
+    }    
 }

Added: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/init.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/init.xml?view=auto&rev=561807
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/init.xml (added)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/init.xml Wed Aug 
1 07:14:06 2007
@@ -0,0 +1,37 @@
+<?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:cxf="http://cxf.apache.org/core"
+       xsi:schemaLocation="
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+    
+    <bean class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestListener">
+        <property name="bus" ref="cxf"/>
+    </bean>
+
+    <cxf:bus>
+        <cxf:features>
+            <bean class= "org.apache.cxf.bus.spring.SpringBusFactoryTest$TestFeature"/>
+        </cxf:features>
+    </cxf:bus>
+    
+</beans>
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/init.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/init.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/init.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message