001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest;
014
015import static org.apache.juneau.internal.StringUtils.*;
016import static org.apache.juneau.parser.Parser.*;
017import static org.apache.juneau.rest.RestContext.*;
018import static org.apache.juneau.rest.HttpRuntimeException.*;
019import static org.apache.juneau.serializer.Serializer.*;
020import static org.apache.juneau.internal.CollectionUtils.*;
021
022import java.lang.annotation.*;
023import java.nio.charset.*;
024import java.util.*;
025
026import javax.servlet.*;
027
028import org.apache.juneau.*;
029import org.apache.juneau.config.*;
030import org.apache.juneau.config.vars.*;
031import org.apache.juneau.encoders.*;
032import org.apache.juneau.html.*;
033import org.apache.juneau.http.*;
034import org.apache.juneau.http.exception.*;
035import org.apache.juneau.httppart.*;
036import org.apache.juneau.oapi.*;
037import org.apache.juneau.parser.*;
038import org.apache.juneau.reflect.*;
039import org.apache.juneau.rest.annotation.*;
040import org.apache.juneau.rest.reshandlers.*;
041import org.apache.juneau.rest.util.RestUtils;
042import org.apache.juneau.rest.vars.*;
043import org.apache.juneau.rest.widget.*;
044import org.apache.juneau.serializer.*;
045import org.apache.juneau.svl.*;
046import org.apache.juneau.svl.vars.*;
047import org.apache.juneau.utils.*;
048
049/**
050 * Defines the initial configuration of a <c>RestServlet</c> or <c>@Rest</c> annotated object.
051 *
052 * <p>
053 * An extension of the {@link ServletConfig} object used during servlet initialization.
054 *
055 * <p>
056 * Provides access to the following initialized resources:
057 * <ul>
058 *    <li>{@link #getConfig()} - The external configuration for this resource.
059 *    <li>{@link #getProperties()} - The modifiable configuration properties for this resource.
060 *    <li>{@link #getVarResolverBuilder()} - The variable resolver for this resource.
061 * </ul>
062 *
063 * <p>
064 * Methods are provided for overriding or augmenting the information provided by the <ja>@Rest</ja> annotation.
065 * In general, most information provided in the <ja>@Rest</ja> annotation can be specified programmatically
066 * through calls on this object.
067 *
068 * <p>
069 * To interact with this object, simply pass it in as a constructor argument or in an INIT hook.
070 * <p class='bcode w800'>
071 *    <jc>// Option #1 - Pass in through constructor.</jc>
072 *    <jk>public</jk> MyResource(RestContextBuilder builder) {
073 *          builder
074 *             .pojoSwaps(TemporalCalendarSwap.IsoLocalDateTime.<jk>class</jk>)
075 *             .set(<jsf>PARSER_debug</jsf>, <jk>true</jk>);
076 *    }
077 *
078 *    <jc>// Option #2 - Use an INIT hook.</jc>
079 *    <ja>@RestHook</ja>(<jsf>INIT</jsf>)
080 *    <jk>public void</jk> init(RestContextBuilder builder) <jk>throws</jk> Exception {
081 *          builder
082 *             .pojoSwaps(TemporalCalendarSwap.IsoLocalDateTime.<jk>class</jk>)
083 *             .set(<jsf>PARSER_debug</jsf>, <jk>true</jk>);
084 *    }
085 * </p>
086 *
087 * <ul class='seealso'>
088 *    <li class='link'>{@doc juneau-rest-server.RestContext}
089 * </ul>
090 */
091public class RestContextBuilder extends BeanContextBuilder implements ServletConfig {
092
093   final ServletConfig inner;
094
095   Class<?> resourceClass;
096   Object resource;
097   ServletContext servletContext;
098   RestContext parentContext;
099
100   //-----------------------------------------------------------------------------------------------------------------
101   // The following fields are meant to be modifiable.
102   // They should not be declared final.
103   // Read-only snapshots of these will be made in RestServletContext.
104   //-----------------------------------------------------------------------------------------------------------------
105
106   RestContextProperties properties;
107   Config config;
108   VarResolverBuilder varResolverBuilder;
109
110   @SuppressWarnings("deprecation")
111   RestContextBuilder(ServletConfig servletConfig, Class<?> resourceClass, RestContext parentContext) throws ServletException {
112      this.inner = servletConfig;
113      this.resourceClass = resourceClass;
114      this.parentContext = parentContext;
115      this.properties = new RestContextProperties();
116
117      ClassInfo rci = ClassInfo.of(resourceClass);
118
119      // Default values.
120      logger(BasicRestLogger.class);
121      partSerializer(OpenApiSerializer.class);
122      partParser(OpenApiParser.class);
123      staticFileResponseHeader("Cache-Control", "max-age=86400, public");
124      encoders(IdentityEncoder.INSTANCE);
125      responseHandlers(
126         ReaderHandler.class,
127         InputStreamHandler.class,
128         DefaultHandler.class
129      );
130
131      try {
132
133         varResolverBuilder = new VarResolverBuilder()
134            .defaultVars()
135            .vars(ConfigVar.class)
136            .vars(FileVar.class)
137            .contextObject("crm", new ClasspathResourceManager(resourceClass));
138
139         VarResolver vr = varResolverBuilder.build();
140
141         List<AnnotationInfo<RestResource>> restResourceAnnotationsParentFirst = rci.getAnnotationInfosParentFirst(RestResource.class);
142         List<AnnotationInfo<Rest>> restAnnotationsParentFirst = rci.getAnnotationInfosParentFirst(Rest.class);
143
144         // Find our config file.  It's the last non-empty @RestResource(config).
145         String configPath = "";
146         for (AnnotationInfo<RestResource> r : restResourceAnnotationsParentFirst)
147            if (! r.getAnnotation().config().isEmpty())
148               configPath = r.getAnnotation().config();
149         for (AnnotationInfo<Rest> r : restAnnotationsParentFirst)
150            if (! r.getAnnotation().config().isEmpty())
151               configPath = r.getAnnotation().config();
152         String cf = vr.resolve(configPath);
153
154         if ("SYSTEM_DEFAULT".equals(cf))
155            this.config = Config.getSystemDefault();
156
157         if (this.config == null) {
158            ConfigBuilder cb = Config.create().varResolver(vr);
159            if (! cf.isEmpty())
160               cb.name(cf);
161            this.config = cb.build();
162         }
163
164         // Add our config file to the variable resolver.
165         varResolverBuilder.contextObject(ConfigVar.SESSION_config, config);
166         vr = varResolverBuilder.build();
167
168         // Add the servlet init parameters to our properties.
169         if (servletConfig != null) {
170            for (Enumeration<String> ep = servletConfig.getInitParameterNames(); ep.hasMoreElements();) {
171               String p = ep.nextElement();
172               String initParam = servletConfig.getInitParameter(p);
173               set(vr.resolve(p), vr.resolve(initParam));
174            }
175         }
176
177         applyAnnotations(rci.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE), vr.createSession());
178
179         // Load stuff from parent-to-child order.
180         // This allows child settings to overwrite parent settings.
181         for (AnnotationInfo<RestResource> e : restResourceAnnotationsParentFirst) {
182            RestResource r = e.getAnnotation();
183            for (Property p : r.properties())
184               set(vr.resolve(p.name()), vr.resolve(p.value()));
185            for (String p : r.flags())
186               set(p, true);
187         }
188         for (AnnotationInfo<Rest> e : restAnnotationsParentFirst) {
189            Rest r = e.getAnnotation();
190            for (Property p : r.properties())
191               set(vr.resolve(p.name()), vr.resolve(p.value()));
192            for (String p : r.flags())
193               set(p, true);
194         }
195
196      } catch (Exception e) {
197         throw new ServletException(e);
198      }
199   }
200
201   @Override /* BeanContextBuilder */
202   public RestContext build() {
203      try {
204         return new RestContext(this);
205      } catch (Exception e) {
206         throw toHttpException(e, InternalServerError.class);
207      }
208   }
209
210   /*
211    * Calls all @RestHook(INIT) methods on the specified resource object.
212    */
213   RestContextBuilder init(Object resource) throws ServletException {
214      this.resource = resource;
215      ClassInfo rci = ClassInfo.of(resourceClass);
216
217      Map<String,MethodInfo> map = new LinkedHashMap<>();
218      for (MethodInfo m : rci.getAllMethodsParentFirst()) {
219         if (m.hasAnnotation(RestHook.class) && m.getAnnotation(RestHook.class).value() == HookEvent.INIT) {
220            m.setAccessible();
221            String sig = m.getSignature();
222            if (! map.containsKey(sig))
223               map.put(sig, m);
224         }
225      }
226      for (MethodInfo m : map.values()) {
227         assertArgsOnlyOfType(m, RestContextBuilder.class, ServletConfig.class);
228         Class<?>[] pt = m.getRawParamTypes();
229         Object[] args = new Object[pt.length];
230         for (int i = 0; i < args.length; i++) {
231            if (pt[i] == RestContextBuilder.class)
232               args[i] = this;
233            else
234               args[i] = this.inner;
235         }
236         try {
237            m.invoke(resource, args);
238         } catch (Exception e) {
239            throw new RestServletException("Exception thrown from @RestHook(INIT) method {0}.", m).initCause(e);
240         }
241      }
242      return this;
243   }
244
245   private static void assertArgsOnlyOfType(MethodInfo m, Class<?>...args) {
246      if (! m.argsOnlyOfType(args))
247         throw new FormattedIllegalArgumentException("Invalid arguments passed to method {0}.  Only arguments of type {1} are allowed.", m, args);
248   }
249
250   RestContextBuilder servletContext(ServletContext servletContext) {
251      this.servletContext = servletContext;
252      return this;
253   }
254
255   /**
256    * Adds the specified {@link Var} classes to this config.
257    *
258    * <p>
259    * These variables affect the variable resolver returned by {@link RestRequest#getVarResolverSession()} which is
260    * used to resolve string variables of the form <js>"$X{...}"</js>.
261    *
262    * <p>
263    * See {@link RestContext#getVarResolver()} for a list of predefined variables.
264    *
265    * @param vars The {@link Var} classes to add to this config.
266    * @return This object (for method chaining).
267    */
268   public RestContextBuilder vars(Class<?>...vars) {
269      this.varResolverBuilder.vars(vars);
270      return this;
271   }
272
273   /**
274    * Adds a var context object to this config.
275    *
276    * <p>
277    * Var context objects are read-only objects associated with the variable resolver for vars that require external
278    * information.
279    *
280    * <p>
281    * For example, the {@link ConfigVar} needs access to this resource's {@link Config} through the
282    * {@link ConfigVar#SESSION_config} object that can be specified as either a session object (temporary) or
283    * context object (permanent).
284    * In this case, we call the following code to add it to the context map:
285    * <p class='bcode w800'>
286    *    config.addVarContextObject(<jsf>SESSION_config</jsf>, configFile);
287    * </p>
288    *
289    * @param name The context object key (i.e. the name that the Var class looks for).
290    * @param object The context object.
291    * @return This object (for method chaining).
292    */
293   public RestContextBuilder varContextObject(String name, Object object) {
294      this.varResolverBuilder.contextObject(name, object);
295      return this;
296   }
297
298   /**
299    * Overwrites the default config file with a custom config file.
300    *
301    * <p>
302    * By default, the config file is determined using the {@link Rest#config() @Rest(config)}
303    * annotation.
304    * This method allows you to programmatically override it with your own custom config file.
305    *
306    * @param config The new config file.
307    * @return This object (for method chaining).
308    */
309   public RestContextBuilder config(Config config) {
310      this.config = config;
311      return this;
312   }
313
314   /**
315    * Creates a new {@link PropertyStore} object initialized with the properties defined in this config.
316    *
317    * @return A new property store.
318    */
319   protected PropertyStoreBuilder createPropertyStore() {
320      return PropertyStore.create().add(properties);
321   }
322
323
324   //----------------------------------------------------------------------------------------------------
325   // Methods that give access to the config file, var resolver, and properties.
326   //----------------------------------------------------------------------------------------------------
327
328   /**
329    * Returns the external configuration file for this resource.
330    *
331    * <p>
332    * The configuration file location is determined via the {@link Rest#config() @Rest(config)}
333    * annotation on the resource.
334    *
335    * <p>
336    * The config file can be programmatically overridden by adding the following method to your resource:
337    * <p class='bcode w800'>
338    *    <jk>public</jk> Config createConfig(ServletConfig servletConfig) <jk>throws</jk> ServletException;
339    * </p>
340    *
341    * <p>
342    * If a config file is not set up, then an empty config file will be returned that is not backed by any file.
343    *
344    * @return The external config file for this resource.  Never <jk>null</jk>.
345    */
346   public Config getConfig() {
347      return config;
348   }
349
350   /**
351    * Returns the configuration properties for this resource.
352    *
353    * <p>
354    * The configuration properties are determined via the {@link Rest#properties() @Rest(properties)} annotation on the resource.
355    *
356    * <p>
357    * The configuration properties can be augmented programmatically by adding the following method to your resource:
358    * <p class='bcode w800'>
359    *    <jk>public</jk> RestContextProperties createProperties(ServletConfig servletConfig) <jk>throws</jk> ServletException;
360    * </p>
361    *
362    * <p>
363    * These properties can be modified during servlet initialization.
364    * However, any modifications made after {@link RestServlet#init(ServletConfig)} has been called will have no effect.
365    *
366    * @return The configuration properties for this resource.  Never <jk>null</jk>.
367    */
368   public RestContextProperties getProperties() {
369      return properties;
370   }
371
372   /**
373    * Creates the variable resolver for this resource.
374    *
375    * <p>
376    * The variable resolver returned by this method can resolve the following variables:
377    * <ul>
378    *    <li>{@link SystemPropertiesVar}
379    *    <li>{@link EnvVariablesVar}
380    *    <li>{@link ConfigVar}
381    *    <li>{@link IfVar}
382    *    <li>{@link SwitchVar}
383    * </ul>
384    *
385    * <p>
386    * Note that the variables supported here are only a subset of those returned by
387    * {@link RestRequest#getVarResolverSession()}.
388    *
389    * @return The variable resolver for this resource.  Never <jk>null</jk>.
390    */
391   public VarResolverBuilder getVarResolverBuilder() {
392      return varResolverBuilder;
393   }
394
395   /**
396    * Returns the REST path defined on this builder.
397    *
398    * @return The REST path defined on this builder.
399    */
400   public String getPath() {
401      Object p = peek(REST_path);
402      return p == null ? "_" : p.toString();
403   }
404
405   //----------------------------------------------------------------------------------------------------
406   // Properties
407   //----------------------------------------------------------------------------------------------------
408
409   /**
410    * Configuration property:  Allow body URL parameter.
411    *
412    * <p>
413    * When enabled, the HTTP body content on PUT and POST requests can be passed in as text using the <js>"body"</js>
414    * URL parameter.
415    * <br>
416    * For example:
417    * <p class='bcode w800'>
418    *  ?body=(name='John%20Smith',age=45)
419    * </p>
420    *
421    * <ul class='seealso'>
422    *    <li class='jf'>{@link RestContext#REST_allowBodyParam}
423    * </ul>
424    *
425    * @param value
426    *    The new value for this setting.
427    *    <br>The default is <jk>true</jk>.
428    * @return This object (for method chaining).
429    */
430   public RestContextBuilder allowBodyParam(boolean value) {
431      return set(REST_allowBodyParam, value);
432   }
433
434   /**
435    * Configuration property:  Allowed header URL parameters.
436    *
437    * <p>
438    * When specified, allows headers such as <js>"Accept"</js> and <js>"Content-Type"</js> to be passed in as URL query
439    * parameters.
440    * <br>
441    * For example:
442    * <p class='bcode w800'>
443    *  ?Accept=text/json&amp;Content-Type=text/json
444    * </p>
445    *
446    * <ul class='seealso'>
447    *    <li class='jf'>{@link RestContext#REST_allowedHeaderParams}
448    * </ul>
449    *
450    * @param value
451    *    The new value for this setting.
452    *    <br>The default is <jk>true</jk>.
453    * @return This object (for method chaining).
454    */
455   public RestContextBuilder allowedHeaderParams(String value) {
456      return set(REST_allowedHeaderParams, value);
457   }
458
459   /**
460    * Configuration property:  Allowed method headers.
461    *
462    * <p>
463    * A comma-delimited list of HTTP method names that are allowed to be passed as values in an <c>X-Method</c> HTTP header
464    * to override the real HTTP method name.
465    * <p>
466    * Allows you to override the actual HTTP method with a simulated method.
467    * <br>For example, if an HTTP Client API doesn't support <c>PATCH</c> but does support <c>POST</c> (because
468    * <c>PATCH</c> is not part of the original HTTP spec), you can add a <c>X-Method: PATCH</c> header on a normal
469    * <c>HTTP POST /foo</c> request call which will make the HTTP call look like a <c>PATCH</c> request in any of the REST APIs.
470    *
471    * <ul class='seealso'>
472    *    <li class='jf'>{@link RestContext#REST_allowedMethodHeaders}
473    * </ul>
474    *
475    * @param value
476    *    The new value for this setting.
477    *    <br>The default is <jk>true</jk>.
478    * @return This object (for method chaining).
479    */
480   public RestContextBuilder allowedMethodHeaders(String value) {
481      return set(REST_allowedMethodHeaders, value);
482   }
483
484   /**
485    * Configuration property:  Allowed method parameters.
486    *
487    * <p>
488    * When specified, the HTTP method can be overridden by passing in a <js>"method"</js> URL parameter on a regular
489    * GET request.
490    * <br>
491    * For example:
492    * <p class='bcode w800'>
493    *  ?method=OPTIONS
494    * </p>
495    *
496    * <ul class='seealso'>
497    *    <li class='jf'>{@link RestContext#REST_allowedMethodParams}
498    * </ul>
499    *
500    * @param value
501    *    The new value for this setting.
502    *    <br>The default is <code>[<js>"HEAD"</js>,<js>"OPTIONS"</js>]</code>.
503    *    <br>Individual values can also be comma-delimited lists.
504    * @return This object (for method chaining).
505    */
506   public RestContextBuilder allowedMethodParams(String value) {
507      return set(REST_allowedMethodParams, value);
508   }
509
510   /**
511    * Configuration property:  Allow header URL parameters.
512    *
513    * <div class='warn'>
514    *    <b>Deprecated</b> - Use {@link #allowedHeaderParams(String)}
515    * </div>
516    *
517    * <p>
518    * When enabled, headers such as <js>"Accept"</js> and <js>"Content-Type"</js> to be passed in as URL query
519    * parameters.
520    * <br>
521    * For example:
522    * <p class='bcode w800'>
523    *  ?Accept=text/json&amp;Content-Type=text/json
524    * </p>
525    *
526    * <ul class='seealso'>
527    *    <li class='jf'>{@link RestContext#REST_allowHeaderParams}
528    * </ul>
529    *
530    * @param value
531    *    The new value for this setting.
532    *    <br>The default is <jk>true</jk>.
533    * @return This object (for method chaining).
534    */
535   @Deprecated
536   public RestContextBuilder allowHeaderParams(boolean value) {
537      return set(REST_allowedHeaderParams, value ? "*" : null);
538   }
539
540   /**
541    * Configuration property:  REST call handler.
542    *
543    * <p>
544    * This class handles the basic lifecycle of an HTTP REST call.
545    * <br>Subclasses can be used to customize how these HTTP calls are handled.
546    *
547    * <ul class='seealso'>
548    *    <li class='jf'>{@link RestContext#REST_callHandler}
549    * </ul>
550    *
551    * @param value
552    *    The new value for this setting.
553    *    <br>The default is {@link BasicRestCallHandler}.
554    * @return This object (for method chaining).
555    */
556   public RestContextBuilder callHandler(Class<? extends RestCallHandler> value) {
557      return set(REST_callHandler, value);
558   }
559
560   /**
561    * Configuration property:  REST call handler.
562    *
563    * <p>
564    * Same as {@link #callHandler(Class)} except input is a pre-constructed instance.
565    *
566    * <ul class='seealso'>
567    *    <li class='jf'>{@link RestContext#REST_callHandler}
568    * </ul>
569    *
570    * @param value
571    *    The new value for this setting.
572    *    <br>The default is {@link BasicRestCallHandler}.
573    * @return This object (for method chaining).
574    */
575   public RestContextBuilder callHandler(RestCallHandler value) {
576      return set(REST_callHandler, value);
577   }
578
579   /**
580    * Configuration property:  REST call logger.
581    *
582    * <p>
583    * Specifies the logger to use for logging of HTTP requests and responses.
584    *
585    * <ul class='seealso'>
586    *    <li class='link'>{@doc juneau-rest-server.LoggingAndDebugging}
587    *    <li class='jf'>{@link RestContext#REST_callLogger}
588    * </ul>
589    *
590    * @param value
591    *    The new value for this setting.
592    *    <br>The default is {@link BasicRestCallLogger}.
593    * @return This object (for method chaining).
594    */
595   public RestContextBuilder callLogger(Class<? extends RestCallLogger> value) {
596      return set(REST_callLogger, value);
597   }
598
599   /**
600    * Configuration property:  REST call logger.
601    *
602    * <p>
603    * Specifies the logger to use for logging of HTTP requests and responses.
604    *
605    * <ul class='seealso'>
606    *    <li class='link'>{@doc juneau-rest-server.LoggingAndDebugging}
607    *    <li class='jf'>{@link RestContext#REST_callLogger}
608    * </ul>
609    *
610    * @param value
611    *    The new value for this setting.
612    *    <br>The default is {@link BasicRestCallLogger}.
613    * @return This object (for method chaining).
614    */
615   public RestContextBuilder callLogger(RestCallLogger value) {
616      return set(REST_callLogger, value);
617   }
618
619   /**
620    * Configuration property:  REST call logging rules.
621    *
622    * <p>
623    * Specifies rules on how to handle logging of HTTP requests/responses.
624    *
625    * <ul class='seealso'>
626    *    <li class='link'>{@doc juneau-rest-server.LoggingAndDebugging}
627    *    <li class='jf'>{@link RestContext#REST_callLoggerConfig}
628    * </ul>
629    *
630    * @param value
631    *    The new value for this setting.
632    *    <br>The default is {@link RestCallLoggerConfig#DEFAULT}.
633    * @return This object (for method chaining).
634    */
635   public RestContextBuilder callLoggerConfig(RestCallLoggerConfig value) {
636      return set(REST_callLoggerConfig, value);
637   }
638
639   /**
640    * Configuration property:  Children.
641    *
642    * <p>
643    * Defines children of this resource.
644    *
645    * <p>
646    * A REST child resource is simply another servlet that is initialized as part of the parent resource and has a
647    * servlet path directly under the parent servlet path.
648    *
649    * <ul class='seealso'>
650    *    <li class='jf'>{@link RestContext#REST_children}
651    * </ul>
652    *
653    * @param values The values to add to this setting.
654    * @return This object (for method chaining).
655    */
656   public RestContextBuilder children(Class<?>...values) {
657      return addTo(REST_children, values);
658   }
659
660   /**
661    * Configuration property:  Children.
662    *
663    * <p>
664    * Same as {@link #children(Class...)} except input is pre-constructed instances.
665    *
666    * <ul class='seealso'>
667    *    <li class='jf'>{@link RestContext#REST_children}
668    * </ul>
669    *
670    * @param values The values to add to this setting.
671    * @return This object (for method chaining).
672    */
673   public RestContextBuilder children(Object...values) {
674      return addTo(REST_children, values);
675   }
676
677   /**
678    * Configuration property:  Children.
679    *
680    * <p>
681    * Shortcut for adding a single child to this resource.
682    *
683    * <p>
684    * This can be used for resources that don't have a {@link Rest#path() @Rest(path)} annotation.
685    *
686    * <ul class='seealso'>
687    *    <li class='jf'>{@link RestContext#REST_children}
688    * </ul>
689    *
690    * @param path The child path relative to the parent resource URI.
691    * @param child The child to add to this resource.
692    * @return This object (for method chaining).
693    */
694   public RestContextBuilder child(String path, Object child) {
695      return addTo(REST_children, new RestChild(path, child));
696   }
697
698   /**
699    * Configuration property:  Classpath resource finder.
700    *
701    * <p>
702    * Used to retrieve localized files from the classpath.
703    *
704    * <ul class='seealso'>
705    *    <li class='jf'>{@link RestContext#REST_classpathResourceFinder}
706    * </ul>
707    *
708    * @param value
709    *    The new value for this setting.
710    *    <br>The default is {@link ClasspathResourceFinderBasic}.
711    * @return This object (for method chaining).
712    */
713   public RestContextBuilder classpathResourceFinder(Class<? extends ClasspathResourceFinder> value) {
714      return set(REST_classpathResourceFinder, value);
715   }
716
717   /**
718    * Configuration property:  Classpath resource finder.
719    *
720    * <p>
721    * Same as {@link #classpathResourceFinder(ClasspathResourceFinder)} except input is a pre-constructed instance.
722    *
723    * <ul class='seealso'>
724    *    <li class='jf'>{@link RestContext#REST_classpathResourceFinder}
725    * </ul>
726    *
727    * @param value
728    *    The new value for this setting.
729    *    <br>The default is {@link ClasspathResourceFinderBasic}.
730    * @return This object (for method chaining).
731    */
732   public RestContextBuilder classpathResourceFinder(ClasspathResourceFinder value) {
733      return set(REST_classpathResourceFinder, value);
734   }
735
736   /**
737    * Configuration property:  Client version header.
738    *
739    * <p>
740    * Specifies the name of the header used to denote the client version on HTTP requests.
741    *
742    * <p>
743    * The client version is used to support backwards compatibility for breaking REST interface changes.
744    * <br>Used in conjunction with {@link RestMethod#clientVersion() @RestMethod(clientVersion)} annotation.
745    *
746    * <ul class='seealso'>
747    *    <li class='jf'>{@link RestContext#REST_clientVersionHeader}
748    * </ul>
749    *
750    * @param value
751    *    The new value for this setting.
752    *    <br>The default is <js>"X-Client-Version"</js>.
753    * @return This object (for method chaining).
754    */
755   public RestContextBuilder clientVersionHeader(String value) {
756      return set(REST_clientVersionHeader, value);
757   }
758
759   /**
760    * Configuration property:  Class-level response converters.
761    *
762    * <p>
763    * Associates one or more {@link RestConverter converters} with a resource class.
764    *
765    * <ul class='seealso'>
766    *    <li class='jf'>{@link RestContext#REST_converters}
767    * </ul>
768    *
769    * @param values The values to add to this setting.
770    * @return This object (for method chaining).
771    */
772   public RestContextBuilder converters(Class<?>...values) {
773      return addTo(REST_converters, values);
774   }
775
776   /**
777    * Configuration property:  Response converters.
778    *
779    * <p>
780    * Same as {@link #converters(Class...)} except input is pre-constructed instances.
781    *
782    * <ul class='seealso'>
783    *    <li class='jf'>{@link RestContext#REST_converters}
784    * </ul>
785    *
786    * @param values The values to add to this setting.
787    * @return This object (for method chaining).
788    */
789   public RestContextBuilder converters(RestConverter...values) {
790      return addTo(REST_converters, values);
791   }
792
793   /**
794    * Configuration property:  Debug mode.
795    *
796    * Enables the following:
797    * <ul class='spaced-list'>
798    *    <li>
799    *       HTTP request/response bodies are cached in memory for logging purposes.
800    *    <li>
801    *       Request/response messages are automatically logged.
802    * </ul>
803    *
804    * <ul class='seealso'>
805    *    <li class='jf'>{@link RestContext#REST_debug}
806    *    <li class='jf'>{@link BeanContext#BEAN_debug}
807    * </ul>
808    *
809    * @param value The new value for this setting.
810    * @return This object (for method chaining).
811    */
812   @Override
813   public RestContextBuilder debug(boolean value) {
814      super.debug(value);
815      return debug(Enablement.TRUE);
816   }
817
818   /**
819    * Configuration property:  Debug mode.
820    *
821    * <p>
822    * Enables the following:
823    * <ul class='spaced-list'>
824    *    <li>
825    *       HTTP request/response bodies are cached in memory for logging purposes.
826    * </ul>
827    *
828    * @param value The new value for this setting.
829    * @return This object (for method chaining).
830    */
831   public RestContextBuilder debug(Enablement value) {
832      return set(REST_debug, value);
833   }
834
835   /**
836    * Configuration property:  Default character encoding.
837    *
838    * <p>
839    * The default character encoding for the request and response if not specified on the request.
840    *
841    * <ul class='seealso'>
842    *    <li class='jf'>{@link RestContext#REST_defaultCharset}
843    * </ul>
844    *
845    * @param value
846    *    The new value for this setting.
847    *    <br>The default is <js>"utf-8"</js>.
848    * @return This object (for method chaining).
849    */
850   public RestContextBuilder defaultCharset(String value) {
851      return set(REST_defaultCharset, value);
852   }
853
854   /**
855    * Configuration property:  Default character encoding.
856    *
857    * <p>
858    * Same as {@link #defaultCharset(Charset)} but takes in an instance of {@link Charset}.
859    *
860    * <ul class='seealso'>
861    *    <li class='jf'>{@link RestContext#REST_defaultCharset}
862    * </ul>
863    *
864    * @param value
865    *    The new value for this setting.
866    *    <br>The default is <js>"utf-8"</js>.
867    * @return This object (for method chaining).
868    */
869   public RestContextBuilder defaultCharset(Charset value) {
870      return set(REST_defaultCharset, value);
871   }
872
873   /**
874    * Configuration property:  Default request attributes.
875    *
876    * <div class='warn'>
877    *    <b>Deprecated</b> - Use {@link #reqAttrs(String...)}
878    * </div>
879    */
880   @SuppressWarnings("javadoc")
881   @Deprecated
882   public RestContextBuilder attrs(String...values) throws RestServletException {
883      return reqAttrs(values);
884   }
885
886   /**
887    * Configuration property:  Default request headers.
888    *
889    * <div class='warn'>
890    *    <b>Deprecated</b> - Use {@link #reqHeaders(String...)}
891    * </div>
892    */
893   @SuppressWarnings("javadoc")
894   @Deprecated
895   public RestContextBuilder defaultRequestHeaders(String...headers) throws RestServletException {
896      return reqHeaders(headers);
897   }
898
899   /**
900    * Specifies a default <c>Accept</c> header value if not specified on a request.
901    *
902    * @param value
903    *    The default value of the <c>Accept</c> header.
904    *    <br>Ignored if <jk>null</jk> or empty.
905    * @return This object (for method chaining).
906    */
907   public RestContextBuilder defaultAccept(String value) {
908      if (isNotEmpty(value))
909         reqHeader("Accept", value);
910      return this;
911   }
912
913   /**
914    * Specifies a default <c>Content-Type</c> header value if not specified on a request.
915    *
916    * @param value
917    *    The default value of the <c>Content-Type</c> header.
918    *    <br>Ignored if <jk>null</jk> or empty.
919    * @return This object (for method chaining).
920    */
921   public RestContextBuilder defaultContentType(String value) {
922      if (isNotEmpty(value))
923         reqHeader("Content-Type", value);
924      return this;
925   }
926
927   /**
928    * Configuration property:  Default request attribute.
929    *
930    * <div class='warn'>
931    *    <b>Deprecated</b> - Use {@link #reqAttr(String, Object)}
932    * </div>
933    */
934   @SuppressWarnings("javadoc")
935   @Deprecated
936   public RestContextBuilder attr(String name, Object value) {
937      return reqAttr(name, value);
938   }
939
940   /**
941    * Configuration property:  Default request headers.
942    *
943    * <div class='warn'>
944    *    <b>Deprecated</b> - Use {@link #reqHeader(String,Object)}
945    * </div>
946    */
947   @SuppressWarnings("javadoc")
948   @Deprecated
949   public RestContextBuilder defaultRequestHeader(String name, Object value) {
950      return reqHeader(name, value);
951   }
952
953   /**
954    * Configuration property:  Default response headers.
955    *
956    * <div class='warn'>
957    *    <b>Deprecated</b> - Use {@link #resHeaders(String...)}
958    * </div>
959    */
960   @SuppressWarnings("javadoc")
961   @Deprecated
962   public RestContextBuilder defaultResponseHeaders(String...headers) throws RestServletException {
963      return resHeaders(headers);
964   }
965
966   /**
967    * Configuration property:  Default response headers.
968    *
969    * <div class='warn'>
970    *    <b>Deprecated</b> - Use {@link #resHeader(String, Object)}
971    * </div>
972    */
973   @SuppressWarnings("javadoc")
974   @Deprecated
975   public RestContextBuilder defaultResponseHeader(String name, Object value) {
976      return resHeader(name, value);
977   }
978
979   /**
980    * Configuration property:  Compression encoders.
981    *
982    * <p>
983    * These can be used to enable various kinds of compression (e.g. <js>"gzip"</js>) on requests and responses.
984    *
985    * <ul class='seealso'>
986    *    <li class='jf'>{@link RestContext#REST_encoders}
987    * </ul>
988    *
989    * @param values The values to add to this setting.
990    * @return This object (for method chaining).
991    */
992   public RestContextBuilder encoders(Class<?>...values) {
993      return addTo(REST_encoders, values);
994   }
995
996   /**
997    * Configuration property:  Compression encoders.
998    *
999    * <p>
1000    * Same as {@link #encoders(Class...)} except input a pre-constructed instances.
1001    *
1002    * <ul class='seealso'>
1003    *    <li class='jf'>{@link RestContext#REST_encoders}
1004    * </ul>
1005    *
1006    * @param values The values to add to this setting.
1007    * @return This object (for method chaining).
1008    */
1009   public RestContextBuilder encoders(Encoder...values) {
1010      return addTo(REST_encoders, values);
1011   }
1012
1013   /**
1014    * Configuration property:  Class-level guards.
1015    *
1016    * <p>
1017    * Associates one or more {@link RestGuard RestGuards} with all REST methods defined in this class.
1018    *
1019    * <ul class='seealso'>
1020    *    <li class='jf'>{@link RestContext#REST_guards}
1021    * </ul>
1022    *
1023    * @param values The values to add to this setting.
1024    * @return This object (for method chaining).
1025    */
1026   public RestContextBuilder guards(Class<?>...values) {
1027      return addTo(REST_guards, values);
1028   }
1029
1030   /**
1031    * Configuration property:  Class-level guards.
1032    *
1033    * <p>
1034    * Same as {@link #guards(Class...)} except input is pre-constructed instances.
1035    *
1036    * <ul class='seealso'>
1037    *    <li class='jf'>{@link RestContext#REST_guards}
1038    * </ul>
1039    *
1040    * @param values The values to add to this setting.
1041    * @return This object (for method chaining).
1042    */
1043   public RestContextBuilder guards(RestGuard...values) {
1044      return addTo(REST_guards, values);
1045   }
1046
1047   /**
1048    * Configuration property:  REST info provider.
1049    *
1050    * <p>
1051    * Class used to retrieve title/description/swagger information about a resource.
1052    *
1053    * <ul class='seealso'>
1054    *    <li class='jf'>{@link RestContext#REST_infoProvider}
1055    * </ul>
1056    *
1057    * @param value
1058    *    The new value for this setting.
1059    *    <br>The default is {@link BasicRestInfoProvider}.
1060    * @return This object (for method chaining).
1061    */
1062   public RestContextBuilder infoProvider(Class<? extends RestInfoProvider> value) {
1063      return set(REST_infoProvider, value);
1064   }
1065
1066   /**
1067    * Configuration property:  REST info provider.
1068    *
1069    * <p>
1070    * Same as {@link #infoProvider(Class)} except input is a pre-constructed instance.
1071    *
1072    * <ul class='seealso'>
1073    *    <li class='jf'>{@link RestContext#REST_infoProvider}
1074    * </ul>
1075    *
1076    * @param value
1077    *    The new value for this setting.
1078    *    <br>The default is {@link BasicRestInfoProvider}.
1079    * @return This object (for method chaining).
1080    */
1081   public RestContextBuilder infoProvider(RestInfoProvider value) {
1082      return set(REST_infoProvider, value);
1083   }
1084
1085   /**
1086    * Configuration property:  REST logger.
1087    *
1088    * <div class='warn'>
1089    *    <b>Deprecated</b> - Use {@link #callLogger(Class)}
1090    * </div>
1091    *
1092    * <p>
1093    * Specifies the logger to use for logging.
1094    *
1095    * <ul class='seealso'>
1096    *    <li class='jf'>{@link RestContext#REST_logger}
1097    * </ul>
1098    *
1099    * @param value
1100    *    The new value for this setting.
1101    *    <br>The default is {@link BasicRestCallLogger}.
1102    *    <br>Can be <jk>null</jk> to disable logging.
1103    * @return This object (for method chaining).
1104    */
1105   @Deprecated
1106   public RestContextBuilder logger(Class<? extends RestLogger> value) {
1107      return set(REST_logger, value);
1108   }
1109
1110   /**
1111    * Configuration property:  REST logger.
1112    *
1113    * <div class='warn'>
1114    *    <b>Deprecated</b> - Use {@link #callLogger(RestCallLogger)}
1115    * </div>
1116    *
1117    * <p>
1118    * Same as {@link #logger(Class)} except input is a pre-constructed instance.
1119    *
1120    * <ul class='seealso'>
1121    *    <li class='jf'>{@link RestContext#REST_logger}
1122    * </ul>
1123    *
1124    * @param value
1125    *    The new value for this setting.
1126    *    <br>The default is {@link BasicRestLogger}.
1127    *    <br>Can be <jk>null</jk> to disable logging.
1128    * @return This object (for method chaining).
1129    */
1130   @Deprecated
1131   public RestContextBuilder logger(RestLogger value) {
1132      return set(REST_logger, value);
1133   }
1134
1135   /**
1136    * Configuration property:  The maximum allowed input size (in bytes) on HTTP requests.
1137    *
1138    * <p>
1139    * Useful for alleviating DoS attacks by throwing an exception when too much input is received instead of resulting
1140    * in out-of-memory errors which could affect system stability.
1141    *
1142    * <ul class='seealso'>
1143    *    <li class='jf'>{@link RestContext#REST_maxInput}
1144    * </ul>
1145    *
1146    * @param value
1147    *    The new value for this setting.
1148    *    <br>The default is <js>"100M"</js>.
1149    * @return This object (for method chaining).
1150    */
1151   public RestContextBuilder maxInput(String value) {
1152      return set(REST_maxInput, value);
1153   }
1154
1155   /**
1156    * Configuration property:  Messages.
1157    *
1158    * <p>
1159    * Identifies the location of the resource bundle for this class.
1160    *
1161    * <ul class='seealso'>
1162    *    <li class='jf'>{@link RestContext#REST_messages}
1163    * </ul>
1164    *
1165    * @param values The values to add to this setting.
1166    * @return This object (for method chaining).
1167    */
1168   public RestContextBuilder messages(MessageBundleLocation...values) {
1169      return addTo(REST_messages, values);
1170   }
1171
1172   /**
1173    * Configuration property:  Messages.
1174    *
1175    * <p>
1176    * Same as {@link #messages(MessageBundleLocation...)} except allows you to pass in the base class and bundle
1177    * path separately.
1178    *
1179    * <ul class='seealso'>
1180    *    <li class='jf'>{@link RestContext#REST_messages}
1181    * </ul>
1182    *
1183    * @param baseClass
1184    *    The base class that the bundle path is relative to.
1185    *    <br>If <jk>null</jk>, assumed to be the resource class itself.
1186    * @param bundlePath The bundle path relative to the base class.
1187    * @return This object (for method chaining).
1188    */
1189   public RestContextBuilder messages(Class<?> baseClass, String bundlePath) {
1190      return addTo(REST_messages, new MessageBundleLocation(baseClass, bundlePath));
1191   }
1192
1193   /**
1194    * Configuration property:  Messages.
1195    *
1196    * <p>
1197    * Same as {@link #messages(Class,String)} except assumes the base class is the resource class itself.
1198    *
1199    * <ul class='seealso'>
1200    *    <li class='jf'>{@link RestContext#REST_messages}
1201    * </ul>
1202    *
1203    * @param bundlePath The bundle path relative to the base class.
1204    * @return This object (for method chaining).
1205    */
1206   public RestContextBuilder messages(String bundlePath) {
1207      return addTo(REST_messages, new MessageBundleLocation(null, bundlePath));
1208   }
1209
1210   /**
1211    * Configuration property:  MIME types.
1212    *
1213    * <p>
1214    * Defines MIME-type file type mappings.
1215    *
1216    * <ul class='seealso'>
1217    *    <li class='jf'>{@link RestContext#REST_mimeTypes}
1218    * </ul>
1219    *
1220    * @param values The values to add to this setting.
1221    * @return This object (for method chaining).
1222    */
1223   public RestContextBuilder mimeTypes(String...values) {
1224      return addTo(REST_mimeTypes, values);
1225   }
1226
1227   /**
1228    * Configuration property:  Java method parameter resolvers.
1229    *
1230    * <p>
1231    * By default, the Juneau framework will automatically Java method parameters of various types (e.g.
1232    * <c>RestRequest</c>, <c>Accept</c>, <c>Reader</c>).
1233    * This annotation allows you to provide your own resolvers for your own class types that you want resolved.
1234    *
1235    * <ul class='seealso'>
1236    *    <li class='jf'>{@link RestContext#REST_paramResolvers}
1237    * </ul>
1238    *
1239    * @param values The values to add to this setting.
1240    * @return This object (for method chaining).
1241    */
1242   @SuppressWarnings("unchecked")
1243   public RestContextBuilder paramResolvers(Class<? extends RestMethodParam>...values) {
1244      return addTo(REST_paramResolvers, values);
1245   }
1246
1247   /**
1248    * Configuration property:  Java method parameter resolvers.
1249    *
1250    * <p>
1251    * Same as {@link #paramResolvers(Class...)} except input is pre-constructed instances.
1252    *
1253    * <ul class='seealso'>
1254    *    <li class='jf'>{@link RestContext#REST_paramResolvers}
1255    * </ul>
1256    *
1257    * @param values The values to add to this setting.
1258    * @return This object (for method chaining).
1259    */
1260   public RestContextBuilder paramResolvers(RestMethodParam...values) {
1261      return addTo(REST_paramResolvers, values);
1262   }
1263
1264   /**
1265    * Configuration property:  Parser listener.
1266    *
1267    * <p>
1268    * Specifies the parser listener class to use for listening to non-fatal parsing errors.
1269    *
1270    * <ul class='seealso'>
1271    *    <li class='jf'>{@link Parser#PARSER_listener}
1272    * </ul>
1273    *
1274    * @param value The new value for this setting.
1275    * @return This object (for method chaining).
1276    */
1277   public RestContextBuilder parserListener(Class<? extends ParserListener> value) {
1278      if (value != ParserListener.Null.class)
1279         set(PARSER_listener, value);
1280      return this;
1281   }
1282
1283   /**
1284    * Configuration property:  Parsers.
1285    *
1286    * <p>
1287    * Adds class-level parsers to this resource.
1288    *
1289    * <ul class='seealso'>
1290    *    <li class='jf'>{@link RestContext#REST_parsers}
1291    * </ul>
1292    *
1293    * @param values The values to add to this setting.
1294    * @return This object (for method chaining).
1295    */
1296   public RestContextBuilder parsers(Class<?>...values) {
1297      return addTo(REST_parsers, values);
1298   }
1299
1300   /**
1301    * Configuration property:  Parsers.
1302    *
1303    * <p>
1304    * Same as {@link #parsers(Class...)} except input is pre-constructed instances.
1305    *
1306    * <p>
1307    * Parser instances are considered set-in-stone and do NOT inherit properties and transforms defined on the
1308    * resource class or method.
1309    *
1310    * <ul class='seealso'>
1311    *    <li class='jf'>{@link RestContext#REST_parsers}
1312    * </ul>
1313    *
1314    * @param values The values to add to this setting.
1315    * @return This object (for method chaining).
1316    */
1317   public RestContextBuilder parsers(Object...values) {
1318      return addTo(REST_parsers, values);
1319   }
1320
1321   /**
1322    * Configuration property:  Parsers.
1323    *
1324    * <p>
1325    * Same as {@link #parsers(Class...)} except allows you to overwrite the previous value.
1326    *
1327    * <ul class='seealso'>
1328    *    <li class='jf'>{@link RestContext#REST_parsers}
1329    * </ul>
1330    *
1331    * @param values The values to add to this setting.
1332    * @return This object (for method chaining).
1333    */
1334   public RestContextBuilder parsersReplace(Object...values) {
1335      return set(REST_parsers, values);
1336   }
1337
1338   /**
1339    * Configuration property:  HTTP part parser.
1340    *
1341    * <p>
1342    * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters, and URI parts.
1343    *
1344    * <ul class='seealso'>
1345    *    <li class='jf'>{@link RestContext#REST_partParser}
1346    * </ul>
1347    *
1348    * @param value
1349    *    The new value for this setting.
1350    *    <br>The default is {@link OpenApiParser}.
1351    * @return This object (for method chaining).
1352    */
1353   public RestContextBuilder partParser(Class<? extends HttpPartParser> value) {
1354      if (value != HttpPartParser.Null.class)
1355         set(REST_partParser, value);
1356      return this;
1357   }
1358
1359   /**
1360    * Configuration property:  HTTP part parser.
1361    *
1362    * <p>
1363    * Same as {@link #partParser(Class)} except input is a pre-constructed instance.
1364    *
1365    * <ul class='seealso'>
1366    *    <li class='jf'>{@link RestContext#REST_partParser}
1367    * </ul>
1368    *
1369    * @param value
1370    *    The new value for this setting.
1371    *    <br>The default is {@link OpenApiParser}.
1372    * @return This object (for method chaining).
1373    */
1374   public RestContextBuilder partParser(HttpPartParser value) {
1375      return set(REST_partParser, value);
1376   }
1377
1378   /**
1379    * Configuration property:  HTTP part serializer.
1380    *
1381    * <p>
1382    * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters, and URI parts.
1383    *
1384    * <ul class='seealso'>
1385    *    <li class='jf'>{@link RestContext#REST_partSerializer}
1386    * </ul>
1387    *
1388    * @param value
1389    *    The new value for this setting.
1390    *    <br>The default is {@link OpenApiSerializer}.
1391    * @return This object (for method chaining).
1392    */
1393   public RestContextBuilder partSerializer(Class<? extends HttpPartSerializer> value) {
1394      if (value != HttpPartSerializer.Null.class)
1395         set(REST_partSerializer, value);
1396      return this;
1397   }
1398
1399   /**
1400    * Configuration property:  HTTP part serializer.
1401    *
1402    * <p>
1403    * Same as {@link #partSerializer(Class)} except input is a pre-constructed instance.
1404    *
1405    * <ul class='seealso'>
1406    *    <li class='jf'>{@link RestContext#REST_partSerializer}
1407    * </ul>
1408    *
1409    * @param value
1410    *    The new value for this setting.
1411    *    <br>The default is {@link OpenApiSerializer}.
1412    * @return This object (for method chaining).
1413    */
1414   public RestContextBuilder partSerializer(HttpPartSerializer value) {
1415      return set(REST_partSerializer, value);
1416   }
1417
1418   /**
1419    * Configuration property:  Resource path.
1420    *
1421    * <p>
1422    * Identifies the URL subpath relative to the parent resource.
1423    *
1424    * <ul class='seealso'>
1425    *    <li class='jf'>{@link RestContext#REST_path}
1426    * </ul>
1427    *
1428    * @param value The new value for this setting.
1429    * @return This object (for method chaining).
1430    */
1431   public RestContextBuilder path(String value) {
1432      if (startsWith(value, '/'))
1433         value = value.substring(1);
1434      set(REST_path, value);
1435      return this;
1436   }
1437
1438   /**
1439    * Configuration property:  Render response stack traces in responses.
1440    *
1441    * <p>
1442    * Render stack traces in HTTP response bodies when errors occur.
1443    *
1444    * <ul class='seealso'>
1445    *    <li class='jf'>{@link RestContext#REST_renderResponseStackTraces}
1446    * </ul>
1447    *
1448    * @param value
1449    *    The new value for this setting.
1450    *    <br>The default is <jk>false</jk>.
1451    * @return This object (for method chaining).
1452    */
1453   public RestContextBuilder renderResponseStackTraces(boolean value) {
1454      return set(REST_renderResponseStackTraces, value);
1455   }
1456
1457   /**
1458    * Configuration property:  Render response stack traces in responses.
1459    *
1460    * <p>
1461    * Shortcut for calling <code>renderResponseStackTraces(<jk>true</jk>)</code>.
1462    *
1463    * <ul class='seealso'>
1464    *    <li class='jf'>{@link RestContext#REST_renderResponseStackTraces}
1465    * </ul>
1466    *
1467    * @return This object (for method chaining).
1468    */
1469   public RestContextBuilder renderResponseStackTraces() {
1470      return set(REST_renderResponseStackTraces, true);
1471   }
1472
1473   /**
1474    * Configuration property:  Default request attribute.
1475    *
1476    * <p>
1477    * Same as {@link #reqAttrs(String...)} but adds a single attribute name/value pair.
1478    *
1479    * <ul class='seealso'>
1480    *    <li class='jf'>{@link RestContext#REST_reqAttrs}
1481    * </ul>
1482    *
1483    * @param name The HTTP header name.
1484    * @param value The HTTP header value.
1485    * @return This object (for method chaining).
1486    */
1487   public RestContextBuilder reqAttr(String name, Object value) {
1488      return addTo(REST_reqAttrs, name, value);
1489   }
1490
1491   /**
1492    * Configuration property:  Default request attributes.
1493    *
1494    * <p>
1495    * Specifies default values for request attributes if they're not already set on the request.
1496    *
1497    * <ul class='seealso'>
1498    *    <li class='jf'>{@link RestContext#REST_reqAttrs}
1499    * </ul>
1500    *
1501    * @param values The attributes in the format <js>"Name: value"</js>.
1502    * @return This object (for method chaining).
1503    * @throws RestServletException If malformed header is found.
1504    */
1505   public RestContextBuilder reqAttrs(String...values) throws RestServletException {
1506      for (String v : values) {
1507         String[] p = RestUtils.parseKeyValuePair(v);
1508         if (p == null)
1509            throw new RestServletException("Invalid default request attribute specified: ''{0}''.  Must be in the format: ''Name: value''", v);
1510         reqHeader(p[0], p[1]);
1511      }
1512      return this;
1513   }
1514
1515   /**
1516    * Configuration property:  Default request headers.
1517    *
1518    * <p>
1519    * Same as {@link #reqHeaders(String...)} but adds a single header name/value pair.
1520    *
1521    * <ul class='seealso'>
1522    *    <li class='jf'>{@link RestContext#REST_reqHeaders}
1523    * </ul>
1524    *
1525    * @param name The HTTP header name.
1526    * @param value The HTTP header value.
1527    * @return This object (for method chaining).
1528    */
1529   public RestContextBuilder reqHeader(String name, Object value) {
1530      return addTo(REST_reqHeaders, name, value);
1531   }
1532
1533   /**
1534    * Configuration property:  Default request headers.
1535    *
1536    * <p>
1537    * Specifies default values for request headers if they're not passed in through the request.
1538    *
1539    * <ul class='seealso'>
1540    *    <li class='jf'>{@link RestContext#REST_reqHeaders}
1541    * </ul>
1542    *
1543    * @param headers The headers in the format <js>"Header-Name: header-value"</js>.
1544    * @return This object (for method chaining).
1545    * @throws RestServletException If malformed header is found.
1546    */
1547   public RestContextBuilder reqHeaders(String...headers) throws RestServletException {
1548      for (String header : headers) {
1549         String[] h = RestUtils.parseHeader(header);
1550         if (h == null)
1551            throw new RestServletException("Invalid default request header specified: ''{0}''.  Must be in the format: ''Header-Name: header-value''", header);
1552         reqHeader(h[0], h[1]);
1553      }
1554      return this;
1555   }
1556
1557   /**
1558    * Configuration property:  Default response headers.
1559    *
1560    * <p>
1561    * Specifies default values for response headers if they're not set after the Java REST method is called.
1562    *
1563    * <ul class='seealso'>
1564    *    <li class='jf'>{@link RestContext#REST_resHeaders}
1565    * </ul>
1566    *
1567    * @param headers The headers in the format <js>"Header-Name: header-value"</js>.
1568    * @return This object (for method chaining).
1569    * @throws RestServletException If malformed header is found.
1570    */
1571   public RestContextBuilder resHeaders(String...headers) throws RestServletException {
1572      for (String header : headers) {
1573         String[] h = RestUtils.parseHeader(header);
1574         if (h == null)
1575            throw new RestServletException("Invalid default response header specified: ''{0}''.  Must be in the format: ''Header-Name: header-value''", header);
1576         resHeader(h[0], h[1]);
1577      }
1578      return this;
1579   }
1580
1581   /**
1582    * Configuration property:  Default response headers.
1583    *
1584    * <p>
1585    * Same as {@link #resHeaders(String...)} but adds a single header name/value pair.
1586    *
1587    * <ul class='seealso'>
1588    *    <li class='jf'>{@link RestContext#REST_resHeaders}
1589    * </ul>
1590    *
1591    * @param name The HTTP header name.
1592    * @param value The HTTP header value.
1593    * @return This object (for method chaining).
1594    */
1595   public RestContextBuilder resHeader(String name, Object value) {
1596      return addTo(REST_resHeaders, name, value);
1597   }
1598
1599   /**
1600    * REST resource resolver.
1601    *
1602    * <p>
1603    * The resolver used for resolving child resources.
1604    *
1605    * <p>
1606    * Can be used to provide customized resolution of REST resource class instances (e.g. resources retrieve from Spring).
1607    *
1608    * <ul class='seealso'>
1609    *    <li class='jf'>{@link RestContext#REST_resourceResolver}
1610    * </ul>
1611    *
1612    * @param value
1613    *    The new value for this setting.
1614    *    <br>The default is {@link BasicRestResourceResolver}.
1615    * @return This object (for method chaining).
1616    */
1617   public RestContextBuilder resourceResolver(Class<? extends RestResourceResolver> value) {
1618      return set(REST_resourceResolver, value);
1619   }
1620
1621   /**
1622    * REST resource resolver.
1623    *
1624    * <p>
1625    * Same as {@link #resourceResolver(Class)} except input is a pre-constructed instance.
1626    *
1627    * <ul class='seealso'>
1628    *    <li class='jf'>{@link RestContext#REST_resourceResolver}
1629    * </ul>
1630    *
1631    * @param value
1632    *    The new value for this setting.
1633    *    <br>The default is {@link BasicRestResourceResolver}.
1634    * @return This object (for method chaining).
1635    */
1636   public RestContextBuilder resourceResolver(RestResourceResolver value) {
1637      return set(REST_resourceResolver, value);
1638   }
1639
1640   /**
1641    * Configuration property:  Response handlers.
1642    *
1643    * <p>
1644    * Specifies a list of {@link ResponseHandler} classes that know how to convert POJOs returned by REST methods or
1645    * set via {@link RestResponse#setOutput(Object)} into appropriate HTTP responses.
1646    *
1647    * <ul class='seealso'>
1648    *    <li class='jf'>{@link RestContext#REST_responseHandlers}
1649    * </ul>
1650    *
1651    * @param values The values to add to this setting.
1652    * @return This object (for method chaining).
1653    */
1654   public RestContextBuilder responseHandlers(Class<?>...values) {
1655      return addTo(REST_responseHandlers, values);
1656   }
1657
1658   /**
1659    * Configuration property:  Response handlers.
1660    *
1661    * <p>
1662    * Same as {@link #responseHandlers(Class...)} except input is pre-constructed instances.
1663    *
1664    * <ul class='seealso'>
1665    *    <li class='jf'>{@link RestContext#REST_responseHandlers}
1666    * </ul>
1667    *
1668    * @param values The values to add to this setting.
1669    * @return This object (for method chaining).
1670    */
1671   public RestContextBuilder responseHandlers(ResponseHandler...values) {
1672      return addTo(REST_responseHandlers, values);
1673   }
1674
1675   /**
1676    * Configuration property:  Declared roles.
1677    *
1678    * <p>
1679    * A comma-delimited list of all possible user roles.
1680    *
1681    * <p>
1682    * Used in conjunction with {@link RestContextBuilder#roleGuard(String)} is used with patterns.
1683    *
1684    * <h5 class='section'>Example:</h5>
1685    * <p class='bcode w800'>
1686    *    <ja>@Rest</ja>(
1687    *       rolesDeclared=<js>"ROLE_ADMIN,ROLE_READ_WRITE,ROLE_READ_ONLY,ROLE_SPECIAL"</js>,
1688    *       roleGuard=<js>"ROLE_ADMIN || (ROLE_READ_WRITE &amp;&amp; ROLE_SPECIAL)"</js>
1689    *    )
1690    *    <jk>public class</jk> MyResource <jk>extends</jk> RestServlet {
1691    *       ...
1692    *    }
1693    * </p>
1694    *
1695    * <ul class='seealso'>
1696    *    <li class='jf'>{@link RestContext#REST_rolesDeclared}
1697    * </ul>
1698    * @param values The values to add to this setting.
1699    * @return This object (for method chaining).
1700    */
1701   public RestContextBuilder rolesDeclared(String...values) {
1702      return addTo(REST_rolesDeclared, values);
1703   }
1704
1705   /**
1706    * Configuration property:  Role guard.
1707    *
1708    * <p>
1709    * An expression defining if a user with the specified roles are allowed to access methods on this class.
1710    *
1711    * <h5 class='section'>Example:</h5>
1712    * <p class='bcode w800'>
1713    *    <ja>@Rest</ja>(
1714    *       path=<js>"/foo"</js>,
1715    *       roleGuard=<js>"ROLE_ADMIN || (ROLE_READ_WRITE &amp;&amp; ROLE_SPECIAL)"</js>
1716    *    )
1717    *    <jk>public class</jk> MyResource <jk>extends</jk> RestServlet {
1718    *       ...
1719    *    }
1720    * </p>
1721    *
1722    * <ul class='notes'>
1723    *    <li>
1724    *       Supports any of the following expression constructs:
1725    *       <ul>
1726    *          <li><js>"foo"</js> - Single arguments.
1727    *          <li><js>"foo,bar,baz"</js> - Multiple OR'ed arguments.
1728    *          <li><js>"foo | bar | bqz"</js> - Multiple OR'ed arguments, pipe syntax.
1729    *          <li><js>"foo || bar || bqz"</js> - Multiple OR'ed arguments, Java-OR syntax.
1730    *          <li><js>"fo*"</js> - Patterns including <js>'*'</js> and <js>'?'</js>.
1731    *          <li><js>"fo* &amp; *oo"</js> - Multiple AND'ed arguments, ampersand syntax.
1732    *          <li><js>"fo* &amp;&amp; *oo"</js> - Multiple AND'ed arguments, Java-AND syntax.
1733    *          <li><js>"fo* || (*oo || bar)"</js> - Parenthesis.
1734    *       </ul>
1735    *    <li>
1736    *       AND operations take precedence over OR operations (as expected).
1737    *    <li>
1738    *       Whitespace is ignored.
1739    *    <li>
1740    *       <jk>null</jk> or empty expressions always match as <jk>false</jk>.
1741    *    <li>
1742    *       If patterns are used, you must specify the list of declared roles using {@link Rest#rolesDeclared()} or {@link RestContext#REST_rolesDeclared}.
1743    *    <li>
1744    *       Supports {@doc DefaultRestSvlVariables}
1745    *       (e.g. <js>"$L{my.localized.variable}"</js>).
1746    * </ul>
1747    *
1748    * @param value The values to add to this setting.
1749    * @return This object (for method chaining).
1750    */
1751   public RestContextBuilder roleGuard(String value) {
1752      return addTo(REST_roleGuard, value);
1753   }
1754
1755   /**
1756    * Configuration property:  Serializer listener.
1757    *
1758    * <p>
1759    * Specifies the serializer listener class to use for listening to non-fatal serialization errors.
1760    *
1761    * <ul class='seealso'>
1762    *    <li class='jf'>{@link Serializer#SERIALIZER_listener}
1763    * </ul>
1764    *
1765    * @param value The new value for this setting.
1766    * @return This object (for method chaining).
1767    */
1768   public RestContextBuilder serializerListener(Class<? extends SerializerListener> value) {
1769      if (value != SerializerListener.Null.class)
1770         set(SERIALIZER_listener, value);
1771      return this;
1772   }
1773
1774   /**
1775    * Configuration property:  Serializers.
1776    *
1777    * <p>
1778    * Adds class-level serializers to this resource.
1779    *
1780    * <ul class='seealso'>
1781    *    <li class='jf'>{@link RestContext#REST_serializers}
1782    * </ul>
1783    *
1784    * @param values The values to add to this setting.
1785    * @return This object (for method chaining).
1786    */
1787   public RestContextBuilder serializers(Class<?>...values) {
1788      return addTo(REST_serializers, values);
1789   }
1790
1791   /**
1792    * Configuration property:  Serializers.
1793    *
1794    * <p>
1795    * Same as {@link #serializers(Class[])} but replaces any existing values.
1796    *
1797    * <ul class='seealso'>
1798    *    <li class='jf'>{@link RestContext#REST_serializers}
1799    * </ul>
1800    *
1801    * @param values The values to set on this setting.
1802    * @return This object (for method chaining).
1803    */
1804   public RestContextBuilder serializersReplace(Class<?>...values) {
1805      return set(REST_serializers, values);
1806   }
1807
1808   /**
1809    * Configuration property:  Serializers.
1810    *
1811    * <p>
1812    * Same as {@link #serializers(Class...)} except input is pre-constructed instances.
1813    *
1814    * <p>
1815    * Serializer instances are considered set-in-stone and do NOT inherit properties and transforms defined on the
1816    * resource class or method.
1817    *
1818    * <ul class='seealso'>
1819    *    <li class='jf'>{@link RestContext#REST_serializers}
1820    * </ul>
1821    *
1822    * @param values The values to add to this setting.
1823    * @return This object (for method chaining).
1824    */
1825   public RestContextBuilder serializers(Object...values) {
1826      return addTo(REST_serializers, values);
1827   }
1828
1829   /**
1830    * Configuration property:  Serializers.
1831    *
1832    * <p>
1833    * Same as {@link #serializers(Class...)} except allows you to overwrite the previous value.
1834    *
1835    * <ul class='seealso'>
1836    *    <li class='jf'>{@link RestContext#REST_serializers}
1837    * </ul>
1838    *
1839    * @param values The values to add to this setting.
1840    * @return This object (for method chaining).
1841    */
1842   public RestContextBuilder serializersReplace(Object...values) {
1843      return set(REST_serializers, values);
1844   }
1845
1846   /**
1847    * Configuration property:  Static file response headers.
1848    *
1849    * <p>
1850    * Used to customize the headers on responses returned for statically-served files.
1851    *
1852    * <ul class='seealso'>
1853    *    <li class='jf'>{@link RestContext#REST_staticFileResponseHeaders}
1854    * </ul>
1855    *
1856    * @param headers
1857    *    The headers to add to this list.
1858    *    <br>The default is <code>{<js>'Cache-Control'</js>: <js>'max-age=86400, public</js>}</code>.
1859    * @return This object (for method chaining).
1860    */
1861   public RestContextBuilder staticFileResponseHeaders(Map<String,String> headers) {
1862      return addTo(REST_staticFileResponseHeaders, headers);
1863   }
1864
1865   /**
1866    * Configuration property:  Static file response headers.
1867    *
1868    * <p>
1869    * Same as {@link #staticFileResponseHeaders(Map)} but replaces any previous values.
1870    *
1871    * <ul class='seealso'>
1872    *    <li class='jf'>{@link RestContext#REST_staticFileResponseHeaders}
1873    * </ul>
1874    *
1875    * @param headers
1876    *    The headers to set on this list.
1877    *    <br>The default is <code>{<js>'Cache-Control'</js>: <js>'max-age=86400, public</js>}</code>.
1878    * @return This object (for method chaining).
1879    */
1880   public RestContextBuilder staticFileResponseHeadersReplace(Map<String,String> headers) {
1881      return set(REST_staticFileResponseHeaders, headers);
1882   }
1883
1884   /**
1885    * Configuration property:  Static file response headers.
1886    *
1887    * <p>
1888    * Same as {@link #staticFileResponseHeaders(Map)} with append=<jk>true</jk> except headers are strings
1889    * composed of key/value pairs.
1890    *
1891    * <ul class='seealso'>
1892    *    <li class='jf'>{@link RestContext#REST_staticFileResponseHeaders}
1893    * </ul>
1894    *
1895    * @param headers The headers in the format <js>"Header-Name: header-value"</js>.
1896    * @return This object (for method chaining).
1897    * @throws RestServletException If malformed header is found.
1898    */
1899   public RestContextBuilder staticFileResponseHeaders(String...headers) throws RestServletException {
1900      for (String header : headers) {
1901         String[] h = RestUtils.parseHeader(header);
1902         if (h == null)
1903            throw new RestServletException("Invalid static file response header specified: ''{0}''.  Must be in the format: ''Header-Name: header-value''", header);
1904         staticFileResponseHeader(h[0], h[1]);
1905      }
1906      return this;
1907   }
1908
1909   /**
1910    * Configuration property:  Static file response headers.
1911    *
1912    * <p>
1913    * Same as {@link #staticFileResponseHeaders(String...)} except header is broken into name/value pair.
1914    *
1915    * <ul class='seealso'>
1916    *    <li class='jf'>{@link RestContext#REST_staticFileResponseHeaders}
1917    * </ul>
1918    *
1919    * @param name The HTTP header name.
1920    * @param value The HTTP header value.
1921    * @return This object (for method chaining).
1922    */
1923   public RestContextBuilder staticFileResponseHeader(String name, String value) {
1924      return addTo(REST_staticFileResponseHeaders, name, value);
1925   }
1926
1927   /**
1928    * Configuration property:  Static file mappings.
1929    *
1930    * <p>
1931    * Used to define paths and locations of statically-served files such as images or HTML documents.
1932    *
1933    * <ul class='seealso'>
1934    *    <li class='jf'>{@link RestContext#REST_staticFiles}
1935    * </ul>
1936    *
1937    * @param values The values to append to this setting.
1938    * @return This object (for method chaining).
1939    */
1940   public RestContextBuilder staticFiles(StaticFileMapping...values) {
1941      return addTo(REST_staticFiles, values);
1942   }
1943
1944   /**
1945    * Configuration property:  Static file mappings.
1946    *
1947    * <p>
1948    * Same as {@link #staticFiles(StaticFileMapping...)} except input is in the form of a mapping string.
1949    *
1950    * <p>
1951    * Mapping string must be one of these formats:
1952    * <ul>
1953    *    <li><js>"path:location"</js> (e.g. <js>"foodocs:docs/foo"</js>)
1954    *    <li><js>"path:location:headers-json"</js> (e.g. <js>"foodocs:docs/foo:{'Cache-Control':'max-age=86400, public'}"</js>)
1955    * </ul>
1956    *
1957    * <ul class='seealso'>
1958    *    <li class='jf'>{@link RestContext#REST_staticFiles}
1959    * </ul>
1960    *
1961    * @param mappingString The static file mapping string.
1962    * @throws ParseException If mapping string is malformed.
1963    * @return This object (for method chaining).
1964    */
1965   public RestContextBuilder staticFiles(String mappingString) throws ParseException{
1966      for (StaticFileMapping sfm : reverseIterable(StaticFileMapping.parse(resourceClass, mappingString)))
1967         staticFiles(sfm);
1968      return this;
1969   }
1970
1971   /**
1972    * Configuration property:  Static file mappings.
1973    *
1974    * <p>
1975    * Same as {@link #staticFiles(String)} except overrides the base class for retrieving the resource.
1976    *
1977    * <p>
1978    * Mapping string must be one of these formats:
1979    * <ul>
1980    *    <li><js>"path:location"</js> (e.g. <js>"foodocs:docs/foo"</js>)
1981    *    <li><js>"path:location:headers-json"</js> (e.g. <js>"foodocs:docs/foo:{'Cache-Control':'max-age=86400, public'}"</js>)
1982    * </ul>
1983    *
1984    * <ul class='seealso'>
1985    *    <li class='jf'>{@link RestContext#REST_staticFiles}
1986    * </ul>
1987    *
1988    * @param baseClass
1989    *    Overrides the default class to use for retrieving the classpath resource.
1990    *    <br>If <jk>null</jk>, uses the REST resource class.
1991    * @param mappingString The static file mapping string.
1992    * @return This object (for method chaining).
1993    * @throws ParseException If mapping string is malformed.
1994    */
1995   public RestContextBuilder staticFiles(Class<?> baseClass, String mappingString) throws ParseException {
1996      for (StaticFileMapping sfm : reverseIterable(StaticFileMapping.parse(baseClass, mappingString)))
1997         staticFiles(sfm);
1998      return this;
1999   }
2000
2001   /**
2002    * Configuration property:  Static file mappings.
2003    *
2004    * <p>
2005    * Same as {@link #staticFiles(String)} except path and location are already split values.
2006    *
2007    * <ul class='seealso'>
2008    *    <li class='jf'>{@link RestContext#REST_staticFiles}
2009    * </ul>
2010    *
2011    * @param path
2012    *    The mapped URI path.
2013    *    <br>Leading and trailing slashes are trimmed.
2014    * @param location
2015    *    The location relative to the resource class.
2016    *    <br>Leading and trailing slashes are trimmed.
2017    * @return This object (for method chaining).
2018    */
2019   public RestContextBuilder staticFiles(String path, String location) {
2020      return staticFiles(new StaticFileMapping(resourceClass, path, location, null));
2021   }
2022
2023   /**
2024    * Configuration property:  Static file mappings.
2025    *
2026    * <p>
2027    * Same as {@link #staticFiles(String,String)} except overrides the base class for retrieving the resource.
2028    *
2029    * <ul class='seealso'>
2030    *    <li class='jf'>{@link RestContext#REST_staticFiles}
2031    * </ul>
2032    *
2033    * @param baseClass
2034    *    Overrides the default class to use for retrieving the classpath resource.
2035    *    <br>If <jk>null</jk>, uses the REST resource class.
2036    * @param path
2037    *    The mapped URI path.
2038    *    <br>Leading and trailing slashes are trimmed.
2039    * @param location
2040    *    The location relative to the resource class.
2041    *    <br>Leading and trailing slashes are trimmed.
2042    * @return This object (for method chaining).
2043    */
2044   public RestContextBuilder staticFiles(Class<?> baseClass, String path, String location) {
2045      return staticFiles(new StaticFileMapping(baseClass, path, location, null));
2046   }
2047
2048   /**
2049    * Configuration property:  Supported accept media types.
2050    *
2051    * <p>
2052    * Overrides the media types inferred from the serializers that identify what media types can be produced by the resource.
2053    *
2054    * <ul class='seealso'>
2055    *    <li class='jf'>{@link RestContext#REST_produces}
2056    * </ul>
2057    *
2058    * @param values The values to add to this setting.
2059    * @return This object (for method chaining).
2060    */
2061   public RestContextBuilder produces(String...values) {
2062      return addTo(REST_produces, values);
2063   }
2064
2065   /**
2066    * Configuration property:  Supported accept media types.
2067    *
2068    * <p>
2069    * Same as {@link #produces(String...)} but replaces any previous values.
2070    *
2071    * <ul class='seealso'>
2072    *    <li class='jf'>{@link RestContext#REST_produces}
2073    * </ul>
2074    *
2075    * @param values The values to set on this setting.
2076    * @return This object (for method chaining).
2077    */
2078   public RestContextBuilder producesReplace(String...values) {
2079      return set(REST_produces, values);
2080   }
2081
2082   /**
2083    * Configuration property:  Supported accept media types.
2084    *
2085    * <p>
2086    * Same as {@link #produces(String...)} except input is {@link MediaType} instances.
2087    *
2088    * <ul class='seealso'>
2089    *    <li class='jf'>{@link RestContext#REST_produces}
2090    * </ul>
2091    *
2092    * @param values The values to add to this setting.
2093    * @return This object (for method chaining).
2094    */
2095   public RestContextBuilder produces(MediaType...values) {
2096      return addTo(REST_produces, values);
2097   }
2098
2099   /**
2100    * Configuration property:  Supported accept media types.
2101    *
2102    * <p>
2103    * Same as {@link #produces(MediaType...)} but replaces any previous values.
2104    *
2105    * <ul class='seealso'>
2106    *    <li class='jf'>{@link RestContext#REST_produces}
2107    * </ul>
2108    *
2109    * @param values The values to set on this setting.
2110    * @return This object (for method chaining).
2111    */
2112   public RestContextBuilder producesReplace(MediaType...values) {
2113      return set(REST_produces, values);
2114   }
2115
2116   /**
2117    * Configuration property:  Supported content media types.
2118    *
2119    * <p>
2120    * Overrides the media types inferred from the parsers that identify what media types can be consumed by the resource.
2121    *
2122    * <ul class='seealso'>
2123    *    <li class='jf'>{@link RestContext#REST_consumes}
2124    * </ul>
2125    *
2126    * @param values The values to add to this setting.
2127    * @return This object (for method chaining).
2128    */
2129   public RestContextBuilder consumes(String...values) {
2130      return addTo(REST_consumes, values);
2131   }
2132
2133   /**
2134    * Configuration property:  Supported content media types.
2135    *
2136    * <p>
2137    * Same as {@link #consumes(String...)} but replaces any existing values.
2138    *
2139    * <ul class='seealso'>
2140    *    <li class='jf'>{@link RestContext#REST_consumes}
2141    * </ul>
2142    *
2143    * @param values The values to set on this setting.
2144    * @return This object (for method chaining).
2145    */
2146   public RestContextBuilder consumesReplace(String...values) {
2147      return set(REST_consumes, values);
2148   }
2149
2150   /**
2151    * Configuration property:  Supported content media types.
2152    *
2153    * <p>
2154    * Same as {@link #consumes(String...)} except input is {@link MediaType} instances.
2155    *
2156    * <ul class='seealso'>
2157    *    <li class='jf'>{@link RestContext#REST_consumes}
2158    * </ul>
2159    *
2160    * @param values The values to add to this setting.
2161    * @return This object (for method chaining).
2162    */
2163   public RestContextBuilder consumes(MediaType...values) {
2164      return addTo(REST_consumes, values);
2165   }
2166
2167   /**
2168    * Configuration property:  Supported content media types.
2169    *
2170    * <p>
2171    * Same as {@link #consumes(MediaType...)} except replaces any existing values.
2172    *
2173    * <ul class='seealso'>
2174    *    <li class='jf'>{@link RestContext#REST_consumes}
2175    * </ul>
2176    *
2177    * @param values The values to set on this setting.
2178    * @return This object (for method chaining).
2179    */
2180   public RestContextBuilder consumesReplace(MediaType...values) {
2181      return set(REST_consumes, values);
2182   }
2183
2184   /**
2185    * Configuration property:  Properties.
2186    *
2187    * <p>
2188    * Shortcut to add properties to the bean contexts of all serializers and parsers on all methods in the class.
2189    *
2190    * <p>
2191    * Any of the properties defined on {@link RestContext} or any of the serializers and parsers can be specified.
2192    *
2193    * <p>
2194    * Property values will be converted to the appropriate type.
2195    *
2196    * <ul class='seealso'>
2197    *    <li class='jm'>{@link RestContext#REST_properties}
2198    * </ul>
2199    *
2200    * @param values The values to set on this setting.
2201    * @return This object (for method chaining).
2202    */
2203   public RestContextBuilder properties(Map<String,Object> values) {
2204      return addTo(REST_properties, values);
2205   }
2206
2207   /**
2208    * Configuration property:  Properties.
2209    *
2210    * <p>
2211    * Shortcut to add properties to the bean contexts of all serializers and parsers on all methods in the class.
2212    *
2213    * <p>
2214    * Any of the properties defined on {@link RestContext} or any of the serializers and parsers can be specified.
2215    *
2216    * <p>
2217    * Property values will be converted to the appropriate type.
2218    *
2219    * <ul class='seealso'>
2220    *    <li class='jm'>{@link RestContext#REST_properties}
2221    * </ul>
2222    *
2223    * @param name The key to add to the properties.
2224    * @param value The value to add to the properties.
2225    * @return This object (for method chaining).
2226    */
2227   public RestContextBuilder property(String name, Object value) {
2228      return addTo(REST_properties, name, value);
2229   }
2230
2231   /**
2232    * Configuration property:  Resource authority path.
2233    *
2234    * <p>
2235    * Overrides the authority path value for this resource and any child resources.
2236    *
2237    * <p>
2238    * This setting is useful if you want to resolve relative URIs to absolute paths and want to explicitly specify the hostname/port.
2239    *
2240    * <ul class='seealso'>
2241    *    <li class='jf'>{@link RestContext#REST_uriAuthority}
2242    * </ul>
2243    *
2244    * @param value The new value for this setting.
2245    * @return This object (for method chaining).
2246    */
2247   public RestContextBuilder uriAuthority(String value) {
2248      if (! value.isEmpty())
2249         set(REST_uriAuthority, value);
2250      return this;
2251   }
2252
2253   /**
2254    * Configuration property:  Resource context path.
2255    *
2256    * <p>
2257    * Overrides the context path value for this resource and any child resources.
2258    *
2259    * <p>
2260    * This setting is useful if you want to use <js>"context:/child/path"</js> URLs in child resource POJOs but
2261    * the context path is not actually specified on the servlet container.
2262    *
2263    * <ul class='seealso'>
2264    *    <li class='jf'>{@link RestContext#REST_uriContext}
2265    * </ul>
2266    *
2267    * @param value The new value for this setting.
2268    * @return This object (for method chaining).
2269    */
2270   public RestContextBuilder uriContext(String value) {
2271      if (! value.isEmpty())
2272         set(REST_uriContext, value);
2273      return this;
2274   }
2275
2276   /**
2277    * Configuration property:  URI resolution relativity.
2278    *
2279    * <p>
2280    * Specifies how relative URIs should be interpreted by serializers.
2281    *
2282    * <p>
2283    * See {@link UriResolution} for possible values.
2284    *
2285    * <ul class='seealso'>
2286    *    <li class='jf'>{@link RestContext#REST_uriRelativity}
2287    * </ul>
2288    *
2289    * @param value The new value for this setting.
2290    * @return This object (for method chaining).
2291    */
2292   public RestContextBuilder uriRelativity(String value) {
2293      if (! value.isEmpty())
2294         set(REST_uriRelativity, value);
2295      return this;
2296   }
2297
2298   /**
2299    * Configuration property:  URI resolution.
2300    *
2301    * <p>
2302    * Specifies how relative URIs should be interpreted by serializers.
2303    *
2304    * <p>
2305    * See {@link UriResolution} for possible values.
2306    *
2307    * <ul class='seealso'>
2308    *    <li class='jf'>{@link RestContext#REST_uriResolution}
2309    * </ul>
2310    *
2311    * @param value The new value for this setting.
2312    * @return This object (for method chaining).
2313    */
2314   public RestContextBuilder uriResolution(String value) {
2315      if (! value.isEmpty())
2316         set(REST_uriResolution, value);
2317      return this;
2318   }
2319
2320   /**
2321    * Configuration property:  Use classpath resource caching.
2322    *
2323    * <p>
2324    * When enabled, resources retrieved via {@link RestContext#getClasspathResource(String, Locale)} (and related
2325    * methods) will be cached in memory to speed subsequent lookups.
2326    *
2327    * <ul class='seealso'>
2328    *    <li class='jf'>{@link RestContext#REST_useClasspathResourceCaching}
2329    * </ul>
2330    *
2331    * @param value
2332    *    The new value for this setting.
2333    *    <br>The default is <jk>true</jk>.
2334    * @return This object (for method chaining).
2335    */
2336   public RestContextBuilder useClasspathResourceCaching(boolean value) {
2337      return set(REST_useClasspathResourceCaching, value);
2338   }
2339
2340   /**
2341    * Configuration property:  Use stack trace hashes.
2342    *
2343    * <div class='warn'>
2344    *    <b>Deprecated</b> - Use {@link #callLoggerConfig(RestCallLoggerConfig)}
2345    * </div>
2346    *
2347    * <p>
2348    * When enabled, the number of times an exception has occurred will be determined based on stack trace hashsums,
2349    * made available through the {@link RestException#getOccurrence()} method.
2350    *
2351    * <ul class='seealso'>
2352    *    <li class='jf'>{@link RestContext#REST_useStackTraceHashes}
2353    * </ul>
2354    *
2355    * @param value
2356    *    The new value for this setting.
2357    *    <br>The default is <jk>true</jk>.
2358    * @return This object (for method chaining).
2359    */
2360   @Deprecated
2361   public RestContextBuilder useStackTraceHashes(boolean value) {
2362      return set(REST_useStackTraceHashes, value);
2363   }
2364
2365   /**
2366    * Configuration property:  HTML Widgets.
2367    *
2368    * <div class='warn'>
2369    *    <b>Deprecated</b> - Use {@link HtmlDocSerializerBuilder#widgets(Class[])}
2370    * </div>
2371    *
2372    * <p>
2373    * Defines widgets that can be used in conjunction with string variables of the form <js>"$W{name}"</js>to quickly
2374    * generate arbitrary replacement text.
2375    *
2376    * <ul class='seealso'>
2377    *    <li class='jf'>{@link RestContext#REST_widgets}
2378    * </ul>
2379    *
2380    * @param values The values to add to this setting.
2381    * @return This object (for method chaining).
2382    *
2383    */
2384   @SuppressWarnings("unchecked")
2385   @Deprecated
2386   public RestContextBuilder widgets(Class<? extends Widget>...values) {
2387      return addTo(REST_widgets, values);
2388   }
2389
2390   /**
2391    * Configuration property:  HTML Widgets.
2392    *
2393    * <div class='warn'>
2394    *    <b>Deprecated</b> - Use {@link HtmlDocSerializerBuilder#widgetsReplace(Class[])}
2395    * </div>
2396    *
2397    * <p>
2398    * Same as {@link #widgets(Class...)} but replaces any previous values.
2399    *
2400    * <ul class='seealso'>
2401    *    <li class='jf'>{@link RestContext#REST_widgets}
2402    * </ul>
2403    *
2404    * @param values The values to set on this setting.
2405    * @return This object (for method chaining).
2406    */
2407   @SuppressWarnings("unchecked")
2408   @Deprecated
2409   public RestContextBuilder widgetsReplace(Class<? extends Widget>...values) {
2410      return set(REST_widgets, values);
2411   }
2412
2413   /**
2414    * Configuration property:  HTML Widgets.
2415    *
2416    * <div class='warn'>
2417    *    <b>Deprecated</b> - Use {@link HtmlDocSerializerBuilder#widgets(HtmlWidget[])}
2418    * </div>
2419    *
2420    * <p>
2421    * Same as {@link #widgets(Class...)} except input is pre-constructed instances.
2422    *
2423    * <ul class='seealso'>
2424    *    <li class='jf'>{@link RestContext#REST_widgets}
2425    * </ul>
2426    *
2427    * @param values The values to add to this setting.
2428    * @return This object (for method chaining).
2429    */
2430   @Deprecated
2431   public RestContextBuilder widgets(Widget...values) {
2432      return addTo(REST_widgets, values);
2433   }
2434
2435   /**
2436    * Configuration property:  HTML Widgets.
2437    *
2438    * <div class='warn'>
2439    *    <b>Deprecated</b> - Use {@link HtmlDocSerializerBuilder#widgetsReplace(HtmlWidget[])}
2440    * </div>
2441    *
2442    * <p>
2443    * Same as {@link #widgets(Widget...)} except allows you to overwrite the previous value.
2444    *
2445    * <ul class='seealso'>
2446    *    <li class='jf'>{@link RestContext#REST_widgets}
2447    * </ul>
2448    *
2449    * @param values The values to add to this setting.
2450    * @return This object (for method chaining).
2451    */
2452   @Deprecated
2453   public RestContextBuilder widgetsReplace(Widget...values) {
2454      return set(REST_widgets, values);
2455   }
2456
2457   @Override /* BeanContextBuilder */
2458   public RestContextBuilder beanClassVisibility(Visibility value) {
2459      super.beanClassVisibility(value);
2460      return this;
2461   }
2462
2463   @Override /* BeanContextBuilder */
2464   public RestContextBuilder beanConstructorVisibility(Visibility value) {
2465      super.beanConstructorVisibility(value);
2466      return this;
2467   }
2468
2469   @Override /* BeanContextBuilder */
2470   @Deprecated
2471   public RestContextBuilder beanDictionary(Class<?>...values) {
2472      super.beanDictionary(values);
2473      return this;
2474   }
2475
2476   @Override /* BeanContextBuilder */
2477   @Deprecated
2478   public RestContextBuilder beanDictionary(Object...values) {
2479      super.beanDictionary(values);
2480      return this;
2481   }
2482
2483   @Override /* BeanContextBuilder */
2484   @Deprecated
2485   public RestContextBuilder beanDictionaryReplace(Class<?>...values) {
2486      super.beanDictionaryReplace(values);
2487      return this;
2488   }
2489
2490   @Override /* BeanContextBuilder */
2491   @Deprecated
2492   public RestContextBuilder beanDictionaryReplace(Object...values) {
2493      super.beanDictionaryReplace(values);
2494      return this;
2495   }
2496
2497   @Override /* BeanContextBuilder */
2498   @Deprecated
2499   public RestContextBuilder beanDictionaryRemove(Class<?>...values) {
2500      super.beanDictionaryRemove(values);
2501      return this;
2502   }
2503
2504   @Override /* BeanContextBuilder */
2505   @Deprecated
2506   public RestContextBuilder beanDictionaryRemove(Object...values) {
2507      super.beanDictionaryRemove(values);
2508      return this;
2509   }
2510
2511   @Override /* BeanContextBuilder */
2512   public RestContextBuilder beanFieldVisibility(Visibility value) {
2513      super.beanFieldVisibility(value);
2514      return this;
2515   }
2516
2517   @Override /* BeanContextBuilder */
2518   public RestContextBuilder beanFilters(Class<?>...values) {
2519      super.beanFilters(values);
2520      return this;
2521   }
2522
2523   @Override /* BeanContextBuilder */
2524   public RestContextBuilder beanFilters(Object...values) {
2525      super.beanFilters(values);
2526      return this;
2527   }
2528
2529   @Override /* BeanContextBuilder */
2530   public RestContextBuilder beanFiltersReplace(Class<?>...values) {
2531      super.beanFiltersReplace(values);
2532      return this;
2533   }
2534
2535   @Override /* BeanContextBuilder */
2536   public RestContextBuilder beanFiltersReplace(Object...values) {
2537      super.beanFiltersReplace(values);
2538      return this;
2539   }
2540
2541   @Override /* BeanContextBuilder */
2542   public RestContextBuilder beanFiltersRemove(Class<?>...values) {
2543      super.beanFiltersRemove(values);
2544      return this;
2545   }
2546
2547   @Override /* BeanContextBuilder */
2548   public RestContextBuilder beanFiltersRemove(Object...values) {
2549      super.beanFiltersRemove(values);
2550      return this;
2551   }
2552
2553   @Override /* BeanContextBuilder */
2554   public RestContextBuilder beanMapPutReturnsOldValue(boolean value) {
2555      super.beanMapPutReturnsOldValue(value);
2556      return this;
2557   }
2558
2559   @Override /* BeanContextBuilder */
2560   public RestContextBuilder beanMapPutReturnsOldValue() {
2561      super.beanMapPutReturnsOldValue();
2562      return this;
2563   }
2564
2565   @Override /* BeanContextBuilder */
2566   public RestContextBuilder beanMethodVisibility(Visibility value) {
2567      super.beanMethodVisibility(value);
2568      return this;
2569   }
2570
2571   @Override /* BeanContextBuilder */
2572   public RestContextBuilder beansRequireDefaultConstructor(boolean value) {
2573      super.beansRequireDefaultConstructor(value);
2574      return this;
2575   }
2576
2577   @Override /* BeanContextBuilder */
2578   public RestContextBuilder beansRequireDefaultConstructor() {
2579      super.beansRequireDefaultConstructor();
2580      return this;
2581   }
2582
2583   @Override /* BeanContextBuilder */
2584   public RestContextBuilder beansRequireSerializable(boolean value) {
2585      super.beansRequireSerializable(value);
2586      return this;
2587   }
2588
2589   @Override /* BeanContextBuilder */
2590   public RestContextBuilder beansRequireSerializable() {
2591      super.beansRequireSerializable();
2592      return this;
2593   }
2594
2595   @Override /* BeanContextBuilder */
2596   public RestContextBuilder beansRequireSettersForGetters(boolean value) {
2597      super.beansRequireSettersForGetters(value);
2598      return this;
2599   }
2600
2601   @Override /* BeanContextBuilder */
2602   public RestContextBuilder beansRequireSettersForGetters() {
2603      super.beansRequireSettersForGetters();
2604      return this;
2605   }
2606
2607   @Override /* BeanContextBuilder */
2608   public RestContextBuilder beansRequireSomeProperties(boolean value) {
2609      super.beansRequireSomeProperties(value);
2610      return this;
2611   }
2612
2613   @Override /* BeanContextBuilder */
2614   public RestContextBuilder beanTypePropertyName(String value) {
2615      super.beanTypePropertyName(value);
2616      return this;
2617   }
2618
2619   @Override /* BeanContextBuilder */
2620   public RestContextBuilder bpi(Class<?> beanClass, String value) {
2621      super.bpi(beanClass, value);
2622      return this;
2623   }
2624
2625   @Override /* BeanContextBuilder */
2626   public RestContextBuilder bpi(Map<String,String> values) {
2627      super.bpi(values);
2628      return this;
2629   }
2630
2631   @Override /* BeanContextBuilder */
2632   public RestContextBuilder bpi(String beanClassName, String value) {
2633      super.bpi(beanClassName, value);
2634      return this;
2635   }
2636
2637   @Override /* BeanContextBuilder */
2638   public RestContextBuilder bpx(Class<?> beanClass, String properties) {
2639      super.bpx(beanClass, properties);
2640      return this;
2641   }
2642
2643   @Override /* BeanContextBuilder */
2644   public RestContextBuilder bpx(Map<String,String> values) {
2645      super.bpx(values);
2646      return this;
2647   }
2648
2649   @Override /* BeanContextBuilder */
2650   public RestContextBuilder bpx(String beanClassName, String value) {
2651      super.bpx(beanClassName, value);
2652      return this;
2653   }
2654
2655   @Override /* BeanContextBuilder */
2656   public RestContextBuilder bpro(Class<?> beanClass, String value) {
2657      super.bpro(beanClass, value);
2658      return this;
2659   }
2660
2661   @Override /* BeanContextBuilder */
2662   public RestContextBuilder bpro(Map<String,String> values) {
2663      super.bpro(values);
2664      return this;
2665   }
2666
2667   @Override /* BeanContextBuilder */
2668   public RestContextBuilder bpro(String beanClassName, String value) {
2669      super.bpro(beanClassName, value);
2670      return this;
2671   }
2672
2673   @Override /* BeanContextBuilder */
2674   public RestContextBuilder bpwo(Class<?> beanClass, String properties) {
2675      super.bpwo(beanClass, properties);
2676      return this;
2677   }
2678
2679   @Override /* BeanContextBuilder */
2680   public RestContextBuilder bpwo(Map<String,String> values) {
2681      super.bpwo(values);
2682      return this;
2683   }
2684
2685   @Override /* BeanContextBuilder */
2686   public RestContextBuilder bpwo(String beanClassName, String value) {
2687      super.bpwo(beanClassName, value);
2688      return this;
2689   }
2690
2691   @Override /* BeanContextBuilder */
2692   public RestContextBuilder debug() {
2693      debug(Enablement.TRUE);
2694      super.debug();
2695      return this;
2696   }
2697
2698   @Override /* BeanContextBuilder */
2699   public RestContextBuilder dictionary(Class<?>...values) {
2700      super.dictionary(values);
2701      return this;
2702   }
2703
2704   @Override /* BeanContextBuilder */
2705   public RestContextBuilder dictionary(Object...values) {
2706      super.dictionary(values);
2707      return this;
2708   }
2709
2710   @Override /* BeanContextBuilder */
2711   public RestContextBuilder dictionaryReplace(Class<?>...values) {
2712      super.dictionaryReplace(values);
2713      return this;
2714   }
2715
2716   @Override /* BeanContextBuilder */
2717   public RestContextBuilder dictionaryReplace(Object...values) {
2718      super.dictionaryReplace(values);
2719      return this;
2720   }
2721
2722   @Override /* BeanContextBuilder */
2723   public RestContextBuilder dictionaryRemove(Class<?>...values) {
2724      super.dictionaryRemove(values);
2725      return this;
2726   }
2727
2728   @Override /* BeanContextBuilder */
2729   public RestContextBuilder dictionaryRemove(Object...values) {
2730      super.dictionaryRemove(values);
2731      return this;
2732   }
2733
2734   @Override /* BeanContextBuilder */
2735   public <T> RestContextBuilder example(Class<T> c, T o) {
2736      super.example(c, o);
2737      return this;
2738   }
2739
2740   @Override /* BeanContextBuilder */
2741   public <T> RestContextBuilder exampleJson(Class<T> c, String value) {
2742      super.exampleJson(c, value);
2743      return this;
2744   }
2745
2746   @Override /* BeanContextBuilder */
2747   public RestContextBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
2748      super.ignoreInvocationExceptionsOnGetters(value);
2749      return this;
2750   }
2751
2752   @Override /* BeanContextBuilder */
2753   public RestContextBuilder ignoreInvocationExceptionsOnGetters() {
2754      super.ignoreInvocationExceptionsOnGetters();
2755      return this;
2756   }
2757
2758   @Override /* BeanContextBuilder */
2759   public RestContextBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
2760      super.ignoreInvocationExceptionsOnSetters(value);
2761      return this;
2762   }
2763
2764   @Override /* BeanContextBuilder */
2765   public RestContextBuilder ignoreInvocationExceptionsOnSetters() {
2766      super.ignoreInvocationExceptionsOnSetters();
2767      return this;
2768   }
2769
2770   @Override /* BeanContextBuilder */
2771   public RestContextBuilder ignorePropertiesWithoutSetters(boolean value) {
2772      super.ignorePropertiesWithoutSetters(value);
2773      return this;
2774   }
2775
2776   @Override /* BeanContextBuilder */
2777   public RestContextBuilder ignoreUnknownBeanProperties(boolean value) {
2778      super.ignoreUnknownBeanProperties(value);
2779      return this;
2780   }
2781
2782   @Override /* BeanContextBuilder */
2783   public RestContextBuilder ignoreUnknownBeanProperties() {
2784      super.ignoreUnknownBeanProperties();
2785      return this;
2786   }
2787
2788   @Override /* BeanContextBuilder */
2789   public RestContextBuilder ignoreUnknownNullBeanProperties(boolean value) {
2790      super.ignoreUnknownNullBeanProperties(value);
2791      return this;
2792   }
2793
2794   @Override /* BeanContextBuilder */
2795   public RestContextBuilder implClass(Class<?> interfaceClass, Class<?> implClass) {
2796      super.implClass(interfaceClass, implClass);
2797      return this;
2798   }
2799
2800   @Override /* BeanContextBuilder */
2801   public RestContextBuilder implClasses(Map<String,Class<?>> values) {
2802      super.implClasses(values);
2803      return this;
2804   }
2805
2806   @Override /* BeanContextBuilder */
2807   public RestContextBuilder locale(Locale value) {
2808      super.locale(value);
2809      return this;
2810   }
2811
2812   @Override /* BeanContextBuilder */
2813   public RestContextBuilder mediaType(MediaType value) {
2814      super.mediaType(value);
2815      return this;
2816   }
2817
2818   @Override /* BeanContextBuilder */
2819   public RestContextBuilder notBeanClasses(Class<?>...values) {
2820      super.notBeanClasses(values);
2821      return this;
2822   }
2823
2824   @Override /* BeanContextBuilder */
2825   public RestContextBuilder notBeanClasses(Object...values) {
2826      super.notBeanClasses(values);
2827      return this;
2828   }
2829
2830   @Override /* BeanContextBuilder */
2831   public RestContextBuilder notBeanClassesReplace(Class<?>...values) {
2832      super.notBeanClassesReplace(values);
2833      return this;
2834   }
2835
2836   @Override /* BeanContextBuilder */
2837   public RestContextBuilder notBeanClassesReplace(Object...values) {
2838      super.notBeanClassesReplace(values);
2839      return this;
2840   }
2841
2842   @Override /* BeanContextBuilder */
2843   public RestContextBuilder notBeanClassesRemove(Class<?>...values) {
2844      super.notBeanClassesRemove(values);
2845      return this;
2846   }
2847
2848   @Override /* BeanContextBuilder */
2849   public RestContextBuilder notBeanClassesRemove(Object...values) {
2850      super.notBeanClassesRemove(values);
2851      return this;
2852   }
2853
2854   @Override /* BeanContextBuilder */
2855   public RestContextBuilder notBeanPackages(Object...values) {
2856      super.notBeanPackages(values);
2857      return this;
2858   }
2859
2860   @Override /* BeanContextBuilder */
2861   public RestContextBuilder notBeanPackages(String...values) {
2862      super.notBeanPackages(values);
2863      return this;
2864   }
2865
2866   @Override /* BeanContextBuilder */
2867   public RestContextBuilder notBeanPackagesReplace(String...values) {
2868      super.notBeanPackagesReplace(values);
2869      return this;
2870   }
2871
2872   @Override /* BeanContextBuilder */
2873   public RestContextBuilder notBeanPackagesReplace(Object...values) {
2874      super.notBeanPackagesReplace(values);
2875      return this;
2876   }
2877
2878   @Override /* BeanContextBuilder */
2879   public RestContextBuilder notBeanPackagesRemove(String...values) {
2880      super.notBeanPackagesRemove(values);
2881      return this;
2882   }
2883
2884   @Override /* BeanContextBuilder */
2885   public RestContextBuilder notBeanPackagesRemove(Object...values) {
2886      super.notBeanPackagesRemove(values);
2887      return this;
2888   }
2889
2890   @Override /* BeanContextBuilder */
2891   public RestContextBuilder pojoSwaps(Class<?>...values) {
2892      super.pojoSwaps(values);
2893      return this;
2894   }
2895
2896   @Override /* BeanContextBuilder */
2897   public RestContextBuilder pojoSwaps(Object...values) {
2898      super.pojoSwaps(values);
2899      return this;
2900   }
2901
2902   @Override /* BeanContextBuilder */
2903   public RestContextBuilder pojoSwapsReplace(Class<?>...values) {
2904      super.pojoSwapsReplace(values);
2905      return this;
2906   }
2907
2908   @Override /* BeanContextBuilder */
2909   public RestContextBuilder pojoSwapsReplace(Object...values) {
2910      super.pojoSwapsReplace(values);
2911      return this;
2912   }
2913
2914   @Override /* BeanContextBuilder */
2915   public RestContextBuilder pojoSwapsRemove(Class<?>...values) {
2916      super.pojoSwapsRemove(values);
2917      return this;
2918   }
2919
2920   @Override /* BeanContextBuilder */
2921   public RestContextBuilder pojoSwapsRemove(Object...values) {
2922      super.pojoSwapsRemove(values);
2923      return this;
2924   }
2925
2926   @Override /* BeanContextBuilder */
2927   public RestContextBuilder sortProperties(boolean value) {
2928      super.sortProperties(value);
2929      return this;
2930   }
2931
2932   @Override /* BeanContextBuilder */
2933   public RestContextBuilder sortProperties() {
2934      super.sortProperties();
2935      return this;
2936   }
2937
2938   @Override /* BeanContextBuilder */
2939   public RestContextBuilder timeZone(TimeZone value) {
2940      super.timeZone(value);
2941      return this;
2942   }
2943
2944   @Override /* BeanContextBuilder */
2945   public RestContextBuilder useEnumNames(boolean value) {
2946      super.useEnumNames(value);
2947      return this;
2948   }
2949
2950   @Override /* BeanContextBuilder */
2951   public RestContextBuilder useEnumNames() {
2952      super.useEnumNames();
2953      return this;
2954   }
2955
2956   @Override /* BeanContextBuilder */
2957   public RestContextBuilder useInterfaceProxies(boolean value) {
2958      super.useInterfaceProxies(value);
2959      return this;
2960   }
2961
2962   @Override /* BeanContextBuilder */
2963   public RestContextBuilder useJavaBeanIntrospector(boolean value) {
2964      super.useJavaBeanIntrospector(value);
2965      return this;
2966   }
2967
2968   @Override /* BeanContextBuilder */
2969   public RestContextBuilder useJavaBeanIntrospector() {
2970      super.useJavaBeanIntrospector();
2971      return this;
2972   }
2973
2974   @Override /* ContextBuilder */
2975   public RestContextBuilder annotations(Annotation...values) {
2976      super.annotations(values);
2977      return this;
2978   }
2979
2980   @Override /* ContextBuilder */
2981   public RestContextBuilder set(String name, Object value) {
2982      super.set(name, value);
2983      this.properties.put(name, value);
2984      addTo(REST_properties, name, value);
2985      return this;
2986   }
2987
2988   @Override /* ContextBuilder */
2989   public RestContextBuilder set(Map<String,Object> properties) {
2990      super.set(properties);
2991      this.properties.clear();
2992      this.properties.putAll(properties);
2993      addTo(REST_properties, properties);
2994      return this;
2995   }
2996
2997   @Override /* ContextBuilder */
2998   public RestContextBuilder add(Map<String,Object> properties) {
2999      super.add(properties);
3000      return this;
3001   }
3002
3003   @Override /* ContextBuilder */
3004   public RestContextBuilder addTo(String name, Object value) {
3005      super.addTo(name, value);
3006      return this;
3007   }
3008
3009   @Override /* ContextBuilder */
3010   public RestContextBuilder addTo(String name, String key, Object value) {
3011      super.addTo(name, key, value);
3012      return this;
3013   }
3014
3015   @Override /* ContextBuilder */
3016   public RestContextBuilder removeFrom(String name, Object value) {
3017      super.removeFrom(name, value);
3018      return this;
3019   }
3020
3021   @Override /* ContextBuilder */
3022   public RestContextBuilder apply(PropertyStore copyFrom) {
3023      super.apply(copyFrom);
3024      return this;
3025   }
3026
3027   @Override /* ContextBuilder */
3028   public RestContextBuilder applyAnnotations(AnnotationList al, VarResolverSession vrs) {
3029      super.applyAnnotations(al, vrs);
3030      return this;
3031   }
3032
3033   @Override /* ContextBuilder */
3034   public RestContextBuilder applyAnnotations(Class<?>...fromClasses) {
3035      super.applyAnnotations(fromClasses);
3036      return this;
3037   }
3038
3039   @Override /* ContextBuilder */
3040   public RestContextBuilder applyAnnotations(java.lang.reflect.Method...fromMethods) {
3041      super.applyAnnotations(fromMethods);
3042      return this;
3043   }
3044
3045   //----------------------------------------------------------------------------------------------------
3046   // Methods inherited from ServletConfig
3047   //----------------------------------------------------------------------------------------------------
3048
3049   @Override /* ServletConfig */
3050   public String getInitParameter(String name) {
3051      return inner.getInitParameter(name);
3052   }
3053
3054   @Override /* ServletConfig */
3055   public Enumeration<String> getInitParameterNames() {
3056      return inner.getInitParameterNames();
3057   }
3058
3059   @Override /* ServletConfig */
3060   public ServletContext getServletContext() {
3061      return inner.getServletContext();
3062   }
3063
3064   @Override /* ServletConfig */
3065   public String getServletName() {
3066      return inner.getServletName();
3067   }
3068}