Index: src/tools/common/com/sun/ws/rest/tools/annotation/AnnotationProcessorContext.java =================================================================== --- src/tools/common/com/sun/ws/rest/tools/annotation/AnnotationProcessorContext.java (revision 112) +++ src/tools/common/com/sun/ws/rest/tools/annotation/AnnotationProcessorContext.java (working copy) @@ -29,6 +29,7 @@ import java.util.Collection; +import java.util.HashMap; import java.util.Map; /** @@ -55,6 +56,9 @@ /** The name of the ResourceBean to be generated. */ private String resourceBeanClassName; + /** Features to go to ResourceConfig */ + private final Map features = new HashMap(); + /** * APT round number */ @@ -117,5 +121,8 @@ public String getResourceBeanClassName() { return resourceBeanClassName; } - + + public Map getRCFeatures() { + return features; + } } Index: src/tools/common/com/sun/ws/rest/tools/webapp/WebResourcesGenerator.java =================================================================== --- src/tools/common/com/sun/ws/rest/tools/webapp/WebResourcesGenerator.java (revision 112) +++ src/tools/common/com/sun/ws/rest/tools/webapp/WebResourcesGenerator.java (working copy) @@ -30,7 +30,10 @@ import com.sun.ws.rest.tools.annotation.AnnotationProcessorContext; import com.sun.ws.rest.api.core.ResourceConfig; import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; /** @@ -95,13 +98,18 @@ // members JClass setClass = cm.ref(Set.class).narrow(Class.class); JClass hs = cm.ref(HashSet.class).narrow(Class.class); - JFieldVar field = cls.field(JMod.PRIVATE, setClass, "resources"); - field.init(JExpr._new(hs)); + JFieldVar fieldResources = cls.field(JMod.PRIVATE | JMod.FINAL, setClass, "resources"); + fieldResources.init(JExpr._new(hs)); + JClass mapClass = cm.ref(Map.class).narrow(String.class, Boolean.class); + JClass hm = cm.ref(HashMap.class).narrow(String.class, Boolean.class); + JFieldVar fieldFeatures = cls.field(JMod.PRIVATE | JMod.FINAL, mapClass, "features"); + fieldFeatures.init(JExpr._new(hm)); + //Constructor JMethod constrc1 = cls.constructor(JMod.PUBLIC); doc = constrc1.javadoc(); - doc.add("Initializes the Set of web resource classes\n"); + doc.add("Initializes the Set of web resource classes and features\n"); doc.add("to be included in a web application."); JBlock cb1 = constrc1.body(); @@ -109,17 +117,19 @@ cb1.directStatement("resources.add("+clazz+".class);"); } + for (Map.Entry feature : context.getRCFeatures().entrySet()) { + cb1.directStatement("features.put(\"" + feature.getKey() + "\", " + feature.getValue() + ");"); + } + JMethod method = cls.method(JMod.PUBLIC, setClass, "getResourceClasses"); JBlock body = method.body(); - body._return(field); + body._return(fieldResources); - method = cls.method(JMod.PUBLIC, cm.BOOLEAN, "isIgnoreMatrixParams"); + JClass collectionsClass = cm.ref(Collections.class); + method = cls.method(JMod.PUBLIC, mapClass, "getFeatures"); body = method.body(); - body._return(JExpr.TRUE); + body._return(collectionsClass.staticInvoke("unmodifiableMap").arg(JExpr.ref("features"))); - method = cls.method(JMod.PUBLIC, cm.BOOLEAN, "isRedirectToNormalizedURI"); - body = method.body(); - body._return(JExpr.TRUE); // if(options.verbose) // cw = new ProgressCodeWriter(cw, System.out); Index: src/api/com/sun/ws/rest/api/core/ResourceConfig.java =================================================================== --- src/api/com/sun/ws/rest/api/core/ResourceConfig.java (revision 112) +++ src/api/com/sun/ws/rest/api/core/ResourceConfig.java (working copy) @@ -22,6 +22,7 @@ package com.sun.ws.rest.api.core; +import java.util.Map; import java.util.Set; /** @@ -36,18 +37,10 @@ * @return the set of resource classes. */ Set getResourceClasses(); - + /** - * Specifies whether matrix parameters are ignored for the purposes - * of matching a request URI to a resource class. - * @return true if matrix params should be ignored, false if not + * Get the unmodifiable map containing set of features associated with the WebApplication + * @return the unmodifiable map of features. */ - boolean isIgnoreMatrixParams(); - - /** - * Specifies whether the runtime should silently normalize the request URI - * or issue a client redirect to the normailzed request URI. - * @return true if redirects will be used, false if not - */ - boolean isRedirectToNormalizedURI(); + Map getFeatures(); } Index: src/tools/javase5/com/sun/ws/rest/tools/annotation/apt/UriTemplateProcessor.java =================================================================== --- src/tools/javase5/com/sun/ws/rest/tools/annotation/apt/UriTemplateProcessor.java (revision 112) +++ src/tools/javase5/com/sun/ws/rest/tools/annotation/apt/UriTemplateProcessor.java (working copy) @@ -115,6 +115,16 @@ boolean generateWadl = true; /** + * Determines if request should be redirected to canonical URI + */ + boolean redirectToCanonicalURI = true; + + /** + * Determines if /+ should be preserved while redirecting to canonical URIs + */ + boolean preserveContSlashes = false; + + /** * output directory for apt */ String destDirectory = null; @@ -157,6 +167,10 @@ generateWebXml = false; } else if (key.startsWith("-Anowadl")) { generateWadl = false; + } else if (key.startsWith("-Anoredir")) { + redirectToCanonicalURI = false; + } else if (key.startsWith("-Apreserveslashes")) { + preserveContSlashes = true; } else if (key.startsWith("-Awebresourcesdestdir")) { restDestDirectory = key.split("=")[1]; if (!(restDestDirectory.endsWith("/") || @@ -165,6 +179,11 @@ } } } + + context.getRCFeatures().put("RedirectToCanonicalURI", redirectToCanonicalURI); + context.getRCFeatures().put("PreserveContSlashes", preserveContSlashes); + context.getRCFeatures().put("IgnoreMatrixParams", true); + if (!generateWebXml) { if (servletClassName != null) apEnv.getMessager().printError("-Aservletclassname cannot be used with the -Anoservlet option.");