Author: sergeyb
Date: Wed Feb 5 13:23:12 2014
New Revision: 1564766
URL: http://svn.apache.org/r1564766
Log:
Merged revisions 1564734,1564749-1564750 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1564734 | sergeyb | 2014-02-05 12:21:37 +0000 (Wed, 05 Feb 2014) | 1 line
[CXF-5541] Adding a 'bus' parameter to CXFServlet
........
r1564749 | sergeyb | 2014-02-05 12:46:17 +0000 (Wed, 05 Feb 2014) | 1 line
[CXF-5542] Doing the best effort to prevent the loss of TL contexts when
providers are shared between the components with different buses
........
r1564750 | sergeyb | 2014-02-05 12:46:53 +0000 (Wed, 05 Feb 2014) | 1 line
[CXF-5542] Adding the changes to the JAXRS frontend
........
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/model/AbstractResourceInfo.java
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomInFaultyInterceptor.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/web.xml
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/trunk:r1564734-1564750
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/model/AbstractResourceInfo.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java?rev=1564766&r1=1564765&r2=1564766&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
Wed Feb 5 13:23:12 2014
@@ -58,22 +58,27 @@ public abstract class AbstractResourceIn
protected AbstractResourceInfo(Class<?> resourceClass, Class<?>
serviceClass,
boolean isRoot, Bus bus) {
- this(resourceClass, serviceClass, isRoot, true, bus);
+ this(resourceClass, serviceClass, isRoot, true, bus, null);
}
-
+
protected AbstractResourceInfo(Class<?> resourceClass, Class<?>
serviceClass,
boolean isRoot, boolean checkContexts, Bus
bus) {
+ this(resourceClass, serviceClass, isRoot, checkContexts, bus, null);
+ }
+
+ protected AbstractResourceInfo(Class<?> resourceClass, Class<?>
serviceClass,
+ boolean isRoot, boolean checkContexts, Bus
bus,
+ Object provider) {
this.bus = bus;
this.serviceClass = serviceClass;
this.resourceClass = resourceClass;
root = isRoot;
if (checkContexts && resourceClass != null) {
- findContexts(serviceClass);
+ findContexts(serviceClass, provider);
}
}
-
- private void findContexts(Class<?> cls) {
- findContextFields(cls);
+ private void findContexts(Class<?> cls, Object provider) {
+ findContextFields(cls, provider);
findContextSetterMethods(cls);
contextsAvailable = contextFields != null && !contextFields.isEmpty()
|| contextMethods != null && !contextMethods.isEmpty();
@@ -90,7 +95,7 @@ public abstract class AbstractResourceIn
public void setResourceClass(Class<?> rClass) {
resourceClass = rClass;
if (serviceClass.isInterface() && resourceClass != null &&
!resourceClass.isInterface()) {
- findContexts(resourceClass);
+ findContexts(resourceClass, null);
}
}
@@ -98,7 +103,7 @@ public abstract class AbstractResourceIn
return serviceClass;
}
- private void findContextFields(Class<?> cls) {
+ private void findContextFields(Class<?> cls, Object provider) {
if (cls == Object.class || cls == null) {
return;
}
@@ -108,12 +113,28 @@ public abstract class AbstractResourceIn
&& AnnotationUtils.isContextClass(f.getType())) {
contextFields = addContextField(contextFields, f);
if (f.getType() != Application.class) {
- addToMap(getFieldProxyMap(), f,
InjectionUtils.createThreadLocalProxy(f.getType()));
+ addToMap(getFieldProxyMap(), f,
getFieldThreadLocalProxy(f, provider));
+ }
+ }
+ }
+ }
+ findContextFields(cls.getSuperclass(), provider);
+ }
+
+ private static ThreadLocalProxy<?> getFieldThreadLocalProxy(Field f,
Object provider) {
+ if (provider != null) {
+ synchronized (provider) {
+ try {
+ Object proxy = InjectionUtils.extractFieldValue(f,
provider);
+ if (proxy instanceof ThreadLocalProxy) {
+ return (ThreadLocalProxy<?>)proxy;
}
+ } catch (Throwable t) {
+ // continue
}
}
}
- findContextFields(cls.getSuperclass());
+ return InjectionUtils.createThreadLocalProxy(f.getType());
}
@SuppressWarnings("unchecked")
Modified:
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java?rev=1564766&r1=1564765&r2=1564766&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
Wed Feb 5 13:23:12 2014
@@ -26,7 +26,7 @@ public class ProviderInfo<T> extends Abs
private T provider;
public ProviderInfo(T provider, Bus bus) {
- super(provider.getClass(), provider.getClass(), true, bus);
+ super(provider.getClass(), provider.getClass(), true, true, bus,
provider);
this.provider = provider;
}
Modified:
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1564766&r1=1564765&r2=1564766&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Wed Feb 5 13:23:12 2014
@@ -996,6 +996,15 @@ public final class InjectionUtils {
for (Field f : cri.getContextFields()) {
Object value = f.getType() == Application.class ? app :
cri.getContextFieldProxy(f);
+ try {
+ synchronized (instance) {
+ if (value == InjectionUtils.extractFieldValue(f,
instance)) {
+ continue;
+ }
+ }
+ } catch (Throwable t) {
+ // continue
+ }
InjectionUtils.injectFieldValue(f, instance, value);
}
}
Modified:
cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java?rev=1564766&r1=1564765&r2=1564766&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
Wed Feb 5 13:23:12 2014
@@ -41,6 +41,8 @@ import org.springframework.web.context.s
public class CXFServlet extends CXFNonSpringServlet
implements ApplicationListener<ContextRefreshedEvent> {
private static final long serialVersionUID = -5922443981969455305L;
+ private static final String BUS_PARAMETER = "bus";
+
private boolean busCreated;
private XmlWebApplicationContext createdContext;
@@ -72,7 +74,10 @@ public class CXFServlet extends CXFNonSp
wac = createSpringContext(wac, servletConfig, configLocation);
}
if (wac != null) {
- setBus((Bus)wac.getBean("cxf", Bus.class));
+ String busParam = servletConfig.getInitParameter(BUS_PARAMETER);
+ String busName = busParam == null ? "cxf" : busParam.trim();
+
+ setBus((Bus)wac.getBean(busName, Bus.class));
} else {
busCreated = true;
setBus(BusFactory.newInstance().createBus());
Modified:
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomInFaultyInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomInFaultyInterceptor.java?rev=1564766&r1=1564765&r2=1564766&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomInFaultyInterceptor.java
(original)
+++
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomInFaultyInterceptor.java
Wed Feb 5 13:23:12 2014
@@ -28,7 +28,7 @@ import org.apache.cxf.phase.Phase;
public class CustomInFaultyInterceptor extends
AbstractPhaseInterceptor<Message> {
public CustomInFaultyInterceptor() {
- super(Phase.PRE_INVOKE);
+ super(Phase.PRE_LOGICAL);
}
public void handleMessage(Message message) throws Fault {
Modified:
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java?rev=1564766&r1=1564765&r2=1564766&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
(original)
+++
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
Wed Feb 5 13:23:12 2014
@@ -96,6 +96,7 @@ public class JAXRSClientServerResourceJa
"http://localhost:" + PORT + "/webapp/store2";
BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress,
BookStoreSpring.class,
Collections.singletonList(new JacksonJsonProvider()));
+
WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(10000000L);
List<SuperBook> books =
proxy.echoSuperBookCollectionJson(Collections.singletonList(new
SuperBook("Super", 124L, true)));
assertEquals(124L, books.get(0).getId());
@@ -118,7 +119,7 @@ public class JAXRSClientServerResourceJa
public void testEchoGenericSuperBookCollectionProxy() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT + "/webapp/genericstore";
+ "http://localhost:" + PORT + "/webapp/custombus/genericstore";
GenericBookStoreSpring proxy =
JAXRSClientFactory.create(endpointAddress,
GenericBookStoreSpring.class, Collections.singletonList(new
JacksonJsonProvider()));
List<SuperBook> books =
@@ -131,7 +132,7 @@ public class JAXRSClientServerResourceJa
public void testEchoGenericSuperBookProxy() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT + "/webapp/genericstore";
+ "http://localhost:" + PORT + "/webapp/custombus/genericstore";
GenericBookStoreSpring proxy =
JAXRSClientFactory.create(endpointAddress,
GenericBookStoreSpring.class, Collections.singletonList(new
JacksonJsonProvider()));
WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L);
@@ -170,7 +171,7 @@ public class JAXRSClientServerResourceJa
public void testEchoGenericSuperBookWebClient() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT +
"/webapp/genericstore/books/superbook";
+ "http://localhost:" + PORT +
"/webapp/custombus/genericstore/books/superbook";
WebClient wc = WebClient.create(endpointAddress,
Collections.singletonList(new
JacksonJsonProvider()));
wc.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON);
@@ -183,7 +184,7 @@ public class JAXRSClientServerResourceJa
public void testEchoGenericSuperBookWebClientXml() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT +
"/webapp/genericstore/books/superbook";
+ "http://localhost:" + PORT +
"/webapp/custombus/genericstore/books/superbook";
WebClient wc = WebClient.create(endpointAddress);
wc.accept(MediaType.APPLICATION_XML).type(MediaType.APPLICATION_XML);
SuperBook book = wc.post(new SuperBook("Super", 124L, true),
SuperBook.class);
@@ -195,7 +196,7 @@ public class JAXRSClientServerResourceJa
public void testEchoGenericSuperBookCollectionWebClient() throws Exception
{
String endpointAddress =
- "http://localhost:" + PORT +
"/webapp/genericstore/books/superbooks";
+ "http://localhost:" + PORT +
"/webapp/custombus/genericstore/books/superbooks";
WebClient wc = WebClient.create(endpointAddress,
Collections.singletonList(new
JacksonJsonProvider()));
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L);
@@ -213,7 +214,7 @@ public class JAXRSClientServerResourceJa
public void testGetGenericSuperBookCollectionWebClient() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT +
"/webapp/genericstore/books/superbooks2";
+ "http://localhost:" + PORT +
"/webapp/custombus/genericstore/books/superbooks2";
WebClient wc = WebClient.create(endpointAddress,
Collections.singletonList(new
JacksonJsonProvider()));
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L);
@@ -230,7 +231,7 @@ public class JAXRSClientServerResourceJa
public void testEchoGenericSuperBookCollectionWebClientXml() throws
Exception {
String endpointAddress =
- "http://localhost:" + PORT +
"/webapp/genericstore/books/superbooks";
+ "http://localhost:" + PORT +
"/webapp/custombus/genericstore/books/superbooks";
WebClient wc = WebClient.create(endpointAddress);
wc.accept(MediaType.APPLICATION_XML).type(MediaType.APPLICATION_XML);
Collection<? extends SuperBook> books =
Modified:
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml?rev=1564766&r1=1564765&r2=1564766&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml
(original)
+++
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml
Wed Feb 5 13:23:12 2014
@@ -20,13 +20,16 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:core="http://cxf.apache.org/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/core
+http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:/META-INF/cxf/cxf.xml"/>
-
+
<jaxrs:server id="bookservice"
address="/store1">
<jaxrs:serviceBeans>
@@ -47,7 +50,10 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
</jaxrs:providers>
</jaxrs:server>
+ <core:bus name="cxf1" id="cxf1"/>
+
<jaxrs:server id="genericBookStore"
+ bus="cxf1"
address="/genericstore">
<jaxrs:serviceBeans>
<ref bean="gBookStore"/>
Modified:
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/web.xml?rev=1564766&r1=1564765&r2=1564766&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/web.xml
(original)
+++
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/web.xml
Wed Feb 5 13:23:12 2014
@@ -24,23 +24,45 @@
-->
<!-- START SNIPPET: webxml -->
<web-app>
-
- <servlet>
- <servlet-name>CXFServlet</servlet-name>
- <display-name>CXF Servlet</display-name>
- <servlet-class>
- org.apache.cxf.transport.servlet.CXFServlet
- </servlet-class>
- <init-param>
- <param-name>config-location</param-name>
- <param-value>/WEB-INF/beans.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>CXFServlet</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>WEB-INF/beans.xml</param-value>
+ </context-param>
+ <listener>
+ <listener-class>
+ org.springframework.web.context.ContextLoaderListener
+ </listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>CXFServlet</servlet-name>
+ <display-name>CXF Servlet</display-name>
+ <servlet-class>
+ org.apache.cxf.transport.servlet.CXFServlet
+ </servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>CXFServletBus</servlet-name>
+ <display-name>CXF Servlet Bus</display-name>
+ <servlet-class>
+ org.apache.cxf.transport.servlet.CXFServlet
+ </servlet-class>
+ <init-param>
+ <param-name>bus</param-name>
+ <param-value>
+ cxf1
+ </param-value>
+ </init-param>
+
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>CXFServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>CXFServletBus</servlet-name>
+ <url-pattern>/custombus/*</url-pattern>
+ </servlet-mapping>
</web-app>
-<!-- END SNIPPET: webxml -->
\ No newline at end of file
+<!-- END SNIPPET: webxml -->