cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [2/2] git commit: [CXF-5897] Using full class names, avoiding direct refs to 2.0 contexts (to support loading CXF 3.0 into 1.1 envs) in a static map
Date Wed, 30 Jul 2014 09:56:54 GMT
[CXF-5897] Using full class names, avoiding direct refs to 2.0 contexts (to support loading
CXF 3.0 into 1.1 envs) in a static map


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6ad60954
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6ad60954
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6ad60954

Branch: refs/heads/3.0.x-fixes
Commit: 6ad6095498705289e2495f4dfe0044975c5402fd
Parents: 618ec13
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jul 30 12:37:50 2014 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jul 30 12:56:16 2014 +0300

----------------------------------------------------------------------
 .../cxf/jaxrs/model/AbstractResourceInfo.java   | 46 +++++++++++---------
 1 file changed, 25 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6ad60954/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
index 15dbfa0..e8693c8 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
@@ -32,10 +32,7 @@ import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.logging.Logger;
 
-import javax.ws.rs.container.ResourceContext;
-import javax.ws.rs.container.ResourceInfo;
 import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Configuration;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Request;
@@ -58,19 +55,21 @@ public abstract class AbstractResourceInfo {
     
     private static final Set<String> STANDARD_CONTEXT_CLASSES = new HashSet<String>();
     static {
-        STANDARD_CONTEXT_CLASSES.add(Application.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(UriInfo.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(HttpHeaders.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(Request.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(SecurityContext.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(Providers.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(ResourceContext.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(Configuration.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(ResourceInfo.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add(ContextResolver.class.getSimpleName());
-        STANDARD_CONTEXT_CLASSES.add("HttpServletRequest");
-        STANDARD_CONTEXT_CLASSES.add("HttpServletResponse");
-        STANDARD_CONTEXT_CLASSES.add("ServletContext");
+        // JAX-RS 1.0-1.1
+        STANDARD_CONTEXT_CLASSES.add(Application.class.getName());
+        STANDARD_CONTEXT_CLASSES.add(UriInfo.class.getName());
+        STANDARD_CONTEXT_CLASSES.add(HttpHeaders.class.getName());
+        STANDARD_CONTEXT_CLASSES.add(Request.class.getName());
+        STANDARD_CONTEXT_CLASSES.add(SecurityContext.class.getName());
+        STANDARD_CONTEXT_CLASSES.add(Providers.class.getName());
+        STANDARD_CONTEXT_CLASSES.add(ContextResolver.class.getName());
+        STANDARD_CONTEXT_CLASSES.add("javax.servlet.http.HttpServletRequest");
+        STANDARD_CONTEXT_CLASSES.add("javax.servlet.http.HttpServletResponse");
+        STANDARD_CONTEXT_CLASSES.add("javax.servlet.ServletContext");
+        // JAX-RS 2.0
+        STANDARD_CONTEXT_CLASSES.add("javax.ws.rs.container.ResourceContext");
+        STANDARD_CONTEXT_CLASSES.add("javax.ws.rs.container.ResourceInfo");
+        STANDARD_CONTEXT_CLASSES.add("javax.ws.rs.core.Configuration");
     }
     
     protected boolean root;
@@ -151,7 +150,8 @@ public abstract class AbstractResourceInfo {
             for (Annotation a : f.getAnnotations()) {
                 if (a.annotationType() == Context.class) {
                     contextFields = addContextField(contextFields, f);
-                    if (f.getType() != Application.class) {
+                    if (f.getType().isInterface()) {
+                        checkContextClass(f.getType());
                         addToMap(getFieldProxyMap(true), f, getFieldThreadLocalProxy(f, provider));
                     }
                 }
@@ -271,11 +271,15 @@ public abstract class AbstractResourceInfo {
     
     private void checkContextMethod(Method m, Object provider) {
         Class<?> type = m.getParameterTypes()[0];
-        if (type.isInterface() || (type == Application.class)) {        
+        if (type.isInterface() || type == Application.class) {        
+            checkContextClass(type);
             addContextMethod(type, m, provider);
-            if (!STANDARD_CONTEXT_CLASSES.contains(type.getSimpleName())) {
-                LOG.fine("Injecting a custom context " + type + ", ContextProvider is required
for this type");
-            }
+        }
+    }
+    private void checkContextClass(Class<?> type) {
+        if (!STANDARD_CONTEXT_CLASSES.contains(type.getName())) {
+            LOG.fine("Injecting a custom context " + type.getName() 
+                     + ", ContextProvider is required for this type");
         }
     }
     


Mime
View raw message