cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r451232 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/configuration/spring/ rt/core/src/main/java/org/apache/cxf/bus/resource/ rt/core/src/main/java/org/apache/cxf/bus/spring/ rt/core/src/main/resources/META-INF/cxf/...
Date Fri, 29 Sep 2006 11:13:52 GMT
Author: andreasmyth
Date: Fri Sep 29 04:13:51 2006
New Revision: 451232

URL: http://svn.apache.org/viewvc?view=rev&rev=451232
Log:
Some fixes to Spring based bus implementation.
Removed side effects of implementor injection on bus's ResourceManager.
Changed initialisation sequence in InstrumentationManager to work in both bus implementations.

Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/resource/ResourceManagerImpl.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
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
    incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/InstrumentationManagerImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java?view=diff&rev=451232&r1=451231&r2=451232
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
Fri Sep 29 04:13:51 2006
@@ -99,7 +99,7 @@
             // to have no effect - the most common cause is that they have been using
             // incorrect bean ids
             LogUtils.log(LOG, Level.INFO, "NO_MATCHING_BEAN_MSG", new Object[] {beanName});
-            // LOG.log(Level.INFO, "NO_MATCHING_BEAN_MSG", beanName);
+            LOG.log(Level.INFO, "NO_MATCHING_BEAN_MSG", beanName);
         }
     }
     

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/resource/ResourceManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/resource/ResourceManagerImpl.java?view=diff&rev=451232&r1=451231&r2=451232
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/resource/ResourceManagerImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/resource/ResourceManagerImpl.java
Fri Sep 29 04:13:51 2006
@@ -19,20 +19,31 @@
 
 package org.apache.cxf.bus.resource;
 
+import java.util.List;
 import java.util.Map;
 
-import org.apache.cxf.BusException;
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
+import org.apache.cxf.Bus;
 import org.apache.cxf.resource.DefaultResourceManager;
 import org.apache.cxf.resource.PropertiesResolver;
+import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.resource.ResourceResolver;
 
 
 public class ResourceManagerImpl extends DefaultResourceManager {
 
+    private Bus bus;
+
     public ResourceManagerImpl() {
-        super();
     }
-    
-    public ResourceManagerImpl(Map<String, Object> properties) throws BusException
{ 
+
+    public ResourceManagerImpl(List<ResourceResolver> r) {
+        super(r);
+    }
+
+    public ResourceManagerImpl(Map<String, Object> properties) { 
         super();
         registeredResolvers.clear();
         
@@ -66,4 +77,16 @@
         */
     } 
     
+    @Resource
+    public void setBus(Bus b) {
+        bus = b;
+    }
+
+    @PostConstruct
+    public void register() {
+        if (null != bus) {
+            bus.setExtension(this, ResourceManager.class);
+        }
+    }
+
 }

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=451232&r1=451231&r2=451232
==============================================================================
--- 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
Fri Sep 29 04:13:51 2006
@@ -39,7 +39,7 @@
 
     public synchronized Bus getDefaultBus() {
         if (null == defaultBus) {
-            defaultBus = new SpringBusImpl();
+            defaultBus = createBus();
         }
         return defaultBus;
     }
@@ -57,18 +57,17 @@
     }
     
     public Bus createBus(String cfgFile, boolean includeDefaults) {        
-        
+
         BusApplicationContext bac = null;
         try {      
             bac = new BusApplicationContext(cfgFile, includeDefaults);           
         } catch (BeansException ex) {
             LogUtils.log(LOG, Level.WARNING, "APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
-            
         }
         
         bac.refresh();
         Bus bus = (Bus)bac.getBean(DEFAULT_BUS_ID);
-        
+       
         Configurer configurer = new ConfigurerImpl(bac);
         bus.setExtension(configurer, Configurer.class);
 

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=451232&r1=451231&r2=451232
==============================================================================
--- 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 Fri Sep 29 04:13:51
2006
@@ -28,6 +28,16 @@
     <bean class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"/>
     
     <bean id="org.apache.cxf.extension.ExtensionManager" class="org.apache.cxf.bus.spring.extension.ExtensionManagerImpl"/>
+  
+    <bean id="org.apache.cxf.resource.ResourceManager" class="org.apache.cxf.bus.resource.ResourceManagerImpl">
+       <constructor-arg>
+            <list>
+                <bean class="org.apache.cxf.resource.ClasspathResolver"/>
+                <bean class="org.apache.cxf.resource.ClassLoaderResolver"/>
+            </list>
+       </constructor-arg>
+       <property name="bus" ref="cxf"/>
+    </bean>
         
     <bean id="org.apache.cxf.binding.BindingFactoryManager" class="org.apache.cxf.binding.BindingFactoryManagerImpl">
         <property name="extensionManager" ref="org.apache.cxf.extension.ExtensionManager"/>

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=451232&r1=451231&r2=451232
==============================================================================
--- 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
Fri Sep 29 04:13:51 2006
@@ -27,11 +27,13 @@
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.endpoint.ServerRegistry;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.workqueue.WorkQueueManager;
@@ -45,6 +47,8 @@
         assertNotNull(bus);
         BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);  
         assertNotNull("No binding factory manager", bfm);
+        assertNotNull("No configurer", bus.getExtension(Configurer.class));
+        assertNotNull("No resource manager", bus.getExtension(ResourceManager.class));
         assertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.class));
         assertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.class));
         assertNotNull("No wsdl manager", bus.getExtension(WSDLManager.class));

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=451232&r1=451231&r2=451232
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Fri Sep 29 04:13:51 2006
@@ -50,7 +50,9 @@
 import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.jaxws.support.ProviderServiceFactoryBean;
+import org.apache.cxf.resource.DefaultResourceManager;
 import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.resource.ResourceResolver;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.AbstractServiceFactoryBean;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -198,6 +200,8 @@
     protected void injectResources(Object instance) {
         if (instance != null) {
             ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
+            List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
+            resourceManager = new DefaultResourceManager(resolvers); 
             resourceManager.addResourceResolver(new WebContextResourceResolver());
             ResourceInjector injector = new ResourceInjector(resourceManager);
             injector.inject(instance);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java?view=diff&rev=451232&r1=451231&r2=451232
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
Fri Sep 29 04:13:51 2006
@@ -29,7 +29,9 @@
 import junit.framework.TestCase;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.cxf.CXFBusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.interceptor.Fault;
@@ -47,12 +49,7 @@
     private static final QName PORT_NAME = 
         new QName("http://apache.org/hello_world_soap_http", "SoapPort");
 
-    private CXFBusFactory factory;
-    
-    public void setUp() {
-        factory = new CXFBusFactory();
-        factory.setDefaultBus(null);
-    }
+    private BusFactory factory;
     
     public void tearDown() {
         Bus bus = factory.getDefaultBus();
@@ -60,10 +57,26 @@
             bus.shutdown(true);
             factory.setDefaultBus(null);
         }
+        System.clearProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME);
+    }
+   
+    public void testCXFDefaultClientEndpoint() {
+        factory = new CXFBusFactory();
+        factory.setDefaultBus(null);
+        factory.getDefaultBus();
+        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
+        doTestDefaultClientEndpoint();
     }
      
-    public void testDefaultClientEndpoint() {        
+    public void testSpringDefaultClientEndpoint() {
+        factory = new SpringBusFactory();
+        factory.setDefaultBus(null);
         factory.getDefaultBus();
+        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, SpringBusFactory.class.getName());
+        doTestDefaultClientEndpoint();
+    }
+     
+    private void doTestDefaultClientEndpoint() {        
 
         javax.xml.ws.Service service = new SOAPService();
         Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
@@ -104,14 +117,31 @@
         printInterceptors("outFault", interceptors);
         assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
     }
+
+    public void testCXFConfiguredClientEndpoint() {
+        CXFBusFactory cf = new CXFBusFactory();
+        factory = cf;
+        factory.setDefaultBus(null);
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(Configurer.USER_CFG_FILE_PROPERTY_NAME,
+            "org/apache/cxf/jaxws/configured-endpoints.xml");
+        cf.setDefaultBus(cf.createBus(null, properties));
+        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
+        doTestConfiguredClientEndpoint();
+    }
     
+    public void testSpringConfiguredClientEndpoint() {
+        SpringBusFactory sf = new SpringBusFactory();
+        factory = sf;
+        factory.setDefaultBus(null);
+        sf.setDefaultBus(sf.createBus("org/apache/cxf/jaxws/configured-endpoints.xml"));
+        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, SpringBusFactory.class.getName());
+        doTestConfiguredClientEndpoint();
+    }
+
     @SuppressWarnings("unchecked")
-    public void testConfiguredClientEndpoint() {
-        Map<String, Object> properties = new HashMap<String, Object>();
-        properties.put(Configurer.USER_CFG_FILE_PROPERTY_NAME, 
-                       "org/apache/cxf/jaxws/configured-endpoints.xml");
-        factory.setDefaultBus(factory.createBus(null, properties));
-        
+    private void doTestConfiguredClientEndpoint() {
+
         javax.xml.ws.Service service = new SOAPService();
         Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
 
@@ -157,8 +187,23 @@
                      findTestInterceptor(interceptors).getId());
     }
     
-    public void testDefaultServerEndpoint() {
+    public void testCXFDefaultServerEndpoint() {
+        factory = new CXFBusFactory();
+        factory.setDefaultBus(null);
         factory.getDefaultBus();
+        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
+        doTestDefaultServerEndpoint();
+    }
+     
+    public void testSpringDefaultServerEndpoint() {
+        factory = new SpringBusFactory();
+        factory.setDefaultBus(null);
+        factory.getDefaultBus();
+        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, SpringBusFactory.class.getName());
+        doTestDefaultServerEndpoint();
+    }
+     
+    private void doTestDefaultServerEndpoint() {
         
         Object implementor = new GreeterImpl(); 
         EndpointImpl ei = (EndpointImpl)(javax.xml.ws.Endpoint.create(implementor));
@@ -187,13 +232,30 @@
         interceptors = svc.getOutFaultInterceptors();
         assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
     }
+
+    public void testCXFConfiguredServerEndpoint() {
+        CXFBusFactory cf = new CXFBusFactory();
+        factory = cf;
+        factory.setDefaultBus(null);
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(Configurer.USER_CFG_FILE_PROPERTY_NAME,
+            "org/apache/cxf/jaxws/configured-endpoints.xml");
+        cf.setDefaultBus(cf.createBus(null, properties));
+        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
+        doTestConfiguredServerEndpoint();
+    }
+    
+    public void testSpringConfiguredServerEndpoint() {
+        SpringBusFactory sf = new SpringBusFactory();
+        factory = sf;
+        factory.setDefaultBus(null);
+        sf.setDefaultBus(sf.createBus("org/apache/cxf/jaxws/configured-endpoints.xml"));
+        System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, SpringBusFactory.class.getName());
+        doTestConfiguredServerEndpoint();
+    }
     
     @SuppressWarnings("unchecked")
-    public void testConfiguredServerEndpoint() {
-        Map<String, Object> properties = new HashMap<String, Object>();
-        properties.put(Configurer.USER_CFG_FILE_PROPERTY_NAME, 
-                       "org/apache/cxf/jaxws/configured-endpoints.xml");
-        factory.setDefaultBus(factory.createBus(null, properties));
+    private void doTestConfiguredServerEndpoint() {
         
         Object implementor = new GreeterImpl(); 
         EndpointImpl ei = (EndpointImpl)(javax.xml.ws.Endpoint.create(implementor));

Modified: incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/InstrumentationManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/InstrumentationManagerImpl.java?view=diff&rev=451232&r1=451231&r2=451232
==============================================================================
--- incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/InstrumentationManagerImpl.java
(original)
+++ incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/InstrumentationManagerImpl.java
Fri Sep 29 04:13:51 2006
@@ -49,14 +49,7 @@
     private List <Instrumentation> instrumentations;
     private JMXManagedComponentManager jmxManagedComponentManager;
     
-   
     public InstrumentationManagerImpl() {
-        if (null == getInstrumentation()) {
-            setInstrumentation(new InstrumentationType());
-        }      
-        if (null == getJMXConnectorPolicy()) {
-            setJMXConnectorPolicy(new JMXConnectorPolicyType());
-        }      
     }
        
     public Bus getBus() {
@@ -66,7 +59,6 @@
     @Resource
     public void setBus(Bus bus) {        
         this.bus = bus;
-        initInstrumentationManagerImpl();
     }
     
     @PostConstruct
@@ -75,14 +67,22 @@
             bus.setExtension(this, InstrumentationManager.class);
         }
     }
-    
+
     @Override
     public String getBeanName() {
         return InstrumentationManager.class.getName();
     }
-    
+   
+    @PostConstruct 
     public void initInstrumentationManagerImpl() {
         LOG.info("Setting up InstrumentationManager");
+
+        if (null == getInstrumentation()) {
+            setInstrumentation(new InstrumentationType());
+        }      
+        if (null == getJMXConnectorPolicy()) {
+            setJMXConnectorPolicy(new JMXConnectorPolicyType());
+        }      
         
         if (getInstrumentation().isEnabled()) {
             LOG.fine("Instrumentation is enabled.");

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java?view=diff&rev=451232&r1=451231&r2=451232
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/management/ManagedBusTest.java
Fri Sep 29 04:13:51 2006
@@ -28,10 +28,13 @@
 import org.apache.cxf.bus.cxf.CXFBusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.management.InstrumentationManager;
+import org.apache.cxf.management.InstrumentationManagerImpl;
+import org.apache.cxf.management.InstrumentationType;
 
 public class ManagedBusTest extends TestCase {
 
-    public void testManagedCXFBus() {
+    public void xtestManagedCXFBus() {
         CXFBusFactory factory = new CXFBusFactory();
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(Configurer.USER_CFG_FILE_PROPERTY_NAME, 
@@ -40,9 +43,19 @@
         bus.shutdown(true);
     }
 
-    public void xtestManagedSpringBus() {
+    public void testManagedSpringBus() {
         SpringBusFactory factory = new SpringBusFactory();
         Bus bus = factory.createBus("org/apache/cxf/systest/management/managed-spring.xml",
true);
+        InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
+        assertNotNull(im);
+        InstrumentationManagerImpl imi = (InstrumentationManagerImpl)im;
+        InstrumentationType i = imi.getInstrumentation();
+        assertNotNull(i);
+        System.out.println("isEnabled: " + i.isEnabled());
+        System.out.println("isJMXEnabled: " + i.isJMXEnabled());
+        
+
+
         bus.shutdown(true);
     }
 }



Mime
View raw message