cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r585633 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/common/annotation/ common/common/src/main/java/org/apache/cxf/common/injection/ common/common/src/main/java/org/apache/cxf/resource/ common/common/src/test/java/o...
Date Wed, 17 Oct 2007 19:07:00 GMT
Author: dkulp
Date: Wed Oct 17 12:06:58 2007
New Revision: 585633

URL: http://svn.apache.org/viewvc?rev=585633&view=rev
Log:
Fix injection when Spring AOP is used by allowing the Spring BeanPostProcessor to do the injection.
Change QueryHandlerRegistryImpl to be configured/created via spring


Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf.extension  
(with props)
Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
    incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java
    incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java
Wed Oct 17 12:06:58 2007
@@ -26,7 +26,9 @@
 import java.util.List;
 
 public abstract class AbstractAnnotationVisitor implements AnnotationVisitor {
-    protected Object target; 
+    protected Object target;
+    protected Class<?> targetClass;
+    
 
     private final List<Class<? extends Annotation>> targetAnnotations = 
                                  new ArrayList<Class<? extends Annotation>>();

@@ -62,10 +64,18 @@
 
     public void setTarget(Object object) {
         target = object;
+        targetClass = object.getClass();
+    }
+    public void setTarget(Object object, Class<?> cls) {
+        target = object;
+        targetClass = cls;
     }
     
     public Object getTarget() { 
         return target;
+    } 
+    public Class<?> getTargetClass() { 
+        return targetClass;
     } 
 
 }

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
Wed Oct 17 12:06:58 2007
@@ -79,13 +79,16 @@
     public void inject(Object o, Class claz) {
         AnnotationProcessor processor = new AnnotationProcessor(o); 
         processor.accept(this, claz); 
-        invokePostConstruct();
     }
     
     public void construct(Object o) {
         setTarget(o);
         invokePostConstruct();
     }
+    public void construct(Object o, Class<?> cls) {
+        setTarget(o, cls);
+        invokePostConstruct();
+    }
 
 
     public void destroy(Object o) {
@@ -345,6 +348,10 @@
         Collection<Method> methods = new LinkedList<Method>(); 
         addAnnotatedMethods(acls, getTarget().getClass().getMethods(), methods); 
         addAnnotatedMethods(acls, getTarget().getClass().getDeclaredMethods(), methods);
+        if (getTargetClass() != getTarget().getClass()) {
+            addAnnotatedMethods(acls, getTargetClass().getMethods(), methods); 
+            addAnnotatedMethods(acls, getTargetClass().getDeclaredMethods(), methods);  
         
+        }
         return methods;
     } 
 
@@ -388,6 +395,9 @@
     }
 
     private Object resolveResource(String resourceName, Class<?> type) {
+        if (resourceManager == null) {
+            return null;
+        }
         return resourceManager.resolveResource(resourceName, type, resourceResolvers);
     }
         

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
Wed Oct 17 12:06:58 2007
@@ -81,6 +81,9 @@
     
     private <T> T findResource(String name, Class<T> type, boolean asStream,

                                List<ResourceResolver> resolvers) {
+        if (resolvers == null) {
+            resolvers = registeredResolvers;
+        }
         
         if (LOG.isLoggable(Level.FINE)) { 
             LOG.fine("resolving resource <" + name + ">" + (asStream ? " as stream
"  

Modified: incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java
(original)
+++ incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java
Wed Oct 17 12:06:58 2007
@@ -139,6 +139,7 @@
     private void doInjectTest(Target target, Class<?> clazz) {
 
         injector.inject(target, clazz);
+        injector.construct(target);
         assertNotNull(target.getResource1()); 
         assertEquals(RESOURCE_ONE, target.getResource1()); 
 

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
Wed Oct 17 12:06:58 2007
@@ -157,6 +157,7 @@
         
         try {
             injector.inject(obj);
+            injector.construct(obj);
         } finally {
             if (null != namespacesResolver) {
                 resourceManager.removeResourceResolver(namespacesResolver);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
Wed Oct 17 12:06:58 2007
@@ -19,30 +19,59 @@
 
 package org.apache.cxf.bus.spring;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.cxf.common.injection.ResourceInjector;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.resource.ResourceResolver;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
 import org.springframework.core.Ordered;
 
-public class Jsr250BeanPostProcessor implements DestructionAwareBeanPostProcessor, Ordered
{
+public class Jsr250BeanPostProcessor 
+    implements DestructionAwareBeanPostProcessor, Ordered, ApplicationContextAware {
 
     private ResourceInjector injector;
-    
+    private ApplicationContext context;
+
     Jsr250BeanPostProcessor() {
         injector = new ResourceInjector(null, null); 
     }
-
+    
+    public void setApplicationContext(ApplicationContext arg0) throws BeansException {
+        context = arg0;    
+    }
+    
     public int getOrder() {
-        return 1002;
+        return 1010;
     }
         
     public Object postProcessAfterInitialization(Object bean, String beanId) throws BeansException
{
+        if (bean != null
+            && injector != null) {
+            injector.construct(bean);
+        }
+        if (bean instanceof ResourceManager) {
+            ResourceManager rm = (ResourceManager)bean;
+
+            Map<String, Object> mp = CastUtils.cast(context.getBeansOfType(ResourceResolver.class));
+            Collection<ResourceResolver> resolvs = CastUtils.cast(mp.values());
+            List<ResourceResolver> resolvers = new ArrayList<ResourceResolver>(rm.getResourceResolvers());
+            resolvers.addAll(resolvs);
+            injector = new ResourceInjector(rm, resolvers);
+        }
         return bean;
     }
 
     public Object postProcessBeforeInitialization(Object bean, String beanId) throws BeansException
{
-        if (bean != null) {
-            injector.construct(bean);
+        if (bean != null && injector != null) {
+            injector.inject(bean);
         }
         return bean;
     }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java
Wed Oct 17 12:06:58 2007
@@ -19,8 +19,8 @@
 
 package org.apache.cxf.transport.http;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
@@ -34,19 +34,27 @@
     List<QueryHandler> queryHandlers;
     Bus bus;
     
+    
+    public QueryHandlerRegistryImpl() {
+    }
+    public QueryHandlerRegistryImpl(Bus b, List<QueryHandler> handlers) {
+        bus = b;
+        queryHandlers = new CopyOnWriteArrayList<QueryHandler>(handlers);
+    }
+    
+    
     @PostConstruct
     public void register() {
+        if (queryHandlers == null) {
+            queryHandlers = new CopyOnWriteArrayList<QueryHandler>();
+            if (bus != null) {
+                queryHandlers.add(new WSDLQueryHandler(bus));
+            }
+        }
         if (null != bus) {
             bus.setExtension(this, QueryHandlerRegistry.class);
         }
     }
-    
-    @PostConstruct
-    public void init() {
-        queryHandlers = new ArrayList<QueryHandler>();
-        registerHandler(new WSDLQueryHandler(bus));
-    }
-
 
     public List<QueryHandler> getHandlers() {
         return queryHandlers;

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?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- 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 Oct 17 12:06:58
2007
@@ -96,7 +96,14 @@
         
 
     <bean id="org.apache.cxf.transports.http.QueryHandlerRegistry" class="org.apache.cxf.transport.http.QueryHandlerRegistryImpl">
-        <property name="bus" ref="cxf"/>
+        <constructor-arg ref="cxf"/>
+        <constructor-arg>
+        	<list>
+        		<bean class="org.apache.cxf.transport.http.WSDLQueryHandler">
+			        <constructor-arg ref="cxf"/>
+        		</bean>	
+        	</list>
+        </constructor-arg>
     </bean>
 
     <bean id="org.apache.cxf.endpoint.EndpointResolverRegistry" class="org.apache.cxf.endpoint.EndpointResolverRegistryImpl">

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
Wed Oct 17 12:06:58 2007
@@ -199,8 +199,10 @@
             ResourceInjector injector = new ResourceInjector(resourceManager);
             if (Proxy.isProxyClass(instance.getClass()) && getServiceClass() != null)
{
                 injector.inject(instance, getServiceClass());
+                injector.construct(instance, getServiceClass());
             } else {
                 injector.inject(instance);
+                injector.construct(instance);
             }
         }
     }  

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
Wed Oct 17 12:06:58 2007
@@ -179,6 +179,7 @@
             resolvers.add(new InitParamResourceResolver(params));
             ResourceInjector resInj = new ResourceInjector(resMgr, resolvers);
             resInj.inject(handler);
+            resInj.construct(handler);
         }
     }
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java?rev=585633&r1=585632&r2=585633&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
Wed Oct 17 12:06:58 2007
@@ -108,6 +108,7 @@
 //            resourceManager.addResourceResolver(new WebContextEntriesResourceResolver());
             ResourceInjector injector = new ResourceInjector(resourceManager);
             injector.inject(handler);
+            injector.construct(handler);
         }
 
     }

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml?rev=585633&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
Wed Oct 17 12:06:58 2007
@@ -0,0 +1,28 @@
+<?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:foo="http://cxf.apache.org/configuration/foo"
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+    
+    <bean class="org.apache.cxf.jaxws.context.WebServiceContextResourceResolver" lazy-init="false"/>
+</beans>

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf.extension
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf.extension?rev=585633&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf.extension (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf.extension Wed
Oct 17 12:06:58 2007
@@ -0,0 +1 @@
+META-INF/cxf/cxf-extension-jaxws.xml
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf.extension
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message