cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1211239 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
Date Tue, 06 Dec 2011 23:59:23 GMT
Author: dkulp
Date: Tue Dec  6 23:59:22 2011
New Revision: 1211239

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

........
  r1211229 | dkulp | 2011-12-06 18:42:20 -0500 (Tue, 06 Dec 2011) | 1 line
  
  [CXF-3959] Fix issues of double injection with Spring Part 1
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java

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

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?rev=1211239&r1=1211238&r2=1211239&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
Tue Dec  6 23:59:22 2011
@@ -63,6 +63,7 @@ public class JaxWsServerFactoryBean exte
     protected List<Handler> handlers = new ArrayList<Handler>();
 
     private boolean blockPostConstruct;
+    private boolean blockInjection;
     
     public JaxWsServerFactoryBean() {
         this(new JaxWsServiceFactoryBean());
@@ -251,7 +252,7 @@ public class JaxWsServerFactoryBean exte
      * @param instance
      */
     protected void injectResources(Object instance) {
-        if (instance != null) {
+        if (instance != null && !blockInjection) {
             ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
             List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
             resourceManager = new DefaultResourceManager(resolvers); 
@@ -272,7 +273,6 @@ public class JaxWsServerFactoryBean exte
     }
 
     /**
-     * 
      * @param blockPostConstruct @PostConstruct method will not be called 
      *  if this property is set to true - this may be necessary in cases
      *  when the @PostConstruct method needs to be called at a later stage,
@@ -281,5 +281,14 @@ public class JaxWsServerFactoryBean exte
     public void setBlockPostConstruct(boolean blockPostConstruct) {
         this.blockPostConstruct = blockPostConstruct;
     }
+    /**
+     * No injection or PostContstuct will be called if this is set to true.
+     * If the container has already handled the injection, this should 
+     * be set to true.
+     * @param b
+     */
+    public void setBlockInjection(boolean b) {
+        this.blockInjection = b;
+    }
       
 }

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java?rev=1211239&r1=1211238&r2=1211239&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
Tue Dec  6 23:59:22 2011
@@ -152,6 +152,7 @@ public class EndpointDefinitionParser ex
         if (!StringUtils.isEmpty(val)) {
             if (val.startsWith("#")) {
                 bean.addConstructorArgReference(val.substring(1));
+                bean.addPropertyValue("checkBlockConstuct", Boolean.TRUE);
             } else {
                 try {
                     Object obj = ClassLoaderUtils.loadClass(val, getClass()).newInstance();
@@ -179,6 +180,8 @@ public class EndpointDefinitionParser ex
     public static class SpringEndpointImpl extends EndpointImpl
         implements ApplicationContextAware {
     
+        boolean checkBlockConstruct;
+        
         public SpringEndpointImpl(Object o) {
             super(o instanceof Bus ? (Bus)o : null,
                 o instanceof Bus ? null : o);
@@ -188,8 +191,26 @@ public class EndpointDefinitionParser ex
             super(bus, implementor);
         }
         
+        public void setCheckBlockConstuct(Boolean b) {
+            checkBlockConstruct = b;
+        }
         
         public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (checkBlockConstruct) {
+                try {
+                    Class<?> cls = Class
+                        .forName("org.springframework.context.annotation.CommonAnnotationBeanPostProcessor");
+                    if (ctx.getBeanNamesForType(cls, true, false).length != 0) {
+                        //Spring will handle the postconstruct, but won't inject the 
+                        // WebServiceContext so we do need to do that.
+                        super.getServerFactory().setBlockPostConstruct(true);
+                    } else {
+                        super.getServerFactory().setBlockInjection(true);
+                    }
+                } catch (ClassNotFoundException e) {
+                    //ignore
+                }
+            }
             if (getBus() == null) {
                 setBus(BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx));
             }



Mime
View raw message