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