cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1513438 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/test/java/org/apac...
Date Tue, 13 Aug 2013 10:57:56 GMT
Author: sergeyb
Date: Tue Aug 13 10:57:56 2013
New Revision: 1513438

URL: http://svn.apache.org/r1513438
Log:
Removing the dead code from AbstractResourceInfo, especially now that custom Contexts are
supported, dropping support for Resource annotations on context classes on fields (already
not supported on setters or method parameters)

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java?rev=1513438&r1=1513437&r2=1513438&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
Tue Aug 13 10:57:56 2013
@@ -29,14 +29,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.annotation.Resource;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Context;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalProxy;
-import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 
 public abstract class AbstractResourceInfo {
@@ -118,8 +116,7 @@ public abstract class AbstractResourceIn
         }
         for (Field f : cls.getDeclaredFields()) {
             for (Annotation a : f.getAnnotations()) {
-                if (a.annotationType() == Context.class || a.annotationType() == Resource.class

-                    && AnnotationUtils.isContextClass(f.getType())) {
+                if (a.annotationType() == Context.class) {
                     contextFields = addContextField(contextFields, f);
                     if (f.getType() != Application.class) {
                         addToMap(getFieldProxyMap(true), f, InjectionUtils.createThreadLocalProxy(f.getType()));

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java?rev=1513438&r1=1513437&r2=1513438&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
Tue Aug 13 10:57:56 2013
@@ -24,15 +24,9 @@ import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
-import java.util.ResourceBundle;
 import java.util.Set;
-import java.util.logging.Logger;
 
 import javax.annotation.Priority;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.BeanParam;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.CookieParam;
@@ -47,31 +41,13 @@ import javax.ws.rs.PathParam;
 import javax.ws.rs.Priorities;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
-import javax.ws.rs.container.ResourceContext;
-import javax.ws.rs.container.ResourceInfo;
-import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.SecurityContext;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.ext.ContextResolver;
-import javax.ws.rs.ext.Providers;
-
-import org.apache.cxf.common.i18n.BundleUtils;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.jaxrs.ext.MessageContext;
 
 public final class AnnotationUtils {
 
-    private static final Logger LOG = LogUtils.getL7dLogger(AnnotationUtils.class);
-    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AnnotationUtils.class);
-
-    private static final Set<Class<?>> CONTEXT_CLASSES;
     private static final Set<Class<?>> PARAM_ANNOTATION_CLASSES;
     private static final Set<Class<?>> METHOD_ANNOTATION_CLASSES;
     static {
-        CONTEXT_CLASSES = initContextClasses();
         PARAM_ANNOTATION_CLASSES = initParamAnnotationClasses();
         METHOD_ANNOTATION_CLASSES = initMethodAnnotationClasses();
     }
@@ -79,34 +55,7 @@ public final class AnnotationUtils {
     private AnnotationUtils() {
 
     }
-
-    private static Set<Class<?>> initContextClasses() {
-        Set<Class<?>> classes = new HashSet<Class<?>>();
-        classes.add(UriInfo.class);
-        classes.add(SecurityContext.class);
-        classes.add(HttpHeaders.class);
-        classes.add(ContextResolver.class);
-        classes.add(Providers.class);
-        classes.add(Request.class);
-        classes.add(ResourceInfo.class);
-        classes.add(ResourceContext.class);
-        classes.add(Application.class);
-        // Servlet API
-        try {
-            classes.add(HttpServletRequest.class);
-            classes.add(HttpServletResponse.class);
-            classes.add(ServletConfig.class);
-            classes.add(ServletContext.class);
-        } catch (Throwable ex) {
-            // it is not a problem on the client side and the exception will be
-            // thrown later on if the injection of one of these contexts will be
-            // attempted on the server side
-            LOG.fine(new org.apache.cxf.common.i18n.Message("NO_SERVLET_API", BUNDLE).toString());
-        }
-        // CXF-specific
-        classes.add(MessageContext.class);
-        return classes;
-    }
+    
 
     private static Set<Class<?>> initParamAnnotationClasses() {
         Set<Class<?>> classes = new HashSet<Class<?>>();
@@ -147,10 +96,6 @@ public final class AnnotationUtils {
         return names;
     }
     
-    public static boolean isContextClass(Class<?> contextClass) {
-        return CONTEXT_CLASSES.contains(contextClass);
-    }
-
     public static boolean isParamAnnotationClass(Class<?> annotationClass) {
         return PARAM_ANNOTATION_CLASSES.contains(annotationClass);
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=1513438&r1=1513437&r2=1513438&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java Tue Aug 13
10:57:56 2013
@@ -29,7 +29,6 @@ import java.util.UUID;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -138,9 +137,9 @@ public class Customer extends AbstractCu
     private Application application2;
     private int applicationInjections;
     
-    @Resource private HttpServletRequest servletRequest;
-    @Resource private HttpServletResponse servletResponse;
-    @Resource private ServletContext servletContext;
+    @Context private HttpServletRequest servletRequest;
+    @Context private HttpServletResponse servletResponse;
+    @Context private ServletContext servletContext;
     @Context private HttpServletRequest servletRequest2;
     @Context private HttpServletResponse servletResponse2;
     @Context private ServletContext servletContext2;

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java?rev=1513438&r1=1513437&r2=1513438&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
Tue Aug 13 10:57:56 2013
@@ -29,7 +29,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import javax.annotation.Resource;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -59,9 +58,9 @@ public class ClassResourceInfoTest exten
     public static class TestClass {
         @Context UriInfo u;
         @Context HttpHeaders h;
-        @Resource HttpServletRequest req;
-        @Resource HttpServletResponse res;
-        @Resource ServletContext c;
+        @Context HttpServletRequest req;
+        @Context HttpServletResponse res;
+        @Context ServletContext c;
         int i;
         
         @GET
@@ -95,9 +94,9 @@ public class ClassResourceInfoTest exten
     }
     
     static class TestClass3 {
-        @Resource HttpServletRequest req;
-        @Resource HttpServletResponse res;
-        @Resource ServletContext c;
+        @Context HttpServletRequest req;
+        @Context HttpServletResponse res;
+        @Context ServletContext c;
         
         @GET
         public void getIt() { 

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java?rev=1513438&r1=1513437&r2=1513438&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java
Tue Aug 13 10:57:56 2013
@@ -27,6 +27,7 @@ import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import javax.jws.WebMethod;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.xml.bind.JAXBContext;
@@ -47,7 +48,7 @@ public class BookStoreSoapRestImpl imple
 
     private Map<Long, Book> books = new HashMap<Long, Book>();
     private boolean ignoreJaxrsClient;
-    @Resource
+    @Context
     private MessageContext jaxrsContext;
     
     @Resource(name = "restClient")



Mime
View raw message