cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r585682 - in /incubator/cxf/branches/2.0.x-fixes: ./ 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/comm...
Date Wed, 17 Oct 2007 20:42:31 GMT
Author: dkulp
Date: Wed Oct 17 13:42:30 2007
New Revision: 585682

URL: http://svn.apache.org/viewvc?rev=585682&view=rev
Log:
Merged revisions 585633 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r585633 | dkulp | 2007-10-17 15:06:58 -0400 (Wed, 17 Oct 2007) | 4 lines
  
  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/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
      - copied unchanged from r585633, incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf-extension-jaxws.xml
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf.extension
      - copied unchanged from r585633, incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META-INF/cxf/cxf.extension
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java
    incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
    incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
    incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/resources/META-INF/cxf/cxf.xml
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AbstractAnnotationVisitor.java
Wed Oct 17 13:42:30 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/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
Wed Oct 17 13:42:30 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/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
Wed Oct 17 13:42:30 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/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java
Wed Oct 17 13:42:30 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/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
Wed Oct 17 13:42:30 2007
@@ -157,6 +157,7 @@
         
         try {
             injector.inject(obj);
+            injector.construct(obj);
         } finally {
             if (null != namespacesResolver) {
                 resourceManager.removeResourceResolver(namespacesResolver);

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
Wed Oct 17 13:42:30 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/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/QueryHandlerRegistryImpl.java
Wed Oct 17 13:42:30 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/branches/2.0.x-fixes/rt/core/src/main/resources/META-INF/cxf/cxf.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/resources/META-INF/cxf/cxf.xml?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/resources/META-INF/cxf/cxf.xml (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/resources/META-INF/cxf/cxf.xml Wed
Oct 17 13:42:30 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/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
Wed Oct 17 13:42:30 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/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
Wed Oct 17 13:42:30 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/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java?rev=585682&r1=585681&r2=585682&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
Wed Oct 17 13:42:30 2007
@@ -108,6 +108,7 @@
 //            resourceManager.addResourceResolver(new WebContextEntriesResourceResolver());
             ResourceInjector injector = new ResourceInjector(resourceManager);
             injector.inject(handler);
+            injector.construct(handler);
         }
 
     }



Mime
View raw message