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