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.ArrayUtils.*;
016import static org.apache.juneau.internal.ReflectionUtils.*;
017import static org.apache.juneau.internal.StringUtils.*;
018import static org.apache.juneau.parser.Parser.*;
019import static org.apache.juneau.rest.RestContext.*;
020import static org.apache.juneau.serializer.Serializer.*;
021
022import java.lang.reflect.Method;
023import java.nio.charset.*;
024import java.util.*;
025
026import javax.servlet.*;
027
028import org.apache.juneau.*;
029import org.apache.juneau.config.*;
030import org.apache.juneau.config.vars.*;
031import org.apache.juneau.encoders.*;
032import org.apache.juneau.http.*;
033import org.apache.juneau.httppart.*;
034import org.apache.juneau.internal.*;
035import org.apache.juneau.parser.*;
036import org.apache.juneau.rest.annotation.*;
037import org.apache.juneau.rest.response.*;
038import org.apache.juneau.rest.widget.*;
039import org.apache.juneau.serializer.*;
040import org.apache.juneau.svl.*;
041import org.apache.juneau.svl.vars.*;
042import org.apache.juneau.utils.*;
043
044/**
045 * Defines the initial configuration of a <code>RestServlet</code> or <code>@RestResource</code> annotated object.
046 * 
047 * <p>
048 * An extension of the {@link ServletConfig} object used during servlet initialization.
049 * 
050 * <p>
051 * Provides access to the following initialized resources:
052 * <ul>
053 *    <li>{@link #getConfig()} - The external configuration for this resource.
054 *    <li>{@link #getProperties()} - The modifiable configuration properties for this resource.
055 *    <li>{@link #getVarResolverBuilder()} - The variable resolver for this resource.
056 * </ul>
057 * 
058 * <p>
059 * Methods are provided for overriding or augmenting the information provided by the <ja>@RestResource</ja> annotation.
060 * In general, most information provided in the <ja>@RestResource</ja> annotation can be specified programmatically
061 * through calls on this object.
062 * 
063 * <p>
064 * To interact with this object, simply pass it in as a constructor argument or in an INIT hook.
065 * <p class='bcode'>
066 *    <jc>// Option #1 - Pass in through constructor.</jc>
067 *    <jk>public</jk> MyResource(RestContextBuilder builder) {
068 *          builder
069 *             .pojoSwaps(CalendarSwap.<jsf>RFC2822DTZ</jsf>.<jk>class</jk>)
070 *             .set(<jsf>PARSER_debug</jsf>, <jk>true</jk>);
071 *    }
072 * 
073 *    <jc>// Option #2 - Use an INIT hook.</jc>
074 *    <ja>@RestHook</ja>(<jsf>INIT</jsf>)
075 *    <jk>public void</jk> init(RestContextBuilder builder) <jk>throws</jk> Exception {
076 *          builder
077 *             .pojoSwaps(CalendarSwap.<jsf>RFC2822DTZ</jsf>.<jk>class</jk>)
078 *             .set(<jsf>PARSER_debug</jsf>, <jk>true</jk>);
079 *    }
080 * </p>
081 * 
082 * <h5 class='section'>See Also:</h5>
083 * <ul>
084 *    <li class='link'><a class="doclink" href="../../../../overview-summary.html#juneau-rest-server.RestContext">Overview &gt; juneau-rest-server &gt; RestContext</a>
085 * </ul>
086 */
087public class RestContextBuilder extends BeanContextBuilder implements ServletConfig {
088
089   final ServletConfig inner;
090   
091   Class<?> resourceClass;
092   Object resource;
093   ServletContext servletContext;
094   RestContext parentContext;
095
096   //---------------------------------------------------------------------------
097   // The following fields are meant to be modifiable.
098   // They should not be declared final.
099   // Read-only snapshots of these will be made in RestServletContext.
100   //---------------------------------------------------------------------------
101
102   RestContextProperties properties;
103   Config config;
104   VarResolverBuilder varResolverBuilder;
105   String path;
106   HtmlDocBuilder htmlDocBuilder;
107
108   /**
109    * Constructor for top-level servlets when using dependency injection.
110    * 
111    * <p>
112    * Work-in-progress.
113    * 
114    * @param config
115    *    The servlet config object we're extending.
116    * @param resourceClass
117    *    The class annotated with the {@link RestResource @RestResource} annotation.
118    * @throws ServletException
119    */
120   public RestContextBuilder(ServletConfig config, Class<?> resourceClass) throws ServletException {
121      this(config, resourceClass, null);
122   }
123
124   /**
125    * Constructor.
126    * 
127    * @param servletConfig The servlet config passed into the servlet by the servlet container.
128    * @param resource The class annotated with <ja>@RestResource</ja>.
129    * @throws ServletException Something bad happened.
130    */
131   RestContextBuilder(ServletConfig servletConfig, Class<?> resourceClass, RestContext parentContext) throws ServletException {
132      this.inner = servletConfig;
133      this.resourceClass = resourceClass;
134      this.parentContext = parentContext;
135      
136      properties = new RestContextProperties();
137      logger(BasicRestLogger.class);
138      staticFileResponseHeader("Cache-Control", "max-age=86400, public");
139      encoders(IdentityEncoder.INSTANCE);
140
141      try {
142
143         htmlDocBuilder = new HtmlDocBuilder(properties);
144         varResolverBuilder = new VarResolverBuilder()
145            .defaultVars()
146            .vars(ConfigVar.class);
147
148         VarResolver vr = varResolverBuilder.build();
149
150         Map<Class<?>,RestResource> restResourceAnnotationsParentFirst = findAnnotationsMapParentFirst(RestResource.class, resourceClass);
151
152         // Find our config file.  It's the last non-empty @RestResource.config().
153         String configPath = "";
154         for (RestResource r : restResourceAnnotationsParentFirst.values())
155            if (! r.config().isEmpty())
156               configPath = r.config();
157         String cf = vr.resolve(configPath);
158         ConfigBuilder cb = Config.create().varResolver(vr);
159         if (! cf.isEmpty())
160            cb.name(cf);
161      
162         this.config = cb.build();
163
164         // Add our config file to the variable resolver.
165         varResolverBuilder.contextObject(ConfigVar.SESSION_config, config);
166         vr = varResolverBuilder.build();
167
168         // Add the servlet init parameters to our properties.
169         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         // Load stuff from parent-to-child order.
176         // This allows child settings to overwrite parent settings.
177         for (Map.Entry<Class<?>,RestResource> e : restResourceAnnotationsParentFirst.entrySet()) {
178            Class<?> c = e.getKey();
179            RestResource r = e.getValue();
180            for (Property p : r.properties())
181               set(vr.resolve(p.name()), vr.resolve(p.value()));
182            for (String p : r.flags())
183               set(p, true);
184            serializers(r.serializers());
185            parsers(r.parsers());
186            encoders(r.encoders());
187            if (r.produces().length > 0)
188               produces(false, resolveVars(vr, r.produces()));
189            if (r.consumes().length > 0)
190               consumes(false, resolveVars(vr, r.consumes()));
191            defaultRequestHeaders(resolveVars(vr, r.defaultRequestHeaders()));
192            defaultResponseHeaders(resolveVars(vr, r.defaultResponseHeaders()));
193            responseHandlers(r.responseHandlers());
194            converters(r.converters());
195            guards(reverse(r.guards()));
196            children(r.children());
197            beanFilters((Object[])r.beanFilters());
198            pojoSwaps(r.pojoSwaps());
199            paramResolvers(r.paramResolvers());
200            if (r.serializerListener() != SerializerListener.Null.class)
201               serializerListener(r.serializerListener());
202            if (r.parserListener() != ParserListener.Null.class)
203               parserListener(r.parserListener());
204            contextPath(vr.resolve(r.contextPath()));
205            for (String mapping : r.staticFiles())
206               staticFiles(c, vr.resolve(mapping));
207            if (! r.messages().isEmpty())
208               messages(c, vr.resolve(r.messages()));
209            staticFileResponseHeaders(resolveVars(vr, r.staticFileResponseHeaders()));
210            if (! r.useClasspathResourceCaching().isEmpty())
211               useClasspathResourceCaching(Boolean.valueOf(vr.resolve(r.useClasspathResourceCaching())));
212            if (r.classpathResourceFinder() != ClasspathResourceFinder.Null.class)
213               classpathResourceFinder(r.classpathResourceFinder());
214            if (! r.path().isEmpty())
215               path(vr.resolve(r.path()));
216            if (! r.clientVersionHeader().isEmpty())
217               clientVersionHeader(vr.resolve(r.clientVersionHeader()));
218            if (r.resourceResolver() != RestResourceResolver.Null.class)
219               resourceResolver(r.resourceResolver());
220            if (r.logger() != RestLogger.Null.class)
221               logger(r.logger());
222            if (r.callHandler() != RestCallHandler.Null.class)
223               callHandler(r.callHandler());
224            if (r.infoProvider() != RestInfoProvider.Null.class)
225               infoProvider(r.infoProvider());
226            if (! r.allowHeaderParams().isEmpty())
227               allowHeaderParams(Boolean.valueOf(vr.resolve(r.allowHeaderParams())));
228            if (! r.allowedMethodParams().isEmpty())
229               allowedMethodParams(vr.resolve(r.allowedMethodParams()));
230            if (! r.allowBodyParam().isEmpty())
231               allowBodyParam(Boolean.valueOf(vr.resolve(r.allowBodyParam())));
232            if (! r.renderResponseStackTraces().isEmpty())
233               renderResponseStackTraces(Boolean.valueOf(vr.resolve(r.renderResponseStackTraces())));
234            if (! r.useStackTraceHashes().isEmpty())
235               useStackTraceHashes(Boolean.valueOf(vr.resolve(r.useStackTraceHashes())));
236            if (! r.defaultCharset().isEmpty())
237               defaultCharset(vr.resolve(r.defaultCharset()));
238            if (! r.maxInput().isEmpty())
239               maxInput(vr.resolve(r.maxInput()));
240            mimeTypes(resolveVars(vr, r.mimeTypes()));
241
242            HtmlDoc hd = r.htmldoc();
243            widgets(hd.widgets());
244            htmlDocBuilder.process(hd);
245         }
246
247         responseHandlers(
248            StreamableHandler.class,
249            WritableHandler.class,
250            ReaderHandler.class,
251            InputStreamHandler.class,
252            RedirectHandler.class,
253            DefaultHandler.class
254         );
255
256      } catch (Exception e) {
257         throw new ServletException(e);
258      }
259   }
260   
261   private static String[] resolveVars(VarResolver vr, String[] in) {
262      String[] out = new String[in.length];
263      for (int i = 0; i < in.length; i++) 
264         out[i] = vr.resolve(in[i]);
265      return out;
266   }
267
268   /*
269    * Calls all @RestHook(INIT) methods on the specified resource object.
270    */
271   void init(Object resource) throws ServletException {
272      this.resource = resource;
273
274      // Once we have the resource object, we can construct the Widgets.
275      // We want to do that here so that we can update the script/style properties while they're still modifiable.
276      HtmlDocBuilder hdb = getHtmlDocBuilder();
277      PropertyStore ps = getPropertyStore();
278      Widget[] widgets = ps.getInstanceArrayProperty(REST_widgets, Widget.class, new Widget[0], true, ps, resource);
279      for (Widget w : widgets) {
280         hdb.script("INHERIT", "$W{"+w.getName()+".script}");
281         hdb.style("INHERIT", "$W{"+w.getName()+".style}");
282      }
283      widgets(false, widgets);
284      
285      Map<String,Method> map = new LinkedHashMap<>();
286      for (Method m : ClassUtils.getAllMethods(this.resourceClass, true)) {
287         if (m.isAnnotationPresent(RestHook.class) && m.getAnnotation(RestHook.class).value() == HookEvent.INIT) {
288            Visibility.setAccessible(m);
289            String sig = ClassUtils.getMethodSignature(m);
290            if (! map.containsKey(sig))
291               map.put(sig, m);
292         }
293      }
294      for (Method m : map.values()) {
295         ClassUtils.assertArgsOfType(m, RestContextBuilder.class, ServletConfig.class);
296         Class<?>[] argTypes = m.getParameterTypes();
297         Object[] args = new Object[argTypes.length];
298         for (int i = 0; i < args.length; i++) {
299            if (argTypes[i] == RestContextBuilder.class)
300               args[i] = this;
301            else
302               args[i] = this.inner;
303         }
304         try {
305            m.invoke(resource, args);
306         } catch (Exception e) {
307            throw new RestServletException("Exception thrown from @RestHook(INIT) method {0}.", m).initCause(e);
308         }
309      }
310   }
311   
312   RestContextBuilder servletContext(ServletContext servletContext) {
313      this.servletContext = servletContext;
314      return this;
315   }
316
317   /**
318    * Adds the specified {@link Var} classes to this config.
319    * 
320    * <p>
321    * These variables affect the variable resolver returned by {@link RestRequest#getVarResolverSession()} which is
322    * used to resolve string variables of the form <js>"$X{...}"</js>.
323    * 
324    * <p>
325    * See {@link RestContext#getVarResolver()} for a list of predefined variables.
326    * 
327    * @param vars The {@link Var} classes to add to this config.
328    * @return This object (for method chaining).
329    */
330   public RestContextBuilder vars(Class<?>...vars) {
331      this.varResolverBuilder.vars(vars);
332      return this;
333   }
334
335   /**
336    * Adds a var context object to this config.
337    * 
338    * <p>
339    * Var context objects are read-only objects associated with the variable resolver for vars that require external
340    * information.
341    * 
342    * <p>
343    * For example, the {@link ConfigVar} needs access to this resource's {@link Config} through the
344    * {@link ConfigVar#SESSION_config} object that can be specified as either a session object (temporary) or
345    * context object (permanent).
346    * In this case, we call the following code to add it to the context map:
347    * <p class='bcode'>
348    *    config.addVarContextObject(<jsf>SESSION_config</jsf>, configFile);
349    * </p>
350    * 
351    * @param name The context object key (i.e. the name that the Var class looks for).
352    * @param object The context object.
353    * @return This object (for method chaining).
354    */
355   public RestContextBuilder varContextObject(String name, Object object) {
356      this.varResolverBuilder.contextObject(name, object);
357      return this;
358   }
359
360   /**
361    * Overwrites the default config file with a custom config file.
362    * 
363    * <p>
364    * By default, the config file is determined using the {@link RestResource#config() @RestResource.config()}
365    * annotation.
366    * This method allows you to programmatically override it with your own custom config file.
367    * 
368    * @param config The new config file.
369    * @return This object (for method chaining).
370    */
371   public RestContextBuilder config(Config config) {
372      this.config = config;
373      return this;
374   }
375
376   /**
377    * Returns an instance of an HTMLDOC builder for setting HTMLDOC-related properties.
378    * 
379    * @return An instance of an HTMLDOC builder for setting HTMLDOC-related properties.
380    */
381   public HtmlDocBuilder getHtmlDocBuilder() {
382      return htmlDocBuilder;
383   }
384
385   /**
386    * Creates a new {@link PropertyStore} object initialized with the properties defined in this config.
387    * 
388    * @return A new property store.
389    */
390   protected PropertyStoreBuilder createPropertyStore() {
391      return PropertyStore.create().add(properties);
392   }
393
394
395   //----------------------------------------------------------------------------------------------------
396   // Methods that give access to the config file, var resolver, and properties.
397   //----------------------------------------------------------------------------------------------------
398
399   /**
400    * Returns the external configuration file for this resource.
401    * 
402    * <p>
403    * The configuration file location is determined via the {@link RestResource#config() @RestResource.config()}
404    * annotation on the resource.
405    * 
406    * <p>
407    * The config file can be programmatically overridden by adding the following method to your resource:
408    * <p class='bcode'>
409    *    <jk>public</jk> Config createConfig(ServletConfig servletConfig) <jk>throws</jk> ServletException;
410    * </p>
411    * 
412    * <p>
413    * If a config file is not set up, then an empty config file will be returned that is not backed by any file.
414    * 
415    * @return The external config file for this resource.  Never <jk>null</jk>.
416    */
417   public Config getConfig() {
418      return config;
419   }
420
421   /**
422    * Returns the configuration properties for this resource.
423    * 
424    * <p>
425    * The configuration properties are determined via the {@link RestResource#properties() @RestResource.properties()} annotation on the resource.
426    * 
427    * <p>
428    * The configuration properties can be augmented programmatically by adding the following method to your resource:
429    * <p class='bcode'>
430    *    <jk>public</jk> RestContextProperties createProperties(ServletConfig servletConfig) <jk>throws</jk> ServletException;
431    * </p>
432    * 
433    * <p>
434    * These properties can be modified during servlet initialization.
435    * However, any modifications made after {@link RestServlet#init(ServletConfig)} has been called will have no effect.
436    * 
437    * @return The configuration properties for this resource.  Never <jk>null</jk>.
438    */
439   public RestContextProperties getProperties() {
440      return properties;
441   }
442
443   /**
444    * Creates the variable resolver for this resource.
445    * 
446    * <p>
447    * The variable resolver returned by this method can resolve the following variables:
448    * <ul>
449    *    <li>{@link SystemPropertiesVar}
450    *    <li>{@link EnvVariablesVar}
451    *    <li>{@link ConfigVar}
452    *    <li>{@link IfVar}
453    *    <li>{@link SwitchVar}
454    * </ul>
455    * 
456    * <p>
457    * Note that the variables supported here are only a subset of those returned by
458    * {@link RestRequest#getVarResolverSession()}.
459    * 
460    * @return The variable resolver for this resource.  Never <jk>null</jk>.
461    */
462   public VarResolverBuilder getVarResolverBuilder() {
463      return varResolverBuilder;
464   }
465
466   
467   //----------------------------------------------------------------------------------------------------
468   // Properties
469   //----------------------------------------------------------------------------------------------------
470
471   /**
472    * Configuration property:  Allow body URL parameter.
473    * 
474    * <p>
475    * When enabled, the HTTP body content on PUT and POST requests can be passed in as text using the <js>"body"</js>
476    * URL parameter.
477    * <br>
478    * For example: 
479    * <p class='bcode'>
480    *  ?body=(name='John%20Smith',age=45)
481    * </p>
482    * 
483    * <h5 class='section'>See Also:</h5>
484    * <ul>
485    *    <li class='jf'>{@link RestContext#REST_allowBodyParam}
486    * </ul>
487    * 
488    * @param value 
489    *    The new value for this setting.
490    *    <br>The default is <jk>true</jk>.
491    * @return This object (for method chaining).
492    */
493   public RestContextBuilder allowBodyParam(boolean value) {
494      return set(REST_allowBodyParam, value);
495   }
496
497   /**
498    * Configuration property:  Allowed method parameters.
499    * 
500    * <p>
501    * When specified, the HTTP method can be overridden by passing in a <js>"method"</js> URL parameter on a regular
502    * GET request.
503    * <br>
504    * For example: 
505    * <p class='bcode'>
506    *  ?method=OPTIONS
507    * </p>
508    * 
509    * <h5 class='section'>See Also:</h5>
510    * <ul>
511    *    <li class='jf'>{@link RestContext#REST_allowedMethodParams}
512    * </ul>
513    * 
514    * @param value 
515    *    The new value for this setting.
516    *    <br>The default is <code>[<js>"HEAD"</js>,<js>"OPTIONS"</js>]</code>.
517    *    <br>Individual values can also be comma-delimited lists.
518    * @return This object (for method chaining).
519    */
520   public RestContextBuilder allowedMethodParams(String...value) {
521      return set(REST_allowedMethodParams, StringUtils.join(value, ','));
522   }
523
524   /**
525    * Configuration property:  Allow header URL parameters.
526    * 
527    * <p>
528    * When enabled, headers such as <js>"Accept"</js> and <js>"Content-Type"</js> to be passed in as URL query
529    * parameters.
530    * <br>
531    * For example: 
532    * <p class='bcode'>
533    *  ?Accept=text/json&amp;Content-Type=text/json
534    * </p>
535    * 
536    * <h5 class='section'>See Also:</h5>
537    * <ul>
538    *    <li class='jf'>{@link RestContext#REST_allowHeaderParams}
539    * </ul>
540    * 
541    * @param value 
542    *    The new value for this setting.
543    *    <br>The default is <jk>true</jk>.
544    * @return This object (for method chaining).
545    */
546   public RestContextBuilder allowHeaderParams(boolean value) {
547      return set(REST_allowHeaderParams, value);
548   }
549
550   /**
551    * Configuration property:  REST call handler.
552    * 
553    * <p>
554    * This class handles the basic lifecycle of an HTTP REST call.
555    * <br>Subclasses can be used to customize how these HTTP calls are handled.
556    * 
557    * <h5 class='section'>See Also:</h5>
558    * <ul>
559    *    <li class='jf'>{@link RestContext#REST_callHandler}
560    * </ul>
561    * 
562    * @param value 
563    *    The new value for this setting.
564    *    <br>The default is {@link BasicRestCallHandler}.
565    * @return This object (for method chaining).
566    */
567   public RestContextBuilder callHandler(Class<? extends RestCallHandler> value) {
568      return set(REST_callHandler, value);
569   }
570
571   /**
572    * Configuration property:  REST call handler.
573    * 
574    * <p>
575    * Same as {@link #callHandler(Class)} except input is a pre-constructed instance.
576    * 
577    * <h5 class='section'>See Also:</h5>
578    * <ul>
579    *    <li class='jf'>{@link RestContext#REST_callHandler}
580    * </ul>
581    * 
582    * @param value 
583    *    The new value for this setting.
584    *    <br>The default is {@link BasicRestCallHandler}.
585    * @return This object (for method chaining).
586    */
587   public RestContextBuilder callHandler(RestCallHandler value) {
588      return set(REST_callHandler, value);
589   }
590
591   /**
592    * Configuration property:  Children.
593    * 
594    * <p>
595    * Defines children of this resource.
596    * 
597    * <p>
598    * A REST child resource is simply another servlet that is initialized as part of the parent resource and has a
599    * servlet path directly under the parent servlet path.
600    * 
601    * <h5 class='section'>See Also:</h5>
602    * <ul>
603    *    <li class='jf'>{@link RestContext#REST_children}
604    * </ul>
605    * 
606    * @param values The values to add to this setting.
607    * @return This object (for method chaining).
608    */
609   public RestContextBuilder children(Class<?>...values) {
610      return addTo(REST_children, values);
611   }
612
613   /**
614    * Configuration property:  Children.
615    * 
616    * <p>
617    * Same as {@link #children(Class...)} except input is pre-constructed instances.
618    * 
619    * <h5 class='section'>See Also:</h5>
620    * <ul>
621    *    <li class='jf'>{@link RestContext#REST_children}
622    * </ul>
623    * 
624    * @param values The values to add to this setting.
625    * @return This object (for method chaining).
626    */
627   public RestContextBuilder children(Object...values) {
628      return addTo(REST_children, values);
629   }
630
631   /**
632    * Configuration property:  Children.
633    * 
634    * <p>
635    * Shortcut for adding a single child to this resource.
636    * 
637    * <p>
638    * This can be used for resources that don't have a {@link RestResource#path() @RestResource.path()} annotation.
639    * 
640    * <h5 class='section'>See Also:</h5>
641    * <ul>
642    *    <li class='jf'>{@link RestContext#REST_children}
643    * </ul>
644    * 
645    * @param path The child path relative to the parent resource URI.
646    * @param child The child to add to this resource.
647    * @return This object (for method chaining).
648    */
649   public RestContextBuilder child(String path, Object child) {
650      return addTo(REST_children, new RestChild(path, child));
651   }
652
653   /**
654    * Configuration property:  Classpath resource finder. 
655    * 
656    * <p>
657    * Used to retrieve localized files from the classpath.
658    * 
659    * <h5 class='section'>See Also:</h5>
660    * <ul>
661    *    <li class='jf'>{@link RestContext#REST_classpathResourceFinder}
662    * </ul>
663    * 
664    * @param value 
665    *    The new value for this setting.
666    *    <br>The default is {@link ClasspathResourceFinderBasic}.
667    * @return This object (for method chaining).
668    */
669   public RestContextBuilder classpathResourceFinder(Class<? extends ClasspathResourceFinder> value) {
670      return set(REST_classpathResourceFinder, value);
671   }
672   
673   /**
674    * Configuration property:  Classpath resource finder. 
675    * 
676    * <p>
677    * Same as {@link #classpathResourceFinder(ClasspathResourceFinder)} except input is a pre-constructed instance.
678    * 
679    * <h5 class='section'>See Also:</h5>
680    * <ul>
681    *    <li class='jf'>{@link RestContext#REST_classpathResourceFinder}
682    * </ul>
683    * 
684    * @param value 
685    *    The new value for this setting.
686    *    <br>The default is {@link ClasspathResourceFinderBasic}.
687    * @return This object (for method chaining).
688    */
689   public RestContextBuilder classpathResourceFinder(ClasspathResourceFinder value) {
690      return set(REST_classpathResourceFinder, value);
691   }
692
693   /**
694    * Configuration property:  Client version header.
695    * 
696    * <p>
697    * Specifies the name of the header used to denote the client version on HTTP requests.
698    * 
699    * <p>
700    * The client version is used to support backwards compatibility for breaking REST interface changes.
701    * <br>Used in conjunction with {@link RestMethod#clientVersion() @RestMethod.clientVersion()} annotation.
702    * 
703    * <h5 class='section'>See Also:</h5>
704    * <ul>
705    *    <li class='jf'>{@link RestContext#REST_clientVersionHeader}
706    * </ul>
707    * 
708    * @param value 
709    *    The new value for this setting.
710    *    <br>The default is <js>"X-Client-Version"</js>.
711    * @return This object (for method chaining).
712    */
713   public RestContextBuilder clientVersionHeader(String value) {
714      return set(REST_clientVersionHeader, value);
715   }
716
717   /**
718    * Configuration property:  Resource context path. 
719    * 
720    * <p>
721    * Overrides the context path value for this resource and any child resources.
722    * 
723    * <p>
724    * This setting is useful if you want to use <js>"context:/child/path"</js> URLs in child resource POJOs but
725    * the context path is not actually specified on the servlet container.
726    * 
727    * <h5 class='section'>See Also:</h5>
728    * <ul>
729    *    <li class='jf'>{@link RestContext#REST_contextPath}
730    * </ul>
731    * 
732    * @param value The new value for this setting.
733    * @return This object (for method chaining).
734    */
735   public RestContextBuilder contextPath(String value) {
736      if (! value.isEmpty())
737         set(REST_contextPath, value);
738      return this;
739   }
740
741   /**
742    * Configuration property:  Class-level response converters.
743    * 
744    * <p>
745    * Associates one or more {@link RestConverter converters} with a resource class.
746    * 
747    * <h5 class='section'>See Also:</h5>
748    * <ul>
749    *    <li class='jf'>{@link RestContext#REST_converters}
750    * </ul>
751    * 
752    * @param values The values to add to this setting.
753    * @return This object (for method chaining).
754    */
755   public RestContextBuilder converters(Class<?>...values) {
756      return addTo(REST_converters, values);
757   }
758
759   /**
760    * Configuration property:  Response converters.
761    * 
762    * <p>
763    * Same as {@link #converters(Class...)} except input is pre-constructed instances.
764    * 
765    * <h5 class='section'>See Also:</h5>
766    * <ul>
767    *    <li class='jf'>{@link RestContext#REST_converters}
768    * </ul>
769    * 
770    * @param values The values to add to this setting.
771    * @return This object (for method chaining).
772    */
773   public RestContextBuilder converters(RestConverter...values) {
774      return addTo(REST_converters, values);
775   }
776
777   /**
778    * Configuration property:  Default character encoding.
779    * 
780    * <p>
781    * The default character encoding for the request and response if not specified on the request.
782    * 
783    * <h5 class='section'>See Also:</h5>
784    * <ul>
785    *    <li class='jf'>{@link RestContext#REST_defaultCharset}
786    * </ul>
787    * 
788    * @param value 
789    *    The new value for this setting.
790    *    <br>The default is <js>"utf-8"</js>.
791    * @return This object (for method chaining).
792    */
793   public RestContextBuilder defaultCharset(String value) {
794      return set(REST_defaultCharset, value);
795   }
796
797   /**
798    * Configuration property:  Default character encoding.
799    * 
800    * <p>
801    * Same as {@link #defaultCharset(Charset)} but takes in an instance of {@link Charset}.
802    * 
803    * <h5 class='section'>See Also:</h5>
804    * <ul>
805    *    <li class='jf'>{@link RestContext#REST_defaultCharset}
806    * </ul>
807    * 
808    * @param value 
809    *    The new value for this setting.
810    *    <br>The default is <js>"utf-8"</js>.
811    * @return This object (for method chaining).
812    */
813   public RestContextBuilder defaultCharset(Charset value) {
814      return set(REST_defaultCharset, value);
815   }
816
817   /**
818    * Configuration property:  Default request headers.
819    * 
820    * <p>
821    * Specifies default values for request headers if they're not passed in through the request.
822    * 
823    * <h5 class='section'>See Also:</h5>
824    * <ul>
825    *    <li class='jf'>{@link RestContext#REST_defaultRequestHeaders}
826    * </ul>
827    * 
828    * @param headers The headers in the format <js>"Header-Name: header-value"</js>.
829    * @return This object (for method chaining).
830    * @throws RestServletException If malformed header is found.
831    */
832   public RestContextBuilder defaultRequestHeaders(String...headers) throws RestServletException {
833      for (String header : headers) {
834         String[] h = RestUtils.parseHeader(header);
835         if (h == null)
836            throw new RestServletException("Invalid default request header specified: ''{0}''.  Must be in the format: ''Header-Name: header-value''", header);
837         defaultRequestHeader(h[0], h[1]);
838      }
839      return this;
840   }
841
842   /**
843    * Configuration property:  Default request headers.
844    * 
845    * <p>
846    * Same as {@link #defaultRequestHeaders(String...)} but adds a single header name/value pair.
847    * 
848    * <h5 class='section'>See Also:</h5>
849    * <ul>
850    *    <li class='jf'>{@link RestContext#REST_defaultRequestHeaders}
851    * </ul>
852    * 
853    * @param name The HTTP header name.
854    * @param value The HTTP header value.
855    * @return This object (for method chaining).
856    */
857   public RestContextBuilder defaultRequestHeader(String name, Object value) {
858      return addTo(REST_defaultRequestHeaders, name, value);
859   }
860
861   /**
862    * Configuration property:  Default response headers.
863    * 
864    * <p>
865    * Specifies default values for response headers if they're not set after the Java REST method is called.
866    * 
867    * <h5 class='section'>See Also:</h5>
868    * <ul>
869    *    <li class='jf'>{@link RestContext#REST_defaultResponseHeaders}
870    * </ul>
871    * 
872    * @param headers The headers in the format <js>"Header-Name: header-value"</js>.
873    * @return This object (for method chaining).
874    * @throws RestServletException If malformed header is found.
875    */
876   public RestContextBuilder defaultResponseHeaders(String...headers) throws RestServletException {
877      for (String header : headers) {
878         String[] h = RestUtils.parseHeader(header);
879         if (h == null)
880            throw new RestServletException("Invalid default response header specified: ''{0}''.  Must be in the format: ''Header-Name: header-value''", header);
881         defaultResponseHeader(h[0], h[1]);
882      }
883      return this;
884   }
885
886   /**
887    * Configuration property:  Default response headers.
888    * 
889    * <p>
890    * Same as {@link #defaultResponseHeaders(String...)} but adds a single header name/value pair.
891    * 
892    * <h5 class='section'>See Also:</h5>
893    * <ul>
894    *    <li class='jf'>{@link RestContext#REST_defaultResponseHeaders}
895    * </ul>
896    * 
897    * @param name The HTTP header name.
898    * @param value The HTTP header value.
899    * @return This object (for method chaining).
900    */
901   public RestContextBuilder defaultResponseHeader(String name, Object value) {
902      return addTo(REST_defaultResponseHeaders, name, value);
903   }
904   
905   /**
906    * Configuration property:  Compression encoders. 
907    * 
908    * <p>
909    * These can be used to enable various kinds of compression (e.g. <js>"gzip"</js>) on requests and responses.
910    * 
911    * <h5 class='section'>See Also:</h5>
912    * <ul>
913    *    <li class='jf'>{@link RestContext#REST_encoders}
914    * </ul>
915    * 
916    * @param values The values to add to this setting.
917    * @return This object (for method chaining).
918    */
919   public RestContextBuilder encoders(Class<?>...values) {
920      return addTo(REST_encoders, values);
921   }
922
923   /**
924    * Configuration property:  Compression encoders. 
925    * 
926    * <p>
927    * Same as {@link #encoders(Class...)} except input a pre-constructed instances.
928    * 
929    * <h5 class='section'>See Also:</h5>
930    * <ul>
931    *    <li class='jf'>{@link RestContext#REST_encoders}
932    * </ul>
933    * 
934    * @param values The values to add to this setting.
935    * @return This object (for method chaining).
936    */
937   public RestContextBuilder encoders(Encoder...values) {
938      return addTo(REST_encoders, values);
939   }
940
941   /**
942    * Configuration property:  Class-level guards.
943    * 
944    * <p>
945    * Associates one or more {@link RestGuard RestGuards} with all REST methods defined in this class.
946    * 
947    * <h5 class='section'>See Also:</h5>
948    * <ul>
949    *    <li class='jf'>{@link RestContext#REST_guards}
950    * </ul>
951    * 
952    * @param values The values to add to this setting.
953    * @return This object (for method chaining).
954    */
955   public RestContextBuilder guards(Class<?>...values) {
956      return addTo(REST_guards, values);
957   }
958
959   /**
960    * Configuration property:  Class-level guards.
961    * 
962    * <p>
963    * Same as {@link #guards(Class...)} except input is pre-constructed instances.
964    * 
965    * <h5 class='section'>See Also:</h5>
966    * <ul>
967    *    <li class='jf'>{@link RestContext#REST_guards}
968    * </ul>
969    * 
970    * @param values The values to add to this setting.
971    * @return This object (for method chaining).
972    */
973   public RestContextBuilder guards(RestGuard...values) {
974      return addTo(REST_guards, values);
975   }
976
977   /**
978    * Configuration property:  REST info provider. 
979    * 
980    * <p>
981    * Class used to retrieve title/description/swagger information about a resource.
982    * 
983    * <h5 class='section'>See Also:</h5>
984    * <ul>
985    *    <li class='jf'>{@link RestContext#REST_infoProvider}
986    * </ul>
987    * 
988    * @param value 
989    *    The new value for this setting.
990    *    <br>The default is {@link BasicRestInfoProvider}.
991    * @return This object (for method chaining).
992    */
993   public RestContextBuilder infoProvider(Class<? extends RestInfoProvider> value) {
994      return set(REST_infoProvider, value);
995   }
996
997   /**
998    * Configuration property:  REST info provider. 
999    * 
1000    * <p>
1001    * Same as {@link #infoProvider(Class)} except input is a pre-constructed instance.
1002    * 
1003    * <h5 class='section'>See Also:</h5>
1004    * <ul>
1005    *    <li class='jf'>{@link RestContext#REST_infoProvider}
1006    * </ul>
1007    * 
1008    * @param value 
1009    *    The new value for this setting.
1010    *    <br>The default is {@link BasicRestInfoProvider}.
1011    * @return This object (for method chaining).
1012    */
1013   public RestContextBuilder infoProvider(RestInfoProvider value) {
1014      return set(REST_infoProvider, value);
1015   }
1016
1017   /**
1018    * Configuration property:  REST logger.
1019    * 
1020    * <p>
1021    * Specifies the logger to use for logging.
1022    * 
1023    * <h5 class='section'>See Also:</h5>
1024    * <ul>
1025    *    <li class='jf'>{@link RestContext#REST_logger}
1026    * </ul>
1027    * 
1028    * @param value 
1029    *    The new value for this setting.  
1030    *    <br>The default is {@link BasicRestLogger}.
1031    *    <br>Can be <jk>null</jk> to disable logging.
1032    * @return This object (for method chaining).
1033    */
1034   public RestContextBuilder logger(Class<? extends RestLogger> value) {
1035      return set(REST_logger, value);
1036   }
1037
1038   /**
1039    * Configuration property:  REST logger.
1040    * 
1041    * <p>
1042    * Same as {@link #logger(Class)} except input is a pre-constructed instance.
1043    * 
1044    * <h5 class='section'>See Also:</h5>
1045    * <ul>
1046    *    <li class='jf'>{@link RestContext#REST_logger}
1047    * </ul>
1048    * 
1049    * @param value 
1050    *    The new value for this setting.  
1051    *    <br>The default is {@link BasicRestLogger}.
1052    *    <br>Can be <jk>null</jk> to disable logging.
1053    * @return This object (for method chaining).
1054    */
1055   public RestContextBuilder logger(RestLogger value) {
1056      return set(REST_logger, value);
1057   }
1058
1059   /**
1060    * Configuration property:  The maximum allowed input size (in bytes) on HTTP requests.
1061    * 
1062    * <p>
1063    * Useful for alleviating DoS attacks by throwing an exception when too much input is received instead of resulting
1064    * in out-of-memory errors which could affect system stability.
1065    * 
1066    * <h5 class='section'>See Also:</h5>
1067    * <ul>
1068    *    <li class='jf'>{@link RestContext#REST_maxInput}
1069    * </ul>
1070    * 
1071    * @param value 
1072    *    The new value for this setting.
1073    *    <br>The default is <js>"100M"</js>.
1074    * @return This object (for method chaining).
1075    */
1076   public RestContextBuilder maxInput(String value) {
1077      return set(REST_maxInput, value);
1078   }
1079
1080   /**
1081    * Configuration property:  Messages. 
1082    * 
1083    * <p>
1084    * Identifies the location of the resource bundle for this class.
1085    * 
1086    * <h5 class='section'>See Also:</h5>
1087    * <ul>
1088    *    <li class='jf'>{@link RestContext#REST_messages}
1089    * </ul>
1090    * 
1091    * @param values The values to add to this setting.
1092    * @return This object (for method chaining).
1093    */
1094   public RestContextBuilder messages(MessageBundleLocation...values) {
1095      return addTo(REST_messages, values);
1096   }
1097
1098   /**
1099    * Configuration property:  Messages. 
1100    * 
1101    * <p>
1102    * Same as {@link #messages(MessageBundleLocation...)} except allows you to pass in the base class and bundle
1103    * path separately.
1104    * 
1105    * <h5 class='section'>See Also:</h5>
1106    * <ul>
1107    *    <li class='jf'>{@link RestContext#REST_messages}
1108    * </ul>
1109    * 
1110    * @param baseClass 
1111    *    The base class that the bundle path is relative to.
1112    *    <br>If <jk>null</jk>, assumed to be the resource class itself.
1113    * @param bundlePath The bundle path relative to the base class.
1114    * @return This object (for method chaining).
1115    */
1116   public RestContextBuilder messages(Class<?> baseClass, String bundlePath) {
1117      return addTo(REST_messages, new MessageBundleLocation(baseClass, bundlePath));
1118   }
1119   
1120   /**
1121    * Configuration property:  Messages. 
1122    * 
1123    * <p>
1124    * Same as {@link #messages(Class,String)} except assumes the base class is the resource class itself.
1125    * 
1126    * <h5 class='section'>See Also:</h5>
1127    * <ul>
1128    *    <li class='jf'>{@link RestContext#REST_messages}
1129    * </ul>
1130    * 
1131    * @param bundlePath The bundle path relative to the base class.
1132    * @return This object (for method chaining).
1133    */
1134   public RestContextBuilder messages(String bundlePath) {
1135      return addTo(REST_messages, new MessageBundleLocation(null, bundlePath));
1136   }
1137
1138   /**
1139    * Configuration property:  MIME types. 
1140    * 
1141    * <p>
1142    * Defines MIME-type file type mappings.
1143    * 
1144    * <h5 class='section'>See Also:</h5>
1145    * <ul>
1146    *    <li class='jf'>{@link RestContext#REST_mimeTypes}
1147    * </ul>
1148    * 
1149    * @param values The values to add to this setting.
1150    * @return This object (for method chaining).
1151    */
1152   public RestContextBuilder mimeTypes(String...values) {
1153      return addTo(REST_mimeTypes, values);
1154   }
1155
1156   /**
1157    * Configuration property:  Java method parameter resolvers.
1158    * 
1159    * <p>
1160    * By default, the Juneau framework will automatically Java method parameters of various types (e.g.
1161    * <code>RestRequest</code>, <code>Accept</code>, <code>Reader</code>).
1162    * This annotation allows you to provide your own resolvers for your own class types that you want resolved.
1163    * 
1164    * <h5 class='section'>See Also:</h5>
1165    * <ul>
1166    *    <li class='jf'>{@link RestContext#REST_paramResolvers}
1167    * </ul>
1168    * 
1169    * @param values The values to add to this setting.
1170    * @return This object (for method chaining).
1171    */
1172   @SuppressWarnings("unchecked")
1173   public RestContextBuilder paramResolvers(Class<? extends RestParam>...values) {
1174      return addTo(REST_paramResolvers, values);
1175   }
1176
1177   /**
1178    * Configuration property:  Java method parameter resolvers.
1179    * 
1180    * <p>
1181    * Same as {@link #paramResolvers(Class...)} except input is pre-constructed instances.
1182    * 
1183    * <h5 class='section'>See Also:</h5>
1184    * <ul>
1185    *    <li class='jf'>{@link RestContext#REST_paramResolvers}
1186    * </ul>
1187    * 
1188    * @param values The values to add to this setting.
1189    * @return This object (for method chaining).
1190    */
1191   public RestContextBuilder paramResolvers(RestParam...values) {
1192      return addTo(REST_paramResolvers, values);
1193   }
1194
1195   /**
1196    * Configuration property:  Parser listener.
1197    * 
1198    * <p>
1199    * Specifies the parser listener class to use for listening to non-fatal parsing errors.
1200    * 
1201    * <h5 class='section'>See Also:</h5>
1202    * <ul>
1203    *    <li class='jf'>{@link Parser#PARSER_listener}
1204    * </ul>
1205    * 
1206    * @param value The new value for this setting.
1207    * @return This object (for method chaining).
1208    */
1209   public RestContextBuilder parserListener(Class<? extends ParserListener> value) {
1210      return set(PARSER_listener, value);
1211   }
1212
1213   /**
1214    * Configuration property:  Parsers. 
1215    * 
1216    * <p>
1217    * Adds class-level parsers to this resource.
1218    * 
1219    * <h5 class='section'>See Also:</h5>
1220    * <ul>
1221    *    <li class='jf'>{@link RestContext#REST_parsers}
1222    * </ul>
1223    * 
1224    * @param values The values to add to this setting.
1225    * @return This object (for method chaining).
1226    */
1227   public RestContextBuilder parsers(Class<?>...values) {
1228      return addTo(REST_parsers, values);
1229   }
1230
1231   /**
1232    * Configuration property:  Parsers. 
1233    * 
1234    * <p>
1235    * Same as {@link #parsers(Class...)} except allows you to overwrite the previous value.
1236    * 
1237    * <h5 class='section'>See Also:</h5>
1238    * <ul>
1239    *    <li class='jf'>{@link RestContext#REST_parsers}
1240    * </ul>
1241    * 
1242    * @param append
1243    *    If <jk>true</jk>, append to the existing list, otherwise overwrite the previous value. 
1244    * @param values The values to add to this setting.
1245    * @return This object (for method chaining).
1246    */
1247   public RestContextBuilder parsers(boolean append, Object...values) {
1248      return set(append, REST_parsers, values);
1249   }
1250
1251   /**
1252    * Configuration property:  Parsers. 
1253    * 
1254    * <p>
1255    * Same as {@link #parsers(Class...)} except input is pre-constructed instances.
1256    * 
1257    * <p>
1258    * Parser instances are considered set-in-stone and do NOT inherit properties and transforms defined on the
1259    * resource class or method. 
1260    * 
1261    * <h5 class='section'>See Also:</h5>
1262    * <ul>
1263    *    <li class='jf'>{@link RestContext#REST_parsers}
1264    * </ul>
1265    * 
1266    * @param values The values to add to this setting.
1267    * @return This object (for method chaining).
1268    */
1269   public RestContextBuilder parsers(Object...values) {
1270      return addTo(REST_parsers, values);
1271   }
1272
1273   /**
1274    * Configuration property:  HTTP part parser. 
1275    * 
1276    * <p>
1277    * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters, and URI parts.
1278    * 
1279    * <h5 class='section'>See Also:</h5>
1280    * <ul>
1281    *    <li class='jf'>{@link RestContext#REST_partParser}
1282    * </ul>
1283    * 
1284    * @param value 
1285    *    The new value for this setting.
1286    *    <br>The default is {@link UonPartParser}.
1287    * @return This object (for method chaining).
1288    */
1289   public RestContextBuilder partParser(Class<? extends HttpPartParser> value) {
1290      return set(REST_partParser, value);
1291   }
1292
1293   /**
1294    * Configuration property:  HTTP part parser. 
1295    * 
1296    * <p>
1297    * Same as {@link #partParser(Class)} except input is a pre-constructed instance.
1298    * 
1299    * <h5 class='section'>See Also:</h5>
1300    * <ul>
1301    *    <li class='jf'>{@link RestContext#REST_partParser}
1302    * </ul>
1303    * 
1304    * @param value 
1305    *    The new value for this setting.
1306    *    <br>The default is {@link UonPartParser}.
1307    * @return This object (for method chaining).
1308    */
1309   public RestContextBuilder partParser(HttpPartParser value) {
1310      return set(REST_partParser, value);
1311   }
1312
1313   /**
1314    * Configuration property:  HTTP part serializer. 
1315    * 
1316    * <p>
1317    * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters, and URI parts.
1318    * 
1319    * <h5 class='section'>See Also:</h5>
1320    * <ul>
1321    *    <li class='jf'>{@link RestContext#REST_partSerializer}
1322    * </ul>
1323    * 
1324    * @param value 
1325    *    The new value for this setting.
1326    *    <br>The default is {@link SimpleUonPartSerializer}.
1327    * @return This object (for method chaining).
1328    */
1329   public RestContextBuilder partSerializer(Class<? extends HttpPartSerializer> value) {
1330      return set(REST_partSerializer, value);
1331   }
1332
1333   /**
1334    * Configuration property:  HTTP part serializer. 
1335    * 
1336    * <p>
1337    * Same as {@link #partSerializer(Class)} except input is a pre-constructed instance.
1338    * 
1339    * <h5 class='section'>See Also:</h5>
1340    * <ul>
1341    *    <li class='jf'>{@link RestContext#REST_partSerializer}
1342    * </ul>
1343    * 
1344    * @param value 
1345    *    The new value for this setting.
1346    *    <br>The default is {@link SimpleUonPartSerializer}.
1347    * @return This object (for method chaining).
1348    */
1349   public RestContextBuilder partSerializer(HttpPartSerializer value) {
1350      return set(REST_partSerializer, value);
1351   }
1352
1353   /**
1354    * Configuration property:  Resource path.   
1355    * 
1356    * <p>
1357    * Identifies the URL subpath relative to the parent resource.
1358    * 
1359    * <h5 class='section'>See Also:</h5>
1360    * <ul>
1361    *    <li class='jf'>{@link RestContext#REST_path}
1362    * </ul>
1363    * 
1364    * @param value The new value for this setting.
1365    * @return This object (for method chaining).
1366    */
1367   public RestContextBuilder path(String value) {
1368      if (startsWith(value, '/'))
1369         value = value.substring(1);
1370      this.path = value;
1371      return this;
1372   }
1373
1374   /**
1375    * Configuration property:  Render response stack traces in responses.
1376    * 
1377    * <p>
1378    * Render stack traces in HTTP response bodies when errors occur.
1379    * 
1380    * <h5 class='section'>See Also:</h5>
1381    * <ul>
1382    *    <li class='jf'>{@link RestContext#REST_renderResponseStackTraces}
1383    * </ul>
1384    * 
1385    * @param value 
1386    *    The new value for this setting.
1387    *    <br>The default is <jk>false</jk>.
1388    * @return This object (for method chaining).
1389    */
1390   public RestContextBuilder renderResponseStackTraces(boolean value) {
1391      return set(REST_renderResponseStackTraces, value);
1392   }
1393
1394   /**
1395    * Configuration property:  Render response stack traces in responses.
1396    * 
1397    * <p>
1398    * Shortcut for calling <code>renderResponseStackTraces(<jk>true</jk>)</code>.
1399    * 
1400    * <h5 class='section'>See Also:</h5>
1401    * <ul>
1402    *    <li class='jf'>{@link RestContext#REST_renderResponseStackTraces}
1403    * </ul>
1404    * 
1405    * @return This object (for method chaining).
1406    */
1407   public RestContextBuilder renderResponseStackTraces() {
1408      return set(REST_renderResponseStackTraces, true);
1409   }
1410
1411   /**
1412    * REST resource resolver.
1413    * 
1414    * <p>
1415    * The resolver used for resolving child resources.
1416    * 
1417    * <p>
1418    * Can be used to provide customized resolution of REST resource class instances (e.g. resources retrieve from Spring).
1419    * 
1420    * <h5 class='section'>See Also:</h5>
1421    * <ul>
1422    *    <li class='jf'>{@link RestContext#REST_resourceResolver}
1423    * </ul>
1424    * 
1425    * @param value 
1426    *    The new value for this setting.
1427    *    <br>The default is {@link BasicRestResourceResolver}.
1428    * @return This object (for method chaining).
1429    */
1430   public RestContextBuilder resourceResolver(Class<? extends RestResourceResolver> value) {
1431      return set(REST_resourceResolver, value);
1432   }
1433
1434   /**
1435    * REST resource resolver.
1436    * 
1437    * <p>
1438    * Same as {@link #resourceResolver(Class)} except input is a pre-constructed instance.
1439    * 
1440    * <h5 class='section'>See Also:</h5>
1441    * <ul>
1442    *    <li class='jf'>{@link RestContext#REST_resourceResolver}
1443    * </ul>
1444    * 
1445    * @param value 
1446    *    The new value for this setting.
1447    *    <br>The default is {@link BasicRestResourceResolver}.
1448    * @return This object (for method chaining).
1449    */
1450   public RestContextBuilder resourceResolver(RestResourceResolver value) {
1451      return set(REST_resourceResolver, value);
1452   }
1453
1454   /**
1455    * Configuration property:  Response handlers.
1456    * 
1457    * <p>
1458    * Specifies a list of {@link ResponseHandler} classes that know how to convert POJOs returned by REST methods or
1459    * set via {@link RestResponse#setOutput(Object)} into appropriate HTTP responses.
1460    * 
1461    * <h5 class='section'>See Also:</h5>
1462    * <ul>
1463    *    <li class='jf'>{@link RestContext#REST_responseHandlers}
1464    * </ul>
1465    * 
1466    * @param values The values to add to this setting.
1467    * @return This object (for method chaining).
1468    */
1469   public RestContextBuilder responseHandlers(Class<?>...values) {
1470      return addTo(REST_responseHandlers, values);
1471   }
1472
1473   /**
1474    * Configuration property:  Response handlers.
1475    * 
1476    * <p>
1477    * Same as {@link #responseHandlers(Class...)} except input is pre-constructed instances.
1478    * 
1479    * <h5 class='section'>See Also:</h5>
1480    * <ul>
1481    *    <li class='jf'>{@link RestContext#REST_responseHandlers}
1482    * </ul>
1483    * 
1484    * @param values The values to add to this setting.
1485    * @return This object (for method chaining).
1486    */
1487   public RestContextBuilder responseHandlers(ResponseHandler...values) {
1488      return addTo(REST_responseHandlers, values);
1489   }
1490
1491   /**
1492    * Configuration property:  Serializer listener.
1493    * 
1494    * <p>
1495    * Specifies the serializer listener class to use for listening to non-fatal serialization errors.
1496    * 
1497    * <h5 class='section'>See Also:</h5>
1498    * <ul>
1499    *    <li class='jf'>{@link Serializer#SERIALIZER_listener}
1500    * </ul>
1501    * 
1502    * @param value The new value for this setting.
1503    * @return This object (for method chaining).
1504    */
1505   public RestContextBuilder serializerListener(Class<? extends SerializerListener> value) {
1506      return set(SERIALIZER_listener, value);
1507   }
1508
1509   /**
1510    * Configuration property:  Serializers. 
1511    * 
1512    * <p>
1513    * Adds class-level serializers to this resource.
1514    * 
1515    * <h5 class='section'>See Also:</h5>
1516    * <ul>
1517    *    <li class='jf'>{@link RestContext#REST_serializers}
1518    * </ul>
1519    * 
1520    * @param values The values to add to this setting.
1521    * @return This object (for method chaining).
1522    */
1523   public RestContextBuilder serializers(Class<?>...values) {
1524      return addTo(REST_serializers, values);
1525   }
1526
1527   /**
1528    * Configuration property:  Serializers. 
1529    * 
1530    * <p>
1531    * Same as {@link #serializers(Class...)} except allows you to overwrite the previous value.
1532    * 
1533    * <h5 class='section'>See Also:</h5>
1534    * <ul>
1535    *    <li class='jf'>{@link RestContext#REST_serializers}
1536    * </ul>
1537    * 
1538    * @param append
1539    *    If <jk>true</jk>, append to the existing list, otherwise overwrite the previous value. 
1540    * @param values The values to add to this setting.
1541    * @return This object (for method chaining).
1542    */
1543   public RestContextBuilder serializers(boolean append, Object...values) {
1544      return set(append, REST_serializers, values);
1545   }
1546
1547   /**
1548    * Configuration property:  Serializers. 
1549    * 
1550    * <p>
1551    * Same as {@link #serializers(Class...)} except input is pre-constructed instances.
1552    * 
1553    * <p>
1554    * Serializer instances are considered set-in-stone and do NOT inherit properties and transforms defined on the
1555    * resource class or method. 
1556    * 
1557    * <h5 class='section'>See Also:</h5>
1558    * <ul>
1559    *    <li class='jf'>{@link RestContext#REST_serializers}
1560    * </ul>
1561    * 
1562    * @param values The values to add to this setting.
1563    * @return This object (for method chaining).
1564    */
1565   public RestContextBuilder serializers(Object...values) {
1566      return addTo(REST_serializers, values);
1567   }
1568
1569   /**
1570    * Configuration property:  Static file response headers. 
1571    * 
1572    * <p>
1573    * Used to customize the headers on responses returned for statically-served files.
1574    * 
1575    * <h5 class='section'>See Also:</h5>
1576    * <ul>
1577    *    <li class='jf'>{@link RestContext#REST_staticFileResponseHeaders}
1578    * </ul>
1579    * 
1580    * @param append
1581    *    If <jk>true</jk>, append to the existing list, otherwise overwrite the previous value. 
1582    * @param headers 
1583    *    The headers to add to this list.
1584    *    <br>The default is <code>{<js>'Cache-Control'</js>: <js>'max-age=86400, public</js>}</code>.
1585    * @return This object (for method chaining).
1586    */
1587   public RestContextBuilder staticFileResponseHeaders(boolean append, Map<String,String> headers) {
1588      return set(append, REST_staticFileResponseHeaders, headers);
1589   }
1590
1591   /**
1592    * Configuration property:  Static file response headers. 
1593    * 
1594    * <p>
1595    * Same as {@link #staticFileResponseHeaders(boolean, Map)} with append=<jk>true</jk> except headers are strings 
1596    * composed of key/value pairs.
1597    * 
1598    * <h5 class='section'>See Also:</h5>
1599    * <ul>
1600    *    <li class='jf'>{@link RestContext#REST_staticFileResponseHeaders}
1601    * </ul>
1602    * 
1603    * @param headers The headers in the format <js>"Header-Name: header-value"</js>.
1604    * @return This object (for method chaining).
1605    * @throws RestServletException If malformed header is found.
1606    */
1607   public RestContextBuilder staticFileResponseHeaders(String...headers) throws RestServletException {
1608      for (String header : headers) {
1609         String[] h = RestUtils.parseHeader(header);
1610         if (h == null)
1611            throw new RestServletException("Invalid static file response header specified: ''{0}''.  Must be in the format: ''Header-Name: header-value''", header);
1612         staticFileResponseHeader(h[0], h[1]);
1613      }
1614      return this;
1615   }
1616
1617   /**
1618    * Configuration property:  Static file response headers. 
1619    * 
1620    * <p>
1621    * Same as {@link #staticFileResponseHeaders(String...)} except header is broken into name/value pair.
1622    * 
1623    * <h5 class='section'>See Also:</h5>
1624    * <ul>
1625    *    <li class='jf'>{@link RestContext#REST_staticFileResponseHeaders}
1626    * </ul>
1627    * 
1628    * @param name The HTTP header name.
1629    * @param value The HTTP header value.
1630    * @return This object (for method chaining).
1631    */
1632   public RestContextBuilder staticFileResponseHeader(String name, String value) {
1633      return addTo(REST_staticFileResponseHeaders, name, value);
1634   }
1635
1636   /**
1637    * Configuration property:  Static file mappings. 
1638    * 
1639    * <p>
1640    * Used to define paths and locations of statically-served files such as images or HTML documents.
1641    * 
1642    * <h5 class='section'>See Also:</h5>
1643    * <ul>
1644    *    <li class='jf'>{@link RestContext#REST_staticFiles}
1645    * </ul>
1646    * 
1647    * @param values The values to append to this setting.
1648    * @return This object (for method chaining).
1649    */
1650   public RestContextBuilder staticFiles(StaticFileMapping...values) {
1651      return addTo(REST_staticFiles, values);
1652   }
1653
1654   /**
1655    * Configuration property:  Static file mappings. 
1656    * 
1657    * <p>
1658    * Same as {@link #staticFiles(StaticFileMapping...)} except input is in the form of a mapping string.
1659    * 
1660    * <p>
1661    * Mapping string must be one of these formats:
1662    * <ul>
1663    *    <li><js>"path:location"</js> (e.g. <js>"foodocs:docs/foo"</js>)
1664    *    <li><js>"path:location:headers-json"</js> (e.g. <js>"foodocs:docs/foo:{'Cache-Control':'max-age=86400, public'}"</js>)
1665    * </ul>
1666    * 
1667    * <h5 class='section'>See Also:</h5>
1668    * <ul>
1669    *    <li class='jf'>{@link RestContext#REST_staticFiles}
1670    * </ul>
1671    * 
1672    * @param mappingString The static file mapping string.
1673    * @return This object (for method chaining).
1674    */
1675   public RestContextBuilder staticFiles(String mappingString) {
1676      return staticFiles(new StaticFileMapping(resourceClass, mappingString));
1677   }
1678
1679   /**
1680    * Configuration property:  Static file mappings. 
1681    * 
1682    * <p>
1683    * Same as {@link #staticFiles(String)} except overrides the base class for retrieving the resource.
1684    * 
1685    * <p>
1686    * Mapping string must be one of these formats:
1687    * <ul>
1688    *    <li><js>"path:location"</js> (e.g. <js>"foodocs:docs/foo"</js>)
1689    *    <li><js>"path:location:headers-json"</js> (e.g. <js>"foodocs:docs/foo:{'Cache-Control':'max-age=86400, public'}"</js>)
1690    * </ul>
1691    * 
1692    * <h5 class='section'>See Also:</h5>
1693    * <ul>
1694    *    <li class='jf'>{@link RestContext#REST_staticFiles}
1695    * </ul>
1696    * 
1697    * @param baseClass 
1698    *    Overrides the default class to use for retrieving the classpath resource. 
1699    *    <br>If <jk>null<jk>, uses the REST resource class.
1700    * @param mappingString The static file mapping string.
1701    * @return This object (for method chaining).
1702    */
1703   public RestContextBuilder staticFiles(Class<?> baseClass, String mappingString) {
1704      return staticFiles(new StaticFileMapping(baseClass, mappingString));
1705   }
1706   
1707   /**
1708    * Configuration property:  Static file mappings. 
1709    * 
1710    * <p>
1711    * Same as {@link #staticFiles(String)} except path and location are already split values.
1712    * 
1713    * <h5 class='section'>See Also:</h5>
1714    * <ul>
1715    *    <li class='jf'>{@link RestContext#REST_staticFiles}
1716    * </ul>
1717    * 
1718    * @param path 
1719    *    The mapped URI path.
1720    *    <br>Leading and trailing slashes are trimmed.
1721    * @param location 
1722    *    The location relative to the resource class.
1723    *    <br>Leading and trailing slashes are trimmed.
1724    * @return This object (for method chaining).
1725    */
1726   public RestContextBuilder staticFiles(String path, String location) {
1727      return staticFiles(new StaticFileMapping(null, path, location, null));
1728   }
1729
1730   /**
1731    * Configuration property:  Static file mappings. 
1732    * 
1733    * <p>
1734    * Same as {@link #staticFiles(String,String)} except overrides the base class for retrieving the resource.
1735    * 
1736    * <h5 class='section'>See Also:</h5>
1737    * <ul>
1738    *    <li class='jf'>{@link RestContext#REST_staticFiles}
1739    * </ul>
1740    * 
1741    * @param baseClass 
1742    *    Overrides the default class to use for retrieving the classpath resource. 
1743    *    <br>If <jk>null<jk>, uses the REST resource class.
1744    * @param path 
1745    *    The mapped URI path.
1746    *    <br>Leading and trailing slashes are trimmed.
1747    * @param location 
1748    *    The location relative to the resource class.
1749    *    <br>Leading and trailing slashes are trimmed.
1750    * @return This object (for method chaining).
1751    */
1752   public RestContextBuilder staticFiles(Class<?> baseClass, String path, String location) {
1753      return staticFiles(new StaticFileMapping(baseClass, path, location, null));
1754   }
1755
1756   /**
1757    * Configuration property:  Supported accept media types.
1758    * 
1759    * <p>
1760    * Overrides the media types inferred from the serializers that identify what media types can be produced by the resource.
1761    * 
1762    * <h5 class='section'>See Also:</h5>
1763    * <ul>
1764    *    <li class='jf'>{@link RestContext#REST_produces}
1765    * </ul>
1766    * 
1767    * @param append
1768    *    If <jk>true</jk>, append to the existing list, otherwise overwrite the previous value. 
1769    * @param values The values to add to this setting.
1770    * @return This object (for method chaining).
1771    */
1772   public RestContextBuilder produces(boolean append, String...values) {
1773      return set(append, REST_produces, values);
1774   }
1775
1776   /**
1777    * Configuration property:  Supported accept media types.
1778    * 
1779    * <p>
1780    * Same as {@link #produces(boolean, String...)} except input is {@link MediaType} instances.
1781    * 
1782    * <h5 class='section'>See Also:</h5>
1783    * <ul>
1784    *    <li class='jf'>{@link RestContext#REST_produces}
1785    * </ul>
1786    * 
1787    * @param append
1788    *    If <jk>true</jk>, append to the existing list, otherwise overwrite the previous value. 
1789    * @param values The values to add to this setting.
1790    * @return This object (for method chaining).
1791    */
1792   public RestContextBuilder produces(boolean append, MediaType...values) {
1793      return set(append, REST_produces, values);
1794   }
1795
1796   /**
1797    * Configuration property:  Supported content media types.
1798    * 
1799    * <p>
1800    * Overrides the media types inferred from the parsers that identify what media types can be consumed by the resource.
1801    * 
1802    * <h5 class='section'>See Also:</h5>
1803    * <ul>
1804    *    <li class='jf'>{@link RestContext#REST_consumes}
1805    * </ul>
1806    * 
1807    * @param append
1808    *    If <jk>true</jk>, append to the existing list, otherwise overwrite the previous value. 
1809    * @param values The values to add to this setting.
1810    * @return This object (for method chaining).
1811    */
1812   public RestContextBuilder consumes(boolean append, String...values) {
1813      return set(append, REST_consumes, values);
1814   }
1815
1816   /**
1817    * Configuration property:  Supported content media types.
1818    * 
1819    * <p>
1820    * Same as {@link #consumes(boolean, String...)} except input is {@link MediaType} instances.
1821    * 
1822    * <h5 class='section'>See Also:</h5>
1823    * <ul>
1824    *    <li class='jf'>{@link RestContext#REST_consumes}
1825    * </ul>
1826    * 
1827    * @param append
1828    *    If <jk>true</jk>, append to the existing list, otherwise overwrite the previous value. 
1829    * @param values The values to add to this setting.
1830    * @return This object (for method chaining).
1831    */
1832   public RestContextBuilder consumes(boolean append, MediaType...values) {
1833      return set(append, REST_consumes, values);
1834   }
1835
1836   /**
1837    * Configuration property:  Use classpath resource caching. 
1838    * 
1839    * <p>
1840    * When enabled, resources retrieved via {@link RestContext#getClasspathResource(String, Locale)} (and related 
1841    * methods) will be cached in memory to speed subsequent lookups.
1842    * 
1843    * <h5 class='section'>See Also:</h5>
1844    * <ul>
1845    *    <li class='jf'>{@link RestContext#REST_useClasspathResourceCaching}
1846    * </ul>
1847    * 
1848    * @param value 
1849    *    The new value for this setting.
1850    *    <br>The default is <jk>true</jk>.
1851    * @return This object (for method chaining).
1852    */
1853   public RestContextBuilder useClasspathResourceCaching(boolean value) {
1854      return set(REST_useClasspathResourceCaching, value);
1855   }
1856
1857   /**
1858    * Configuration property:  Use stack trace hashes.
1859    * 
1860    * <p>
1861    * When enabled, the number of times an exception has occurred will be determined based on stack trace hashsums,
1862    * made available through the {@link RestException#getOccurrence()} method.
1863    * 
1864    * <h5 class='section'>See Also:</h5>
1865    * <ul>
1866    *    <li class='jf'>{@link RestContext#REST_useStackTraceHashes}
1867    * </ul>
1868    * 
1869    * @param value 
1870    *    The new value for this setting.
1871    *    <br>The default is <jk>true</jk>.
1872    * @return This object (for method chaining).
1873    */
1874   public RestContextBuilder useStackTraceHashes(boolean value) {
1875      return set(REST_useStackTraceHashes, value);
1876   }
1877
1878   /**
1879    * Configuration property:  HTML Widgets. 
1880    * 
1881    * <p>
1882    * Defines widgets that can be used in conjunction with string variables of the form <js>"$W{name}"</js>to quickly
1883    * generate arbitrary replacement text.
1884    * 
1885    * <h5 class='section'>See Also:</h5>
1886    * <ul>
1887    *    <li class='jf'>{@link RestContext#REST_widgets}
1888    * </ul>
1889    * 
1890    * @param values The values to add to this setting.
1891    * @return This object (for method chaining).
1892    */
1893   @SuppressWarnings("unchecked")
1894   public RestContextBuilder widgets(Class<? extends Widget>...values) {
1895      return addTo(REST_widgets, values);
1896   }
1897   
1898   /**
1899    * Configuration property:  HTML Widgets. 
1900    * 
1901    * <p>
1902    * Same as {@link #widgets(Class...)} except input is pre-constructed instances.
1903    * 
1904    * <h5 class='section'>See Also:</h5>
1905    * <ul>
1906    *    <li class='jf'>{@link RestContext#REST_widgets}
1907    * </ul>
1908    * 
1909    * @param values The values to add to this setting.
1910    * @return This object (for method chaining).
1911    */
1912   public RestContextBuilder widgets(Widget...values) {
1913      return addTo(REST_widgets, values);
1914   }
1915
1916   /**
1917    * Configuration property:  HTML Widgets. 
1918    * 
1919    * <p>
1920    * Same as {@link #widgets(Widget...)} except allows you to overwrite the previous value.
1921    * 
1922    * <h5 class='section'>See Also:</h5>
1923    * <ul>
1924    *    <li class='jf'>{@link RestContext#REST_widgets}
1925    * </ul>
1926    * 
1927    * @param append 
1928    *    If <jk>true</jk>, appends to the existing list of widgets.
1929    *    <br>Otherwise, replaces the previous list.
1930    * @param values The values to add to this setting.
1931    * @return This object (for method chaining).
1932    */
1933   public RestContextBuilder widgets(boolean append, Widget...values) {
1934      return set(append, REST_widgets, values);
1935   }
1936
1937   @Override /* BeanContextBuilder */
1938   public RestContextBuilder beansRequireDefaultConstructor(boolean value) {
1939      super.beansRequireDefaultConstructor(value);
1940      return this;
1941   }
1942
1943   @Override /* BeanContextBuilder */
1944   public RestContextBuilder beansRequireDefaultConstructor() {
1945      super.beansRequireDefaultConstructor();
1946      return this;
1947   }
1948
1949   @Override /* BeanContextBuilder */
1950   public RestContextBuilder beansRequireSerializable(boolean value) {
1951      super.beansRequireSerializable(value);
1952      return this;
1953   }
1954
1955   @Override /* BeanContextBuilder */
1956   public RestContextBuilder beansRequireSerializable() {
1957      super.beansRequireSerializable();
1958      return this;
1959   }
1960
1961   @Override /* BeanContextBuilder */
1962   public RestContextBuilder beansRequireSettersForGetters(boolean value) {
1963      super.beansRequireSettersForGetters(value);
1964      return this;
1965   }
1966
1967   @Override /* BeanContextBuilder */
1968   public RestContextBuilder beansRequireSettersForGetters() {
1969      super.beansRequireSettersForGetters();
1970      return this;
1971   }
1972
1973   @Override /* BeanContextBuilder */
1974   public RestContextBuilder beansRequireSomeProperties(boolean value) {
1975      super.beansRequireSomeProperties(value);
1976      return this;
1977   }
1978
1979   @Override /* BeanContextBuilder */
1980   public RestContextBuilder beanMapPutReturnsOldValue(boolean value) {
1981      super.beanMapPutReturnsOldValue(value);
1982      return this;
1983   }
1984
1985   @Override /* BeanContextBuilder */
1986   public RestContextBuilder beanMapPutReturnsOldValue() {
1987      super.beanMapPutReturnsOldValue();
1988      return this;
1989   }
1990
1991   @Override /* BeanContextBuilder */
1992   public RestContextBuilder beanConstructorVisibility(Visibility value) {
1993      super.beanConstructorVisibility(value);
1994      return this;
1995   }
1996
1997   @Override /* BeanContextBuilder */
1998   public RestContextBuilder beanClassVisibility(Visibility value) {
1999      super.beanClassVisibility(value);
2000      return this;
2001   }
2002
2003   @Override /* BeanContextBuilder */
2004   public RestContextBuilder beanFieldVisibility(Visibility value) {
2005      super.beanFieldVisibility(value);
2006      return this;
2007   }
2008
2009   @Override /* BeanContextBuilder */
2010   public RestContextBuilder beanMethodVisibility(Visibility value) {
2011      super.beanMethodVisibility(value);
2012      return this;
2013   }
2014
2015   @Override /* BeanContextBuilder */
2016   public RestContextBuilder useJavaBeanIntrospector(boolean value) {
2017      super.useJavaBeanIntrospector(value);
2018      return this;
2019   }
2020
2021   @Override /* BeanContextBuilder */
2022   public RestContextBuilder useJavaBeanIntrospector() {
2023      super.useJavaBeanIntrospector();
2024      return this;
2025   }
2026
2027   @Override /* BeanContextBuilder */
2028   public RestContextBuilder useInterfaceProxies(boolean value) {
2029      super.useInterfaceProxies(value);
2030      return this;
2031   }
2032
2033   @Override /* BeanContextBuilder */
2034   public RestContextBuilder ignoreUnknownBeanProperties(boolean value) {
2035      super.ignoreUnknownBeanProperties(value);
2036      return this;
2037   }
2038
2039   @Override /* BeanContextBuilder */
2040   public RestContextBuilder ignoreUnknownBeanProperties() {
2041      super.ignoreUnknownBeanProperties();
2042      return this;
2043   }
2044
2045   @Override /* BeanContextBuilder */
2046   public RestContextBuilder ignoreUnknownNullBeanProperties(boolean value) {
2047      super.ignoreUnknownNullBeanProperties(value);
2048      return this;
2049   }
2050
2051   @Override /* BeanContextBuilder */
2052   public RestContextBuilder ignorePropertiesWithoutSetters(boolean value) {
2053      super.ignorePropertiesWithoutSetters(value);
2054      return this;
2055   }
2056
2057   @Override /* BeanContextBuilder */
2058   public RestContextBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
2059      super.ignoreInvocationExceptionsOnGetters(value);
2060      return this;
2061   }
2062
2063   @Override /* BeanContextBuilder */
2064   public RestContextBuilder ignoreInvocationExceptionsOnGetters() {
2065      super.ignoreInvocationExceptionsOnGetters();
2066      return this;
2067   }
2068
2069   @Override /* BeanContextBuilder */
2070   public RestContextBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
2071      super.ignoreInvocationExceptionsOnSetters(value);
2072      return this;
2073   }
2074
2075   @Override /* BeanContextBuilder */
2076   public RestContextBuilder ignoreInvocationExceptionsOnSetters() {
2077      super.ignoreInvocationExceptionsOnSetters();
2078      return this;
2079   }
2080
2081   @Override /* BeanContextBuilder */
2082   public RestContextBuilder sortProperties(boolean value) {
2083      super.sortProperties(value);
2084      return this;
2085   }
2086
2087   @Override /* BeanContextBuilder */
2088   public RestContextBuilder sortProperties() {
2089      super.sortProperties();
2090      return this;
2091   }
2092
2093   @Override /* BeanContextBuilder */
2094   public RestContextBuilder notBeanPackages(Object...values) {
2095      super.notBeanPackages(values);
2096      return this;
2097   }
2098
2099   @Override /* BeanContextBuilder */
2100   public RestContextBuilder notBeanPackages(String...values) {
2101      super.notBeanPackages(values);
2102      return this;
2103   }
2104
2105   @Override /* BeanContextBuilder */
2106   public RestContextBuilder notBeanPackages(boolean append, Object...values) {
2107      super.notBeanPackages(append, values);
2108      return this;
2109   }
2110
2111   @Override /* BeanContextBuilder */
2112   public RestContextBuilder notBeanPackagesRemove(Object...values) {
2113      super.notBeanPackagesRemove(values);
2114      return this;
2115   }
2116
2117   @Override /* BeanContextBuilder */
2118   public RestContextBuilder notBeanClasses(Object...values) {
2119      super.notBeanClasses(values);
2120      return this;
2121   }
2122
2123   @Override /* BeanContextBuilder */
2124   public RestContextBuilder notBeanClasses(Class<?>...values) {
2125      super.notBeanClasses(values);
2126      return this;
2127   }
2128
2129   @Override /* BeanContextBuilder */
2130   public RestContextBuilder notBeanClasses(boolean append, Object...values) {
2131      super.notBeanClasses(append, values);
2132      return this;
2133   }
2134
2135   @Override /* BeanContextBuilder */
2136   public RestContextBuilder notBeanClassesRemove(Object...values) {
2137      super.notBeanClassesRemove(values);
2138      return this;
2139   }
2140
2141   @Override /* BeanContextBuilder */
2142   public RestContextBuilder beanFilters(Object...values) {
2143      super.beanFilters(values);
2144      return this;
2145   }
2146
2147   @Override /* BeanContextBuilder */
2148   public RestContextBuilder beanFilters(Class<?>...values) {
2149      super.beanFilters(values);
2150      return this;
2151   }
2152
2153   @Override /* BeanContextBuilder */
2154   public RestContextBuilder beanFilters(boolean append, Object...values) {
2155      super.beanFilters(append, values);
2156      return this;
2157   }
2158
2159   @Override /* BeanContextBuilder */
2160   public RestContextBuilder beanFiltersRemove(Object...values) {
2161      super.beanFiltersRemove(values);
2162      return this;
2163   }
2164
2165   @Override /* BeanContextBuilder */
2166   public RestContextBuilder pojoSwaps(Object...values) {
2167      super.pojoSwaps(values);
2168      return this;
2169   }
2170
2171   @Override /* BeanContextBuilder */
2172   public RestContextBuilder pojoSwaps(Class<?>...values) {
2173      super.pojoSwaps(values);
2174      return this;
2175   }
2176
2177   @Override /* BeanContextBuilder */
2178   public RestContextBuilder pojoSwaps(boolean append, Object...values) {
2179      super.pojoSwaps(append, values);
2180      return this;
2181   }
2182
2183   @Override /* BeanContextBuilder */
2184   public RestContextBuilder pojoSwapsRemove(Object...values) {
2185      super.pojoSwapsRemove(values);
2186      return this;
2187   }
2188
2189   @Override /* BeanContextBuilder */
2190   public RestContextBuilder implClasses(Map<String,Class<?>> values) {
2191      super.implClasses(values);
2192      return this;
2193   }
2194
2195   @Override /* BeanContextBuilder */
2196   public <T> RestContextBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
2197      super.implClass(interfaceClass, implClass);
2198      return this;
2199   }
2200
2201   @Override /* BeanContextBuilder */
2202   public RestContextBuilder beanDictionary(Object...values) {
2203      super.beanDictionary(values);
2204      return this;
2205   }
2206
2207   @Override /* BeanContextBuilder */
2208   public RestContextBuilder beanDictionary(Class<?>...values) {
2209      super.beanDictionary(values);
2210      return this;
2211   }
2212
2213   @Override /* BeanContextBuilder */
2214   public RestContextBuilder beanDictionary(boolean append, Object...values) {
2215      super.beanDictionary(append, values);
2216      return this;
2217   }
2218
2219   @Override /* BeanContextBuilder */
2220   public RestContextBuilder beanDictionaryRemove(Object...values) {
2221      super.beanDictionaryRemove(values);
2222      return this;
2223   }
2224
2225   @Override /* BeanContextBuilder */
2226   public RestContextBuilder beanTypePropertyName(String value) {
2227      super.beanTypePropertyName(value);
2228      return this;
2229   }
2230
2231   @Override /* BeanContextBuilder */
2232   public RestContextBuilder locale(Locale value) {
2233      super.locale(value);
2234      return this;
2235   }
2236
2237   @Override /* BeanContextBuilder */
2238   public RestContextBuilder timeZone(TimeZone value) {
2239      super.timeZone(value);
2240      return this;
2241   }
2242
2243   @Override /* BeanContextBuilder */
2244   public RestContextBuilder mediaType(MediaType value) {
2245      super.mediaType(value);
2246      return this;
2247   }
2248
2249   @Override /* BeanContextBuilder */
2250   public RestContextBuilder debug() {
2251      super.debug();
2252      return this;
2253   }
2254
2255   @Override /* ContextBuilder */
2256   public RestContextBuilder set(String name, Object value) {
2257      super.set(name, value);
2258      this.properties.put(name, value);
2259      return this;
2260   }
2261
2262   @Override /* ContextBuilder */
2263   public RestContextBuilder set(boolean append, String name, Object value) {
2264      super.set(append, name, value);
2265      return this;
2266   }
2267
2268   @Override /* ContextBuilder */
2269   public RestContextBuilder set(Map<String,Object> properties) {
2270      super.set(properties);
2271      this.properties.clear();
2272      this.properties.putAll(properties);
2273      return this;
2274   }
2275
2276   @Override /* ContextBuilder */
2277   public RestContextBuilder add(Map<String,Object> properties) {
2278      super.add(properties);
2279      return this;
2280   }
2281
2282   @Override /* ContextBuilder */
2283   public RestContextBuilder addTo(String name, Object value) {
2284      super.addTo(name, value);
2285      return this;
2286   }
2287
2288   @Override /* ContextBuilder */
2289   public RestContextBuilder addTo(String name, String key, Object value) {
2290      super.addTo(name, key, value);
2291      return this;
2292   }
2293
2294   @Override /* ContextBuilder */
2295   public RestContextBuilder removeFrom(String name, Object value) {
2296      super.removeFrom(name, value);
2297      return this;
2298   }
2299
2300   @Override /* ContextBuilder */
2301   public RestContextBuilder apply(PropertyStore copyFrom) {
2302      super.apply(copyFrom);
2303      return this;
2304   }
2305   
2306
2307   //----------------------------------------------------------------------------------------------------
2308   // Methods inherited from ServletConfig
2309   //----------------------------------------------------------------------------------------------------
2310
2311   @Override /* ServletConfig */
2312   public String getInitParameter(String name) {
2313      return inner.getInitParameter(name);
2314   }
2315
2316   @Override /* ServletConfig */
2317   public Enumeration<String> getInitParameterNames() {
2318      return inner.getInitParameterNames();
2319   }
2320
2321   @Override /* ServletConfig */
2322   public ServletContext getServletContext() {
2323      return inner.getServletContext();
2324   }
2325
2326   @Override /* ServletConfig */
2327   public String getServletName() {
2328      return inner.getServletName();
2329   }
2330
2331   @Override /* BeanContextBuilder */
2332   public BeanContext build() {
2333      // We don't actually generate bean context objects from this class yet.
2334      return null;
2335   }
2336}