cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1518711 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
Date Thu, 29 Aug 2013 17:07:52 GMT
Author: sergeyb
Date: Thu Aug 29 17:07:51 2013
New Revision: 1518711

URL: http://svn.apache.org/r1518711
Log:
Merged revisions 1518627 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1518627 | sergeyb | 2013-08-29 13:48:17 +0100 (Thu, 29 Aug 2013) | 1 line
  
  Making it easy to disable JAXRS SpringResourceFactory calling lifecycle methods
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1518627

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

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java?rev=1518711&r1=1518710&r2=1518711&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
Thu Aug 29 17:07:51 2013
@@ -43,6 +43,7 @@ public class SpringResourceFactory imple
     private Method postConstructMethod;
     private Method preDestroyMethod;
     private boolean isSingleton;
+    private boolean callLifecycleMethods = true;
     
     public SpringResourceFactory() {
         
@@ -73,12 +74,18 @@ public class SpringResourceFactory imple
     public Object getInstance(Message m) {
         Object[] values = ResourceUtils.createConstructorArguments(c, m);
         Object instance = values.length > 0 ? ac.getBean(beanId, values) : ac.getBean(beanId);
-        if (!isSingleton || m == null) {
+        initInstance(m, instance);
+        return instance;
+    }
+
+    protected void initInstance(Message m, Object instance) {
+        if (callLifecycleMethods && (!isSingleton() || m == null)) {
             InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod);
         }
-        return instance;
     }
 
+    
+    
     /**
      * {@inheritDoc}
      */
@@ -90,7 +97,7 @@ public class SpringResourceFactory imple
      * {@inheritDoc}
      */
     public void releaseInstance(Message m, Object o) {
-        if (!isSingleton) {
+        if (callLifecycleMethods && !isSingleton()) {
             InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod);
         }
     }
@@ -119,4 +126,7 @@ public class SpringResourceFactory imple
         return c.getDeclaringClass();
     }
 
+    public void setCallLifecycleMethods(boolean callLifecycleMethods) {
+        this.callLifecycleMethods = callLifecycleMethods;
+    }
 }



Mime
View raw message