cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r961823 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/
Date Thu, 08 Jul 2010 15:52:24 GMT
Author: sergeyb
Date: Thu Jul  8 15:52:24 2010
New Revision: 961823

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

........
  r961818 | sergeyb | 2010-07-08 16:44:42 +0100 (Thu, 08 Jul 2010) | 1 line
  
  CXF-2886 : adding a blockPostConstruct property to JaxWsServerFactoryBean
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul  8 15:52:24 2010
@@ -1 +1 @@
-/cxf/trunk:960506,961051
+/cxf/trunk:960506,961051,961818

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

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=961823&r1=961822&r2=961823&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Thu Jul  8 15:52:24 2010
@@ -264,6 +264,14 @@ public class EndpointImpl extends javax.
         return endpointName.toString() + ".jaxws-endpoint";
     }
 
+    protected JaxWsServerFactoryBean getServerFactory() {
+        return serverFactory;
+    }
+    
+    protected void setServerFactory(JaxWsServerFactoryBean bean) {
+        this.serverFactory = bean;
+    }
+    
     protected void checkProperties() {
         if (properties != null) {
             if (properties.containsKey("javax.xml.ws.wsdl.description")) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?rev=961823&r1=961822&r2=961823&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
Thu Jul  8 15:52:24 2010
@@ -61,6 +61,8 @@ import org.apache.cxf.service.model.Bind
 public class JaxWsServerFactoryBean extends ServerFactoryBean {
     protected boolean doInit;
     protected List<Handler> handlers = new ArrayList<Handler>();
+
+    private boolean blockPostConstruct;
     
     public JaxWsServerFactoryBean() {
         this(new JaxWsServiceFactoryBean());
@@ -229,11 +231,27 @@ public class JaxWsServerFactoryBean exte
             ResourceInjector injector = new ResourceInjector(resourceManager);
             if (Proxy.isProxyClass(instance.getClass()) && getServiceClass() != null)
{
                 injector.inject(instance, getServiceClass());
-                injector.construct(instance, getServiceClass());
+                if (!blockPostConstruct) {
+                    injector.construct(instance, getServiceClass());
+                }
             } else {
                 injector.inject(instance);
-                injector.construct(instance);
+                if (!blockPostConstruct) {
+                    injector.construct(instance);
+                }
             }
         }
-    }  
+    }
+
+    /**
+     * 
+     * @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,
+     *  for example, when a higher level container does its own injection.  
+     */
+    public void setBlockPostConstruct(boolean blockPostConstruct) {
+        this.blockPostConstruct = blockPostConstruct;
+    }
+      
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java?rev=961823&r1=961822&r2=961823&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java
Thu Jul  8 15:52:24 2010
@@ -160,4 +160,29 @@ public class JaxWsServerFactoryBeanTest 
                         doc,
                         XPathConstants.NODE);
     }
+    
+    @Test
+    public void testPostConstructCalled() throws Exception {
+        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+        factory.setServiceClass(Hello.class);
+        Hello bean = new Hello();
+        factory.setServiceBean(bean);
+        String address = "http://localhost:9001/jaxwstest";
+        factory.setAddress(address);
+        factory.create();
+        assertTrue("PostConstruct is not called", bean.isPostConstructCalled());
+    }
+    
+    @Test
+    public void testPostConstructBlocked() throws Exception {
+        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+        factory.setServiceClass(Hello.class);
+        Hello bean = new Hello();
+        factory.setServiceBean(bean);
+        String address = "http://localhost:9001/jaxwstest";
+        factory.setAddress(address);
+        factory.setBlockPostConstruct(true);
+        factory.create();
+        assertFalse("PostConstruct is called", bean.isPostConstructCalled());
+    }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java?rev=961823&r1=961822&r2=961823&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
Thu Jul  8 15:52:24 2010
@@ -21,12 +21,26 @@ package org.apache.cxf.jaxws.service;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.annotation.PostConstruct;
 import javax.jws.WebMethod;
 import javax.jws.WebService;
 
 @WebService
 public class Hello {
 
+    private boolean postConstructCalled;
+    
+    @PostConstruct
+    @WebMethod(exclude = true)
+    public void init() {
+        postConstructCalled = true;
+    }
+    
+    @WebMethod(exclude = true)
+    public boolean isPostConstructCalled() {
+        return postConstructCalled;
+    }
+    
     @WebMethod
     public String sayHi(String text) {
         return text;



Mime
View raw message