Author: sergeyb
Date: Thu Aug 29 12:48:17 2013
New Revision: 1518627
URL: http://svn.apache.org/r1518627
Log:
Making it easy to disable JAXRS SpringResourceFactory calling lifecycle methods
Modified:
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
Modified:
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java?rev=1518627&r1=1518626&r2=1518627&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
(original)
+++
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
Thu Aug 29 12:48:17 2013
@@ -49,6 +49,7 @@ public class SpringResourceFactory imple
private Method postConstructMethod;
private Method preDestroyMethod;
private boolean isSingleton;
+ private boolean callLifecycleMethods = true;
public SpringResourceFactory() {
@@ -83,12 +84,18 @@ public class SpringResourceFactory imple
: Collections.singletonMap(Application.class,
application.getProvider()));
Object[] values = ResourceUtils.createConstructorArguments(c, m,
!isSingleton(), mapValues);
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}
*/
@@ -100,7 +107,7 @@ public class SpringResourceFactory imple
* {@inheritDoc}
*/
public void releaseInstance(Message m, Object o) {
- if (!isSingleton()) {
+ if (callLifecycleMethods && !isSingleton()) {
InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod);
}
}
@@ -129,4 +136,7 @@ public class SpringResourceFactory imple
return c.getDeclaringClass();
}
+ public void setCallLifecycleMethods(boolean callLifecycleMethods) {
+ this.callLifecycleMethods = callLifecycleMethods;
+ }
}