cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1453798 [1/2] - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/a...
Date Thu, 07 Mar 2013 12:10:32 GMT
Author: sergeyb
Date: Thu Mar  7 12:10:31 2013
New Revision: 1453798

URL: http://svn.apache.org/r1453798
Log:
[CXF-4882] Removing CXF JAX-RS filter extensions

Removed:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/RequestHandler.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResponseHandler.java
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/JAASAuthenticationFilter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/SimpleAuthorizingFilter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/WadlGeneratorTest.java
    cxf/trunk/rt/rs/security/cors/src/main/java/org/apache/cxf/rs/security/cors/CrossOriginResourceSharingFilter.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/OAuthRequestFilter.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/auth/saml/Saml2BearerAuthHandler.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/filters/OAuthRequestFilter.java
    cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/AbstractServiceProviderFilter.java
    cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlPostBindingFilter.java
    cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlRedirectBindingFilter.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/AbstractSamlInHandler.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedInHandler.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlFormInHandler.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlHeaderInHandler.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/authorization/ClaimsAuthorizingFilter.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/XmlEncInHandler.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/XmlSigInHandler.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyRequestHandler.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FormatResponseHandler.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamWriterProvider.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Thu Mar  7 12:10:31 2013
@@ -240,14 +240,15 @@ public class JAXRSInvoker extends Abstra
                                                          httpMethod,
                                                          values,
                                                          contentType,
-                                                         acceptContentType,
-                                                         true);
+                                                         acceptContentType);
                 exchange.put(OperationResourceInfo.class, subOri);
                 inMessage.put(URITemplate.TEMPLATE_PARAMETERS, values);
             
                 if (JAXRSUtils.runContainerRequestFilters(providerFactory,
                                                       inMessage,
-                                                      false, subOri.getNameBindings())) {
+                                                      false, 
+                                                      subOri.getNameBindings(),
+                                                      true)) {
                     return new MessageContentsList(exchange.get(Response.class));
                 }
                 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java Thu Mar  7 12:10:31 2013
@@ -26,14 +26,10 @@ import java.util.Map;
 
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
-import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.message.Message;
 
@@ -80,10 +76,6 @@ public class RequestPreprocessor {
         handleTypeQuery(m, queries);
         handleCType(m, queries);
         handleMethod(m, queries, new HttpHeadersImpl(m));
-        Response r = checkMetadataRequest(m, u);
-        if (r != null) {
-            m.getExchange().put(Response.class, r);
-        }
         return new UriInfoImpl(m, null).getPath();
     }
     
@@ -181,45 +173,6 @@ public class RequestPreprocessor {
         ((Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS))
         .put(HttpHeaders.ACCEPT, Collections.singletonList(acceptValue));
     }
-    
-    /*
-     * TODO : looks like QueryHandler is well suited for the purpose of serving
-     * wadl/wsdl2 root requests with URIs which can not be used for selecting
-     * ClassResourceInfo which is where RequestFilters invoked after the resource class
-     * has been selected are handy. Consider implementing this method as part of the QueryHandler,
-     * we will need to save the list of ClassResourceInfos on the EndpointInfo though
-     */
-    public Response checkMetadataRequest(Message m, UriInfo ui) {
-        String originalRequestURI = (String)m.get(Message.REQUEST_URI);
-        String query = (String)m.get(Message.QUERY_STRING);
-        if (query != null && query.contains(WadlGenerator.WADL_QUERY)) {
-            String requestURI = getValueWithoutSlash(originalRequestURI);
-            String baseAddress = getValueWithoutSlash(HttpUtils.getBaseAddress(m));
-            if (baseAddress.equals(requestURI)) {
-                return handleMetadataRequest(m);
-            }
-        } else if (originalRequestURI != null && originalRequestURI.endsWith(".xsd")) {
-            // trying WADLGenerator which may be caching schema resources won't
-            // interfere with custom schema handlers if any
-            return handleMetadataRequest(m);
-        }
-        return null;
-    }
-    
-    private Response handleMetadataRequest(Message m) { 
-        List<ProviderInfo<RequestHandler>> shs = ServerProviderFactory.getInstance(m).getRequestHandlers();
-        // this is actually being tested by ProviderFactory unit tests but just in case
-        // WadlGenerator, the custom or default one, must be the first one
-        if (shs.size() > 0 && shs.get(0).getProvider() instanceof WadlGenerator) {
-            return shs.get(0).getProvider().handleRequest(m, null);
-        } else {
-            return null;
-        }
-    }
-    
-    private static String getValueWithoutSlash(String value) {
-        return value.endsWith("/") ? value.substring(0, value.length() - 1) : value;
-    }
-    
+        
     
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Thu Mar  7 12:10:31 2013
@@ -36,18 +36,15 @@ import javax.ws.rs.core.Response;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
-import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
@@ -116,13 +113,10 @@ public class JAXRSInInterceptor extends 
         RequestPreprocessor rp = providerFactory.getRequestPreprocessor();
         if (rp != null) {
             rp.preprocess(message, new UriInfoImpl(message, null));
-            if (message.getExchange().get(Response.class) != null) {
-                return;
-            }
         }
         
         // Global pre-match request filters
-        if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null)) {
+        if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null, false)) {
             return;
         }
         
@@ -168,50 +162,21 @@ public class JAXRSInInterceptor extends 
         
         
         OperationResourceInfo ori = null;     
-        boolean operChecked = false;
-        List<ProviderInfo<RequestHandler>> shs = providerFactory.getRequestHandlers();
-        for (ProviderInfo<RequestHandler> sh : shs) {
-            if (ori == null && !operChecked) {
-                try {                
-                    ori = JAXRSUtils.findTargetMethod(matchedResources, 
-                        message, httpMethod, matchedValues,
-                        requestContentType, acceptContentTypes, false);
-                    setExchangeProperties(message, ori, matchedValues, resources.size());
-                } catch (WebApplicationException ex) {
-                    operChecked = true;
-                }
-                
-            }
-            InjectionUtils.injectContexts(sh.getProvider(), sh, message);
-            ClassResourceInfo cri = null;
-            if (ori == null && matchedResources.size() == 1) {
-                cri = matchedResources.keySet().iterator().next();
-            } else {
-                cri = ori.getClassResourceInfo();
-            }
-            Response response = sh.getProvider().handleRequest(message, cri);
-            if (response != null) {
+        
+        try {                
+            ori = JAXRSUtils.findTargetMethod(matchedResources, message, 
+                      httpMethod, matchedValues, requestContentType, acceptContentTypes, true);
+            setExchangeProperties(message, ori, matchedValues, resources.size());
+        } catch (WebApplicationException ex) {
+            if (JAXRSUtils.noResourceMethodForOptions(ex.getResponse(), httpMethod)) {
+                Response response = JAXRSUtils.createResponse(resources, null, null, 200, true);
                 message.getExchange().put(Response.class, response);
                 return;
+            } else {
+                throw ex;
             }
-            
         }
         
-        if (ori == null) {
-            try {                
-                ori = JAXRSUtils.findTargetMethod(matchedResources, message, 
-                                            httpMethod, matchedValues, requestContentType, acceptContentTypes, true);
-                setExchangeProperties(message, ori, matchedValues, resources.size());
-            } catch (WebApplicationException ex) {
-                if (JAXRSUtils.noResourceMethodForOptions(ex.getResponse(), httpMethod)) {
-                    Response response = JAXRSUtils.createResponse(resources, null, null, 200, true);
-                    message.getExchange().put(Response.class, response);
-                    return;
-                } else {
-                    throw ex;
-                }
-            }
-        }
 
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Request path is: " + rawPath);
@@ -228,7 +193,8 @@ public class JAXRSInInterceptor extends 
         if (JAXRSUtils.runContainerRequestFilters(providerFactory,
                                                   message,
                                                   false, 
-                                                  ori.getNameBindings())) {
+                                                  ori.getNameBindings(),
+                                                  false)) {
             return;
         }
         

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Thu Mar  7 12:10:31 2013
@@ -52,14 +52,12 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
 import org.apache.cxf.io.CachedOutputStream;
-import org.apache.cxf.jaxrs.ext.ResponseHandler;
 import org.apache.cxf.jaxrs.impl.AsyncResponseImpl;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.WriterInterceptorMBW;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider;
 import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
@@ -155,21 +153,10 @@ public class JAXRSOutInterceptor extends
         JAXRSUtils.runContainerResponseFilters(providerFactory, response, message, ori);
         Response updatedResponse = message.get(Response.class);
         if (updatedResponse != null) {
-            response = updatedResponse;
-        }
-        
-        List<ProviderInfo<ResponseHandler>> handlers = 
-            ServerProviderFactory.getInstance(message).getResponseHandlers();
-        for (ProviderInfo<ResponseHandler> rh : handlers) {
-            InjectionUtils.injectContexts(rh.getProvider(), rh, 
-                                               message.getExchange().getInMessage());
-            Response r = rh.getProvider().handleResponse(message, ori, response);
-            if (r != null) {
-                response = r;
-            }
-            
+            return updatedResponse;
+        } else {
+            return response;
         }
-        return response;
     }
     
     private int getStatus(Message message, int defaultValue) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java Thu Mar  7 12:10:31 2013
@@ -48,6 +48,8 @@ import java.util.logging.Logger;
 
 import javax.ws.rs.BadRequestException;
 import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -88,11 +90,10 @@ import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
 import org.apache.cxf.jaxrs.ext.Oneway;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.xml.XMLSource;
 import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
-import org.apache.cxf.jaxrs.impl.UriInfoImpl;
+import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.Parameter;
@@ -111,7 +112,7 @@ import org.apache.cxf.staxutils.Delegati
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.ws.commons.schema.XmlSchema;
 
-public class WadlGenerator implements RequestHandler {
+public class WadlGenerator implements ContainerRequestFilter {
 
     public static final String WADL_QUERY = "_wadl";
     public static final MediaType WADL_TYPE = MediaType.valueOf("application/vnd.sun.wadl+xml");
@@ -166,13 +167,18 @@ public class WadlGenerator implements Re
         this.useSingleSlashResource = other.useSingleSlashResource;
     }
 
-    public Response handleRequest(Message m, ClassResourceInfo resource) {
-
+    public void filter(ContainerRequestContext context) {
+    
+        Message m = JAXRSUtils.getCurrentMessage();
+        doFilter(context, m);
+    }
+    
+    protected void doFilter(ContainerRequestContext context, Message m) {
         if (!"GET".equals(m.get(Message.HTTP_REQUEST_METHOD))) {
-            return null;
+            return;
         }
 
-        UriInfo ui = new UriInfoImpl(m);
+        UriInfo ui = context.getUriInfo();
         if (!ui.getQueryParameters().containsKey(WADL_QUERY)) {
             if (!schemaLocationMap.isEmpty()) {
                 String path = ui.getPath(false);
@@ -180,14 +186,15 @@ public class WadlGenerator implements Re
                     path = path.substring(1);
                 }
                 if (schemaLocationMap.containsKey(path)) {
-                    return getExistingSchema(m, ui, path);
+                    context.abortWith(getExistingSchema(m, ui, path));
                 }
             }
-            return null;
+            return;
         }
 
         if (ignoreRequests) {
-            return Response.status(404).build();
+            context.abortWith(Response.status(404).build());
+            return;
         }
 
         HttpHeaders headers = new HttpHeadersImpl(m);
@@ -198,7 +205,8 @@ public class WadlGenerator implements Re
         
         Response response = getExistingWadl(m, ui, type);
         if (response != null) {
-            return response;
+            context.abortWith(response);
+            return;
         }
         
         boolean isJson = type == MediaType.APPLICATION_JSON_TYPE; 
@@ -215,18 +223,18 @@ public class WadlGenerator implements Re
         StringBuilder sbResources = new StringBuilder();
         sbResources.append("<resources base=\"").append(getBaseURI(m, ui)).append("\">");
 
-        List<ClassResourceInfo> cris = getResourcesList(m, resource);
+        List<ClassResourceInfo> cris = getResourcesList(m, ui);
 
         ResourceTypes resourceTypes =
             ResourceUtils.getAllRequestResponseTypes(cris, useJaxbContextForQnames);
         Set<Class<?>> allTypes = resourceTypes.getAllTypes().keySet();
         
-        JAXBContext context = useJaxbContextForQnames 
+        JAXBContext jaxbContext = useJaxbContextForQnames 
             ? ResourceUtils.createJaxbContext(new HashSet<Class<?>>(allTypes), null, null) : null;
         
-        SchemaWriter schemaWriter = createSchemaWriter(resourceTypes, context, ui);
+        SchemaWriter schemaWriter = createSchemaWriter(resourceTypes, jaxbContext, ui);
         ElementQNameResolver qnameResolver =
-            schemaWriter == null ? null : createElementQNameResolver(context);
+            schemaWriter == null ? null : createElementQNameResolver(jaxbContext);
 
         Map<Class<?>, QName> clsMap = new IdentityHashMap<Class<?>, QName>();
         Set<ClassResourceInfo> visitedResources = new LinkedHashSet<ClassResourceInfo>();
@@ -256,10 +264,11 @@ public class WadlGenerator implements Re
         sbMain.append("</application>");
 
         m.getExchange().put(JAXRSUtils.IGNORE_MESSAGE_WRITERS, ignoreMessageWriters);
-        return Response.ok().type(type).entity(
+        Response r = Response.ok().type(type).entity(
                 createResponseEntity(sbMain.toString(), isJson)).build();
+        context.abortWith(r);
     }
-
+    
     private Object createResponseEntity(String entity, boolean isJson) {
         if (!isJson) {
             return entity;
@@ -841,9 +850,26 @@ public class WadlGenerator implements Re
         return opsWithSamePath;
     }
 
-    public List<ClassResourceInfo> getResourcesList(Message m, ClassResourceInfo cri) {
-        return cri != null ? Collections.singletonList(cri)
-               : ((JAXRSServiceImpl)m.getExchange().get(Service.class)).getClassResourceInfos();
+    public List<ClassResourceInfo> getResourcesList(Message m, UriInfo ui) {
+        final String slash = "/";
+        String path = ui.getPath();
+        if (!path.startsWith(slash)) {
+            path = slash + path;
+        }
+        List<ClassResourceInfo> all = ((JAXRSServiceImpl)m.getExchange().get(Service.class))
+            .getClassResourceInfos();
+        if (slash.equals(path) && !ui.getAbsolutePath().getPath().endsWith(slash)) {
+            return all;
+        }
+        List<ClassResourceInfo> cris = new LinkedList<ClassResourceInfo>();
+        for (ClassResourceInfo cri : all) {
+            MultivaluedMap<String, String> map = new MetadataMap<String, String>();
+            if (cri.getURITemplate().match(path, map)
+                && slash.equals(map.getFirst(URITemplate.FINAL_MATCH_GROUP))) {
+                cris.add(cri);
+            }
+        }
+        return cris;
     }
     
     //TODO: deal with caching later on

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java Thu Mar  7 12:10:31 2013
@@ -49,8 +49,6 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.ext.ResponseHandler;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
 import org.apache.cxf.jaxrs.impl.ResourceInfoImpl;
@@ -70,20 +68,11 @@ public final class ServerProviderFactory
                         ContainerResponseFilter.class,
                         ReaderInterceptor.class,
                         WriterInterceptor.class};
-    // Server specific providers
     private List<ProviderInfo<ExceptionMapper<?>>> exceptionMappers = 
         new ArrayList<ProviderInfo<ExceptionMapper<?>>>(1);
     
-    // RequestHandler & ResponseHandler will have to be deprecated for 2.7.0
-    private List<ProviderInfo<RequestHandler>> requestHandlers = 
-        new ArrayList<ProviderInfo<RequestHandler>>(1);
-    private List<ProviderInfo<ResponseHandler>> responseHandlers = 
-        new ArrayList<ProviderInfo<ResponseHandler>>(1);
-    
-    // ContainerRequestFilter & ContainerResponseFilter are introduced in JAX-RS 2.0
     private List<ProviderInfo<ContainerRequestFilter>> preMatchContainerRequestFilters = 
         new ArrayList<ProviderInfo<ContainerRequestFilter>>(1);
-    //TODO: consider using List as a value type for postmatching filters
     private Map<NameKey, ProviderInfo<ContainerRequestFilter>> postMatchContainerRequestFilters = 
         new LinkedHashMap<NameKey, ProviderInfo<ContainerRequestFilter>>();
     private Map<NameKey, ProviderInfo<ContainerResponseFilter>> postMatchContainerResponseFilters = 
@@ -92,12 +81,14 @@ public final class ServerProviderFactory
     private ProviderInfo<Application> application;
     private List<DynamicFeature> dynamicFeatures = new LinkedList<DynamicFeature>();
     
-    // This may be better be kept at OperationResourceInfo ? Though we may have many methods
-    // across different resources that use the same BeanParam. 
     private Map<Class<?>, BeanParamInfo> beanParams = new HashMap<Class<?>, BeanParamInfo>();
-    
+    private ProviderInfo<ContainerRequestFilter> wadlGenerator;
+        
     private ServerProviderFactory(ProviderFactory baseFactory, Bus bus) {
         super(baseFactory, bus);
+        if (baseFactory == null) {
+            wadlGenerator = new ProviderInfo<ContainerRequestFilter>(new WadlGenerator(), bus);
+        }
     }
     
     public static ServerProviderFactory getInstance() {
@@ -126,19 +117,38 @@ public final class ServerProviderFactory
         }
         factory = new ServerProviderFactory(null, bus);
         ProviderFactory.initBaseFactory(factory);
-        factory.setProviders(new WebApplicationExceptionMapper(),
-                             new WadlGenerator());
+        factory.setProviders(new WebApplicationExceptionMapper());
+        
         bus.setProperty(SHARED_SERVER_FACTORY, factory);
         return factory;
     }
     
     public List<ProviderInfo<ContainerRequestFilter>> getPreMatchContainerRequestFilters() {
-        return Collections.unmodifiableList(preMatchContainerRequestFilters);
+        return getContainerRequestFilters(preMatchContainerRequestFilters, true);
     }
     
     public List<ProviderInfo<ContainerRequestFilter>> getPostMatchContainerRequestFilters(List<String> names) {
-        return getPostMatchContainerFilters(postMatchContainerRequestFilters, 
-                                            names);
+        return getPostMatchContainerFilters(postMatchContainerRequestFilters, names);
+        
+    }
+    
+    private List<ProviderInfo<ContainerRequestFilter>> getContainerRequestFilters(
+        List<ProviderInfo<ContainerRequestFilter>> filters, boolean syncNeeded) {
+        ProviderInfo<ContainerRequestFilter> generator = wadlGenerator != null ? wadlGenerator 
+            : ((ServerProviderFactory)getBaseFactory()).wadlGenerator;
+        if (filters.size() == 0) {
+            return Collections.singletonList(generator);
+        } else if (!syncNeeded) {
+            filters.add(0, generator);
+            return filters;
+        } else {
+            synchronized (filters) {
+                if (filters.get(0) != generator) {
+                    filters.add(0, generator);
+                }
+            }
+            return filters;
+        }
     }
     
     public List<ProviderInfo<ContainerResponseFilter>> getContainerResponseFilters(List<String> names) {
@@ -173,34 +183,6 @@ public final class ServerProviderFactory
         return list;
     }
     
-    public List<ProviderInfo<RequestHandler>> getRequestHandlers() {
-        List<ProviderInfo<RequestHandler>> handlers = null;
-        if (requestHandlers.size() == 0) {
-            handlers = ((ServerProviderFactory)getBaseFactory()).requestHandlers;
-        } else {
-            handlers = new ArrayList<ProviderInfo<RequestHandler>>();
-            boolean customWADLHandler = false;
-            for (int i = 0; i < requestHandlers.size(); i++) {
-                if (requestHandlers.get(i).getProvider() instanceof WadlGenerator) {
-                    customWADLHandler = true;
-                    break;
-                }
-            }
-            if (!customWADLHandler) {
-                // TODO : this works only because we know we only have a single 
-                // system handler which is a default WADLGenerator, think of a better approach
-                handlers.addAll(((ServerProviderFactory)getBaseFactory()).requestHandlers);    
-            }
-            handlers.addAll(requestHandlers);
-            
-        }
-        return Collections.unmodifiableList(handlers);
-    }
-    
-    public List<ProviderInfo<ResponseHandler>> getResponseHandlers() {
-        return Collections.unmodifiableList(responseHandlers);
-    }
-    
     public void addBeanParamInfo(BeanParamInfo bpi) {
         beanParams.put(bpi.getResourceClass(), bpi);
     }
@@ -248,26 +230,15 @@ public final class ServerProviderFactory
                 continue;
             }
             Class<?> oClass = ClassHelper.getRealClass(o);
-            
-            
-            if (RequestHandler.class.isAssignableFrom(oClass)) {
-                requestHandlers.add(new ProviderInfo<RequestHandler>((RequestHandler)o, getBus())); 
-            }
-            
-            if (ResponseHandler.class.isAssignableFrom(oClass)) {
-                responseHandlers.add(new ProviderInfo<ResponseHandler>((ResponseHandler)o, getBus())); 
-            }
-            
+                        
             if (ContainerRequestFilter.class.isAssignableFrom(oClass)) {
-                addContainerFilter(postMatchRequestFilters,
-                   new ProviderInfo<ContainerRequestFilter>((ContainerRequestFilter)o, getBus()),
-                   preMatchContainerRequestFilters);
+                addContainerRequestFilter(postMatchRequestFilters,
+                    new ProviderInfo<ContainerRequestFilter>((ContainerRequestFilter)o, getBus()));
             }
             
             if (ContainerResponseFilter.class.isAssignableFrom(oClass)) {
-                addContainerFilter(postMatchResponseFilters,
-                   new ProviderInfo<ContainerResponseFilter>((ContainerResponseFilter)o, getBus()),
-                   null); 
+                postMatchResponseFilters.add(
+                   new ProviderInfo<ContainerResponseFilter>((ContainerResponseFilter)o, getBus())); 
             }
             
             if (DynamicFeature.class.isAssignableFrom(oClass)) {
@@ -286,21 +257,25 @@ public final class ServerProviderFactory
         mapContainerFilters(postMatchContainerResponseFilters, postMatchResponseFilters, false);
         
         injectContextProxies( 
-            requestHandlers, responseHandlers, exceptionMappers,
+            exceptionMappers,
             postMatchContainerRequestFilters.values(), preMatchContainerRequestFilters,
             postMatchContainerResponseFilters.values(),
             readerInterceptors, writerInterceptors);
     }
 //CHECKSTYLE:ON
     
-    private static <T> void addContainerFilter(List<ProviderInfo<T>> postMatchFilters,
-                                               ProviderInfo<T> p,
-                                               List<ProviderInfo<T>> preMatchFilters) {
-        T filter = p.getProvider();
-        if (preMatchFilters != null && isPrematching(filter.getClass())) {
-            preMatchFilters.add(p);
+    private void addContainerRequestFilter(
+        List<ProviderInfo<ContainerRequestFilter>> postMatchFilters,
+        ProviderInfo<ContainerRequestFilter> p) {
+        ContainerRequestFilter filter = p.getProvider();
+        if (filter instanceof WadlGenerator) {
+            wadlGenerator = p; 
         } else {
-            postMatchFilters.add(p);
+            if (isPrematching(filter.getClass())) {
+                preMatchContainerRequestFilters.add(p);
+            } else {
+                postMatchFilters.add(p);
+            }
         }
         
     }
@@ -325,8 +300,6 @@ public final class ServerProviderFactory
     public void clearProviders() {
         super.clearProviders();
         exceptionMappers.clear();
-        requestHandlers.clear();
-        responseHandlers.clear();
         postMatchContainerRequestFilters.clear();
         postMatchContainerResponseFilters.clear();
         preMatchContainerRequestFilters.clear();
@@ -365,8 +338,7 @@ public final class ServerProviderFactory
     }
     
     protected static boolean isPrematching(Class<?> filterCls) {
-        return AnnotationUtils.getAnnotation(filterCls.getAnnotations(), 
-                                      PreMatching.class) != null;
+        return AnnotationUtils.getClassAnnotation(filterCls, PreMatching.class) != null;
     }
     
     private static <T> void mapContainerFilters(Map<NameKey, ProviderInfo<T>> map,

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/JAASAuthenticationFilter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/JAASAuthenticationFilter.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/JAASAuthenticationFilter.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/JAASAuthenticationFilter.java Thu Mar  7 12:10:31 2013
@@ -24,6 +24,9 @@ import java.util.List;
 
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.login.Configuration;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -34,15 +37,13 @@ import org.apache.cxf.common.util.String
 import org.apache.cxf.interceptor.security.AuthenticationException;
 import org.apache.cxf.interceptor.security.JAASLoginInterceptor;
 import org.apache.cxf.interceptor.security.NamePasswordCallbackHandler;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 
-
-public class JAASAuthenticationFilter implements RequestHandler {
+@PreMatching
+public class JAASAuthenticationFilter implements ContainerRequestFilter {
 
     private static final List<MediaType> HTML_MEDIA_TYPES = 
         Arrays.asList(MediaType.APPLICATION_XHTML_XML_TYPE, MediaType.TEXT_HTML_TYPE);
@@ -57,6 +58,12 @@ public class JAASAuthenticationFilter im
         }    
     };
     
+    @Deprecated
+    public void setRolePrefix(String name) {
+        interceptor.setRolePrefix(name);
+    }
+
+    
     public void setIgnoreBasePath(boolean ignore) {
         this.ignoreBasePath = ignore;
     }
@@ -69,11 +76,6 @@ public class JAASAuthenticationFilter im
         interceptor.setLoginConfig(config);
     }
     
-    @Deprecated
-    public void setRolePrefix(String name) {
-        interceptor.setRolePrefix(name);
-    }
-    
     public void setRedirectURI(String uri) {
         this.redirectURI = URI.create(uri);
     }
@@ -86,14 +88,14 @@ public class JAASAuthenticationFilter im
         return new NamePasswordCallbackHandler(name, password);
     }
     
-    public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
+    public void filter(ContainerRequestContext context) {
+        Message m = JAXRSUtils.getCurrentMessage();
         try {
             interceptor.handleMessage(m);
-            return null;
         } catch (AuthenticationException ex) {
-            return handleAuthenticationException(ex, m);
+            context.abortWith(handleAuthenticationException(ex, m));
         } catch (SecurityException ex) {
-            return handleAuthenticationException(ex, m);
+            context.abortWith(handleAuthenticationException(ex, m));
         }
     }
 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java Thu Mar  7 12:10:31 2013
@@ -29,6 +29,9 @@ import javax.security.auth.login.Configu
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 import javax.ws.rs.NotAuthorizedException;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
@@ -40,8 +43,7 @@ import org.apache.cxf.common.util.Base64
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.security.SecurityContext;
@@ -50,8 +52,8 @@ import org.ietf.jgss.GSSException;
 import org.ietf.jgss.GSSManager;
 import org.ietf.jgss.GSSName;
 import org.ietf.jgss.Oid;
-
-public class KerberosAuthenticationFilter implements RequestHandler {
+@PreMatching
+public class KerberosAuthenticationFilter implements ContainerRequestFilter {
 
     private static final Logger LOG = LogUtils.getL7dLogger(KerberosAuthenticationFilter.class);
     
@@ -67,7 +69,7 @@ public class KerberosAuthenticationFilte
     private String servicePrincipalName;
     private String realm;
     
-    public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
+    public void filter(ContainerRequestContext context) {
         
         List<String> authHeaders = messageContext.getHttpHeaders()
             .getRequestHeader(HttpHeaders.AUTHORIZATION);
@@ -106,7 +108,7 @@ public class KerberosAuthenticationFilte
                 gssContext.dispose();
                 gssContext = null;
             }
-
+            Message m = JAXRSUtils.getCurrentMessage();
             m.put(SecurityContext.class, 
                 new KerberosSecurityContext(new KerberosPrincipal(simpleUserName,
                                                                   complexUserName),
@@ -122,8 +124,6 @@ public class KerberosAuthenticationFilte
             LOG.fine("PrivilegedActionException: " + e.getMessage());
             throw new NotAuthorizedException(getFaultResponse());
         }
-        
-        return null;
     }
 
     protected GSSContext createGSSContext() throws GSSException {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/SimpleAuthorizingFilter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/SimpleAuthorizingFilter.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/SimpleAuthorizingFilter.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/SimpleAuthorizingFilter.java Thu Mar  7 12:10:31 2013
@@ -18,24 +18,23 @@
  */
 package org.apache.cxf.jaxrs.security;
 
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.core.Response;
 
 import org.apache.cxf.interceptor.security.AbstractAuthorizingInInterceptor;
 import org.apache.cxf.interceptor.security.AccessDeniedException;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.message.Message;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 
-public class SimpleAuthorizingFilter implements RequestHandler {
+public class SimpleAuthorizingFilter implements ContainerRequestFilter {
 
     private AbstractAuthorizingInInterceptor interceptor;
     
-    public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
+    public void filter(ContainerRequestContext context) {
         try {
-            interceptor.handleMessage(m);
-            return null;
+            interceptor.handleMessage(JAXRSUtils.getCurrentMessage());
         } catch (AccessDeniedException ex) {
-            return Response.status(Response.Status.FORBIDDEN).build();
+            context.abortWith(Response.status(Response.Status.FORBIDDEN).build());
         }
     }
 

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=1453798&r1=1453797&r2=1453798&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 Thu Mar  7 12:10:31 2013
@@ -131,7 +131,7 @@ public final class AnnotationUtils {
     }
 
     public static int getBindingPriority(Class<?> providerCls) {
-        Priority b = providerCls.getAnnotation(Priority.class);
+        Priority b = getClassAnnotation(providerCls, Priority.class);
         return b == null ? Priorities.USER : b.value();
     }
     public static List<String> getNameBindings(Annotation[] targetAnns) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Thu Mar  7 12:10:31 2013
@@ -139,6 +139,7 @@ import org.apache.cxf.jaxrs.provider.Ser
 import org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 
@@ -363,7 +364,16 @@ public final class JAXRSUtils {
         
         return null;
     }
-    
+    public static OperationResourceInfo findTargetMethod(
+        Map<ClassResourceInfo, MultivaluedMap<String, String>> matchedResources,
+        Message message,
+        String httpMethod, 
+        MultivaluedMap<String, String> matchedValues,
+        String requestContentType, 
+        List<MediaType> acceptContentTypes) {
+        return findTargetMethod(matchedResources, message, httpMethod, matchedValues,
+                                requestContentType, acceptContentTypes, true);
+    }
     public static OperationResourceInfo findTargetMethod(
         Map<ClassResourceInfo, MultivaluedMap<String, String>> matchedResources,
         Message message,
@@ -371,7 +381,7 @@ public final class JAXRSUtils {
         MultivaluedMap<String, String> matchedValues,
         String requestContentType, 
         List<MediaType> acceptContentTypes,
-        boolean logNow) {
+        boolean throwException) {
         
         final boolean isFineLevelLoggable = LOG.isLoggable(Level.FINE); 
                 
@@ -471,6 +481,10 @@ public final class JAXRSUtils {
             return ori;
         }
         
+        if (!throwException) {
+            return null;
+        }
+        
         int status;
         
         // criteria matched the least number of times will determine the error code;
@@ -495,7 +509,7 @@ public final class JAXRSUtils {
                                                    httpMethod,
                                                    requestType.toString(),
                                                    convertTypesToString(acceptContentTypes));
-        if (!"OPTIONS".equalsIgnoreCase(httpMethod) && logNow) {
+        if (!"OPTIONS".equalsIgnoreCase(httpMethod)) {
             LOG.warning(errorMsg.toString());
         }
         Response response = 
@@ -1501,8 +1515,11 @@ public final class JAXRSUtils {
         return XMLUtils.convertStringToQName(name, "");
     }
     
-    public static boolean runContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, 
-                                              List<String> names) {
+    public static boolean runContainerRequestFilters(ServerProviderFactory pf, 
+                                                     Message m, 
+                                                     boolean preMatch, 
+                                                     List<String> names,
+                                                     boolean sub) {
         List<ProviderInfo<ContainerRequestFilter>> containerFilters = preMatch 
             ? pf.getPreMatchContainerRequestFilters() : pf.getPostMatchContainerRequestFilters(names);
         if (!containerFilters.isEmpty()) {
@@ -1545,4 +1562,12 @@ public final class JAXRSUtils {
             }
         }
     }
+    
+    public static Message getCurrentMessage() {
+        return PhaseInterceptorChain.getCurrentMessage();
+    }
+    
+    public static ClassResourceInfo getRootResource(Message m) {
+        return (ClassResourceInfo)m.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java Thu Mar  7 12:10:31 2013
@@ -489,7 +489,7 @@ public class SelectMethodCandidatesTest 
          
         if (mResources != null) {
             OperationResourceInfo ori = JAXRSUtils.findTargetMethod(mResources, null, httpMethod, 
-                                                    values, requestContentType, acceptContentTypes, true);
+                                                    values, requestContentType, acceptContentTypes);
             if (ori != null) {
                 return ori;
             }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java Thu Mar  7 12:10:31 2013
@@ -24,22 +24,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
 import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.jaxrs.JAXRSServiceImpl;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
-import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.servlet.ServletDestination;
@@ -79,20 +69,6 @@ public class RequestPreprocessorTest ext
     }
     
     @Test
-    public void testWadlQuery() {
-        Message m = mockMessage("http://localhost:8080/bar", "/bar", "_wadl", "GET");
-        ClassResourceInfo cri = 
-            ResourceUtils.createClassResourceInfo(TestResource.class, TestResource.class, true, true);
-        m.getExchange().put(Service.class, new JAXRSServiceImpl(Collections.singletonList(cri)));
-        RequestPreprocessor sqh = new RequestPreprocessor();
-        sqh.preprocess(m, new UriInfoImpl(m, null));
-        Response r = m.getExchange().get(Response.class);
-        assertNotNull(r);
-        assertEquals(MediaType.APPLICATION_XML,
-                     r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE));
-    }
-    
-    @Test
     public void testTypeQuery() {
         Message m = mockMessage("http://localhost:8080", "/bar", "_type=xml", "POST");
         RequestPreprocessor sqh = new RequestPreprocessor();
@@ -149,14 +125,4 @@ public class RequestPreprocessorTest ext
         return m;
     }
     
-    @Path("/test")
-    private static class TestResource {
-        //suppress the unused get method warning in eclipse.   The class is private
-        //so nothing really calls the "get" method, but this is needed for the
-        //test case
-        @GET
-        public String get() {
-            return "test";
-        }
-    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java Thu Mar  7 12:10:31 2013
@@ -44,6 +44,7 @@ import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
+import org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Exchange;
@@ -74,7 +75,9 @@ public class WadlGeneratorTest extends A
     @Test
     public void testNoWadl() {
         WadlGenerator wg = new WadlGenerator();
-        assertNull(wg.handleRequest(new MessageImpl(), null));
+        Message m = new MessageImpl();
+        m.setExchange(new ExchangeImpl());
+        assertNull(handleRequest(wg, m));
     }
     
     @Test
@@ -84,9 +87,8 @@ public class WadlGeneratorTest extends A
         
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         checkGrammars(doc.getDocumentElement(), "thebook", "thebook2", "thechapter");
@@ -101,9 +103,8 @@ public class WadlGeneratorTest extends A
         
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         List<Element> grammarEls = DOMUtils.getChildrenWithName(doc.getDocumentElement(), 
@@ -137,9 +138,8 @@ public class WadlGeneratorTest extends A
         
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         checkGrammarsWithLinks(doc.getDocumentElement(), Collections.singletonList("http://books.xsd"));
@@ -154,9 +154,8 @@ public class WadlGeneratorTest extends A
         
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         checkGrammarsWithLinks(doc.getDocumentElement(), 
@@ -173,9 +172,8 @@ public class WadlGeneratorTest extends A
         
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         checkGrammarsWithLinks(doc.getDocumentElement(), 
@@ -192,9 +190,8 @@ public class WadlGeneratorTest extends A
         
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         checkGrammars(doc.getDocumentElement(), "book", "book2", "chapter");
@@ -209,9 +206,8 @@ public class WadlGeneratorTest extends A
         wg.setNamespacePrefix("ns");
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         checkDocs(doc.getDocumentElement(), "My Application", "", "");
@@ -231,9 +227,8 @@ public class WadlGeneratorTest extends A
         wg.setNamespacePrefix("ns");
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(TestResource.class, TestResource.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         checkDocs(doc.getDocumentElement(), "My Application", "", "");
@@ -259,9 +254,8 @@ public class WadlGeneratorTest extends A
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStoreWithSingleSlash.class, 
                                                   BookStoreWithSingleSlash.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
-        
-        Response r = wg.handleRequest(m, cri);
+        Message m = mockMessage("http://localhost:8080/baz", "/", WadlGenerator.WADL_QUERY, cri);
+        Response r = handleRequest(wg, m);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         List<Element> rootEls = getWadlResourcesInfo(doc, "http://localhost:8080/baz", 1);
@@ -303,8 +297,8 @@ public class WadlGeneratorTest extends A
         List<ClassResourceInfo> cris = new ArrayList<ClassResourceInfo>();
         cris.add(cri1);
         cris.add(cri2);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, cris);
-        Response r = wg.handleRequest(m, null);
+        Message m = mockMessage("http://localhost:8080/baz", "", WadlGenerator.WADL_QUERY, cris);
+        Response r = handleRequest(wg, m);
         assertEquals(WadlGenerator.WADL_TYPE.toString(),
                      r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE));
         String wadl = r.getEntity().toString();
@@ -316,6 +310,11 @@ public class WadlGeneratorTest extends A
         assertEquals("/orders", orderResource.getAttribute("path"));
     }
 
+    private Response handleRequest(WadlGenerator wg, Message m) {
+        wg.doFilter(new ContainerRequestContextImpl(m, true, false), m);
+        return m.getExchange().get(Response.class);
+    }
+    
     private void checkGrammars(Element appElement, 
                                String bookEl,
                                String book2El, 
@@ -752,7 +751,11 @@ public class WadlGeneratorTest extends A
         return resourceEls;
     }
     
-    
+    private Message mockMessage(String baseAddress, String pathInfo, String query,
+                                ClassResourceInfo cri) throws Exception {
+        return mockMessage(baseAddress, pathInfo, query, Collections.singletonList(cri));
+        
+    }
     private Message mockMessage(String baseAddress, String pathInfo, String query,
                                 List<ClassResourceInfo> cris) throws Exception {
         Message m = new MessageImpl();

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java Thu Mar  7 12:10:31 2013
@@ -35,6 +35,9 @@ import javax.activation.DataSource;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
@@ -54,11 +57,9 @@ import org.apache.cxf.jaxrs.Customer;
 import org.apache.cxf.jaxrs.CustomerParameterHandler;
 import org.apache.cxf.jaxrs.JAXBContextProvider;
 import org.apache.cxf.jaxrs.JAXBContextProvider2;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
 import org.apache.cxf.jaxrs.resources.Book;
@@ -90,34 +91,34 @@ public class ProviderFactoryTest extends
     @Test
     public void testCustomWadlHandler() {
         ServerProviderFactory pf = ServerProviderFactory.getInstance();
-        assertEquals(1, pf.getRequestHandlers().size());
-        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
+        assertEquals(1, pf.getPreMatchContainerRequestFilters().size());
+        assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator);
         
         WadlGenerator wg = new WadlGenerator();
         pf.setUserProviders(Collections.singletonList(wg));
-        assertEquals(1, pf.getRequestHandlers().size());
-        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
-        assertSame(wg, pf.getRequestHandlers().get(0).getProvider());
+        assertEquals(1, pf.getPreMatchContainerRequestFilters().size());
+        assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator);
+        assertSame(wg, pf.getPreMatchContainerRequestFilters().get(0).getProvider());
     }
     
     @Test
     public void testCustomTestHandler() {
         ServerProviderFactory pf = ServerProviderFactory.getInstance();
-        assertEquals(1, pf.getRequestHandlers().size());
-        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
+        assertEquals(1, pf.getPreMatchContainerRequestFilters().size());
+        assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator);
         
         TestHandler th = new TestHandler();
         pf.setUserProviders(Collections.singletonList(th));
-        assertEquals(2, pf.getRequestHandlers().size());
-        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
-        assertSame(th, pf.getRequestHandlers().get(1).getProvider());
+        assertEquals(2, pf.getPreMatchContainerRequestFilters().size());
+        assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator);
+        assertSame(th, pf.getPreMatchContainerRequestFilters().get(1).getProvider());
     }
     
     @Test
     public void testCustomTestAndWadlHandler() {
         ServerProviderFactory pf = ServerProviderFactory.getInstance();
-        assertEquals(1, pf.getRequestHandlers().size());
-        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
+        assertEquals(1, pf.getPreMatchContainerRequestFilters().size());
+        assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator);
         
         List<Object> providers = new ArrayList<Object>();
         WadlGenerator wg = new WadlGenerator();
@@ -125,9 +126,9 @@ public class ProviderFactoryTest extends
         TestHandler th = new TestHandler();
         providers.add(th);
         pf.setUserProviders(providers);
-        assertEquals(2, pf.getRequestHandlers().size());
-        assertSame(wg, pf.getRequestHandlers().get(0).getProvider());
-        assertSame(th, pf.getRequestHandlers().get(1).getProvider());
+        assertEquals(2, pf.getPreMatchContainerRequestFilters().size());
+        assertSame(wg, pf.getPreMatchContainerRequestFilters().get(0).getProvider());
+        assertSame(th, pf.getPreMatchContainerRequestFilters().get(1).getProvider());
     }
     
     
@@ -731,10 +732,11 @@ public class ProviderFactoryTest extends
         
     }
     
-    private static class TestHandler implements RequestHandler {
+    @PreMatching
+    private static class TestHandler implements ContainerRequestFilter {
 
-        public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
-            return null;
+        public void filter(ContainerRequestContext context) {
+            // complete
         }
         
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Thu Mar  7 12:10:31 2013
@@ -1457,24 +1457,23 @@ public class JAXRSUtilsTest extends Asse
         cri.setMethodDispatcher(md);
         
         OperationResourceInfo ori = JAXRSUtils.findTargetMethod(getMap(cri), null, "GET", 
-              new MetadataMap<String, String>(), "*/*", getTypes("text/plain"), true);
+              new MetadataMap<String, String>(), "*/*", getTypes("text/plain"));
         
         assertSame(ori, ori2);
         
         ori = JAXRSUtils.findTargetMethod(getMap(cri), null, "GET", new MetadataMap<String, String>(), 
-                                              "*/*", getTypes("text/xml"), true);
+                                              "*/*", getTypes("text/xml"));
                          
         assertSame(ori, ori1);
         
         ori = JAXRSUtils.findTargetMethod(getMap(cri), null, "GET", new MetadataMap<String, String>(), 
                                           "*/*", 
-                                          JAXRSUtils.sortMediaTypes(getTypes("*,text/plain,text/xml")), true);
+                                          JAXRSUtils.sortMediaTypes(getTypes("*,text/plain,text/xml")));
                      
         assertSame(ori, ori2);
         ori = JAXRSUtils.findTargetMethod(getMap(cri), null, "GET", new MetadataMap<String, String>(), 
                                           "*/*", 
-                                          JAXRSUtils.sortMediaTypes(getTypes("*,text/plain, text/xml,x/y")),
-                                          true);
+                                          JAXRSUtils.sortMediaTypes(getTypes("*,text/plain, text/xml,x/y")));
                      
         assertSame(ori, ori2);
     }
@@ -1851,7 +1850,7 @@ public class JAXRSUtilsTest extends Asse
         
         if (mResources != null) {
             OperationResourceInfo ori = JAXRSUtils.findTargetMethod(mResources, null, httpMethod, 
-                                                   values, requestContentType, acceptContentTypes, true);
+                                                   values, requestContentType, acceptContentTypes);
             if (ori != null) {
                 return ori;
             }

Modified: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/WadlGeneratorTest.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/WadlGeneratorTest.java (original)
+++ cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/WadlGeneratorTest.java Thu Mar  7 12:10:31 2013
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
@@ -33,6 +34,7 @@ import org.w3c.dom.Document;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
+import org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
@@ -65,19 +67,23 @@ public class WadlGeneratorTest extends A
     
     @Test
     public void testWadlInJsonFormat() throws Exception {
-        WadlGenerator wg = new WadlGenerator();
-        wg.setUseJaxbContextForQnames(false);
-        wg.setIgnoreMessageWriters(false);
-        
-        wg.setExternalLinks(Collections.singletonList("json.schema"));
-        
         ClassResourceInfo cri = 
             ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
-        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
+        final Message m = mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
         Map<String, List<String>> headers = new HashMap<String, List<String>>();
         headers.put("Accept", Collections.singletonList("application/json"));
         m.put(Message.PROTOCOL_HEADERS, headers);
-        Response r = wg.handleRequest(m, cri);
+        
+        WadlGenerator wg = new WadlGenerator() {
+            public void filter(ContainerRequestContext context) {
+                super.doFilter(context, m);
+            }
+        };
+        wg.setUseJaxbContextForQnames(false);
+        wg.setIgnoreMessageWriters(false);
+        wg.setExternalLinks(Collections.singletonList("json.schema"));
+        
+        Response r = handleRequest(wg, m);
         assertEquals("application/json",
                 r.getMetadata().getFirst("Content-Type").toString());
         
@@ -98,12 +104,15 @@ public class WadlGeneratorTest extends A
             + "{\"@element\":\"Chapter\",\"@mediaType\":\"application\\/json\"}]}";
         assertTrue(s.contains(expected2));
     }
-    
+    private Response handleRequest(WadlGenerator wg, Message m) {
+        wg.filter(new ContainerRequestContextImpl(m, true, false));
+        return m.getExchange().get(Response.class);
+    }
     private Message mockMessage(String baseAddress, String pathInfo, String query,
-                                List<ClassResourceInfo> cris) throws Exception {
+                                ClassResourceInfo cri) throws Exception {
         Message m = new MessageImpl();
         Exchange e = new ExchangeImpl();
-        e.put(Service.class, new JAXRSServiceImpl(cris));
+        e.put(Service.class, new JAXRSServiceImpl(Collections.singletonList(cri)));
         m.setExchange(e);
         control.reset();
         ServletDestination d = control.createMock(ServletDestination.class);

Modified: cxf/trunk/rt/rs/security/cors/src/main/java/org/apache/cxf/rs/security/cors/CrossOriginResourceSharingFilter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/cors/src/main/java/org/apache/cxf/rs/security/cors/CrossOriginResourceSharingFilter.java?rev=1453798&r1=1453797&r2=1453798&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/cors/src/main/java/org/apache/cxf/rs/security/cors/CrossOriginResourceSharingFilter.java (original)
+++ cxf/trunk/rt/rs/security/cors/src/main/java/org/apache/cxf/rs/security/cors/CrossOriginResourceSharingFilter.java Thu Mar  7 12:10:31 2013
@@ -28,16 +28,19 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
 
 import org.apache.cxf.common.util.ReflectionUtil;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.ext.ResponseHandler;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
@@ -45,6 +48,8 @@ import org.apache.cxf.jaxrs.model.URITem
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
 
 /**
  * A single class that provides both an input and an output filter for CORS, following
@@ -61,7 +66,9 @@ import org.apache.cxf.message.Message;
  * </pre>
  * or unless the <tt>defaultOptionsMethodsHandlePreflight</tt> property of this class is set to <tt>true</tt>.
  */
-public class CrossOriginResourceSharingFilter implements RequestHandler, ResponseHandler {
+@PreMatching
+public class CrossOriginResourceSharingFilter implements ContainerRequestFilter, 
+    ContainerResponseFilter {
     private static final Pattern SPACE_PATTERN = Pattern.compile(" ");
     private static final Pattern FIELD_COMMA_PATTERN = Pattern.compile(",\\w*");
     
@@ -87,29 +94,37 @@ public class CrossOriginResourceSharingF
     private Integer maxAge;
     private Integer preflightFailStatus = 200;
     private boolean defaultOptionsMethodsHandlePreflight;
+    private boolean findResourceMethod = true;
     
-    
-    private <T extends Annotation> T  getAnnotation(OperationResourceInfo ori,
+    private <T extends Annotation> T  getAnnotation(Method m,
                                                     Class<T> annClass) {
-        if (ori == null) {
+        if (m == null) {
             return null;
         }
-        return ReflectionUtil.getAnnotationForMethodOrContainingClass(
-             ori.getAnnotatedMethod(),  annClass);
+        return ReflectionUtil.getAnnotationForMethodOrContainingClass(m,  annClass);
     }
 
-    public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
-        OperationResourceInfo opResInfo = m.getExchange().get(OperationResourceInfo.class);
-        CrossOriginResourceSharing annotation = 
-            getAnnotation(opResInfo, CrossOriginResourceSharing.class);
+    public void filter(ContainerRequestContext context) {
+        Message m = JAXRSUtils.getCurrentMessage();
         
-        if ("OPTIONS".equals(m.get(Message.HTTP_REQUEST_METHOD))) {
-            return preflightRequest(m, annotation, opResInfo, resourceClass);
+        String httpMethod = (String)m.get(Message.HTTP_REQUEST_METHOD);
+        if (HttpMethod.OPTIONS.equals(httpMethod)) {
+            Response r = preflightRequest(m);
+            if (r != null) {
+                context.abortWith(r);
+            }
+        } else if (findResourceMethod) {
+            Method method = findResourceMethod ? getResourceMethod(m, httpMethod) : null;
+            simpleRequest(m, method);
+        } else {
+            m.getInterceptorChain().add(new CorsInInterceptor());
         }
-        return simpleRequest(m, annotation);
+        
     }
 
-    private Response simpleRequest(Message m, CrossOriginResourceSharing ann) {
+    private Response simpleRequest(Message m, Method resourceMethod) {
+        CrossOriginResourceSharing ann = 
+            getAnnotation(resourceMethod, CrossOriginResourceSharing.class);
         List<String> values = getHeaderValues(CorsHeaderConstants.HEADER_ORIGIN, true);
         // 5.1.1 there has to be an origin
         if (values == null || values.size() == 0) {
@@ -159,8 +174,7 @@ public class CrossOriginResourceSharingF
      * @return
      */
     //CHECKSTYLE:OFF
-    private Response preflightRequest(Message m, CrossOriginResourceSharing corsAnn,
-                                      OperationResourceInfo opResInfo, ClassResourceInfo resourceClass) {
+    private Response preflightRequest(Message m) {
 
         // Validate main CORS preflight properties (origin, method) 
         // even if Local preflight is requested
@@ -184,9 +198,12 @@ public class CrossOriginResourceSharingF
          * Ask JAX-RS runtime to validate that the matching resource method actually exists.
          */
         
-        Method method = getPreflightMethod(m, requestMethod);
-        if (method == null) {
-            return null;
+        Method method = null;
+        if (findResourceMethod) {
+            method = getResourceMethod(m, requestMethod);
+            if (method == null) {
+                return null;
+            }
         }
         
         /*
@@ -195,8 +212,14 @@ public class CrossOriginResourceSharingF
          * has one of our annotations on it (or its parent class) indicating 'localPreflight' --
          * or the defaultOptionsMethodsHandlePreflight flag is true.
          */
-        LocalPreflight preflightAnnotation = 
-            getAnnotation(opResInfo, LocalPreflight.class);
+        LocalPreflight preflightAnnotation = null;
+        if (!defaultOptionsMethodsHandlePreflight) {
+            Method optionsMethod = getResourceMethod(m, "OPTIONS");
+            if (optionsMethod != null) {
+                preflightAnnotation = getAnnotation(optionsMethod, LocalPreflight.class);
+            }
+        }
+                
         if (preflightAnnotation != null || defaultOptionsMethodsHandlePreflight) { 
             m.put(LOCAL_PREFLIGHT, "true");
             m.put(LOCAL_PREFLIGHT_ORIGIN, origin);
@@ -204,8 +227,7 @@ public class CrossOriginResourceSharingF
             return null; // let the resource method take all responsibility.
         }
         
-        CrossOriginResourceSharing ann = method.getAnnotation(CrossOriginResourceSharing.class);
-        ann = ann == null ? corsAnn : ann;
+        CrossOriginResourceSharing ann = getAnnotation(method, CrossOriginResourceSharing.class);
         
         /* We aren't required to have any annotation at all. If no annotation,
          * the properties of this filter make all the decisions.
@@ -259,7 +281,7 @@ public class CrossOriginResourceSharingF
         return Response.status(status).build();
     }
     
-    private Method getPreflightMethod(Message m, String httpMethod) {
+    private Method getResourceMethod(Message m, String httpMethod) {
         String requestUri = HttpUtils.getPathToMatch(m, true);
         
         List<ClassResourceInfo> resources = JAXRSUtils.getRootResources(m);
@@ -285,8 +307,7 @@ public class CrossOriginResourceSharingF
         OperationResourceInfo ori = JAXRSUtils.findTargetMethod(matchedResources, 
                                     m, httpMethod, values, 
                                     contentType, 
-                                    Collections.singletonList(acceptType), 
-                                    true); 
+                                    Collections.singletonList(acceptType), false); 
         if (ori == null) {
             return null;
         }
@@ -315,18 +336,20 @@ public class CrossOriginResourceSharingF
         m.getExchange().put(CorsHeaderConstants.HEADER_AC_ALLOW_CREDENTIALS, effectiveAllowCredentials(ann));
     }
 
-    public Response handleResponse(Message m, OperationResourceInfo ori, Response response) {
+    public void filter(ContainerRequestContext requestContext,
+                       ContainerResponseContext responseContext) {
+        
+        Message m = JAXRSUtils.getCurrentMessage();
+        
         String op = (String)m.getExchange().get(CrossOriginResourceSharingFilter.class.getName());
         if (op == null || op == PREFLIGHT_FAILED) {
-            return response;
+            return;
         }
          
-        ResponseBuilder rbuilder = Response.fromResponse(response);
-        
         /* Common to simple and preflight */
-        rbuilder.header(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN, 
+        responseContext.getHeaders().putSingle(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN, 
                         m.getExchange().get(CorsHeaderConstants.HEADER_ORIGIN));
-        rbuilder.header(CorsHeaderConstants.HEADER_AC_ALLOW_CREDENTIALS,
+        responseContext.getHeaders().putSingle(CorsHeaderConstants.HEADER_AC_ALLOW_CREDENTIALS,
                         m.getExchange().get(CorsHeaderConstants.HEADER_AC_ALLOW_CREDENTIALS));
         
         if (SIMPLE_REQUEST.equals(op)) {
@@ -334,31 +357,28 @@ public class CrossOriginResourceSharingF
             List<String> effectiveExposeHeaders 
                 = getHeadersFromInput(m, CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS);
             if (effectiveExposeHeaders != null) {
-                addHeaders(rbuilder, CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS, 
+                addHeaders(responseContext, CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS, 
                            effectiveExposeHeaders, false);
             }
             // if someone wants to clear the cache, we can't help them.
-            return rbuilder.build();
         } else {
             // 5.2.8 max-age
             String maValue = (String)m.getExchange().get(CorsHeaderConstants.HEADER_AC_MAX_AGE);
             if (maValue != null) {
-                rbuilder.header(CorsHeaderConstants.HEADER_AC_MAX_AGE, maValue);
+                responseContext.getHeaders().putSingle(CorsHeaderConstants.HEADER_AC_MAX_AGE, maValue);
             }
             // 5.2.9 add allowed methods
             /*
              * Currently, input side just lists the one requested method, and spec endorses that.
              */
-            addHeaders(rbuilder, CorsHeaderConstants.HEADER_AC_ALLOW_METHODS,
+            addHeaders(responseContext, CorsHeaderConstants.HEADER_AC_ALLOW_METHODS,
                        getHeadersFromInput(m, CorsHeaderConstants.HEADER_AC_ALLOW_METHODS), false);
             // 5.2.10 add allowed headers
             List<String> rqAllowedHeaders = getHeadersFromInput(m,
                                                                 CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS);
             if (rqAllowedHeaders != null) {
-                addHeaders(rbuilder, CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS, rqAllowedHeaders, false);
+                addHeaders(responseContext, CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS, rqAllowedHeaders, false);
             }
-            return rbuilder.build();
-
         }
     }
 
@@ -480,9 +500,10 @@ public class CrossOriginResourceSharingF
         return results;
     }
     
-    private void addHeaders(ResponseBuilder rb, String key, List<String> values, boolean spaceSeparated) {
+    private void addHeaders(ContainerResponseContext responseContext, 
+                            String key, List<String> values, boolean spaceSeparated) {
         String sb = concatValues(values, spaceSeparated);
-        rb.header(key, sb);
+        responseContext.getHeaders().putSingle(key, sb);
     }
 
     private String concatValues(List<String> values, boolean spaceSeparated) {
@@ -576,11 +597,6 @@ public class CrossOriginResourceSharingF
         this.preflightFailStatus = status;
     }
 
-
-    public boolean isDefaultOptionsMethodsHandlePreflight() {
-        return defaultOptionsMethodsHandlePreflight;
-    }
-
     /**
      * What to do when a preflight request comes along for a resource that has a handler method for
      * \@OPTIONS and there is no <tt>@{@link CrossResourceSharing}(localPreflight = val)</tt>
@@ -593,5 +609,20 @@ public class CrossOriginResourceSharingF
         this.defaultOptionsMethodsHandlePreflight = defaultOptionsMethodsHandlePreflight;
     }
 
+    public void setFindResourceMethod(boolean findResourceMethod) {
+        this.findResourceMethod = findResourceMethod;
+    }
     
+    private class CorsInInterceptor extends AbstractPhaseInterceptor<Message> {
+
+        public CorsInInterceptor() {
+            super(Phase.PRE_INVOKE);
+        }
+
+        @Override
+        public void handleMessage(Message message) {
+            OperationResourceInfo ori = message.getExchange().get(OperationResourceInfo.class);
+            simpleRequest(message, ori.getAnnotatedMethod());    
+        }
+    }
 }



Mime
View raw message