Class RestOpContext.Builder
- Enclosing class:
- RestOpContext
- 
Method SummaryModifier and TypeMethodDescriptionannotations(Annotation... values) Defines annotations to apply to specific classes and methods.apply(AnnotationWorkList work) Applies a set of applied to this builder.applyAnnotations(Class<?>... from) Same asContext.Builder.applyAnnotations(Object...)but explicitly specifies a class varargs to avoid compilation warnings.applyAnnotations(Object... from) Applies any of the various@XConfig annotations on the specified classes or methods to this context.Returns the bean context sub-builder.Returns access to the bean store being used by this builder.Adds a bean to the bean store of this operation.Adds a bean to the bean store of this operation.protected RestOpContext.BuilderSpecifies aBeanStoreto use when resolving constructor arguments.build()Build the object.Specifies a cache to use for hashkey-based caching.clientVersion(String value) Client version pattern matcher.Supported content media types.Returns the response converter list sub-builder.final RestOpContext.Builderconverters(Class<? extends RestConverter>... value) Adds one or more converters to use to convert response objects for this operation.converters(RestConverter... value) Adds one or more converters to this operation.copy()Copy creator.protected BeanContext.BuildercreateBeanContext(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the bean context sub-builder.protected RestConverterList.BuildercreateConverters(BeanStore beanStore, Supplier<?> resource) Instantiates the response converter list sub-builder.protected NamedAttributeMapcreateDefaultRequestAttributes(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default request attributes sub-builder.protected PartListcreateDefaultRequestFormData(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default request form data.protected HeaderListcreateDefaultRequestHeaders(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default request headers.protected PartListcreateDefaultRequestQueryData(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default request query data.protected HeaderListcreateDefaultResponseHeaders(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default response headers.protected EncoderSet.BuildercreateEncoders(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the encoder group sub-builder.protected RestGuardList.BuildercreateGuards(BeanStore beanStore, Supplier<?> resource) Instantiates the guard list sub-builder.protected JsonSchemaGenerator.BuildercreateJsonSchemaGenerator(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the JSON schema generator sub-builder.protected RestMatcherList.BuildercreateMatchers(BeanStore beanStore, Supplier<?> resource) Instantiates the matcher list sub-builder.protected ParserSet.BuildercreateParsers(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the parser group sub-builder.protected HttpPartParser.CreatorcreatePartParser(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the part parser sub-builder.protected HttpPartSerializer.CreatorcreatePartSerializer(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the part serializer sub-builder.protected SerializerSet.BuildercreateSerializers(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the serializer group sub-builder.debug()Context configuration property: Debug mode.debug(boolean value) Same asContext.Builder.debug()but allows you to explicitly specify the value.debug(Enablement value) Debug mode.defaultCharset(Charset value) Default character encoding.Returns the default classes list.Returns the default request attributes sub-builder.defaultRequestAttributes(NamedAttribute... value) Adds one or more default request attributes to this operation.Returns the default request form data.defaultRequestFormData(NameValuePair... value) Adds one or more default request form data to this operation.Returns the default request headers.defaultRequestHeaders(Header... value) Adds one or more default request headers to this operation.Returns the default request query data.defaultRequestQueryData(NameValuePair... value) Adds one or more default request query data to this operation.Returns the default response headers.defaultResponseHeaders(Header... value) Adds one or more default response headers to this operation.dotAll()When enabled, append"/*" to path patterns if not already present.encoders()Returns the encoder group sub-builder.final RestOpContext.BuilderAdds one or more encoders to this operation.Adds one or more encoders to this operation.protected Class<? extends RestOpContext>Specifies the default implementation class if not specified viatype(Class).protected UrlPathMatcherListInstantiates the path matchers for this method.guards()Returns the guard list sub-builder.final RestOpContext.BuilderAdds one or more guards to this operation.Adds one or more guards to this operation.httpMethod(String value) HTTP method name.Specifies a pre-instantiated bean for theContext.Builder.build()method to return.Returns the JSON schema generator sub-builder.jsonSchemaGenerator(Class<? extends JsonSchemaGenerator> value) Specifies the JSON schema generator for this operation.Specifies the JSON schema generator for this operation.matchers()Returns the matcher list sub-builder.final RestOpContext.Buildermatchers(Class<? extends RestMatcher>... value) Adds one or more matchers to this operation.matchers(RestMatcher... value) Adds one or more matchers to this operation.The maximum allowed input size (in bytes) on HTTP requests.parsers()Returns the parser group sub-builder.final RestOpContext.BuilderAdds one or more parsers to this operation.Adds one or more parsers to this operation.Returns the part parser sub-builder.partParser(Class<? extends HttpPartParser> value) Specifies the part parser to use for parsing HTTP parts for this operation.partParser(HttpPartParser value) Specifies the part parser to use for parsing HTTP parts for this operation.Returns the part serializer sub-builder.partSerializer(Class<? extends HttpPartSerializer> value) Specifies the part serializer to use for serializing HTTP parts for this operation.partSerializer(HttpPartSerializer value) Specifies the part serializer to use for serializing HTTP parts for this operation.Resource method paths.protected voidHandles processing of any annotations on parameters.Supported accept media types.Supplier<?>resource()Returns the REST servlet/bean instance that this context is defined against.Role guard.rolesDeclared(String... values) Declared roles.Returns the serializer group sub-builder.final RestOpContext.Builderserializers(Class<? extends Serializer>... value) Adds one or more serializers to this operation.serializers(Serializer... value) Adds one or more serializers to this operation.Associates a context class with this builder.Methods inherited from class org.apache.juneau.Context.Builderannotations, apply, build, canApply, getApplied, getType, hashKey, isDebug, registerBuilders
- 
Method Details- 
copyDescription copied from class:Context.BuilderCopy creator.- Specified by:
- copyin class- Context.Builder
- Returns:
- A new mutable copy of this builder.
 
- 
buildDescription copied from class:Context.BuilderBuild the object.- Overrides:
- buildin class- Context.Builder
- Returns:
- The built object.
 
- 
getDefaultImplClassSpecifies the default implementation class if not specified viatype(Class).- Returns:
- The default implementation class if not specified via type(Class).
 
- 
resourceReturns the REST servlet/bean instance that this context is defined against.- Returns:
- The REST servlet/bean instance that this context is defined against.
 
- 
defaultClassesReturns the default classes list.This defines the implementation classes for a variety of bean types. Default classes are inherited from the parent REST object. Typically used on the top-level RestContext.Builderto affect class types for that REST object and all children.Modifying the default class list on this builder does not affect the default class list on the parent builder, but changes made here are inherited by child builders. - Returns:
- The default classes list for this builder.
 
- 
beanStoreReturns access to the bean store being used by this builder.Can be used to add more beans to the bean store. - Returns:
- The bean store being used by this builder.
 
- 
beanStoreSpecifies aBeanStoreto use when resolving constructor arguments.- Parameters:
- beanStore- The bean store to use for resolving constructor arguments.
- Returns:
- This object.
 
- 
beanStoreAdds a bean to the bean store of this operation.Equivalent to calling: builder .beanStore().add(beanType ,bean );- Type Parameters:
- T- The class to associate this bean with.
- Parameters:
- beanType- The class to associate this bean with.
- bean- The bean. Can be- null .
- Returns:
- This object.
 
- 
beanStoreAdds a bean to the bean store of this operation.Equivalent to calling: builder .beanStore().add(beanType ,bean ,name );- Type Parameters:
- T- The class to associate this bean with.
- Parameters:
- beanType- The class to associate this bean with.
- bean- The bean. Can be- null .
- name- The bean name if this is a named bean. Can be- null .
- Returns:
- This object.
 
- 
beanContextReturns the bean context sub-builder.- Returns:
- The bean context sub-builder.
 
- 
createBeanContextprotected BeanContext.Builder createBeanContext(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the bean context sub-builder.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new bean context sub-builder.
 
- 
encodersReturns the encoder group sub-builder.- Returns:
- The encoder group sub-builder.
 
- 
encodersAdds one or more encoders to this operation.Equivalent to calling: builder .encoders().add(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
encodersAdds one or more encoders to this operation.Equivalent to calling: builder .encoders().add(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createEncodersprotected EncoderSet.Builder createEncoders(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the encoder group sub-builder.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new encoder group sub-builder.
 
- 
serializersReturns the serializer group sub-builder.- Returns:
- The serializer group sub-builder.
 
- 
serializersAdds one or more serializers to this operation.Equivalent to calling: builder .serializers().add(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
serializersAdds one or more serializers to this operation.Equivalent to calling: builder .serializers().add(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createSerializersprotected SerializerSet.Builder createSerializers(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the serializer group sub-builder.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new serializer group sub-builder.
 
- 
parsersReturns the parser group sub-builder.- Returns:
- The parser group sub-builder.
 
- 
parsersAdds one or more parsers to this operation.Equivalent to calling: builder .parsers().add(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
parsersAdds one or more parsers to this operation.Equivalent to calling: builder .parsers().add(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createParsersprotected ParserSet.Builder createParsers(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the parser group sub-builder.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new parser group sub-builder.
 
- 
partSerializerReturns the part serializer sub-builder.- Returns:
- The part serializer sub-builder.
 
- 
partSerializerSpecifies the part serializer to use for serializing HTTP parts for this operation.Equivalent to calling: builder .partSerializer().type(value );- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
partSerializerSpecifies the part serializer to use for serializing HTTP parts for this operation.Equivalent to calling: builder .partSerializer().impl(value );- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
createPartSerializerprotected HttpPartSerializer.Creator createPartSerializer(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the part serializer sub-builder.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new part serializer sub-builder.
 
- 
partParserReturns the part parser sub-builder.- Returns:
- The part parser sub-builder.
 
- 
partParserSpecifies the part parser to use for parsing HTTP parts for this operation.Equivalent to calling: builder .partParser().type(value );- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
partParserSpecifies the part parser to use for parsing HTTP parts for this operation.Equivalent to calling: builder .partParser().impl(value );- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
createPartParserprotected HttpPartParser.Creator createPartParser(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the part parser sub-builder.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new part parser sub-builder.
 
- 
jsonSchemaGeneratorReturns the JSON schema generator sub-builder.- Returns:
- The JSON schema generator sub-builder.
 
- 
jsonSchemaGeneratorSpecifies the JSON schema generator for this operation.Equivalent to calling: builder .jsonSchemaGenerator().type(value );- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
jsonSchemaGeneratorSpecifies the JSON schema generator for this operation.Equivalent to calling: builder .jsonSchemaGenerator().impl(value );- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
createJsonSchemaGeneratorprotected JsonSchemaGenerator.Builder createJsonSchemaGenerator(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the JSON schema generator sub-builder.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new JSON schema generator sub-builder.
 
- 
convertersReturns the response converter list sub-builder.- Returns:
- The response converter list sub-builder.
 
- 
convertersAdds one or more converters to use to convert response objects for this operation.Equivalent to calling: builder .converters().append(value );- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
convertersAdds one or more converters to this operation.Equivalent to calling: builder .converters().append(value );- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
createConvertersInstantiates the response converter list sub-builder.Associates one or more converterswith a resource class.
 These converters get called immediately after execution of the REST method in the same order specified in the annotation.
 The object passed into this converter is the object returned from the Java method or passed into theRestResponse.setContent(Object)method.Can be used for performing post-processing on the response object before serialization. When multiple converters are specified, they're executed in the order they're specified in the annotation (e.g. first the results will be traversed, then the resulting node will be searched/sorted). Example:// Our converter. public class MyConverterimplements RestConverter {@Override public Object convert(RestRequestreq , Objectobject ) {// Do something with object and return another object. // Or just return the same object for a no-op. } }// Option #1 - Registered via annotation resolving to a config file setting with default value. @Rest (converters={MyConverter.class })public class MyResource {// Option #2 - Registered via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .converters(MyConverter.class );// Pass in an instance instead. builder .converters(new MyConverter()); }// Option #3 - Registered via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .converters(MyConverter.class ); } }Notes:- 
      When defined as a class, the implementation must have one of the following constructors:
      - public T(BeanContext)
- public T()
- public static T- create (RestContext)
- public static T- create ()
 
- Inner classes of the REST resource class are allowed.
 See Also:- Traversable- Allows URL additional path info to address individual elements in a POJO tree.
- Queryable- Allows query/view/sort functions to be performed on POJOs.
- Introspectable- Allows Java public methods to be invoked on the returned POJOs.
- Rest.converters()
- Converters
 - Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new response converter list sub-builder.
 
- 
      When defined as a class, the implementation must have one of the following constructors:
      
- 
guardsReturns the guard list sub-builder.- Returns:
- The guard list sub-builder.
 
- 
guardsAdds one or more guards to this operation.Equivalent to calling: builder .guards().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
guardsAdds one or more guards to this operation.Equivalent to calling: builder .guards().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createGuardsInstantiates the guard list sub-builder.Instantiates based on the following logic: - Looks for guards set via any of the following:
- Looks for a static or non-static createGuards() method that returnsRestGuard[]- Method- The Java method this context belongs to.
- RestContext
- BeanStore
- Any juneau-rest-server-springboot Basics.
 
- Resolves it via the bean store registered in this context.
- Instantiates a RestGuard[0] .
 - Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new guard list sub-builder.
 
- 
matchersReturns the matcher list sub-builder.- Returns:
- The matcher list sub-builder.
 
- 
matchersAdds one or more matchers to this operation.Equivalent to calling: builder .matchers().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
matchersAdds one or more matchers to this operation.Equivalent to calling: builder .matchers().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createMatchersInstantiates the matcher list sub-builder.Associates one or more RestMatcherswith the specified method.If multiple matchers are specified, ONE matcher must pass. 
 Note that this is different than guards where ALL guards needs to pass.Notes:- 
      When defined as a class, the implementation must have one of the following constructors:
      - public T(RestContext)
- public T()
- public static T- create (RestContext)
- public static T- create ()
 
- Inner classes of the REST resource class are allowed.
 See Also:Instantiates based on the following logic: - Looks for matchers set via any of the following:
- Looks for a static or non-static createMatchers() method that returnsRestMatcher[]- Method- The Java method this context belongs to.
- RestContext
- BeanStore
- Any juneau-rest-server-springboot Basics.
 
- Resolves it via the bean store registered in this context.
- Instantiates a RestMatcher[0] .
 - Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new matcher list sub-builder.
 
- 
      When defined as a class, the implementation must have one of the following constructors:
      
- 
getPathMatchersInstantiates the path matchers for this method.- Returns:
- The path matchers for this method.
 
- 
dotAllWhen enabled, append"/*" to path patterns if not already present.- Returns:
- This object.
 
- 
defaultRequestHeadersReturns the default request headers.- Returns:
- The default request headers.
 
- 
defaultRequestHeadersAdds one or more default request headers to this operation.Equivalent to calling: builder .defaultRequestHeaders().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createDefaultRequestHeadersprotected HeaderList createDefaultRequestHeaders(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default request headers.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new default request headers sub-builder.
 
- 
defaultResponseHeadersReturns the default response headers.- Returns:
- The default response headers.
 
- 
defaultResponseHeadersAdds one or more default response headers to this operation.Equivalent to calling: builder .defaultResponseHeaders().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createDefaultResponseHeadersprotected HeaderList createDefaultResponseHeaders(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default response headers.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new default response headers sub-builder.
 
- 
defaultRequestAttributesReturns the default request attributes sub-builder.- Returns:
- The default request attributes sub-builder.
 
- 
defaultRequestAttributesAdds one or more default request attributes to this operation.Equivalent to calling: builder .defaultRequestAttributes().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createDefaultRequestAttributesprotected NamedAttributeMap createDefaultRequestAttributes(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default request attributes sub-builder.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new default request attributes sub-builder.
 
- 
defaultRequestQueryDataReturns the default request query data.- Returns:
- The default request query data.
 
- 
defaultRequestQueryDataAdds one or more default request query data to this operation.Equivalent to calling: builder .defaultRequestQueryData().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createDefaultRequestQueryDataprotected PartList createDefaultRequestQueryData(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default request query data.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new default request query data sub-builder.
 
- 
defaultRequestFormDataReturns the default request form data.- Returns:
- The default request form data.
 
- 
defaultRequestFormDataAdds one or more default request form data to this operation.Equivalent to calling: builder .defaultRequestFormData().append(value );- Parameters:
- value- The values to add.
- Returns:
- This object.
 
- 
createDefaultRequestFormDataprotected PartList createDefaultRequestFormData(BeanStore beanStore, RestContext.Builder parent, Supplier<?> resource) Instantiates the default request form data.- Parameters:
- beanStore- The factory used for creating beans and retrieving injected beans.
- parent- The builder for the REST resource class.
- resource- The REST servlet/bean instance that this context is defined against.
- Returns:
- A new default request form data sub-builder.
 
- 
processParameterAnnotations
- 
clientVersionClient version pattern matcher.Specifies whether this method can be called based on the client version. The client version is identified via the HTTP request header identified by @Rest(clientVersionHeader)which by default is"Client-Version" .This is a specialized kind of RestMatcherthat allows you to invoke different Java methods for the same method/path based on the client version.The format of the client version range is similar to that of OSGi versions. In the following example, the Java methods are mapped to the same HTTP method and URL "/foobar" .// Call this method if Client-Version is at least 2.0. // Note that this also matches 2.0.1. @RestGet (path="/foobar" , clientVersion="2.0" )public Object method1() {...}// Call this method if Client-Version is at least 1.1, but less than 2.0. @RestGet (path="/foobar" , clientVersion="[1.1,2.0)" )public Object method2() {...}// Call this method if Client-Version is less than 1.1. @RestGet (path="/foobar" , clientVersion="[0,1.1)" )public Object method3() {...}It's common to combine the client version with transforms that will convert new POJOs into older POJOs for backwards compatibility. // Call this method if Client-Version is at least 2.0. @RestGet (path="/foobar" , clientVersion="2.0" )public NewPojo newMethod() {...}// Call this method if Client-Version is at least 1.1, but less than 2.0. @RestGet (path="/foobar" , clientVersion="[1.1,2.0)" )@BeanConfig(swaps=NewToOldSwap. class )public NewPojo oldMethod() {return newMethod(); }Note that in the previous example, we're returning the exact same POJO, but using a transform to convert it into an older form. The old method could also just return back a completely different object. The range can be any of the following: - "[0,1.0)" = Less than 1.0. 1.0 and 1.0.0 does not match.
- "[0,1.0]" = Less than or equal to 1.0. Note that 1.0.1 will match.
- "1.0" = At least 1.0. 1.0 and 2.0 will match.
 See Also:- Parameters:
- value- The new value for this setting.
- Returns:
- This object.
 
- 
debugDebug mode.Enables the following: - HTTP request/response bodies are cached in memory for logging purposes.
 If not sppecified, the debug enablement is inherited from the class context. - Parameters:
- value- The new value for this setting.
- Returns:
- This object.
 
- 
defaultCharsetDefault character encoding.The default character encoding for the request and response if not specified on the request. This overrides the value defined on the RestContext.See Also:- Parameters:
- value- The new value for this setting.
 The default is the first value found:- System property "RestContext.defaultCharset" 
- Environment variable
"RESTCONTEXT_defaultCharset" "utf-8" 
- Environment variable
 
- System property 
- Returns:
- This object.
 
- 
httpMethodHTTP method name.Typically "GET" ,"PUT" ,"POST" ,"DELETE" , or"OPTIONS" .Method names are case-insensitive (always folded to upper-case). Note that you can use HttpMethodfor constant values.Besides the standard HTTP method names, the following can also be specified: - 
      "*" - Denotes any method.
 Use this if you want to capture any HTTP methods in a single Java method.
 The@Methodannotation and/orRestRequest.getMethod()method can be used to distinguish the actual HTTP method name.
- 
      "" - Auto-detect.
 The method name is determined based on the Java method name.
 For example, if the method isdoPost(...) , then the method name is automatically detected as"POST" .
 Otherwise, defaults to"GET" .
- 
      "RRPC" - Remote-proxy interface.
 This denotes a Java method that returns an object (usually an interface, often annotated with the@Remoteannotation) to be used as a remote proxy usingRestClient.getRemoteInterface(Class<T> interfaceClass, String url) .
 This allows you to construct client-side interface proxies using REST as a transport medium.
 Conceptually, this is simply a fancyPOST against the url"/{path}/{javaMethodName}" where the arguments are marshalled from the client to the server as an HTTP content containing an array of objects, passed to the method as arguments, and then the resulting object is marshalled back to the client.
- 
      Anything else
      - Overloaded non-HTTP-standard names that are passed in through a &method=methodName URL parameter.
 See Also:- Parameters:
- value- The new value for this setting.
- Returns:
- This object.
 
- 
      
- 
maxInputThe maximum allowed input size (in bytes) on HTTP requests.Useful for alleviating DoS attacks by throwing an exception when too much input is received instead of resulting in out-of-memory errors which could affect system stability. Example:// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (maxInput="$C{REST/maxInput,10M}" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .maxInput("10M" ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .maxInput("10M" ); }// Override at the method level. @RestPost (maxInput="10M" )public Object myMethod() {...} }Notes:- 
      String value that gets resolved to a long .
- 
      Can be suffixed with any of the following representing kilobytes, megabytes, and gigabytes:
      'K' ,'M' ,'G' .
- 
      A value of "-1" can be used to represent no limit.
 See Also:- Parameters:
- value- The new value for this setting.
 The default is the first value found:- System property "RestContext.maxInput" 
- Environment variable
"RESTCONTEXT_MAXINPUT" "100M" 
- Environment variable
 
 The default is- "100M" .
- System property 
- Returns:
- This object.
 
- 
      String value that gets resolved to a 
- 
pathResource method paths.Identifies the URL subpath relative to the servlet class. Notes:- This method is only applicable for Java methods.
- 
      Slashes are trimmed from the path ends.
      
 As a convention, you may want to start your path with'/' simple because it make it easier to read.
 - Parameters:
- values- The new values for this setting.
- Returns:
- This object.
 
- 
producesSupported accept media types.Overrides the media types inferred from the serializers that identify what media types can be produced by the resource. 
 An example where this might be useful if you have serializers registered that handle media types that you don't want exposed in the Swagger documentation.This affects the returned values from the following: - RestContext.getProduces()
- SwaggerProvider.getSwagger(RestContext,Locale)- Affects produces field.
 See Also:- Parameters:
- values- The values to add to this setting.
- Returns:
- This object.
 
- 
rolesDeclaredDeclared roles.A comma-delimited list of all possible user roles. Used in conjunction with roleGuard(String)is used with patterns.Example:@Rest ( rolesDeclared="ROLE_ADMIN,ROLE_READ_WRITE,ROLE_READ_ONLY,ROLE_SPECIAL" , roleGuard="ROLE_ADMIN || (ROLE_READ_WRITE && ROLE_SPECIAL)" )public class MyResourceextends BasicRestServlet { ... }See Also:- Parameters:
- values- The values to add to this setting.
- Returns:
- This object.
 
- 
roleGuardRole guard.An expression defining if a user with the specified roles are allowed to access methods on this class. Example:@Rest ( path="/foo" , roleGuard="ROLE_ADMIN || (ROLE_READ_WRITE && ROLE_SPECIAL)" )public class MyResourceextends BasicRestServlet { ... }Notes:- 
      Supports any of the following expression constructs:
      - "foo" - Single arguments.
- "foo,bar,baz" - Multiple OR'ed arguments.
- "foo | bar | bqz" - Multiple OR'ed arguments, pipe syntax.
- "foo || bar || bqz" - Multiple OR'ed arguments, Java-OR syntax.
- "fo*" - Patterns including- '*' and- '?' .
- "fo* & *oo" - Multiple AND'ed arguments, ampersand syntax.
- "fo* && *oo" - Multiple AND'ed arguments, Java-AND syntax.
- "fo* || (*oo || bar)" - Parenthesis.
 
- AND operations take precedence over OR operations (as expected).
- Whitespace is ignored.
- 
      null or empty expressions always match asfalse .
- 
      If patterns are used, you must specify the list of declared roles using Rest.rolesDeclared()orrolesDeclared(String...).
- 
      Supports SVL Variables
      (e.g. "$L{my.localized.variable}" ).
 - Parameters:
- value- The values to add to this setting.
- Returns:
- This object.
 
- 
      Supports any of the following expression constructs:
      
- 
consumesSupported content media types.Overrides the media types inferred from the parsers that identify what media types can be consumed by the resource. 
 An example where this might be useful if you have parsers registered that handle media types that you don't want exposed in the Swagger documentation.This affects the returned values from the following: See Also:- Parameters:
- values- The values to add to this setting.
- Returns:
- This object.
 
- 
annotationsDescription copied from class:Context.BuilderDefines annotations to apply to specific classes and methods.Allows you to dynamically apply Juneau annotations typically applied directly to classes and methods. Useful in cases where you want to use the functionality of the annotation on beans and bean properties but do not have access to the code to do so. As a rule, any Juneau annotation with an on() method can be used with this setting.The following example shows the equivalent methods for applying the @Beanannotation:// Class with explicit annotation. @Bean (properties="street,city,state" )public class A {...}// Class with annotation applied via @BeanConfig public class B {...}// Java REST method with @BeanConfig annotation. @RestGet (...)@Bean (on="B" , properties="street,city,state" )public void doFoo() {...}In general, the underlying framework uses this method when it finds dynamically applied annotations on config annotations. However, concrete implementations of annotations are also provided that can be passed directly into builder classes like so: // Create a concrete @Bean annotation. Bean annotation = BeanAnnotation.create (B.class ).properties("street,city,state" ).build();// Apply it to a serializer. WriterSerializerserializer = JsonSerializer.create ().annotations(annotation ).build();// Serialize a bean with the dynamically applied annotation. Stringjson =serializer .serialize(new B());The following is the list of annotations builders provided that can be constructed and passed into the builder class: - BeanAnnotation
- BeancAnnotation
- BeanIgnoreAnnotation
- BeanpAnnotation
- ExampleAnnotation
- NamePropertyAnnotation
- ParentPropertyAnnotation
- SwapAnnotation
- UriAnnotation
- CsvAnnotation
- HtmlAnnotation
- JsonAnnotation
- SchemaAnnotation
- MsgPackAnnotation
- OpenApiAnnotation
- PlainTextAnnotation
- SoapXmlAnnotation
- UonAnnotation
- UrlEncodingAnnotation
- XmlAnnotation
 The syntax for the on() pattern match parameter depends on whether it applies to a class, method, field, or constructor. The valid pattern matches are:- Classes:
      - Fully qualified:
            - "com.foo.MyClass" 
 
- Fully qualified inner class:
            - "com.foo.MyClass$Inner1$Inner2" 
 
- Simple:
            - "MyClass" 
 
- Simple inner:
            - "MyClass$Inner1$Inner2" 
- "Inner1$Inner2" 
- "Inner2" 
 
 
- Fully qualified:
            
- Methods:
      - Fully qualified with args:
            - "com.foo.MyClass.myMethod(String,int)" 
- "com.foo.MyClass.myMethod(java.lang.String,int)" 
- "com.foo.MyClass.myMethod()" 
 
- Fully qualified:
            - "com.foo.MyClass.myMethod" 
 
- Simple with args:
            - "MyClass.myMethod(String,int)" 
- "MyClass.myMethod(java.lang.String,int)" 
- "MyClass.myMethod()" 
 
- Simple:
            - "MyClass.myMethod" 
 
- Simple inner class:
            - "MyClass$Inner1$Inner2.myMethod" 
- "Inner1$Inner2.myMethod" 
- "Inner2.myMethod" 
 
 
- Fully qualified with args:
            
- Fields:
      - Fully qualified:
            - "com.foo.MyClass.myField" 
 
- Simple:
            - "MyClass.myField" 
 
- Simple inner class:
            - "MyClass$Inner1$Inner2.myField" 
- "Inner1$Inner2.myField" 
- "Inner2.myField" 
 
 
- Fully qualified:
            
- Constructors:
      - Fully qualified with args:
            - "com.foo.MyClass(String,int)" 
- "com.foo.MyClass(java.lang.String,int)" 
- "com.foo.MyClass()" 
 
- Simple with args:
            - "MyClass(String,int)" 
- "MyClass(java.lang.String,int)" 
- "MyClass()" 
 
- Simple inner class:
            - "MyClass$Inner1$Inner2()" 
- "Inner1$Inner2()" 
- "Inner2()" 
 
 
- Fully qualified with args:
            
- A comma-delimited list of anything on this list.
 See Also:- Overrides:
- annotationsin class- Context.Builder
- Parameters:
- values- The annotations to register with the context.
- Returns:
- This object.
 
- 
applyDescription copied from class:Context.BuilderApplies a set of applied to this builder.An AnnotationWorkconsists of a single pair ofAnnotationInfothat represents an annotation instance, andAnnotationApplierwhich represents the code used to apply the values in that annotation to a specific builder.Example:// A class annotated with a config annotation. @BeanConfig (sortProperties="$S{sortProperties,false}" )public class MyClass {...}// Find all annotations that themselves are annotated with @ContextPropertiesApply. AnnotationListannotations = ClassInfo.of (MyClass.class ).getAnnotationList(CONTEXT_APPLY_FILTER ); VarResolverSessionvrs = VarResolver.DEFAULT .createSession(); AnnotationWorkListwork = AnnotationWorkList.of(vrs ,annotations );// Apply any settings found on the annotations. WriterSerializerserializer = JsonSerializer .create () .apply(work ) .build();- Overrides:
- applyin class- Context.Builder
- Parameters:
- work- The list of annotations and appliers to apply to this builder.
- Returns:
- This object.
 
- 
applyAnnotationsDescription copied from class:Context.BuilderApplies any of the various@XConfig annotations on the specified classes or methods to this context.Any annotations found that themselves are annotated with ContextApplywill be resolved and applied as properties to this builder. These annotations include:- BeanConfig
- CsvConfig
- HtmlConfig
- HtmlDocConfig
- JsonConfig
- JsonSchemaConfig
- MsgPackConfig
- OpenApiConfig
- ParserConfig
- PlainTextConfig
- SerializerConfig
- SoapXmlConfig
- UonConfig
- UrlEncodingConfig
- XmlConfig
- RdfConfig 
 Annotations on classes are appended in the following order: - On the package of this class.
- On interfaces ordered parent-to-child.
- On parent classes ordered parent-to-child.
- On this class.
 Annotations on methods are appended in the following order: - On the package of the method class.
- On interfaces ordered parent-to-child.
- On parent classes ordered parent-to-child.
- On the method class.
- On this method and matching methods ordered parent-to-child.
 The default var resolver VarResolver.DEFAULTis used to resolve any variables in annotation field values.Example:// A class annotated with a config annotation. @BeanConfig (sortProperties="$S{sortProperties,false}" )public class MyClass {...}// Apply any settings found on the annotations. WriterSerializerserializer = JsonSerializer .create () .applyAnnotations(MyClass.class ) .build();// A method annotated with a config annotation. public class MyClass {@BeanConfig (sortProperties="$S{sortProperties,false}" )public void myMethod() {...} }// Apply any settings found on the annotations. WriterSerializerserializer = JsonSerializer .create () .applyAnnotations(MyClass.class .getMethod("myMethod" )) .build();- Overrides:
- applyAnnotationsin class- Context.Builder
- Parameters:
- from- The classes or methods on which the annotations are defined. Can be any of the following types:- Class
- ClassInfo
- Method
- MethodInfo
- A collection/stream/array of anything on this list.
 
- Returns:
- This object.
 
- 
applyAnnotationsDescription copied from class:Context.BuilderSame asContext.Builder.applyAnnotations(Object...)but explicitly specifies a class varargs to avoid compilation warnings.- Overrides:
- applyAnnotationsin class- Context.Builder
- Parameters:
- from- The classes or methods on which the annotations are defined.
- Returns:
- This object.
 
- 
cacheDescription copied from class:Context.BuilderSpecifies a cache to use for hashkey-based caching.- Overrides:
- cachein class- Context.Builder
- Parameters:
- value- The cache.
- Returns:
- This object.
 
- 
debugDescription copied from class:Context.BuilderContext configuration property: Debug mode.Enables the following additional information during serialization: - When bean getters throws exceptions, the exception includes the object stack information in order to determine how that method was invoked.
- 
      Enables BeanTraverseContext.Builder.detectRecursions().
 Enables the following additional information during parsing: - When bean setters throws exceptions, the exception includes the object stack information in order to determine how that method was invoked.
 Example:// Create a serializer with debug enabled. WriterSerializerserializer = JsonSerializer .create () .debug() .build();// Create a POJO model with a recursive loop. public class MyBean {public Objectf ; } MyBeanbean =new MyBean();bean .f =bean ;// Throws a SerializeException and not a StackOverflowError Stringjson =serializer .serialize(bean );See Also:- Overrides:
- debugin class- Context.Builder
- Returns:
- This object.
 
- 
debugDescription copied from class:Context.BuilderSame asContext.Builder.debug()but allows you to explicitly specify the value.- Overrides:
- debugin class- Context.Builder
- Parameters:
- value- The value for this setting.
- Returns:
- This object.
 
- 
implDescription copied from class:Context.BuilderSpecifies a pre-instantiated bean for theContext.Builder.build()method to return.- Overrides:
- implin class- Context.Builder
- Parameters:
- value- The value for this setting.
- Returns:
- This object.
 
- 
typeDescription copied from class:Context.BuilderAssociates a context class with this builder.This is the type of object that this builder creates when the Context.Builder.build()method is called.By default, it's the outer class of where the builder class is defined. - Overrides:
- typein class- Context.Builder
- Parameters:
- value- The context class that this builder should create.
- Returns:
- This object.
 
 
-