cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1565628 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/
Date Fri, 07 Feb 2014 12:17:53 GMT
Author: sergeyb
Date: Fri Feb  7 12:17:53 2014
New Revision: 1565628

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

........
  r1565616 | sergeyb | 2014-02-07 10:51:43 +0000 (Fri, 07 Feb 2014) | 1 line
  
  [CXF-5542] Minor updates
........

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/utils/InjectionUtils.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml

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

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=1565628&r1=1565627&r2=1565628&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
Fri Feb  7 12:17:53 2014
@@ -122,7 +122,6 @@ public abstract class AbstractResourceIn
     }
     
     private static ThreadLocalProxy<?> getFieldThreadLocalProxy(Field f, Object provider)
{
-        ThreadLocalProxy<?> defaultValue = InjectionUtils.createThreadLocalProxy(f.getType());

         if (provider != null) {
             Object proxy = null;
             synchronized (provider) {
@@ -132,18 +131,17 @@ public abstract class AbstractResourceIn
                     // continue
                 }
                 if (!(proxy instanceof ThreadLocalProxy)) {
-                    proxy = defaultValue;
+                    proxy = InjectionUtils.createThreadLocalProxy(f.getType());
                     InjectionUtils.injectFieldValue(f, provider, proxy);
                 }
             }
             return (ThreadLocalProxy<?>)proxy;
         } else {
-            return defaultValue;
+            return InjectionUtils.createThreadLocalProxy(f.getType());
         }
     }
     
     private static ThreadLocalProxy<?> getMethodThreadLocalProxy(Method m, Object provider)
{
-        ThreadLocalProxy<?> defaultValue = InjectionUtils.createThreadLocalProxy(m.getParameterTypes()[0]);

         if (provider != null) {
             Object proxy = null;
             synchronized (provider) {
@@ -155,24 +153,27 @@ public abstract class AbstractResourceIn
                     // continue
                 }
                 if (!(proxy instanceof ThreadLocalProxy)) {
-                    proxy = defaultValue;
+                    proxy = InjectionUtils.createThreadLocalProxy(m.getParameterTypes()[0]);
                     InjectionUtils.injectThroughMethod(provider, m, proxy);
                 }
             }
             return (ThreadLocalProxy<?>)proxy;
         } else {
-            return defaultValue;
+            return InjectionUtils.createThreadLocalProxy(m.getParameterTypes()[0]);
         }
     }
     
     @SuppressWarnings("unchecked")
     private <T> Map<Class<?>, Map<T, ThreadLocalProxy<?>>>
getProxyMap(Class<T> keyCls, String prop) {
-        Object property = bus.getProperty(prop);
-        if (property == null) {
-            Map<Class<?>, Map<T, ThreadLocalProxy<?>>> map
-                = new ConcurrentHashMap<Class<?>, Map<T, ThreadLocalProxy<?>>>(2);
-            bus.setProperty(prop, map);
-            property = map;
+        Object property = null;
+        synchronized (bus) {
+            property = bus.getProperty(prop);
+            if (property == null) {
+                Map<Class<?>, Map<T, ThreadLocalProxy<?>>> map
+                    = new ConcurrentHashMap<Class<?>, Map<T, ThreadLocalProxy<?>>>(2);
+                bus.setProperty(prop, map);
+                property = map;
+            }
         }
         return (Map<Class<?>, Map<T, ThreadLocalProxy<?>>>)property;
     }
@@ -288,8 +289,9 @@ public abstract class AbstractResourceIn
     }
     
     private Map<Class<?>, List<Field>> addContextField(Map<Class<?>,
List<Field>> theFields, Field f) {
-        
-        theFields = theFields == null ? new HashMap<Class<?>, List<Field>>()
: theFields;
+        if (theFields == null) {
+            theFields = new HashMap<Class<?>, List<Field>>();
+        }
         
         List<Field> fields = theFields.get(serviceClass);
         if (fields == null) {
@@ -302,12 +304,13 @@ public abstract class AbstractResourceIn
         return theFields;
     }
     
-    private <T, V> void addToMap(Map<Class<?>, Map<T, V>> theFields,

-                               T f, V proxy) {
-        Map<T, V> proxies = theFields.get(serviceClass);
+    private <T, V> void addToMap(Map<Class<?>, Map<T, V>> proxyMap,
+                                 T f, 
+                                 V proxy) {
+        Map<T, V> proxies = proxyMap.get(serviceClass);
         if (proxies == null) {
             proxies = new HashMap<T, V>();
-            theFields.put(serviceClass, proxies);
+            proxyMap.put(serviceClass, proxies);
         }
         if (!proxies.containsKey(f)) {
             proxies.put(f, proxy);

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=1565628&r1=1565627&r2=1565628&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
Fri Feb  7 12:17:53 2014
@@ -1001,37 +1001,35 @@ public final class InjectionUtils {
         if (!cri.contextsAvailable() || !cri.isSingleton()) {
             return;
         }
-        
-        for (Map.Entry<Class<?>, Method> entry : cri.getContextMethods().entrySet())
{
-            Method method = entry.getValue();
-            Object value = method.getParameterTypes()[0] == Application.class 
-                ? app : cri.getContextSetterProxy(method);
-            try {
-                synchronized (instance) {
+        synchronized (instance) {        
+            for (Map.Entry<Class<?>, Method> entry : cri.getContextMethods().entrySet())
{
+                Method method = entry.getValue();
+                Object value = method.getParameterTypes()[0] == Application.class 
+                    ? app : cri.getContextSetterProxy(method);
+                try {
                     if (value == InjectionUtils.extractFromMethod(instance, 
                                                                   getGetterFromSetter(method),

                                                                   false)) {
                         continue;
                     }
+                    
+                } catch (Throwable t) {
+                    // continue
                 }
-            } catch (Throwable t) {
-                // continue
+                InjectionUtils.injectThroughMethod(instance, method, value);
             }
-            InjectionUtils.injectThroughMethod(instance, method, value);
-        }
-        
-        for (Field f : cri.getContextFields()) {
-            Object value = f.getType() == Application.class ? app : cri.getContextFieldProxy(f);
-            try {
-                synchronized (instance) {
+            
+            for (Field f : cri.getContextFields()) {
+                Object value = f.getType() == Application.class ? app : cri.getContextFieldProxy(f);
+                try {
                     if (value == InjectionUtils.extractFieldValue(f, instance)) {
                         continue;
                     }
+                } catch (Throwable t) {
+                    // continue
                 }
-            } catch (Throwable t) {
-                // continue
+                InjectionUtils.injectFieldValue(f, instance, value);
             }
-            InjectionUtils.injectFieldValue(f, instance, value);
         }
     }
     

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=1565628&r1=1565627&r2=1565628&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
Fri Feb  7 12:17:53 2014
@@ -69,11 +69,12 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
             <ref bean="gBookStore2"/>
         </jaxrs:serviceBeans>
         <jaxrs:providers>
-            <ref bean="jackson"/>
+            <ref bean="jackson2"/>
         </jaxrs:providers>
     </jaxrs:server>
     
     <bean id="jackson" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
+    <bean id="jackson2" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
     <bean id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStore"/>
     <bean id="bookstore2" class="org.apache.cxf.systest.jaxrs.BookStoreSpring"/>
     <bean id="gBookStore" class="org.apache.cxf.systest.jaxrs.GenericBookStoreSpring"/>



Mime
View raw message