From commits-return-4761-archive-asf-public=cust-asf.ponee.io@juneau.apache.org Sat Jan 6 00:51:23 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 6B3C2180647 for ; Sat, 6 Jan 2018 00:51:23 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5B423160C28; Fri, 5 Jan 2018 23:51:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 031AA160C27 for ; Sat, 6 Jan 2018 00:51:20 +0100 (CET) Received: (qmail 52565 invoked by uid 500); 5 Jan 2018 23:51:20 -0000 Mailing-List: contact commits-help@juneau.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@juneau.apache.org Delivered-To: mailing list commits@juneau.apache.org Received: (qmail 52555 invoked by uid 99); 5 Jan 2018 23:51:20 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Jan 2018 23:51:20 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 500211805E0 for ; Fri, 5 Jan 2018 23:51:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -11.731 X-Spam-Level: X-Spam-Status: No, score=-11.731 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id St7dNpmBnX94 for ; Fri, 5 Jan 2018 23:51:05 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id E3F855F470 for ; Fri, 5 Jan 2018 23:51:01 +0000 (UTC) Received: (qmail 51874 invoked by uid 99); 5 Jan 2018 23:51:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Jan 2018 23:51:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EBFEDDFC3E; Fri, 5 Jan 2018 23:51:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jamesbognar@apache.org To: commits@juneau.incubator.apache.org Message-Id: <2d8bd45eb4a4459b91c5426f03051f56@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: juneau git commit: RestContext refactoring. Date: Fri, 5 Jan 2018 23:51:00 +0000 (UTC) Repository: juneau Updated Branches: refs/heads/master 779be8b4c -> 30ac20a16 RestContext refactoring. Project: http://git-wip-us.apache.org/repos/asf/juneau/repo Commit: http://git-wip-us.apache.org/repos/asf/juneau/commit/30ac20a1 Tree: http://git-wip-us.apache.org/repos/asf/juneau/tree/30ac20a1 Diff: http://git-wip-us.apache.org/repos/asf/juneau/diff/30ac20a1 Branch: refs/heads/master Commit: 30ac20a1621322bf63b8cdfbffce9190d75e13f1 Parents: 779be8b Author: JamesBognar Authored: Fri Jan 5 18:50:57 2018 -0500 Committer: JamesBognar Committed: Fri Jan 5 18:50:57 2018 -0500 ---------------------------------------------------------------------- .../org/apache/juneau/rest/RestContext.java | 1297 +++++++++--------- .../apache/juneau/rest/RestContextBuilder.java | 26 +- 2 files changed, 632 insertions(+), 691 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/juneau/blob/30ac20a1/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java index b270a97..bc2aa30 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java @@ -63,39 +63,6 @@ public final class RestContext extends BeanContext { private static final String PREFIX = "RestContext."; /** - * Configuration property: Allow header URL parameters. - * - *
    - *
  • Name: "RestContext.allowHeaderParams.b" - *
  • Data type: Boolean - *
  • Default: true - *
  • Session-overridable: false - *
- * - *

- * When enabled, headers such as "Accept" and "Content-Type" to be passed in as URL query - * parameters. - *
- * For example: "?Accept=text/json&Content-Type=text/json" - * - *

Notes:
- *
    - *
  • Property: {@link RestContext#REST_allowHeaderParams} - *
  • Annotations: - *
      - *
    • {@link RestResource#allowHeaderParams()} - *
    - *
  • Methods: - *
      - *
    • {@link RestContextBuilder#allowHeaderParams(boolean)} - *
    - *
  • Parameter name is case-insensitive. - *
  • Useful for debugging REST interface using only a browser. - *
- */ - public static final String REST_allowHeaderParams = PREFIX + "allowHeaderParams.b"; - - /** * Configuration property: Allow body URL parameter. * *
    @@ -168,178 +135,174 @@ public final class RestContext extends BeanContext { public static final String REST_allowedMethodParams = PREFIX + "allowedMethodParams.s"; /** - * Configuration property: Render response stack traces in responses. + * Configuration property: Allow header URL parameters. * *
      - *
    • Name: "RestContext.renderResponseStackTraces.b" + *
    • Name: "RestContext.allowHeaderParams.b" *
    • Data type: Boolean - *
    • Default: false + *
    • Default: true *
    • Session-overridable: false *
    * *

    - * Render stack traces in HTTP response bodies when errors occur. - * + * When enabled, headers such as "Accept" and "Content-Type" to be passed in as URL query + * parameters. + *
    + * For example: "?Accept=text/json&Content-Type=text/json" + * *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_renderResponseStackTraces} + *
    • Property: {@link RestContext#REST_allowHeaderParams} *
    • Annotations: *
        - *
      • {@link RestResource#renderResponseStackTraces()} + *
      • {@link RestResource#allowHeaderParams()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#renderResponseStackTraces(boolean)} + *
      • {@link RestContextBuilder#allowHeaderParams(boolean)} *
      - *
    • Useful for debugging, although allowing stack traces to be rendered may cause security concerns so use - * caution when enabling. + *
    • Parameter name is case-insensitive. + *
    • Useful for debugging REST interface using only a browser. *
    */ - public static final String REST_renderResponseStackTraces = PREFIX + "renderResponseStackTraces.b"; + public static final String REST_allowHeaderParams = PREFIX + "allowHeaderParams.b"; /** - * Configuration property: Use stack trace hashes. + * Configuration property: REST call handler. * *
      - *
    • Name: "RestContext.useStackTraceHashes.b" - *
    • Data type: Boolean - *
    • Default: true + *
    • Name: "RestContext.callHandler.o" + *
    • Data type: Class<? extends RestCallHandler> | RestCallHandler + *
    • Default: {@link RestCallHandler} *
    • Session-overridable: false *
    - * + * + *

    + * This class handles the basic lifecycle of an HTTP REST call. + *
    Subclasses can be used to customize how these HTTP calls are handled. + *

    - * When enabled, the number of times an exception has occurred will be determined based on stack trace hashsums, - * made available through the {@link RestException#getOccurrence()} method. - * *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_useStackTraceHashes} - *
    • Annotations: + *
    • Property: {@link RestContext#REST_callHandler} + *
    • Annotations: *
        - *
      • {@link RestResource#useStackTraceHashes()} + *
      • {@link RestResource#callHandler()} *
      - *
    • Methods: + *
    • Methods: *
        - *
      • {@link RestContextBuilder#useStackTraceHashes(boolean)} + *
      • {@link RestContextBuilder#callHandler(Class)} + *
      • {@link RestContextBuilder#callHandler(RestCallHandler)} *
      *
    */ - public static final String REST_useStackTraceHashes = PREFIX + "useStackTraceHashes.b"; - + public static final String REST_callHandler = PREFIX + "callHandler.o"; + /** - * Configuration property: Default character encoding. + * Configuration property: Classpath resource finder. * *
      - *
    • Name: "RestContext.defaultCharset.s" - *
    • Data type: String - *
    • Default: "utf-8" + *
    • Name: "RestContext.classpathResourceFinder.o" + *
    • Data type: {@link ClasspathResourceFinder} + *
    • Default: {@link ClasspathResourceFinderBasic} *
    • Session-overridable: false *
    - * + * *

    - * The default character encoding for the request and response if not specified on the request. - * - *

    Notes:
    + * Used to retrieve localized files from the classpath. + * + *

    + * + *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_defaultCharset} - *
    • Annotations: + *
    • Property: {@link RestContext#REST_classpathResourceFinder} + *
    • Annotations: *
        - *
      • {@link RestResource#defaultCharset()} - *
      • {@link RestMethod#defaultCharset()} + *
      • {@link RestResource#classpathResourceFinder()} *
      - *
    • Methods: + *
    • Methods: *
        - *
      • {@link RestContextBuilder#defaultCharset(String)} + *
      • {@link RestContextBuilder#classpathResourceFinder(Class)} + *
      • {@link RestContextBuilder#classpathResourceFinder(ClasspathResourceFinder)} *
      - *
    + *
  • + * The default value is {@link ClasspathResourceFinderBasic} which provides basic support for finding localized + * resources on the classpath and JVM working directory. + *
    The {@link ClasspathResourceFinderRecursive} is another option that also recursively searches for resources + * up the parent class hierarchy. + *
    Each of these classes can be extended to provide customized handling of resource retrieval. + *
*/ - public static final String REST_defaultCharset = PREFIX + "defaultCharset.s"; + public static final String REST_classpathResourceFinder = PREFIX + "classpathResourceFinder.o"; /** - * Configuration property: The maximum allowed input size (in bytes) on HTTP requests. + * Configuration property: Client version header. * *
    - *
  • Name: "RestContext.maxInput.s" + *
  • Name: "RestContext.clientVersionHeader.s" *
  • Data type: String - *
  • Default: "100M" + *
  • Default: "X-Client-Version" *
  • Session-overridable: false *
+ * + *

+ * Specifies the name of the header used to denote the client version on HTTP requests. * *

- * Useful for alleviating DoS attacks by throwing an exception when too much input is received instead of resulting - * in out-of-memory errors which could affect system stability. + * The client version is used to support backwards compatibility for breaking REST interface changes. + *
Used in conjunction with {@link RestMethod#clientVersion()} annotation. * + *

*

Notes:
*
    - *
  • Property: {@link RestContext#REST_maxInput} - *
  • Annotations: + *
  • Property: {@link RestContext#REST_clientVersionHeader} + *
  • Annotations: *
      - *
    • {@link RestResource#maxInput()} - *
    • {@link RestMethod#maxInput()} + *
    • {@link RestResource#clientVersionHeader()} *
    - *
  • Methods: + *
  • Methods: *
      - *
    • {@link RestContextBuilder#maxInput(String)} + *
    • {@link RestContextBuilder#clientVersionHeader(String)} *
    - *
  • String value that gets resolved to a long. - *
  • Can be suffixed with any of the following representing kilobytes, megabytes, and gigabytes: - * 'K', 'M', 'G'. - *
  • A value of "-1" can be used to represent no limit. *
*/ - public static final String REST_maxInput = PREFIX + "maxInput.s"; - + public static final String REST_clientVersionHeader = PREFIX + "clientVersionHeader.s"; + /** - * Configuration property: Java method parameter resolvers. + * Configuration property: Resource context path. * *
    - *
  • Name: "RestContext.paramResolvers.lo" - *
  • Data type: List<RestParam | Class<? extends RestParam>> - *
  • Default: empty list + *
  • Name: "RestContext.contextPath.s" + *
  • Data type: String + *
  • Default: null *
  • Session-overridable: false *
- * + * *

- * By default, the Juneau framework will automatically Java method parameters of various types (e.g. - * RestRequest, Accept, Reader). - * This annotation allows you to provide your own resolvers for your own class types that you want resolved. + * Overrides the context path value for this resource and any child resources. * *

- * For example, if you want to pass in instances of MySpecialObject to your Java method, define - * the following resolver: - *

- * public class MyRestParam extends RestParam { - * - * // Must have no-arg constructor! - * public MyRestParam() { - * // First two parameters help with Swagger doc generation. - * super(QUERY, "myparam", MySpecialObject.class); - * } - * - * // The method that creates our object. - * // In this case, we're taking in a query parameter and converting it to our object. - * public Object resolve(RestRequest req, RestResponse res) throws Exception { - * return new MySpecialObject(req.getQuery().get("myparam")); - * } - * } - *

- * + * This setting is useful if you want to use "context:/child/path" URLs in child resource POJOs but + * the context path is not actually specified on the servlet container. + * The net effect is that the {@link RestRequest#getContextPath()} and {@link RestRequest#getServletPath()} methods + * will return this value instead of the actual context path of the web app. + * + *

*

Notes:
*
    - *
  • Property: {@link RestContext#REST_paramResolvers} - *
  • Annotations: + *
  • Property: {@link RestContext#REST_contextPath} + *
  • Annotations: *
      - *
    • {@link RestResource#paramResolvers()} + *
    • {@link RestResource#contextPath()} + *
    *
  • Methods: *
      - *
    • {@link RestContextBuilder#paramResolvers(Class...)} - *
    • {@link RestContextBuilder#paramResolvers(RestParam...)} + *
    • {@link RestContextBuilder#contextPath(String)} *
    - *
  • {@link RestParam} classes must have either a no-arg or {@link PropertyStore} argument constructors. *
*/ - public static final String REST_paramResolvers = PREFIX + "paramResolvers.lo"; - + public static final String REST_contextPath = PREFIX + "contextPath.s"; + /** * Configuration property: Class-level response converters. * @@ -381,91 +344,41 @@ public final class RestContext extends BeanContext { public static final String REST_converters = PREFIX + "converters.lo"; /** - * Configuration property: Class-level guards. + * Configuration property: Default character encoding. * *
    - *
  • Name: "RestContext.guards.lo" - *
  • Data type: List<RestGuard | Class<? extends RestGuard>> - *
  • Default: empty list + *
  • Name: "RestContext.defaultCharset.s" + *
  • Data type: String + *
  • Default: "utf-8" *
  • Session-overridable: false *
* *

- * Associates one or more {@link RestGuard RestGuards} with all REST methods defined in this class. - * These guards get called immediately before execution of any REST method in this class. - * - *

- * Typically, guards will be used for permissions checking on the user making the request, but it can also be used - * for other purposes like pre-call validation of a request. + * The default character encoding for the request and response if not specified on the request. * *

Notes:
*
    - *
  • Property: {@link RestContext#REST_guards} + *
  • Property: {@link RestContext#REST_defaultCharset} *
  • Annotations: *
      - *
    • {@link RestResource#guards()} - *
    • {@link RestMethod#guards()} + *
    • {@link RestResource#defaultCharset()} + *
    • {@link RestMethod#defaultCharset()} *
    - *
  • Methods: + *
  • Methods: *
      - *
    • {@link RestContextBuilder#guards(Class...)} - *
    • {@link RestContextBuilder#guards(RestGuard...)} + *
    • {@link RestContextBuilder#defaultCharset(String)} *
    - *
  • {@link RestGuard} classes must have either a no-arg or {@link PropertyStore} argument constructors. *
*/ - public static final String REST_guards = PREFIX + "guards.lo"; - + public static final String REST_defaultCharset = PREFIX + "defaultCharset.s"; + /** - * Configuration property: Response handlers. + * Configuration property: Default request headers. * *
    - *
  • Name: "RestContext.responseHandlers.lo" - *
  • Data type: List<Class<? extends ResponseHandler>> - *
  • Default: empty list - *
  • Session-overridable: false - *
- * - *

- * Specifies a list of {@link ResponseHandler} classes that know how to convert POJOs returned by REST methods or - * set via {@link RestResponse#setOutput(Object)} into appropriate HTTP responses. - * - *

- * By default, the following response handlers are provided out-of-the-box: - *

    - *
  • {@link StreamableHandler} - *
  • {@link WritableHandler} - *
  • {@link ReaderHandler} - *
  • {@link InputStreamHandler} - *
  • {@link RedirectHandler} - *
  • {@link DefaultHandler} - *
- - *

- *

Notes:
- *
    - *
  • Property: {@link RestContext#REST_responseHandlers} - *
  • Annotations: - *
      - *
    • {@link RestResource#responseHandlers()} - *
    - *
  • Methods: - *
      - *
    • {@link RestContextBuilder#responseHandlers(Class...)} -
    • {@link RestContextBuilder#responseHandlers(ResponseHandler...)} -
    - *
  • {@link ResponseHandler} classes must have either a no-arg or {@link PropertyStore} argument constructors. - *
- */ - public static final String REST_responseHandlers = PREFIX + "responseHandlers.lo"; - - /** - * Configuration property: Default request headers. - * - *
    - *
  • Name: "RestContext.defaultRequestHeaders.smo" - *
  • Data type: Map<String,String> - *
  • Default: empty map + *
  • Name: "RestContext.defaultRequestHeaders.smo" + *
  • Data type: Map<String,String> + *
  • Default: empty map *
  • Session-overridable: false *
* @@ -527,141 +440,116 @@ public final class RestContext extends BeanContext { public static final String REST_defaultResponseHeaders = PREFIX + "defaultResponseHeaders.omo"; /** - * Configuration property: Supported accept media types. + * Configuration property: Compression encoders. * *
    - *
  • Name: "RestContext.supportedAcceptTypes.ls" - *
  • Data type: List<String> + *
  • Name: "RestContext.encoders.o" + *
  • Data type: List<Class <? extends Encoder> | Encoder> *
  • Default: empty list *
  • Session-overridable: false *
* *

- * Overrides the media types inferred from the serializers that identify what media types can be produced by the resource. - * - *

- * This affects the values returned by {@link RestRequest#getSupportedAcceptTypes()} and the supported accept - * types shown in {@link RestInfoProvider#getSwagger(RestRequest)}. + * These can be used to enable various kinds of compression (e.g. "gzip") on requests and responses. * - *

- *

Notes:
+ *
Example:
+ *

+ * // Servlet with automated support for GZIP compression + * @RestResource(encoders={GzipEncoder.class}) + * public MyRestServlet extends RestServlet { + * ... + * } + *

+ * + *
Notes:
*
    - *
  • Property: {@link RestContext#REST_supportedAcceptTypes} - *
  • Annotations: + *
  • Property: {@link RestContext#REST_encoders} + *
  • Annotations: *
      - *
    • {@link RestResource#supportedAcceptTypes()} - *
    • {@link RestMethod#supportedAcceptTypes()} - *
    - *
  • Methods: + *
  • {@link RestResource#encoders()} + *
  • {@link RestMethod#encoders()} + *
+ *
  • Methods: *
      - *
    • {@link RestContextBuilder#supportedAcceptTypes(boolean,String...)} - *
    • {@link RestContextBuilder#supportedAcceptTypes(boolean,MediaType...)} + *
    • {@link RestContextBuilder#encoders(Class...)} + *
    • {@link RestContextBuilder#encoders(Encoder...)} *
    - * + *
  • Instance classes must provide a public no-arg constructor, or a public constructor that takes in a + * {@link PropertyStore} object. + *
  • Instance class can be defined as an inner class of the REST resource class. + * */ - public static final String REST_supportedAcceptTypes = PREFIX + "supportedAcceptTypes.ls"; + public static final String REST_encoders = PREFIX + "encoders.lo"; /** - * Configuration property: Supported content media types. + * Configuration property: Class-level guards. * *
      - *
    • Name: "RestContext.supportedContentTypes.ls" - *
    • Data type: List<String> + *
    • Name: "RestContext.guards.lo" + *
    • Data type: List<RestGuard | Class<? extends RestGuard>> *
    • Default: empty list *
    • Session-overridable: false *
    - * - *

    - * Overrides the media types inferred from the parsers that identify what media types can be consumed by the resource. * *

    - * This affects the values returned by {@link RestRequest#getSupportedContentTypes()} and the supported content - * types shown in {@link RestInfoProvider#getSwagger(RestRequest)}. - * - *

    - *

    Notes:
    - *
      - *
    • Property: {@link RestContext#REST_supportedContentTypes} - *
    • Annotations: - *
        - *
      • {@link RestResource#supportedContentTypes()} - *
      • {@link RestMethod#supportedContentTypes()} - *
      - *
    • Methods: - *
        - *
      • {@link RestContextBuilder#supportedContentTypes(boolean,String...)} - *
      • {@link RestContextBuilder#supportedContentTypes(boolean,MediaType...)} - *
      - *
    - */ - public static final String REST_supportedContentTypes = PREFIX + "supportedContentTypes.ls"; - - /** - * Configuration property: Client version header. + * Associates one or more {@link RestGuard RestGuards} with all REST methods defined in this class. + * These guards get called immediately before execution of any REST method in this class. * - *
      - *
    • Name: "RestContext.clientVersionHeader.s" - *
    • Data type: String - *
    • Default: "X-Client-Version" - *
    • Session-overridable: false - *
    - * *

    - * Specifies the name of the header used to denote the client version on HTTP requests. + * Typically, guards will be used for permissions checking on the user making the request, but it can also be used + * for other purposes like pre-call validation of a request. * - *

    - * The client version is used to support backwards compatibility for breaking REST interface changes. - *
    Used in conjunction with {@link RestMethod#clientVersion()} annotation. - * - *

    *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_clientVersionHeader} - *
    • Annotations: + *
    • Property: {@link RestContext#REST_guards} + *
    • Annotations: *
        - *
      • {@link RestResource#clientVersionHeader()} + *
      • {@link RestResource#guards()} + *
      • {@link RestMethod#guards()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#clientVersionHeader(String)} + *
      • {@link RestContextBuilder#guards(Class...)} + *
      • {@link RestContextBuilder#guards(RestGuard...)} *
      + *
    • {@link RestGuard} classes must have either a no-arg or {@link PropertyStore} argument constructors. *
    */ - public static final String REST_clientVersionHeader = PREFIX + "clientVersionHeader.s"; + public static final String REST_guards = PREFIX + "guards.lo"; /** - * Configuration property: REST resource resolver. + * Configuration property: REST info provider. * *
      - *
    • Name: "RestContext.resourceResolver.o" - *
    • Data type: Class<? extends RestResourceResolver> | RestResourceResolver - *
    • Default: {@link RestResourceResolverSimple} + *
    • Name: "RestContext.infoProvider.o" + *
    • Data type: Class<? extends RestInfoProvider> | RestInfoProvider + *
    • Default: {@link RestInfoProvider} *
    • Session-overridable: false *
    * - * The resolver used for resolving child resources. - * *

    - * Can be used to provide customized resolution of REST resource class instances (e.g. resources retrieve from Spring). + * Class used to retrieve title/description/swagger information about a resource. + * + *

    + * Subclasses can be used to customize the documentation on a resource. * *

    *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_resourceResolver} + *
    • Property: {@link RestContext#REST_infoProvider} *
    • Annotations: *
        - *
      • {@link RestResource#resourceResolver()} + *
      • {@link RestResource#infoProvider()} *
      - *
    • Methods: + *
    • Methods: *
        - *
      • {@link RestContextBuilder#resourceResolver(Class)} -
      • {@link RestContextBuilder#resourceResolver(RestResourceResolver)} -
      - *
    • Unless overridden, resource resolvers are inherited from parent resources. + *
    • {@link RestContextBuilder#infoProvider(Class)} + *
    • {@link RestContextBuilder#infoProvider(RestInfoProvider)} + *
    * */ - public static final String REST_resourceResolver = PREFIX + "resourceResolver.o"; - + public static final String REST_infoProvider = PREFIX + "infoProvider.o"; + /** * Configuration property: REST logger. * @@ -686,629 +574,741 @@ public final class RestContext extends BeanContext { *
  • Methods: *
      *
    • {@link RestContextBuilder#logger(Class)} -
    • {@link RestContextBuilder#logger(RestLogger)} -
    + *
  • {@link RestContextBuilder#logger(RestLogger)} + * *
  • The {@link RestLogger.Normal} logger can be used to provide basic error logging to the Java logger. * */ public static final String REST_logger = PREFIX + "logger.o"; /** - * Configuration property: REST call handler. + * Configuration property: The maximum allowed input size (in bytes) on HTTP requests. * *
      - *
    • Name: "RestContext.callHandler.o" - *
    • Data type: Class<? extends RestCallHandler> | RestCallHandler - *
    • Default: {@link RestCallHandler} + *
    • Name: "RestContext.maxInput.s" + *
    • Data type: String + *
    • Default: "100M" *
    • Session-overridable: false *
    - * - *

    - * This class handles the basic lifecycle of an HTTP REST call. - *
    Subclasses can be used to customize how these HTTP calls are handled. - + * *

    + * Useful for alleviating DoS attacks by throwing an exception when too much input is received instead of resulting + * in out-of-memory errors which could affect system stability. + * *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_callHandler} - *
    • Annotations: + *
    • Property: {@link RestContext#REST_maxInput} + *
    • Annotations: *
        - *
      • {@link RestResource#callHandler()} + *
      • {@link RestResource#maxInput()} + *
      • {@link RestMethod#maxInput()} *
      - *
    • Methods: + *
    • Methods: *
        - *
      • {@link RestContextBuilder#callHandler(Class)} - *
      • {@link RestContextBuilder#callHandler(RestCallHandler)} + *
      • {@link RestContextBuilder#maxInput(String)} *
      + *
    • String value that gets resolved to a long. + *
    • Can be suffixed with any of the following representing kilobytes, megabytes, and gigabytes: + * 'K', 'M', 'G'. + *
    • A value of "-1" can be used to represent no limit. *
    */ - public static final String REST_callHandler = PREFIX + "callHandler.o"; - + public static final String REST_maxInput = PREFIX + "maxInput.s"; + /** - * Configuration property: REST info provider. + * Configuration property: Messages. * *
      - *
    • Name: "RestContext.infoProvider.o" - *
    • Data type: Class<? extends RestInfoProvider> | RestInfoProvider - *
    • Default: {@link RestInfoProvider} + *
    • Name: "RestContext.messages.lo" + *
    • Data type: List<MessageBundleLocation> + *
    • Default: null *
    • Session-overridable: false *
    * *

    - * Class used to retrieve title/description/swagger information about a resource. + * Identifies the location of the resource bundle for this class. * *

    - * Subclasses can be used to customize the documentation on a resource. + * This annotation is used to provide localized messages for the following methods: + *

      + *
    • {@link RestRequest#getMessage(String, Object...)} + *
    • {@link RestContext#getMessages()} + *
    * *

    - *

    Notes:
    + * Refer to the {@link MessageBundle} class for a description of the message key formats used in the properties file. + * + *

    + * The value can be a relative path like "nls/Messages", indicating to look for the resource bundle + * "com.foo.sample.nls.Messages" if the resource class is in "com.foo.sample", or it can be an + * absolute path, like "com.foo.sample.nls.Messages" + * + *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_infoProvider} + *
    • Property: {@link RestContext#REST_messages} *
    • Annotations: *
        - *
      • {@link RestResource#infoProvider()} + *
      • {@link RestResource#messages()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#infoProvider(Class)} - *
      • {@link RestContextBuilder#infoProvider(RestInfoProvider)} - *
      - *
    + *
  • {@link RestContextBuilder#messages(String)}, + *
  • {@link RestContextBuilder#messages(Class,String)} + *
  • {@link RestContextBuilder#messages(MessageBundleLocation)} + * + *
  • Mappings are cumulative from parent to child. + * */ - public static final String REST_infoProvider = PREFIX + "infoProvider.o"; + public static final String REST_messages = PREFIX + "messages.lo"; /** - * Configuration property: Resource path. + * Configuration property: MIME types. * *
      - *
    • Name: "RestContext.path.s" - *
    • Data type: String - *
    • Default: null + *
    • Name: "RestContext.mimeTypes.ss" + *
    • Data type: Set<String> + *
    • Default: empty list *
    • Session-overridable: false *
    * *

    - * Identifies the URL subpath relative to the parent resource. - * + * Defines MIME-type file type mappings. + * *

    - *

    Notes:
    + * Used for specifying the content type on file resources retrieved through the following methods: + *
      + *
    • {@link RestContext#resolveStaticFile(String)} + *
    • {@link RestRequest#getClasspathReaderResource(String,boolean,MediaType)} + *
    • {@link RestRequest#getClasspathReaderResource(String,boolean)} + *
    • {@link RestRequest#getClasspathReaderResource(String)} + *
    + * + *

    + * This list appends to the existing list provided by {@link ExtendedMimetypesFileTypeMap}. + * + *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_path} + *
    • Property: {@link RestContext#REST_mimeTypes} *
    • Annotations: *
        - *
      • {@link RestResource#path()} + *
      • {@link RestResource#mimeTypes()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#path(String)} + *
      • {@link RestContextBuilder#mimeTypes(String...)} *
      - *
    • This annotation is ignored on top-level servlets (i.e. servlets defined in web.xml files). - *
      Therefore, implementers can optionally specify a path value for documentation purposes. - *
    • Typically, this setting is only applicable to resources defined as children through the - * {@link RestResource#children()} annotation. - *
      However, it may be used in other ways (e.g. defining paths for top-level resources in microservices). - *
    + *
  • Values are .mime.types formatted entry string. + *
    Example: "image/svg+xml svg" + * */ - public static final String REST_path = PREFIX + "path.s"; + public static final String REST_mimeTypes = PREFIX + "mimeTypes.ss"; /** - * Configuration property: Resource context path. + * Configuration property: Java method parameter resolvers. * *
      - *
    • Name: "RestContext.contextPath.s" - *
    • Data type: String - *
    • Default: null + *
    • Name: "RestContext.paramResolvers.lo" + *
    • Data type: List<RestParam | Class<? extends RestParam>> + *
    • Default: empty list *
    • Session-overridable: false *
    - * - *

    - * Overrides the context path value for this resource and any child resources. * *

    - * This setting is useful if you want to use "context:/child/path" URLs in child resource POJOs but - * the context path is not actually specified on the servlet container. - * The net effect is that the {@link RestRequest#getContextPath()} and {@link RestRequest#getServletPath()} methods - * will return this value instead of the actual context path of the web app. - * + * By default, the Juneau framework will automatically Java method parameters of various types (e.g. + * RestRequest, Accept, Reader). + * This annotation allows you to provide your own resolvers for your own class types that you want resolved. + * *

    + * For example, if you want to pass in instances of MySpecialObject to your Java method, define + * the following resolver: + *

    + * public class MyRestParam extends RestParam { + * + * // Must have no-arg constructor! + * public MyRestParam() { + * // First two parameters help with Swagger doc generation. + * super(QUERY, "myparam", MySpecialObject.class); + * } + * + * // The method that creates our object. + * // In this case, we're taking in a query parameter and converting it to our object. + * public Object resolve(RestRequest req, RestResponse res) throws Exception { + * return new MySpecialObject(req.getQuery().get("myparam")); + * } + * } + *

    + * *
    Notes:
    *
      - *
    • Property: {@link RestContext#REST_contextPath} - *
    • Annotations: + *
    • Property: {@link RestContext#REST_paramResolvers} + *
    • Annotations: *
        - *
      • {@link RestResource#contextPath()} - *
      + *
    • {@link RestResource#paramResolvers()} *
    • Methods: *
        - *
      • {@link RestContextBuilder#contextPath(String)} + *
      • {@link RestContextBuilder#paramResolvers(Class...)} + *
      • {@link RestContextBuilder#paramResolvers(RestParam...)} *
      + *
    • {@link RestParam} classes must have either a no-arg or {@link PropertyStore} argument constructors. *
    */ - public static final String REST_contextPath = PREFIX + "contextPath.s"; - + public static final String REST_paramResolvers = PREFIX + "paramResolvers.lo"; + /** - * Configuration property: Static file mappings. + * Configuration property: Parsers. * *
      - *
    • Name: "RestContext.staticFiles.lo" - *
    • Data type: List<StaticFileMapping> - *
    • Default: null + *
    • Name: "RestContext.parsers.lo" + *
    • Data type: List<Class <? extends Parser> | Parser> + *
    • Default: empty list *
    • Session-overridable: false *
    * *

    - * Used to define paths and locations of statically-served files such as images or HTML documents. - * - *

    - * Static files are found by calling {@link #getClasspathResource(String,Locale)} which uses the registered - * {@link ClasspathResourceFinder} for locating files on the classpath (or other location). - * - *

    - * An example where this class is used is in the {@link RestResource#staticFiles} annotation: - *

    - * package com.foo.mypackage; - * - * @RestResource( - * path="/myresource", - * staticFiles={"htdocs:docs","styles:styles"} - * ) - * public class MyResource extends RestServletDefault {...} - *

    - * - *

    - * In the example above, given a GET request to /myresource/htdocs/foobar.html, the servlet will attempt to find - * the foobar.html file in the following ordered locations: - *

      - *
    1. com.foo.mypackage.docs package. - *
    2. org.apache.juneau.rest.docs package (since RestServletDefault is in org.apache.juneau.rest). - *
    3. [working-dir]/docs directory. - *
    + * Adds class-level parsers to this resource. * *
    Notes:
    *
      - *
    • Property: {@link RestContext#REST_staticFiles} + *
    • Property: {@link RestContext#REST_parsers} *
    • Annotations: *
        - *
      • {@link RestResource#staticFiles()} + *
      • {@link RestResource#parsers()} + *
      • {@link RestMethod#parsers()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#staticFiles(String)}, - *
      • {@link RestContextBuilder#staticFiles(Class,String)} - *
      • {@link RestContextBuilder#staticFiles(String,String)} - *
      • {@link RestContextBuilder#staticFiles(Class,String,String)} - *
      • {@link RestContextBuilder#staticFiles(StaticFileMapping...)} + *
      • {@link RestContextBuilder#parsers(Class...)} + *
      • {@link RestContextBuilder#parsers(boolean,Class...)} + *
      • {@link RestContextBuilder#parsers(Parser...)} + *
      • {@link RestContextBuilder#parsers(boolean,Parser...)} *
      - *
    • Mappings are cumulative from parent to child. - *
    • Child resources can override mappings made on parent resources. - *
    • The media type on the response is determined by the {@link org.apache.juneau.rest.RestContext#getMediaTypeForName(String)} method. - *
    • The resource finder is configured via the {@link #REST_classpathResourceFinder} setting, and can be - * overridden to provide customized handling of resource retrieval. - *
    • The {@link #REST_useClasspathResourceCaching} setting can be used to cache static files in memory - * to improve performance. + *
    • When defined as a class, properties/transforms defined on the resource/method are inherited. + *
    • When defined as an instance, properties/transforms defined on the resource/method are NOT inherited. *
    */ - public static final String REST_staticFiles = PREFIX + "staticFiles.lo"; - + public static final String REST_parsers = PREFIX + "parsers.lo"; + /** - * Configuration property: Messages. + * Configuration property: HTTP part parser. * *
      - *
    • Name: "RestContext.messages.lo" - *
    • Data type: List<MessageBundleLocation> - *
    • Default: null + *
    • Name: "RestContext.partParser.o" + *
    • Data type: Class <? extends HttpPartParser> | HttpPartParser + *
    • Default: {@link UonPartParser} *
    • Session-overridable: false *
    * *

    - * Identifies the location of the resource bundle for this class. - * - *

    - * This annotation is used to provide localized messages for the following methods: - *

      - *
    • {@link RestRequest#getMessage(String, Object...)} - *
    • {@link RestContext#getMessages()} - *
    - * - *

    - * Refer to the {@link MessageBundle} class for a description of the message key formats used in the properties file. - * - *

    - * The value can be a relative path like "nls/Messages", indicating to look for the resource bundle - * "com.foo.sample.nls.Messages" if the resource class is in "com.foo.sample", or it can be an - * absolute path, like "com.foo.sample.nls.Messages" + * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters, and URI parts. * *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_messages} + *
    • Property: {@link RestContext#REST_partParser} *
    • Annotations: *
        - *
      • {@link RestResource#messages()} + *
      • {@link RestResource#partParser()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#messages(String)}, - *
      • {@link RestContextBuilder#messages(Class,String)} - *
      • {@link RestContextBuilder#messages(MessageBundleLocation)} + *
      • {@link RestContextBuilder#partParser(Class)} + *
      • {@link RestContextBuilder#partParser(HttpPartParser)} *
      - *
    • Mappings are cumulative from parent to child. + *
    • When defined as a class, properties/transforms defined on the resource/method are inherited. + *
    • When defined as an instance, properties/transforms defined on the resource/method are NOT inherited. *
    */ - public static final String REST_messages = PREFIX + "messages.lo"; - + public static final String REST_partParser = PREFIX + "partParser.o"; + /** - * Configuration property: Static file response headers. + * Configuration property: HTTP part serializer. * *
      - *
    • Name: "RestContext.staticFileResponseHeaders.omo" - *
    • Data type: Map<String,String> - *
    • Default: {'Cache-Control': 'max-age=86400, public} + *
    • Name: "RestContext.partSerializer.o" + *
    • Data type: Class <? extends HttpPartSerializer> | HttpPartSerializer + *
    • Default: {@link SimpleUonPartSerializer} *
    • Session-overridable: false *
    * *

    - * Used to customize the headers on responses returned for statically-served files. - * + * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters, and URI parts. + * *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_staticFileResponseHeaders} + *
    • Property: {@link RestContext#REST_partSerializer} *
    • Annotations: *
        - *
      • {@link RestResource#staticFileResponseHeaders()} + *
      • {@link RestResource#partSerializer()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#staticFileResponseHeaders(boolean,Map)} - *
      • {@link RestContextBuilder#staticFileResponseHeaders(String...)} - *
      • {@link RestContextBuilder#staticFileResponseHeader(String,String)} + *
      • {@link RestContextBuilder#partSerializer(Class)} + *
      • {@link RestContextBuilder#partSerializer(HttpPartSerializer)} *
      + *
    • When defined as a class, properties/transforms defined on the resource/method are inherited. + *
    • When defined as an instance, properties/transforms defined on the resource/method are NOT inherited. *
    */ - public static final String REST_staticFileResponseHeaders = PREFIX + "staticFileResponseHeaders.omo"; - + public static final String REST_partSerializer = PREFIX + "partSerializer.o"; + /** - * Configuration property: Classpath resource finder. + * Configuration property: Resource path. * *
      - *
    • Name: "RestContext.classpathResourceFinder.o" - *
    • Data type: {@link ClasspathResourceFinder} - *
    • Default: {@link ClasspathResourceFinderBasic} + *
    • Name: "RestContext.path.s" + *
    • Data type: String + *
    • Default: null *
    • Session-overridable: false *
    * *

    - * Used to retrieve localized files from the classpath. - * + * Identifies the URL subpath relative to the parent resource. + * *

    - * - *

    Notes:
    + *
    Notes:
    *
      - *
    • Property: {@link RestContext#REST_classpathResourceFinder} + *
    • Property: {@link RestContext#REST_path} *
    • Annotations: *
        - *
      • {@link RestResource#classpathResourceFinder()} + *
      • {@link RestResource#path()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#classpathResourceFinder(Class)} - *
      • {@link RestContextBuilder#classpathResourceFinder(ClasspathResourceFinder)} + *
      • {@link RestContextBuilder#path(String)} *
      - *
    • - * The default value is {@link ClasspathResourceFinderBasic} which provides basic support for finding localized - * resources on the classpath and JVM working directory. - *
      The {@link ClasspathResourceFinderRecursive} is another option that also recursively searches for resources - * up the parent class hierarchy. - *
      Each of these classes can be extended to provide customized handling of resource retrieval. + *
    • This annotation is ignored on top-level servlets (i.e. servlets defined in web.xml files). + *
      Therefore, implementers can optionally specify a path value for documentation purposes. + *
    • Typically, this setting is only applicable to resources defined as children through the + * {@link RestResource#children()} annotation. + *
      However, it may be used in other ways (e.g. defining paths for top-level resources in microservices). + *
    + */ + public static final String REST_path = PREFIX + "path.s"; + + /** + * Configuration property: Render response stack traces in responses. + * + *
      + *
    • Name: "RestContext.renderResponseStackTraces.b" + *
    • Data type: Boolean + *
    • Default: false + *
    • Session-overridable: false *
    + * + *

    + * Render stack traces in HTTP response bodies when errors occur. + * + *

    Notes:
    + *
      + *
    • Property: {@link RestContext#REST_renderResponseStackTraces} + *
    • Annotations: + *
        + *
      • {@link RestResource#renderResponseStackTraces()} + *
      + *
    • Methods: + *
        + *
      • {@link RestContextBuilder#renderResponseStackTraces(boolean)} + *
      + *
    • Useful for debugging, although allowing stack traces to be rendered may cause security concerns so use + * caution when enabling. + *
    */ - public static final String REST_classpathResourceFinder = PREFIX + "classpathResourceFinder.o"; + public static final String REST_renderResponseStackTraces = PREFIX + "renderResponseStackTraces.b"; /** - * Configuration property: Use classpath resource caching. + * Configuration property: REST resource resolver. * *
      - *
    • Name: "RestContext.useClasspathResourceCaching.b" - *
    • Data type: Boolean - *
    • Default: true + *
    • Name: "RestContext.resourceResolver.o" + *
    • Data type: Class<? extends RestResourceResolver> | RestResourceResolver + *
    • Default: {@link RestResourceResolverSimple} *
    • Session-overridable: false *
    * + * The resolver used for resolving child resources. + * *

    - * When enabled, resources retrieved via {@link RestContext#getClasspathResource(String, Locale)} (and related - * methods) will be cached in memory to speed subsequent lookups. + * Can be used to provide customized resolution of REST resource class instances (e.g. resources retrieve from Spring). + * + *

    + *

    Notes:
    + *
      + *
    • Property: {@link RestContext#REST_resourceResolver} + *
    • Annotations: + *
        + *
      • {@link RestResource#resourceResolver()} + *
      + *
    • Methods: + *
        + *
      • {@link RestContextBuilder#resourceResolver(Class)} +
      • {@link RestContextBuilder#resourceResolver(RestResourceResolver)} +
      + *
    • Unless overridden, resource resolvers are inherited from parent resources. + *
    + */ + public static final String REST_resourceResolver = PREFIX + "resourceResolver.o"; + + /** + * Configuration property: Response handlers. + * + *
      + *
    • Name: "RestContext.responseHandlers.lo" + *
    • Data type: List<Class<? extends ResponseHandler>> + *
    • Default: empty list + *
    • Session-overridable: false + *
    * - *
    Notes:
    + *

    + * Specifies a list of {@link ResponseHandler} classes that know how to convert POJOs returned by REST methods or + * set via {@link RestResponse#setOutput(Object)} into appropriate HTTP responses. + * + *

    + * By default, the following response handlers are provided out-of-the-box: + *

      + *
    • {@link StreamableHandler} + *
    • {@link WritableHandler} + *
    • {@link ReaderHandler} + *
    • {@link InputStreamHandler} + *
    • {@link RedirectHandler} + *
    • {@link DefaultHandler} + *
    + + *

    + *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_useClasspathResourceCaching} + *
    • Property: {@link RestContext#REST_responseHandlers} *
    • Annotations: *
        - *
      • {@link RestResource#useClasspathResourceCaching()} + *
      • {@link RestResource#responseHandlers()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#useClasspathResourceCaching(boolean)} - *
      - *
    + *
  • {@link RestContextBuilder#responseHandlers(Class...)} +
  • {@link RestContextBuilder#responseHandlers(ResponseHandler...)} + + *
  • {@link ResponseHandler} classes must have either a no-arg or {@link PropertyStore} argument constructors. + * */ - public static final String REST_useClasspathResourceCaching = PREFIX + "useClasspathResourceCaching.b"; + public static final String REST_responseHandlers = PREFIX + "responseHandlers.lo"; /** - * Configuration property: HTML Widgets. + * Configuration property: Serializers. * *
      - *
    • Name: "RestContext.widgets.lo" - *
    • Data type: List<Class<? extends Widget> | Widget> + *
    • Name: "RestContext.serializers.lo" + *
    • Data type: List<Class <? extends Serializer> | Serializer> *
    • Default: empty list *
    • Session-overridable: false *
    * *

    - * Defines widgets that can be used in conjunction with string variables of the form "$W{name}"to quickly - * generate arbitrary replacement text. + * Adds class-level serializers to this resource. * - * Widgets resolve the following variables: - *

      - *
    • "$W{name}" - Contents returned by {@link Widget#getHtml(RestRequest)}. - *
    • "$W{name.script}" - Contents returned by {@link Widget#getScript(RestRequest)}. - *
      The script contents are automatically inserted into the <head/script> section - * in the HTML page. - *
    • "$W{name.style}" - Contents returned by {@link Widget#getStyle(RestRequest)}. - *
      The styles contents are automatically inserted into the <head/style> section - * in the HTML page. + *
      Notes:
      + *
        + *
      • Property: {@link RestContext#REST_serializers} + *
      • Annotations: + *
          + *
        • {@link RestResource#serializers()} + *
        • {@link RestMethod#serializers()} + *
        + *
      • Methods: + *
          + *
        • {@link RestContextBuilder#serializers(Class...)} + *
        • {@link RestContextBuilder#serializers(boolean,Class...)} + *
        • {@link RestContextBuilder#serializers(Serializer...)} + *
        • {@link RestContextBuilder#serializers(boolean,Serializer...)} + *
        + *
      • When defined as a class, properties/transforms defined on the resource/method are inherited. + *
      • When defined as an instance, properties/transforms defined on the resource/method are NOT inherited. *
      + */ + public static final String REST_serializers = PREFIX + "serializers.lo"; + + /** + * Configuration property: Static file response headers. * + *
        + *
      • Name: "RestContext.staticFileResponseHeaders.omo" + *
      • Data type: Map<String,String> + *
      • Default: {'Cache-Control': 'max-age=86400, public} + *
      • Session-overridable: false + *
      + * *

      - * The following examples shows how to associate a widget with a REST method and then have it rendered in the links - * and aside section of the page: - * - *

      - * @RestMethod( - * widgets={ - * MyWidget.class - * } - * htmldoc=@HtmlDoc( - * navlinks={ - * "$W{MyWidget}" - * }, - * aside={ - * "Check out this widget: $W{MyWidget}" - * } - * ) - * ) - *

      + * Used to customize the headers on responses returned for statically-served files. * *
      Notes:
      *
        - *
      • Property: {@link RestContext#REST_widgets} + *
      • Property: {@link RestContext#REST_staticFileResponseHeaders} *
      • Annotations: *
          - *
        • {@link HtmlDoc#widgets()} + *
        • {@link RestResource#staticFileResponseHeaders()} *
        *
      • Methods: *
          - *
        • {@link RestContextBuilder#widgets(Class...)} - *
        • {@link RestContextBuilder#widgets(Widget...)} - *
        • {@link RestContextBuilder#widgets(boolean,Widget...)} + *
        • {@link RestContextBuilder#staticFileResponseHeaders(boolean,Map)} + *
        • {@link RestContextBuilder#staticFileResponseHeaders(String...)} + *
        • {@link RestContextBuilder#staticFileResponseHeader(String,String)} *
        - *
      • Widgets are inherited from parent to child, but can be overridden by reusing the widget name. *
      */ - public static final String REST_widgets = PREFIX + "widgets.lo"; + public static final String REST_staticFileResponseHeaders = PREFIX + "staticFileResponseHeaders.omo"; /** - * Configuration property: MIME types. + * Configuration property: Static file mappings. * *
        - *
      • Name: "RestContext.mimeTypes.ss" - *
      • Data type: Set<String> - *
      • Default: empty list + *
      • Name: "RestContext.staticFiles.lo" + *
      • Data type: List<StaticFileMapping> + *
      • Default: null *
      • Session-overridable: false *
      * *

      - * Defines MIME-type file type mappings. + * Used to define paths and locations of statically-served files such as images or HTML documents. * *

      - * Used for specifying the content type on file resources retrieved through the following methods: - *

        - *
      • {@link RestContext#resolveStaticFile(String)} - *
      • {@link RestRequest#getClasspathReaderResource(String,boolean,MediaType)} - *
      • {@link RestRequest#getClasspathReaderResource(String,boolean)} - *
      • {@link RestRequest#getClasspathReaderResource(String)} - *
      + * Static files are found by calling {@link #getClasspathResource(String,Locale)} which uses the registered + * {@link ClasspathResourceFinder} for locating files on the classpath (or other location). + * + *

      + * An example where this class is used is in the {@link RestResource#staticFiles} annotation: + *

      + * package com.foo.mypackage; + * + * @RestResource( + * path="/myresource", + * staticFiles={"htdocs:docs","styles:styles"} + * ) + * public class MyResource extends RestServletDefault {...} + *

      * *

      - * This list appends to the existing list provided by {@link ExtendedMimetypesFileTypeMap}. + * In the example above, given a GET request to /myresource/htdocs/foobar.html, the servlet will attempt to find + * the foobar.html file in the following ordered locations: + *

        + *
      1. com.foo.mypackage.docs package. + *
      2. org.apache.juneau.rest.docs package (since RestServletDefault is in org.apache.juneau.rest). + *
      3. [working-dir]/docs directory. + *
      * *
      Notes:
      *
        - *
      • Property: {@link RestContext#REST_mimeTypes} + *
      • Property: {@link RestContext#REST_staticFiles} *
      • Annotations: *
          - *
        • {@link RestResource#mimeTypes()} + *
        • {@link RestResource#staticFiles()} *
        *
      • Methods: *
          - *
        • {@link RestContextBuilder#mimeTypes(String...)} + *
        • {@link RestContextBuilder#staticFiles(String)}, + *
        • {@link RestContextBuilder#staticFiles(Class,String)} + *
        • {@link RestContextBuilder#staticFiles(String,String)} + *
        • {@link RestContextBuilder#staticFiles(Class,String,String)} + *
        • {@link RestContextBuilder#staticFiles(StaticFileMapping...)} *
        - *
      • Values are .mime.types formatted entry string. - *
        Example: "image/svg+xml svg" + *
      • Mappings are cumulative from parent to child. + *
      • Child resources can override mappings made on parent resources. + *
      • The media type on the response is determined by the {@link org.apache.juneau.rest.RestContext#getMediaTypeForName(String)} method. + *
      • The resource finder is configured via the {@link #REST_classpathResourceFinder} setting, and can be + * overridden to provide customized handling of resource retrieval. + *
      • The {@link #REST_useClasspathResourceCaching} setting can be used to cache static files in memory + * to improve performance. *
      */ - public static final String REST_mimeTypes = PREFIX + "mimeTypes.ss"; - + public static final String REST_staticFiles = PREFIX + "staticFiles.lo"; + /** - * Configuration property: Serializers. + * Configuration property: Supported accept media types. * *
        - *
      • Name: "RestContext.serializers.lo" - *
      • Data type: List<Class <? extends Serializer> | Serializer> + *
      • Name: "RestContext.supportedAcceptTypes.ls" + *
      • Data type: List<String> *
      • Default: empty list *
      • Session-overridable: false *
      * *

      - * Adds class-level serializers to this resource. + * Overrides the media types inferred from the serializers that identify what media types can be produced by the resource. * - *

      Notes:
      + *

      + * This affects the values returned by {@link RestRequest#getSupportedAcceptTypes()} and the supported accept + * types shown in {@link RestInfoProvider#getSwagger(RestRequest)}. + * + *

      + *

      Notes:
      *
        - *
      • Property: {@link RestContext#REST_serializers} - *
      • Annotations: + *
      • Property: {@link RestContext#REST_supportedAcceptTypes} + *
      • Annotations: *
          - *
        • {@link RestResource#serializers()} - *
        • {@link RestMethod#serializers()} - *
        - *
      • Methods: + *
      • {@link RestResource#supportedAcceptTypes()} + *
      • {@link RestMethod#supportedAcceptTypes()} + *
      + *
    • Methods: *
        - *
      • {@link RestContextBuilder#serializers(Class...)} - *
      • {@link RestContextBuilder#serializers(boolean,Class...)} - *
      • {@link RestContextBuilder#serializers(Serializer...)} - *
      • {@link RestContextBuilder#serializers(boolean,Serializer...)} + *
      • {@link RestContextBuilder#supportedAcceptTypes(boolean,String...)} + *
      • {@link RestContextBuilder#supportedAcceptTypes(boolean,MediaType...)} *
      - *
    • When defined as a class, properties/transforms defined on the resource/method are inherited. - *
    • When defined as an instance, properties/transforms defined on the resource/method are NOT inherited. - *
    + * */ - public static final String REST_serializers = PREFIX + "serializers.lo"; + public static final String REST_supportedAcceptTypes = PREFIX + "supportedAcceptTypes.ls"; /** - * Configuration property: Parsers. + * Configuration property: Supported content media types. * *
      - *
    • Name: "RestContext.parsers.lo" - *
    • Data type: List<Class <? extends Parser> | Parser> + *
    • Name: "RestContext.supportedContentTypes.ls" + *
    • Data type: List<String> *
    • Default: empty list *
    • Session-overridable: false *
    * *

    - * Adds class-level parsers to this resource. + * Overrides the media types inferred from the parsers that identify what media types can be consumed by the resource. + * + *

    + * This affects the values returned by {@link RestRequest#getSupportedContentTypes()} and the supported content + * types shown in {@link RestInfoProvider#getSwagger(RestRequest)}. * - *

    Notes:
    + *

    + *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_parsers} - *
    • Annotations: + *
    • Property: {@link RestContext#REST_supportedContentTypes} + *
    • Annotations: *
        - *
      • {@link RestResource#parsers()} - *
      • {@link RestMethod#parsers()} - *
      - *
    • Methods: + *
    • {@link RestResource#supportedContentTypes()} + *
    • {@link RestMethod#supportedContentTypes()} + *
    + *
  • Methods: *
      - *
    • {@link RestContextBuilder#parsers(Class...)} - *
    • {@link RestContextBuilder#parsers(boolean,Class...)} - *
    • {@link RestContextBuilder#parsers(Parser...)} - *
    • {@link RestContextBuilder#parsers(boolean,Parser...)} + *
    • {@link RestContextBuilder#supportedContentTypes(boolean,String...)} + *
    • {@link RestContextBuilder#supportedContentTypes(boolean,MediaType...)} *
    - *
  • When defined as a class, properties/transforms defined on the resource/method are inherited. - *
  • When defined as an instance, properties/transforms defined on the resource/method are NOT inherited. - * + * */ - public static final String REST_parsers = PREFIX + "parsers.lo"; - + public static final String REST_supportedContentTypes = PREFIX + "supportedContentTypes.ls"; + /** - * Configuration property: HTTP part serializer. + * Configuration property: Use classpath resource caching. * *
      - *
    • Name: "RestContext.partSerializer.o" - *
    • Data type: Class <? extends HttpPartSerializer> | HttpPartSerializer - *
    • Default: {@link SimpleUonPartSerializer} + *
    • Name: "RestContext.useClasspathResourceCaching.b" + *
    • Data type: Boolean + *
    • Default: true *
    • Session-overridable: false *
    * *

    - * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters, and URI parts. - * + * When enabled, resources retrieved via {@link RestContext#getClasspathResource(String, Locale)} (and related + * methods) will be cached in memory to speed subsequent lookups. + * *

    Notes:
    *
      - *
    • Property: {@link RestContext#REST_partSerializer} + *
    • Property: {@link RestContext#REST_useClasspathResourceCaching} *
    • Annotations: *
        - *
      • {@link RestResource#partSerializer()} + *
      • {@link RestResource#useClasspathResourceCaching()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#partSerializer(Class)} - *
      • {@link RestContextBuilder#partSerializer(HttpPartSerializer)} + *
      • {@link RestContextBuilder#useClasspathResourceCaching(boolean)} *
      - *
    • When defined as a class, properties/transforms defined on the resource/method are inherited. - *
    • When defined as an instance, properties/transforms defined on the resource/method are NOT inherited. *
    */ - public static final String REST_partSerializer = PREFIX + "partSerializer.o"; + public static final String REST_useClasspathResourceCaching = PREFIX + "useClasspathResourceCaching.b"; /** - * Configuration property: HTTP part parser. + * Configuration property: Use stack trace hashes. * *
      - *
    • Name: "RestContext.partParser.o" - *
    • Data type: Class <? extends HttpPartParser> | HttpPartParser - *
    • Default: {@link UonPartParser} + *
    • Name: "RestContext.useStackTraceHashes.b" + *
    • Data type: Boolean + *
    • Default: true *
    • Session-overridable: false *
    - * + * *

    - * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters, and URI parts. - * - *

    Notes:
    + * When enabled, the number of times an exception has occurred will be determined based on stack trace hashsums, + * made available through the {@link RestException#getOccurrence()} method. + * + *
    Notes:
    *
      - *
    • Property: {@link RestContext#REST_partParser} - *
    • Annotations: + *
    • Property: {@link RestContext#REST_useStackTraceHashes} + *
    • Annotations: *
        - *
      • {@link RestResource#partParser()} + *
      • {@link RestResource#useStackTraceHashes()} *
      - *
    • Methods: + *
    • Methods: *
        - *
      • {@link RestContextBuilder#partParser(Class)} - *
      • {@link RestContextBuilder#partParser(HttpPartParser)} + *
      • {@link RestContextBuilder#useStackTraceHashes(boolean)} *
      - *
    • When defined as a class, properties/transforms defined on the resource/method are inherited. - *
    • When defined as an instance, properties/transforms defined on the resource/method are NOT inherited. - *
    + * */ - public static final String REST_partParser = PREFIX + "partParser.o"; - + public static final String REST_useStackTraceHashes = PREFIX + "useStackTraceHashes.b"; + /** - * Configuration property: Compression encoders. + * Configuration property: HTML Widgets. * *
      - *
    • Name: "RestContext.encoders.o" - *
    • Data type: List<Class <? extends Encoder> | Encoder> + *
    • Name: "RestContext.widgets.lo" + *
    • Data type: List<Class<? extends Widget> | Widget> *
    • Default: empty list *
    • Session-overridable: false *
    * *

    - * These can be used to enable various kinds of compression (e.g. "gzip") on requests and responses. + * Defines widgets that can be used in conjunction with string variables of the form "$W{name}"to quickly + * generate arbitrary replacement text. + * + * Widgets resolve the following variables: + *

      + *
    • "$W{name}" - Contents returned by {@link Widget#getHtml(RestRequest)}. + *
    • "$W{name.script}" - Contents returned by {@link Widget#getScript(RestRequest)}. + *
      The script contents are automatically inserted into the <head/script> section + * in the HTML page. + *
    • "$W{name.style}" - Contents returned by {@link Widget#getStyle(RestRequest)}. + *
      The styles contents are automatically inserted into the <head/style> section + * in the HTML page. + *
    + * + *

    + * The following examples shows how to associate a widget with a REST method and then have it rendered in the links + * and aside section of the page: * - *

    Example:
    *

    - * // Servlet with automated support for GZIP compression - * @RestResource(encoders={GzipEncoder.class}) - * public MyRestServlet extends RestServlet { - * ... - * } + * @RestMethod( + * widgets={ + * MyWidget.class + * } + * htmldoc=@HtmlDoc( + * navlinks={ + * "$W{MyWidget}" + * }, + * aside={ + * "Check out this widget: $W{MyWidget}" + * } + * ) + * ) *

    * *
    Notes:
    *
      - *
    • Property: {@link RestContext#REST_encoders} + *
    • Property: {@link RestContext#REST_widgets} *
    • Annotations: *
        - *
      • {@link RestResource#encoders()} - *
      • {@link RestMethod#encoders()} + *
      • {@link HtmlDoc#widgets()} *
      *
    • Methods: *
        - *
      • {@link RestContextBuilder#encoders(Class...)} - *
      • {@link RestContextBuilder#encoders(Encoder...)} + *
      • {@link RestContextBuilder#widgets(Class...)} + *
      • {@link RestContextBuilder#widgets(Widget...)} + *
      • {@link RestContextBuilder#widgets(boolean,Widget...)} *
      - *
    • Instance classes must provide a public no-arg constructor, or a public constructor that takes in a - * {@link PropertyStore} object. - *
    • Instance class can be defined as an inner class of the REST resource class. + *
    • Widgets are inherited from parent to child, but can be overridden by reusing the widget name. *
    */ - public static final String REST_encoders = PREFIX + "encoders.lo"; - + public static final String REST_widgets = PREFIX + "widgets.lo"; + //------------------------------------------------------------------------------------------------------------------- // Instance @@ -1442,7 +1442,7 @@ public final class RestContext extends BeanContext { defaultResponseHeaders = getMapProperty(REST_defaultResponseHeaders, Object.class); staticFileResponseHeaders = getMapProperty(REST_staticFileResponseHeaders, Object.class); - logger = getInstanceProperty(REST_logger, resource, RestLogger.class, RestLogger.NoOp.class, false); + logger = getInstanceProperty(REST_logger, resource, RestLogger.class, RestLogger.NoOp.class, true, ps); varResolver = builder.varResolverBuilder .vars( @@ -1472,7 +1472,7 @@ public final class RestContext extends BeanContext { partSerializer = getInstanceProperty(REST_partSerializer, HttpPartSerializer.class, SimpleUonPartSerializer.class, true, resource, ps); partParser = getInstanceProperty(REST_partSerializer, HttpPartParser.class, UonPartParser.class, true, resource, ps); encoders = new EncoderGroupBuilder().append(getInstanceArrayProperty(REST_encoders, Encoder.class, new Encoder[0], true, resource, ps)).build(); - beanContext = BeanContext.create().apply(ps).add(properties).build(); + beanContext = BeanContext.create().apply(ps).build(); mimetypesFileTypeMap = new ExtendedMimetypesFileTypeMap(); for (String mimeType : getArrayProperty(REST_mimeTypes, String.class)) @@ -1505,7 +1505,7 @@ public final class RestContext extends BeanContext { this.childResources = Collections.synchronizedMap(new LinkedHashMap()); // Not unmodifiable on purpose so that children can be replaced. Map _widgets = new LinkedHashMap<>(); - for (Widget w : getInstanceArrayProperty(REST_widgets, Widget.class, new Widget[0], true, resource, ps)) + for (Widget w : getInstanceArrayProperty(REST_widgets, resource, Widget.class, new Widget[0], true, ps)) _widgets.put(w.getName(), w); this.widgets = Collections.unmodifiableMap(_widgets); @@ -1534,13 +1534,13 @@ public final class RestContext extends BeanContext { _postInitChildFirstMethodParams = new ArrayList<>(), _destroyMethodParams = new ArrayList<>(); - for (java.lang.reflect.Method method : resource.getClass().getMethods()) { + for (java.lang.reflect.Method method : resourceClass.getMethods()) { if (method.isAnnotationPresent(RestMethod.class)) { RestMethod a = method.getAnnotation(RestMethod.class); methodsFound.add(method.getName() + "," + a.name() + "," + a.path()); try { if (! Modifier.isPublic(method.getModifiers())) - throw new RestServletException("@RestMethod method {0}.{1} must be defined as public.", this.getClass().getName(), method.getName()); + throw new RestServletException("@RestMethod method {0}.{1} must be defined as public.", resourceClass.getName(), method.getName()); CallMethod sm = new CallMethod(resource, method, this); String httpMethod = sm.getHttpMethod(); @@ -1602,12 +1602,12 @@ public final class RestContext extends BeanContext { addToRouter(routers, httpMethod, sm); } } catch (RestServletException e) { - throw new RestServletException("Problem occurred trying to serialize methods on class {0}, methods={1}", this.getClass().getName(), JsonSerializer.DEFAULT_LAX.serialize(methodsFound)).initCause(e); + throw new RestServletException("Problem occurred trying to serialize methods on class {0}, methods={1}", resourceClass.getName(), JsonSerializer.DEFAULT_LAX.serialize(methodsFound)).initCause(e); } } } - for (Method m : ClassUtils.getAllMethods(resource.getClass(), true)) { + for (Method m : ClassUtils.getAllMethods(resourceClass, true)) { if (ClassUtils.isPublic(m) && m.isAnnotationPresent(RestHook.class)) { HookEvent he = m.getAnnotation(RestHook.class).value(); String sig = ClassUtils.getMethodSignature(m); @@ -1700,7 +1700,7 @@ public final class RestContext extends BeanContext { this.callRouters = Collections.unmodifiableMap(_callRouters); // Initialize our child resources. - resourceResolver = getInstanceProperty(REST_resourceResolver, resource, RestResourceResolver.class, parentContext == null ? RestResourceResolverSimple.class : parentContext.resourceResolver, true, this); + resourceResolver = getInstanceProperty(REST_resourceResolver, resource, RestResourceResolver.class, parentContext == null ? RestResourceResolverSimple.class : parentContext.resourceResolver, true, this, ps); for (Object o : builder.childResources) { String path = null; Object r = null; @@ -1740,8 +1740,8 @@ public final class RestContext extends BeanContext { childResources.put(path, rc2); } - callHandler = getInstanceProperty(REST_callHandler, resource, RestCallHandler.class, RestCallHandler.class, true, this); - infoProvider = getInstanceProperty(REST_infoProvider, resource, RestInfoProvider.class, RestInfoProvider.class, true, this); + callHandler = getInstanceProperty(REST_callHandler, resource, RestCallHandler.class, RestCallHandler.class, true, this, ps); + infoProvider = getInstanceProperty(REST_infoProvider, resource, RestInfoProvider.class, RestInfoProvider.class, true, this, ps); } catch (RestException e) { _initException = e; @@ -1760,27 +1760,6 @@ public final class RestContext extends BeanContext { routers.get(httpMethodName).add(cm); } - static final boolean getBoolean(Object o, String systemProperty, boolean def) { - if (o == null) - o = SystemUtils.getFirstBoolean(def, systemProperty); - return "true".equalsIgnoreCase(o.toString()); - } - - static final String getString(Object o, String systemProperty, String def) { - if (o == null) - o = SystemUtils.getFirstString(def, systemProperty); - return o.toString(); - } - - static final long getLong(Object o, String systemProperty, long def) { - String s = StringUtils.toString(o); - if (s == null) - s = System.getProperty(systemProperty); - if (StringUtils.isEmpty(s)) - return def; - return StringUtils.parseLongWithSuffix(s); - } - /** * Returns the resource resolver associated with this context. * @@ -1849,9 +1828,12 @@ public final class RestContext extends BeanContext { * The following is the default list of supported variables: *
      *
    • $C{key[,defaultValue]} - Config file entry. See {@link ConfigFileVar}. + *
    • $CO{arg1[,arg2...]} - Coalesce variable. See {@link CoalesceVar}. + *
    • $CR{arg1[,arg2...]} - Coalesce-and-recurse variable. See {@link CoalesceAndRecurseVar}. *
    • $E{envVar[,defaultValue]} - Environment variable. See {@link EnvVariablesVar}. *
    • $F{path[,defaultValue]} - File resource. See {@link FileVar}. *
    • $I{name[,defaultValue]} - Servlet init parameter. See {@link ServletInitParamVar}. + *
    • $IF{booleanArg,thenValue[,elseValue]} - If/else variable. See {@link IfVar}. *
    • $L{key[,args...]} - Localized message. See {@link LocalizationVar}. *
    • $RA{key1[,key2...]} - Request attribute variable. See {@link RequestAttributeVar}. *
    • $RF{key1[,key2...]} - Request form-data variable. See {@link RequestFormDataVar}. @@ -1861,21 +1843,13 @@ public final class RestContext extends BeanContext { *
    • $R{key1[,key2...]} - Request object variable. See {@link RequestVar}. *
    • $S{systemProperty[,defaultValue]} - System property. See {@link SystemPropertiesVar}. *
    • $SA{contentType,key[,defaultValue]} - Serialized request attribute. See {@link SerializedRequestAttrVar}. + *
    • $SW{stringArg(,pattern,thenValue)+[,elseValue]} - Switch variable. See {@link SwitchVar}. *
    • $U{uri} - URI resolver. See {@link UrlVar}. *
    • $UE{uriPart} - URL-Encoder. See {@link UrlEncodeVar}. *
    • $W{widgetName} - HTML widget variable. See {@link WidgetVar}. *
    * *

    - * The following syntax variables are also provided: - *

      - *
    • $CO{string1[,string2...]} - Coalesce variable. See {@link CoalesceVar}. - *
    • $CR{string1[,string2...]} - Coalesce-and-recurse variable. See {@link CoalesceAndRecurseVar}. - *
    • $IF{booleanArg,thenValue[,elseValue]} - If/else variable. See {@link IfVar}. - *
    • $SW{stringArg(,pattern,thenValue)+[,elseValue]} - Switch variable. See {@link SwitchVar}. - *
    - * - *

    * The list of variables can be extended using the {@link RestContextBuilder#vars(Class...)} method. * For example, this is used to add support for the Args and Manifest-File variables in the microservice * Resource class. @@ -2855,21 +2829,6 @@ public final class RestContext extends BeanContext { return null; } - //---------------------------------------------------------------------------------------------------- - // Utility methods - //---------------------------------------------------------------------------------------------------- - - /** - * Takes in an object of type T or a Class and either casts or constructs a T. - */ - static final T resolve(Object outer, Class c, Object o, Object...cArgs) throws RestServletException { - try { - return ClassUtils.newInstanceFromOuter(outer, c, o, true, cArgs); - } catch (Exception e) { - throw new RestServletException("Exception occurred while constructing class ''{0}''", c).initCause(e); - } - } - @Override /* BeanContextBuilder */ public BeanSession createSession(BeanSessionArgs args) { throw new NoSuchMethodError(); http://git-wip-us.apache.org/repos/asf/juneau/blob/30ac20a1/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java index 70ec0db..8a3d14c 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java @@ -35,7 +35,6 @@ import org.apache.juneau.internal.*; import org.apache.juneau.parser.*; import org.apache.juneau.rest.annotation.*; import org.apache.juneau.rest.response.*; -import org.apache.juneau.rest.vars.*; import org.apache.juneau.rest.widget.*; import org.apache.juneau.serializer.*; import org.apache.juneau.svl.*; @@ -149,7 +148,9 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon EnvVariablesVar.class, ConfigFileVar.class, IfVar.class, - SwitchVar.class + SwitchVar.class, + CoalesceVar.class, + CoalesceAndRecurseVar.class ); VarResolver vr = varResolverBuilder.build(); @@ -327,26 +328,7 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon * used to resolve string variables of the form "$X{...}". * *

    - * By default, this config includes the following variables: - *

      - *
    • {@link SystemPropertiesVar} - *
    • {@link EnvVariablesVar} - *
    • {@link ConfigFileVar} - *
    • {@link IfVar} - *
    • {@link SwitchVar} - *
    - * - *

    - * Later during the construction of {@link RestContext}, we add the following variables: - *

      - *
    • {@link LocalizationVar} - *
    • {@link RequestVar} - *
    • {@link SerializedRequestAttrVar} - *
    • {@link ServletInitParamVar} - *
    • {@link UrlVar} - *
    • {@link UrlEncodeVar} - *
    • {@link WidgetVar} - *
    + * See {@link RestContext#getVarResolver()} for a list of predefined variables. * * @param vars The {@link Var} classes to add to this config. * @return This object (for method chaining).