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