Class RestContext.Builder
- All Implemented Interfaces:
jakarta.servlet.ServletConfig
- Enclosing class:
- RestContext
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilder(Class<?> resourceClass, RestContext parentContext, jakarta.servlet.ServletConfig servletConfig) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionallowedHeaderParams(String value) Allowed header URL parameters.allowedMethodHeaders(String value) Allowed method headers.allowedMethodParams(String value) Allowed method parameters.annotations(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 the bean store in this builder.Adds a bean to the bean store of this class.Adds a bean to the bean store of this class.build()Build the object.Specifies a cache to use for hashkey-based caching.Returns the call logger bean creator.callLogger(Class<? extends CallLogger> value) Specifies the call logger for this class.callLogger(CallLogger value) Specifies the call logger for this class.Add a child REST resource.Child REST resources.clientVersionHeader(String value) Client version header.config()Returns the external configuration file for this resource.Overwrites the default config file with a custom config file.consumes()Returns the media types consumed by this resource if it's manually specified.Supported content media types.copy()Copy creator.protected BeanContext.BuildercreateBeanContext(BeanStore beanStore, Supplier<?> resource) Instantiates the bean context sub-builder.protected BeanStore.BuildercreateBeanStore(Supplier<?> resource) Creates the bean store in this builder.protected BeanCreator<CallLogger>createCallLogger(BeanStore beanStore, Supplier<?> resource) Instantiates the call logger sub-builder.protected ConfigcreateConfig(BeanStore beanStore, Supplier<?> resource, Class<?> resourceClass) Creates the config for this builder.protected BeanCreator<DebugEnablement>createDebugEnablement(BeanStore beanStore, Supplier<?> resource) Instantiates the debug enablement bean creator.protected NamedAttributeMapcreateDefaultRequestAttributes(BeanStore beanStore, Supplier<?> resource) Instantiates the default request attributes sub-builder.protected HeaderListcreateDefaultRequestHeaders(BeanStore beanStore, Supplier<?> resource) Instantiates the default request headers sub-builder.protected HeaderListcreateDefaultResponseHeaders(BeanStore beanStore, Supplier<?> resource) Instantiates the default response headers sub-builder.protected MethodListcreateDestroyMethods(BeanStore beanStore, Supplier<?> resource) Instantiates the destroy method list.protected EncoderSet.BuildercreateEncoders(BeanStore beanStore, Supplier<?> resource) Instantiates the encoder group sub-builder.protected MethodListcreateEndCallMethods(BeanStore beanStore, Supplier<?> resource) Instantiates the end call method list.protected JsonSchemaGenerator.BuildercreateJsonSchemaGenerator(BeanStore beanStore, Supplier<?> resource) Instantiates the JSON schema generator sub-builder.protected LoggercreateLogger(BeanStore beanStore, Supplier<?> resource, Class<?> resourceClass) Instantiates the logger for this resource.protected Messages.BuildercreateMessages(BeanStore beanStore, Supplier<?> resource) Instantiates the messages sub-builder.protected MethodExecStore.BuildercreateMethodExecStore(BeanStore beanStore, Supplier<?> resource) Instantiates the method execution statistics store sub-builder.protected ParserSet.BuildercreateParsers(BeanStore beanStore, Supplier<?> resource) Instantiates the parser group sub-builder.protected HttpPartParser.CreatorcreatePartParser(BeanStore beanStore, Supplier<?> resource) Instantiates the part parser sub-builder.protected HttpPartSerializer.CreatorcreatePartSerializer(BeanStore beanStore, Supplier<?> resource) Instantiates the part serializer sub-builder.protected MethodListcreatePostCallMethods(BeanStore beanStore, Supplier<?> resource) Instantiates the post-call method list.protected MethodListcreatePostInitChildFirstMethods(BeanStore beanStore, Supplier<?> resource) Instantiates the post-init-child-first method list.protected MethodListcreatePostInitMethods(BeanStore beanStore, Supplier<?> resource) Instantiates the post-init method list.protected MethodListcreatePreCallMethods(BeanStore beanStore, Supplier<?> resource) Instantiates the pre-call method list.protected ResponseProcessorList.BuildercreateResponseProcessors(BeanStore beanStore, Supplier<?> resource) Instantiates the response processor list sub-builder.protected RestChildren.BuildercreateRestChildren(BeanStore beanStore, Supplier<?> resource, RestContext restContext) Instantiates the REST children list.protected RestOpArgList.BuildercreateRestOpArgs(BeanStore beanStore, Supplier<?> resource) Instantiates the REST operation args sub-builder.protected RestOperations.BuildercreateRestOperations(BeanStore beanStore, Supplier<?> resource, RestContext restContext) Instantiates the REST operations list.protected SerializerSet.BuildercreateSerializers(BeanStore beanStore, Supplier<?> resource) Instantiates the serializer group sub-builder.protected MethodListcreateStartCallMethods(BeanStore beanStore, Supplier<?> resource) Instantiates the start call method list.protected BeanCreator<StaticFiles>createStaticFiles(BeanStore beanStore, Supplier<?> resource) Instantiates the static files bean creator.protected BeanCreator<SwaggerProvider>createSwaggerProvider(BeanStore beanStore, Supplier<?> resource) Instantiates the swagger provider sub-builder.protected ThrownStore.BuildercreateThrownStore(BeanStore beanStore, Supplier<?> resource, RestContext parent) Instantiates the thrown-store sub-builder.protected VarResolver.BuildercreateVarResolver(BeanStore beanStore, Supplier<?> resource, Class<?> resourceClass) Creates the variable resolver sub-builder.debug()Context configuration property: Debug mode.debug(boolean value) Same asContext.Builder.debug()but allows you to explicitly specify the value.debugDefault(Enablement value) Sets the debug default value.Returns the debug enablement bean creator.debugEnablement(Class<? extends DebugEnablement> value) Specifies the debug enablement class to use for this REST context.debugEnablement(DebugEnablement value) Specifies the debug enablement class to use for this REST context.defaultAccept(String value) Specifies a defaultAccept header value if not specified on a request.defaultCharset(Charset value) Default character encoding.Returns the default implementation class list.defaultClasses(Class<?>... values) Adds to the default implementation class list.defaultContentType(String value) Specifies a defaultContent-Type header value if not specified on a request.Returns the default request attributes sub-builder.defaultRequestAttributes(NamedAttribute... values) Default request attributes.Returns the default request headers.defaultRequestHeaders(Header... values) Default request headers.Returns the default response headers.defaultResponseHeaders(Header... values) Default response headers.defaultSetting(String key, Object value) Sets a value in the default settings map.Returns the default settings map.Returns the destroy method list.Disable content URL parameter.disableContentParam(boolean value) Disable content URL parameter.encoders()Returns the encoder group sub-builder.final RestContext.BuilderAdds one or more encoders to this class.Adds one or more encoders to this class.Returns the end call method list.Returns the encoder group builder containing the encoders for compressing/decompressing input and output streams.getInitParameter(String name) Returns the parser group builder containing the parsers for converting HTTP request bodies into POJOs.Returns the serializer group builder containing the serializers for marshalling POJOs into response bodies.jakarta.servlet.ServletContextSpecifies a pre-instantiated bean for theContext.Builder.build()method to return.Performs initialization on this builder against the specified REST servlet/bean instance.Returns the JSON schema generator sub-builder.jsonSchemaGenerator(Class<? extends JsonSchemaGenerator> value) Specifies the JSON schema generator for this class.Specifies the JSON schema generator for this class.logger()Returns the logger for this resource.Sets the logger for this resource.The maximum allowed input size (in bytes) on HTTP requests.messages()Returns the messages sub-builder.Specifies the messages bundle for this class.Specifies the messages bundle for this class.Returns the method execution statistics store sub-builder.methodExecStore(Class<? extends MethodExecStore> value) Specifies the method execution store for this class.methodExecStore(MethodExecStore value) Specifies the method execution store for this class.parserListener(Class<? extends ParserListener> value) RestContext configuration property: Parser listener.parsers()Returns the parser group sub-builder.final RestContext.BuilderAdds one or more parsers to this class.Adds one or more parsers to this class.Returns the part parser sub-builder.partParser(Class<? extends HttpPartParser> value) Specifies the part parser to use for parsing HTTP parts for this class.partParser(HttpPartParser value) Specifies the part parser to use for parsing HTTP parts for this class.Returns the part serializer sub-builder.partSerializer(Class<? extends HttpPartSerializer> value) Specifies the part serializer to use for serializing HTTP parts for this class.partSerializer(HttpPartSerializer value) Specifies the part serializer to use for serializing HTTP parts for this class.Resource path.Returns the post-call method list.Returns the post-init-child-first method list.Returns the post-init method list.Returns the pre-call method list.produces()Returns the media types produced by this resource if it's manually specified.Supported accept media types.RestContext configuration property: Render response stack traces in responses.renderResponseStackTraces(boolean value) RestContext configuration property: Render response stack traces in responses.Supplier<?>resource()Returns the REST servlet/bean instance that this context is defined against.<T> Optional<T>resourceAs(Class<T> type) Returns the REST servlet/bean instance that this context is defined against if it's the specified type.Returns the response processor list sub-builder.final RestContext.BuilderresponseProcessors(Class<? extends ResponseProcessor>... value) Adds one or more response processors to this class.responseProcessors(ResponseProcessor... value) Adds one or more response processors to this class.restChildren(RestContext restContext) Returns the REST children list.restChildrenClass(Class<? extends RestChildren> value) REST children class.Returns the REST operation args sub-builder.final RestContext.BuilderrestOpArgs(Class<? extends RestOpArg>... value) Adds one or more REST operation args to this class.restOpContextClass(Class<? extends RestOpContext> value) REST operation context class.restOperations(RestContext restContext) Returns the REST operations list.Returns the root bean store.serializerListener(Class<? extends SerializerListener> value) RestContext configuration property: Serializer listener.Returns the serializer group sub-builder.final RestContext.Builderserializers(Class<? extends Serializer>... value) Adds one or more serializers to this class.serializers(Serializer... value) Adds one or more serializers to this class.Returns the start call method list.Returns the static files bean creator.staticFiles(Class<? extends StaticFiles> value) Specifies the static files resource finder for this class.staticFiles(StaticFiles value) Specifies the static files resource finder for this class.Returns the swagger provider sub-builder.swaggerProvider(Class<? extends SwaggerProvider> value) Specifies the swagger provider for this class.swaggerProvider(SwaggerProvider value) Specifies the swagger provider for this class.Returns the thrown-store sub-builder.thrownStore(Class<? extends ThrownStore> value) Specifies the thrown store for this class.thrownStore(ThrownStore value) Specifies the thrown store for this class.Associates a context class with this builder.uriAuthority(String value) Resource authority path.uriContext(String value) Resource context path.uriRelativity(UriRelativity value) URI resolution relativity.uriResolution(UriResolution value) URI resolution.Returns the variable resolver sub-builder.final RestContext.BuilderAdds one or more variables to the var resolver of this class.Adds one or more variables to the var resolver of this class.Methods inherited from class org.apache.juneau.Context.Builder
annotations, asSubtype, build, canApply, getApplied, getType, hashKey, isDebug, registerBuilders
-
Constructor Details
-
Builder
protected Builder(Class<?> resourceClass, RestContext parentContext, jakarta.servlet.ServletConfig servletConfig) Constructor.- Parameters:
resourceClass- The REST servlet/bean type that this context is defined against.parentContext- The parent context if this is a child of another resource.servletConfig- The servlet config if available.
-
-
Method Details
-
allowedHeaderParams
Allowed header URL parameters.When specified, allows headers such as
"Accept" and"Content-Type" to be passed in as URL query parameters.
For example:?Accept=text/json&Content-Type=text/json
Notes:
- Useful for debugging REST interface using only a browser so that you can quickly simulate header values in the URL bar.
- Header names are case-insensitive.
-
Use
"*" to allow any headers to be specified as URL parameters. -
Use
"NONE" (case insensitive) to suppress inheriting a value from a parent class.
See Also:
- Parameters:
value- The new value for this setting.
The default is the first value found:- System property
"RestContext.allowedHeaderParams" - Environment variable
"RESTCONTEXT_ALLOWEDHEADERPARAMS" "Accept,Content-Type" - Environment variable
Cannot benull .- System property
- Returns:
- This object.
-
allowedMethodHeaders
Allowed method headers.A comma-delimited list of HTTP method names that are allowed to be passed as values in an
X-Method HTTP header to override the real HTTP method name.Allows you to override the actual HTTP method with a simulated method.
For example, if an HTTP Client API doesn't supportPATCH but does supportPOST (becausePATCH is not part of the original HTTP spec), you can add aX-Method: PATCH header on a normalHTTP POST /foo request call which will make the HTTP call look like aPATCH request in any of the REST APIs.Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (allowedMethodHeaders="PATCH" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .allowedMethodHeaders("PATCH" ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .allowedMethodHeaders("PATCH" ); } }Notes:
- Method names are case-insensitive.
-
Use
"*" to represent all methods. -
Use
"NONE" (case insensitive) to suppress inheriting a value from a parent class.
See Also:
- Parameters:
value- The new value for this setting.
The default is the first value found:- System property
"RestContext.allowedMethodHeaders" - Environment variable
"RESTCONTEXT_ALLOWEDMETHODHEADERS" "" - Environment variable
Cannot benull .- System property
- Returns:
- This object.
-
allowedMethodParams
Allowed method parameters.When specified, the HTTP method can be overridden by passing in a
"method" URL parameter on a regular GET request.
For example:?method=OPTIONS
Useful in cases where you want to simulate a non-GET request in a browser by simply adding a parameter.
Also useful if you want to construct hyperlinks to non-GET REST endpoints such as links toOPTIONS pages.Note that per the HTTP specification, special care should be taken when allowing non-safe (
POST ,PUT ,DELETE ) methods to be invoked through GET requests.Example:
// Option #1 - Defined via annotation. @Rest (allowedMethodParams="HEAD,OPTIONS,PUT" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .allowedMethodParams("HEAD,OPTIONS,PUT" ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builder builder)throws Exception {builder .allowedMethodParams("HEAD,OPTIONS,PUT" ); } }Notes:
- Format is a comma-delimited list of HTTP method names that can be passed in as a method parameter.
-
'method' parameter name is case-insensitive. -
Use
"*" to represent all methods. -
Use
"NONE" (case insensitive) to suppress inheriting a value from a parent class.
See Also:
- Parameters:
value- The new value for this setting.
The default is the first value found:- System property
"RestContext.allowedMethodParams" - Environment variable
"RESTCONTEXT_ALLOWEDMETHODPARAMS" "HEAD,OPTIONS" - Environment variable
Cannot benull .- System property
- Returns:
- This object.
-
annotations
Description 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:
BeanAnnotationBeancAnnotationBeanIgnoreAnnotationBeanpAnnotationExampleAnnotationNamePropertyAnnotationParentPropertyAnnotationSwapAnnotationUriAnnotationCsvAnnotationHtmlAnnotationJsonAnnotationSchemaAnnotationMsgPackAnnotationOpenApiAnnotationPlainTextAnnotationSoapXmlAnnotationUonAnnotationUrlEncodingAnnotationXmlAnnotation
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 classContext.Builder- Parameters:
values- The annotations to register with the context.
Cannot containnull values.- Returns:
- This object.
-
apply
Description 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. Stream<AnnotationInfo<?>>annotations = ClassInfo.of (MyClass.class ).getAnnotations().stream().filter(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 classContext.Builder- Parameters:
work- The list of annotations and appliers to apply to this builder.
Cannot benull .- Returns:
- This object.
-
applyAnnotations
Description copied from class:Context.BuilderSame asContext.Builder.applyAnnotations(Object...)but explicitly specifies a class varargs to avoid compilation warnings.- Overrides:
applyAnnotationsin classContext.Builder- Parameters:
from- The classes or methods on which the annotations are defined.
Cannot containnull values.- Returns:
- This object.
-
applyAnnotations
Description 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:BeanConfigCsvConfigHtmlConfigHtmlDocConfigJsonConfigJsonSchemaConfigMsgPackConfigOpenApiConfigParserConfigPlainTextConfigSerializerConfigSoapXmlConfigUonConfigUrlEncodingConfigXmlConfigRdfConfig
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 classContext.Builder- Parameters:
from- The classes or methods on which the annotations are defined. Can be any of the following types:ClassClassInfoMethodMethodInfo- A collection/stream/array of anything on this list.
Cannot containnull values.
- Returns:
- This object.
-
beanContext
Returns the bean context sub-builder.The bean context is used to retrieve metadata on Java beans.
The default bean context can overridden via any of the following:
- Injected via bean store.
- Returns:
- The bean context sub-builder.
-
beanStore
Returns the bean store in this builder.The bean store is a simple storage database for beans keyed by type and name.
The bean store is created with the parent root bean store as the parent, allowing any beans in the root bean store to be available in this builder. The root bean store typically pulls from an injection framework such as Spring to allow injected beans to be used.
The default bean store can be overridden via any of the following:
- Class annotation:
@Rest(beanStore) @RestInject-annotated methods:
Args can be any injected bean including@RestInject public [static ] BeanStore myMethod(<args>) {...}BeanStore.Builder, the default builder.
- Returns:
- The bean store in this builder.
- Class annotation:
-
beanStore
Adds a bean to the bean store of this class.Equivalent to calling:
builder .beanStore().add(beanType ,bean );See Also:
- Type Parameters:
T- The class to associate this bean with.- Parameters:
beanType- The class to associate this bean with.bean- The bean.
Can benull (a null bean will be stored in the bean store).- Returns:
- This object.
-
beanStore
Adds a bean to the bean store of this class.Equivalent to calling:
builder .beanStore().add(beanType ,bean ,name );See Also:
- Type Parameters:
T- The class to associate this bean with.- Parameters:
beanType- The class to associate this bean with.bean- The bean.
Can benull (a null bean will be stored in the bean store).name- The bean name if this is a named bean.
Can benull (bean will be stored as an unnamed bean).- Returns:
- This object.
-
build
Description copied from class:Context.BuilderBuild the object.- Overrides:
buildin classContext.Builder- Returns:
- The built object.
-
cache
Description copied from class:Context.BuilderSpecifies a cache to use for hashkey-based caching.When a cache is specified, contexts with the same hash key will be reused from the cache instead of creating new instances. This improves performance when building multiple contexts with identical configurations.
If
null is specified, caching is disabled and each call toContext.Builder.build()will create a new context instance.- Overrides:
cachein classContext.Builder- Parameters:
value- The cache.
Can benull (disables caching, each build creates a new instance).- Returns:
- This object.
-
callLogger
Returns the call logger bean creator.Specifies the logger to use for logging of HTTP requests and responses.
Example:
// Our customized logger. public class MyLoggerextends BasicCallLogger {public MyLogger(BeanStorebeanStore ) {super (beanStore ); }@Override protected void log(Levellevel , Stringmsg , Throwablee ) {// Handle logging ourselves. } }// Option #1 - Registered via annotation resolving to a config file setting with default value. @Rest (callLogger=MyLogger.class )public class MyResource {// Option #2 - Registered via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .callLogger(MyLogger.class ); } }The default call logger can overridden via any of the following:
- Injected via bean store.
- Class annotation:
@Rest(callLogger) @RestInject-annotated method:
Args can be any injected bean.@RestInject public [static ] CallLogger myMethod(<args>) {...}
Notes:
-
The default call logger if not specified is
BasicCallLogger. -
The resource class itself will be used if it implements the
CallLoggerinterface and not explicitly overridden via this annotation. -
When defined as a class, the implementation must have one of the following constructor:
public T(BeanStore)
- Inner classes of the REST resource class are allowed.
See Also:
- Returns:
- The call logger sub-builder.
- Throws:
RuntimeException- Ifinit(Supplier)has not been called.
-
callLogger
Specifies the call logger for this class.Equivalent to calling:
builder .callLogger().impl(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
callLogger
Specifies the call logger for this class.Equivalent to calling:
builder .callLogger().type(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
child
Add a child REST resource.Shortcut for adding a single child to this resource.
This can be used for resources that don't have a
@Rest(path)annotation.- Parameters:
path- The child path relative to the parent resource URI.
Cannot benull .child- The child to add to this resource.- Returns:
- This object.
-
children
Child REST resources.Defines children of this resource.
A REST child resource is simply another servlet or object that is initialized as part of the ascendant resource and has a servlet path directly under the ascendant resource object path.
The main advantage to defining servlets as REST children is that you do not need to define them in theweb.xml file of the web application.
This can cut down on the number of entries that show up in theweb.xml file if you are defining large numbers of servlets.Child resources must specify a value for
@Rest(path)that identifies the subpath of the child resource relative to the ascendant path UNLESS you use thechild(String, Object)method to register it.Child resources can be nested arbitrarily deep using this technique (i.e. children can also have children).
- Servlet initialization:
-
A child resource will be initialized immediately after the ascendant servlet/resource is initialized.
The child resource receives the same servlet config as the ascendant servlet/resource.
This allows configuration information such as servlet initialization parameters to filter to child resources. - Runtime behavior:
-
As a rule, methods defined on the
HttpServletRequest object will behave as if the child servlet were deployed as a top-level resource under the child's servlet path.
For example, thegetServletPath() andgetPathInfo() methods on theHttpServletRequest object will behave as if the child resource were deployed using the child's servlet path.
Therefore, the runtime behavior should be equivalent to deploying the child servlet in theweb.xml file of the web application.
Example:
// Our child resource. @Rest (path="/child" )public class MyChildResource {...}// Option #1 - Registered via annotation. @Rest (children={MyChildResource.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 .children(MyChildResource.class );// Use a pre-instantiated object instead. builder .child("/child" ,new MyChildResource()); }// Option #3 - Registered via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .children(MyChildResource.class ); } }Notes:
-
When defined as classes, instances are resolved using the registered bean store which
by default is
BeanStorewhich requires the class have one of the following constructors:public T(RestContext.Builder)public T()
See Also:
- Parameters:
values- The child resources to add.
Cannot containnull values.
Objects can be any of the specified types:- A class that has a constructor described above.
- An instantiated resource object (such as a servlet object instantiated by a servlet container).
- An instance of
RestChildcontaining an instantiated resource object and a subpath.
- Returns:
- This object.
-
clientVersionHeader
Client version header.Specifies the name of the header used to denote the client version on HTTP requests.
The client version is used to support backwards compatibility for breaking REST interface changes.
Used in conjunction with@RestOp(clientVersion)annotation.Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (clientVersionHeader="$C{REST/clientVersionHeader,Client-Version}" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .clientVersionHeader("Client-Version" ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .clientVersionHeader("Client-Version" ); } }// 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() { ... }See Also:
- Parameters:
value- The new value for this setting.
The default is the first value found:- System property
"RestContext.clientVersionHeader" - Environment variable
"RESTCONTEXT_CLIENTVERSIONHEADER" "Client-Version" - Environment variable
Cannot benull .- System property
- Returns:
- This object.
-
config
Returns the external configuration file for this resource.The config file contains arbitrary configuration information that can be accessed by this class, usually via
$C variables.The default config can be overridden via any of the following:
- Injected via bean store.
- Class annotation:
@Rest(config) @RestInject-annotated method:
Args can be any injected bean.@RestInject public [static ] Config myMethod(<args>) {...}
If a config file is not set up, then an empty config file will be returned that is not backed by any file.
This bean can be accessed directly via
RestContext.getConfig()or passed in as a parameter on aRestOp-annotated method.See Also:
- Returns:
- The external configuration file for this resource.
-
config
Overwrites the default config file with a custom config file.By default, the config file is determined using the
@Rest(config)annotation. This method allows you to programmatically override it with your own custom config file.See Also:
- Parameters:
value- The new config file.
Cannot benull .- Returns:
- This object.
-
consumes
Returns the media types consumed by this resource if it's manually specified.- Returns:
- The media types.
-
consumes
Supported 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.Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (consumes={"$C{REST/supportedConsumes,application/json}" })public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .consumes(false ,"application/json" ) }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .consumes(false ,"application/json" ); } }This affects the returned values from the following:
See Also:
- Parameters:
values- The values to add to this setting.
Cannot containnull values.- Returns:
- This object.
-
copy
Description copied from class:Context.BuilderCopy creator.- Specified by:
copyin classContext.Builder- Returns:
- A new mutable copy of this builder.
-
debug
Description 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 classContext.Builder- Returns:
- This object.
-
debug
Description copied from class:Context.BuilderSame asContext.Builder.debug()but allows you to explicitly specify the value.- Overrides:
debugin classContext.Builder- Parameters:
value- The value for this setting.- Returns:
- This object.
-
debugDefault
Sets the debug default value.The default debug value is the enablement value if not otherwise overridden at the class or method level.
- Parameters:
value- The debug default value.
Cannot benull .- Returns:
- This object.
-
debugEnablement
Returns the debug enablement bean creator.Enables the following:
- HTTP request/response bodies are cached in memory for logging purposes.
- Request/response messages are automatically logged always or per request.
- Returns:
- The debug enablement sub-builder.
-
debugEnablement
Specifies the debug enablement class to use for this REST context.- Parameters:
value- The new value for this setting.
Cannot benull .- Returns:
- This object.
-
debugEnablement
Specifies the debug enablement class to use for this REST context.- Parameters:
value- The new value for this setting.
Cannot benull .- Returns:
- This object.
-
defaultAccept
Specifies a defaultAccept header value if not specified on a request.- Parameters:
value- The default value of theAccept header.
Ignored ifnull or empty.- Returns:
- This object.
-
defaultCharset
Default character encoding.The default character encoding for the request and response if not specified on the request.
Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (defaultCharset="$C{REST/defaultCharset,US-ASCII}" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .defaultCharset("US-ASCII" ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .defaultCharset("US-ASCII" ); }// Override at the method level. @RestGet (defaultCharset="UTF-16" )public Object myMethod() {...} }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
Cannot benull .- System property
- Returns:
- This object.
-
defaultClasses
Returns the default implementation class 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 implementation class list.
-
defaultClasses
Adds to the default implementation class list.A shortcut for the following code:
builder .defaultClasses().add(values );- Parameters:
values- The values to add to the list of default classes.
Cannot containnull values.- Returns:
- This object.
- See Also:
-
defaultContentType
Specifies a defaultContent-Type header value if not specified on a request.- Parameters:
value- The default value of theContent-Type header.
Ignored ifnull or empty.- Returns:
- This object.
-
defaultRequestAttributes
Returns the default request attributes sub-builder.- Returns:
- The default request attributes sub-builder.
-
defaultRequestAttributes
Default request attributes.Specifies default values for request attributes if they're not already set on the request. Affects values returned by the following methods:
Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (defaultRequestAttributes={"Foo=bar" ,"Baz: $C{REST/myAttributeValue}" })public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .defaultRequestAttributes( BasicNamedAttribute.of ("Foo" ,"bar" ), BasicNamedAttribute.of ("Baz" ,true ) ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .defaultRequestAttribute("Foo" ,"bar" ); }// Override at the method level. @RestGet (defaultRequestAttributes={"Foo: bar" })public Object myMethod() {...} }Notes:
- Use
BasicNamedAttribute.of(String, Supplier)to provide a dynamically changeable attribute value.
- Parameters:
values- The attributes.
Cannot containnull values.- Returns:
- This object.
- Use
-
defaultRequestHeaders
Returns the default request headers.- Returns:
- The default request headers.
-
defaultRequestHeaders
Default request headers.Specifies default values for request headers if they're not passed in through the request.
Notes:
-
Affects values returned by
HttpServletRequestWrapper.getHeader(String)when the header is not present on the request. -
The most useful reason for this annotation is to provide a default
Accept header when one is not specified so that a particular defaultSerializeris picked.
Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (defaultRequestHeaders={"Accept: application/json" ,"My-Header=$C{REST/myHeaderValue}" })public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .defaultRequestHeaders( Accept.of ("application/json" ), BasicHeader.of ("My-Header" ,"foo" ) ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .defaultRequestHeaders(Accept.of ("application/json" )); }// Override at the method level. @RestGet (defaultRequestHeaders={"Accept: text/xml" })public Object myMethod() {...} }See Also:
- Parameters:
values- The headers to add.
Cannot containnull values.- Returns:
- This object.
-
Affects values returned by
-
defaultResponseHeaders
Returns the default response headers.- Returns:
- The default response headers.
-
defaultResponseHeaders
Default response headers.Specifies default values for response headers if they're not set after the Java REST method is called.
Notes:
-
This is equivalent to calling
RestResponse.setHeader(String, String)programmatically in each of the Java methods. - The header value will not be set if the header value has already been specified (hence the 'default' in the name).
Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (defaultResponseHeaders={"Content-Type: $C{REST/defaultContentType,text/plain}" ,"My-Header: $C{REST/myHeaderValue}" })public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .defaultResponseHeaders( ContentType.of ("text/plain" ), BasicHeader.ofPair ("My-Header: foo" ) ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .defaultResponseHeaders(ContentType.of ("text/plain" )); } }See Also:
- Parameters:
values- The headers to add.
Cannot containnull values.- Returns:
- This object.
-
This is equivalent to calling
-
defaultSetting
Sets a value in the default settings map.A shortcut for the following code:
builder .defaultSettings().add(key ,value );- Parameters:
key- The setting key.
Cannot benull .value- The setting value.- Returns:
- This object.
- See Also:
-
defaultSettings
Returns the default settings map.Default settings are inherited from the parent REST object. Typically used on the top-level
RestContext.Builderto affect settings for that REST object and all children.Modifying the default settings map on this builder does not affect the default settings on the parent builder, but changes made here are inherited by child builders.
- Returns:
- The default settings map.
-
destroyMethods
Returns the destroy method list.- Returns:
- The destroy method list.
-
disableContentParam
Disable content URL parameter.When enabled, the HTTP content content on PUT and POST requests can be passed in as text using the
"content" URL parameter.
For example:?content=(name='John%20Smith',age=45)
Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (disableContentParam="$C{REST/disableContentParam,true}" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .disableContentParam(); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .disableContentParam(); } }Notes:
-
'content' parameter name is case-insensitive. - Useful for debugging PUT and POST methods using only a browser.
- Returns:
- This object.
-
-
disableContentParam
Disable content URL parameter.Same as
disableContentParam()but allows you to set it as a boolean value.- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
encoders
Returns the encoder group sub-builder.Encoders are used to decode HTTP requests and encode HTTP responses based on
Content-EncodingandAccept-Encodingheaders.The default encoder set has support for identity incoding only. It can be overridden via any of the following:
- Injected via bean store.
- Class annotation:
@Rest(encoders) @RestInject-annotated method:
Args can be any injected bean including EncoderSet.Builder, the default builder.@RestInject public [static ] EncoderSet myMethod(<args>) {...}
See Also:
- Returns:
- The builder for the
EncoderSetobject in the REST context.
-
encoders
Adds one or more encoders to this class.Equivalent to calling:
builder .encoders().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
encoders
Adds one or more encoders to this class.Equivalent to calling:
builder .encoders().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
endCallMethods
Returns the end call method list.- Returns:
- The end call method list.
-
getEncoders
Returns the encoder group builder containing the encoders for compressing/decompressing input and output streams.These can be used to enable various kinds of compression (e.g.
"gzip" ) on requests and responses.The builder is initialized with encoders defined via the
Rest.encoders()annotation. That annotation is applied from parent-to-child order with child entries given priority over parent entries.See Also:
- Returns:
- The encoder group builder for this context builder.
-
getInitParameter
- Specified by:
getInitParameterin interfacejakarta.servlet.ServletConfig
-
getInitParameterNames
- Specified by:
getInitParameterNamesin interfacejakarta.servlet.ServletConfig
-
getParsers
Returns the parser group builder containing the parsers for converting HTTP request bodies into POJOs.Parsers are used to convert the content of HTTP requests into POJOs.
Any of the Juneau framework parsers can be used in this setting.
The parser selected is based on the requestContent-Type header matched against the values returned by the following method using a best-match algorithm:The builder is initialized with parsers defined via the
Rest.parsers()annotation. That annotation is applied from parent-to-child order with child entries given priority over parent entries.See Also:
- Returns:
- The parser group builder for this context builder.
-
getSerializers
Returns the serializer group builder containing the serializers for marshalling POJOs into response bodies.Serializer are used to convert POJOs to HTTP response bodies.
Any of the Juneau framework serializers can be used in this setting.
The serializer selected is based on the requestAccept header matched against the values returned by the following method using a best-match algorithm:The builder is initialized with serializers defined via the
Rest.serializers()annotation. That annotation is applied from parent-to-child order with child entries given priority over parent entries.See Also:
- Returns:
- The serializer group builder for this context builder.
-
getServletContext
- Specified by:
getServletContextin interfacejakarta.servlet.ServletConfig
-
getServletName
- Specified by:
getServletNamein interfacejakarta.servlet.ServletConfig
-
impl
Description copied from class:Context.BuilderSpecifies a pre-instantiated bean for theContext.Builder.build()method to return.If a non-null value is provided and it's an instance of the context type,
Context.Builder.build()will return that instance instead of creating a new one. Ifnull , the normal build process continues.- Overrides:
implin classContext.Builder- Parameters:
value- The value for this setting.
Can benull (normal build process will continue).- Returns:
- This object.
-
init
Performs initialization on this builder against the specified REST servlet/bean instance.- Parameters:
resource- The REST servlet/bean instance that this context is defined against.
Cannot benull .- Returns:
- This object.
- Throws:
jakarta.servlet.ServletException- If hook method calls failed.
-
jsonSchemaGenerator
Returns the JSON schema generator sub-builder.The JSON schema generator is used for generating JSON schema in the auto-generated Swagger documentation.
The default JSON schema generator is a default
JsonSchemaGenerator. It can overridden via any of the following:- Injected via bean store.
@RestInject-annotated method:
Args can be any injected bean including JsonSchemaGenerator.Builder, the default builder.@RestInject public [static ] JsonSchemaGenerator myMethod(<args>) {...}
See Also:
- Returns:
- The JSON schema generator sub-builder.
-
jsonSchemaGenerator
Specifies the JSON schema generator for this class.Equivalent to calling:
builder .jsonSchemaGenerator().type(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
jsonSchemaGenerator
Specifies the JSON schema generator for this class.Equivalent to calling:
builder .jsonSchemaGenerator().impl(value );jsonSchemaGenerator()See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
logger
Returns the logger for this resource.The logger is used in the following locations:
RestServlet.log(Level, Throwable, String, Object...)and related methods.RestObject.log(Level, Throwable, String, Object...)and related methods.- In the
callLogger()of this resource.
RestContext.getLogger()or passed in as a parameter on aRestOp-annotated method.The default config can be overridden via any of the following:
- Injected via bean store.
@RestInject-annotated method:
Args can be any injected bean.@RestInject public [static ] Logger myMethod(<args>) {...}
See Also:
- Returns:
- The logger for this resource.
-
logger
Sets the logger for this resource.See Also:
- Parameters:
value- The logger to use for the REST resource.
Cannot benull .- Returns:
- This object.
-
maxInput
The 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" .
Cannot benull .- System property
- Returns:
- This object.
-
String value that gets resolved to a
-
messages
Returns the messages sub-builder.Messages beans are wrappers around resource bundles containing localized messages.
By default, the resource bundle name is assumed to match the class name. For example, given the class
MyClass.java , the resource bundle is assumed to beMyClass.properties . This property allows you to override this setting to specify a different location such asMyMessages.properties by specifying a value of"MyMessages" .Resource bundles are searched using the following base name patterns:
"{package}.{name}" "{package}.i18n.{name}" "{package}.nls.{name}" "{package}.messages.{name}"
This annotation is used to provide request-localized (based on
Accept-Language ) messages for the following methods:Request-localized messages are also available by passing either of the following parameter types into your Java method:
ResourceBundle- Basic Java resource bundle.Messages- Extended resource bundle with several convenience methods.
"nls/Messages" , indicating to look for the resource bundle"com.foo.sample.nls.Messages" if the resource class is in"com.foo.sample" , or it can be an absolute path like"com.foo.sample.nls.Messages" Examples:
# Contents of org/apache/foo/nls/MyMessages.properties HelloMessage =Hello {0}! // Contents of org/apache/foo/MyResource.java @Rest (messages="nls/MyMessages" )public class MyResource {...}@RestGet ("/hello/{you}" )public Object helloYou(RestRequestreq , Messagesmessages ,@Path ("name" ) Stringyou ) { Stringstring ;// Get it from the RestRequest object. string =req .getMessage("HelloMessage" ,you );// Or get it from the method parameter. string =messages .getString("HelloMessage" ,you );// Or get the message in a locale different from the request. string =messages .forLocale(Locale.UK ).getString("HelloMessage" ,you );return string ; } }The default messages can overridden via any of the following:
- Injected via bean store.
- Class annotation:
@Rest(messages) @RestInject-annotated method:
Args can be any injected bean including Messages.Builder, the default builder.@RestInject public [static ] Messages myMethod(<args>) {...}
Notes:
- Mappings are cumulative from super classes.
Therefore, you can find and retrieve messages up the class-hierarchy chain.
See Also:
- Returns:
- The messages sub-builder.
-
messages
Specifies the messages bundle for this class.Equivalent to calling:
builder .messages().type(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
messages
Specifies the messages bundle for this class.Equivalent to calling:
builder .messages().impl(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
methodExecStore
Returns the method execution statistics store sub-builder.Used for tracking basic call statistics on Java methods in this class. It can be accessed directly via
RestContext.getMethodExecStore()or passed in as a parameter on aRestOp-annotated method.The default method exec store can overridden via any of the following:
- Injected via bean store.
@RestInject-annotated method:
Args can be any injected bean including MethodExecStore.Builder, the default builder.@RestInject public [static ] MethodExecStore myMethod(<args>) {...}
See Also:
- Returns:
- The method execution statistics store sub-builder.
-
methodExecStore
Specifies the method execution store for this class.Equivalent to calling:
builder .methodExecStore().type(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
methodExecStore
Specifies the method execution store for this class.Equivalent to calling:
builder .methodExecStore().impl(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
parserListener
RestContext configuration property: Parser listener.Specifies the parser listener class to use for listening to non-fatal parsing errors.
See Also:
- Parameters:
value- The new value for this setting.
Cannot benull .- Returns:
- This object.
-
parsers
Returns the parser group sub-builder.Parsers are used to HTTP request bodies into POJOs based on the
Content-Typeheader.The default parser set is empty. It can be overridden via any of the following:
- Injected via bean store.
- Class annotation:
@Rest(parsers) @RestInject-annotated method:
Args can be any injected bean including ParserSet.Builder, the default builder.@RestInject public [static ] ParserSet myMethod(<args>) {...}
See Also:
- Returns:
- The parser group sub-builder.
-
parsers
Adds one or more parsers to this class.Equivalent to calling:
builder .parsers().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
parsers
Adds one or more parsers to this class.Equivalent to calling:
builder .parsers().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
partParser
Returns the part parser sub-builder.The part parser is used for parsing HTTP parts such as request headers and query/form/path parameters.
The default part parser is an
OpenApiParser. It can overridden via any of the following:- Injected via bean store.
@RestInject-annotated method:
Args can be any injected bean including HttpPartParser.Builder, the default builder.@RestInject public [static ] HttpPartParser myMethod(<args>) {...}
See Also:
- Returns:
- The part parser sub-builder.
-
partParser
Specifies the part parser to use for parsing HTTP parts for this class.Equivalent to calling:
builder .partParser().type(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
partParser
Specifies the part parser to use for parsing HTTP parts for this class.Equivalent to calling:
builder .partParser().impl(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
partSerializer
Returns the part serializer sub-builder.The part serializer is used for serializing HTTP parts such as response headers.
The default part serializer is an
OpenApiSerializer. It can overridden via any of the following:- Injected via bean store.
@RestInject-annotated method:
Args can be any injected bean including HttpPartSerializer.Builder, the default builder.@RestInject public [static ] HttpPartSerializer myMethod(<args>) {...}
See Also:
- Returns:
- The part serializer sub-builder.
-
partSerializer
Specifies the part serializer to use for serializing HTTP parts for this class.Equivalent to calling:
builder .partSerializer().type(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
partSerializer
Specifies the part serializer to use for serializing HTTP parts for this class.Equivalent to calling:
builder .partSerializer().impl(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
path
Resource path.Identifies the URL subpath relative to the parent resource.
This setting is critical for the routing of HTTP requests from ascendant to child resources.
Example:
// Option #1 - Defined via annotation. @Rest (path="/myResource" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .path("/myResource" ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .path("/myResource" ); } }Notes:
-
This annotation is ignored on top-level servlets (i.e. servlets defined in
web.xml files).
Therefore, implementers can optionally specify a path value for documentation purposes. -
Typically, this setting is only applicable to resources defined as children through the
@Rest(children)annotation.
However, it may be used in other ways (e.g. defining paths for top-level resources in microservices). -
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. - This path is available through the following method:
See Also:
- Parameters:
value- The new value for this setting.
Can benull or empty (path will not be set, defaults to empty string).- Returns:
- This object.
-
This annotation is ignored on top-level servlets (i.e. servlets defined in
-
postCallMethods
Returns the post-call method list.The list of methods that gets called immediately after the
@RestOp annotated method gets called..- Returns:
- The list of methods that gets called immediately after the
@RestOp annotated method gets called..
-
postInitChildFirstMethods
Returns the post-init-child-first method list.- Returns:
- The post-init-child-first method list.
-
postInitMethods
Returns the post-init method list.- Returns:
- The post-init method list.
-
preCallMethods
Returns the pre-call method list.The list of methods that gets called immediately before the
@RestOp annotated method gets called.- Returns:
- The pre-call method list.
-
produces
Returns the media types produced by this resource if it's manually specified.- Returns:
- The media types.
-
produces
Supported 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.Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest (produces={"$C{REST/supportedProduces,application/json}" })public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .produces(false ,"application/json" ) }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .produces(false ,"application/json" ); } }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.
Cannot containnull values.- Returns:
- This object.
-
renderResponseStackTraces
RestContext configuration property: Render response stack traces in responses.Shortcut for calling
renderResponseStackTraces(.true )- Returns:
- This object.
-
renderResponseStackTraces
RestContext configuration property: Render response stack traces in responses.Render stack traces in HTTP response bodies when errors occur.
- Parameters:
value- The new value for this setting.
The default isfalse .- Returns:
- This object.
-
resource
Returns the REST servlet/bean instance that this context is defined against.- Returns:
- The REST servlet/bean instance that this context is defined against.
-
resourceAs
Returns the REST servlet/bean instance that this context is defined against if it's the specified type.- Type Parameters:
T- The expected type of the resource bean.- Parameters:
type- The expected type of the resource bean.
Cannot benull .- Returns:
- The bean cast to that instance, or
Optional.empty()if it's not the specified type.
-
responseProcessors
Returns the response processor list sub-builder.Specifies a list of
ResponseProcessorclasses that know how to convert POJOs returned by REST methods or set viaRestResponse.setContent(Object)into appropriate HTTP responses.By default, the following response handlers are provided in the specified order:
ReaderProcessorInputStreamProcessorThrowableProcessorHttpResponseProcessorHttpResourceProcessorHttpEntityProcessorResponseBeanProcessorPlainTextPojoProcessorSerializedPojoProcessor
Example:
// Our custom response processor for Foo objects. public class MyResponseProcessorimplements ResponseProcessor {@Override public int process(RestOpSessionopSession )throws IOException { RestResponseres =opSession .getResponse(); Foofoo =res .getOutput(Foo.class );if (foo ==null )return NEXT ;// Let the next processor handle it. try (Writerwriter =res .getNegotiatedWriter()) {//Pipe it to the writer ourselves. }return FINISHED ;// We handled it. } } }// Option #1 - Defined via annotation. @Rest (responseProcessors=MyResponseProcessor.class )public class MyResource {// Option #2 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .responseProcessors(MyResponseProcessors.class ); }@RestGet (...)public Object myMethod() {// Return a special object for our handler. return new MySpecialObject(); } }The default response processors can overridden via any of the following:
- Injected via bean store.
- Class annotation:
@Rest(responseProcessors) @RestInject-annotated method:
Args can be any injected bean including ResponseProcessorList.Builder, the default builder.@RestInject public [static ] ResponseProcessorList myMethod(<args>) {...}
Notes:
- Response processors are always inherited from ascendant resources.
-
When defined as a class, the implementation must have one of the following constructors:
public T(RestContext)public T()public static Tcreate (RestContext)public static Tcreate ()
- Inner classes of the REST resource class are allowed.
See Also:
- Returns:
- The response processor list sub-builder.
-
responseProcessors
@SafeVarargs public final RestContext.Builder responseProcessors(Class<? extends ResponseProcessor>... value) Adds one or more response processors to this class.Equivalent to calling:
builder .responseProcessors().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
responseProcessors
Adds one or more response processors to this class.Equivalent to calling:
builder .responseProcessors().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
restChildren
Returns the REST children list.- Parameters:
restContext- The rest context.
Can benull if the bean is a top-level resource.- Returns:
- The REST children list.
- Throws:
Exception- If a problem occurred instantiating one of the child rest contexts.
-
restChildrenClass
REST children class.Allows you to extend the
RestChildrenclass to modify how any of the methods are implemented.The subclass must have a public constructor that takes in any of the following arguments:
RestChildren.Builder- The builder for the object.- Any beans found in the specified bean store.
- Any
Optionalbeans that may or may not be found in the specified bean store.
Example:
// Our extended context class public MyRestChildrenextends RestChildren {public MyRestChildren(RestChildren.Builderbuilder , ARequiredSpringBeanbean1 , Optional<AnOptionalSpringBean>bean2 ) {super (builder ); }// Override any methods. @Override public Optional<RestChildMatch> findMatch(RestCallcall ) { Stringpath =call .getPathInfo();if (path .endsWith("/foo" )) {// Do our own special handling. }return super .findMatch(call ); } }// Option #1 - Defined via annotation. @Rest (restChildrenClass=MyRestChildren.class )public class MyResource { ...// Option #2 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .restChildrenClass(MyRestChildren.class ); } }- Parameters:
value- The new value for this setting.
Cannot benull .- Returns:
- This object.
-
restOpArgs
Returns the REST operation args sub-builder.- Returns:
- The REST operation args sub-builder.
-
restOpArgs
Adds one or more REST operation args to this class.Equivalent to calling:
builder .restOpArgs().add(value );- Parameters:
value- The new value.
Cannot containnull values.- Returns:
- This object.
-
restOpContextClass
REST operation context class.Allows you to extend the
RestOpContextclass to modify how any of the methods are implemented.The subclass must have a public constructor that takes in any of the following arguments:
RestOpContext.Builder- The builder for the object.- Any beans found in the specified bean store.
- Any
Optionalbeans that may or may not be found in the specified bean store.
Example:
// Our extended context class that adds a request attribute to all requests. // The attribute value is provided by an injected spring bean. public MyRestOperationContextextends RestOpContext {private final Optional<?extends Supplier<Object>>fooSupplier ;// Constructor that takes in builder and optional injected attribute provider. public MyRestOperationContext(RestOpContext.Builderbuilder , Optional<AnInjectedFooSupplier>fooSupplier ) {super (builder );this .fooSupplier =fooSupplier .orElseGet(()->null ); }// Override the method used to create default request attributes. @Override protected NamedAttributeMap createDefaultRequestAttributes(Objectresource , BeanStorebeanStore , Methodmethod , RestContextcontext )throws Exception {return super .createDefaultRequestAttributes(resource ,beanStore ,method ,context ) .append(NamedAttribute.of ("foo" , ()->fooSupplier .get()); } }// Option #1 - Defined via annotation. @Rest (restOpContextClass=MyRestOperationContext.class )public class MyResource { ...// Option #2 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .methodContextClass(MyRestOperationContext.class ); }@RestGet public Object foo(RequestAttributesattributes ) {return attributes .get("foo" ); } }- Parameters:
value- The new value for this setting.
Cannot benull .- Returns:
- This object.
-
restOperations
public RestOperations.Builder restOperations(RestContext restContext) throws jakarta.servlet.ServletException Returns the REST operations list.- Parameters:
restContext- The rest context.
Cannot benull .- Returns:
- The REST operations list.
- Throws:
jakarta.servlet.ServletException- If a problem occurred instantiating one of the child rest contexts.
-
rootBeanStore
Returns the root bean store.This is the bean store inherited from the parent resource and does not include any beans added by this class.
- Returns:
- The root bean store.
-
serializerListener
RestContext configuration property: Serializer listener.Specifies the serializer listener class to use for listening to non-fatal serialization errors.
See Also:
- Parameters:
value- The new value for this setting.
Cannot benull .- Returns:
- This object.
-
serializers
Returns the serializer group sub-builder.Serializers are used to convert POJOs to HTTP response bodies based on the
Acceptheader.The default serializer set is empty. It can be overridden via any of the following:
- Injected via bean store.
- Class annotation:
@Rest(serializers) @RestInject-annotated method:
Args can be any injected bean including SerializerSet.Builder, the default builder.@RestInject public [static ] SerializerSet myMethod(<args>) {...}
See Also:
- Returns:
- The serializer group sub-builder.
-
serializers
Adds one or more serializers to this class.Equivalent to calling:
builder .serializers().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
serializers
Adds one or more serializers to this class.Equivalent to calling:
builder .serializers().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
startCallMethods
Returns the start call method list.- Returns:
- The start call method list.
-
staticFiles
Returns the static files bean creator.Used to retrieve localized files to be served up as static files through the REST API via the following predefined methods:
The static file finder can be accessed through the following methods:
The default static files finder implementation class is
BasicStaticFiles. This can be overridden via the following:-
The
@Rest(staticFiles)annotation. -
Overridden
StaticFilesimplementation class name specified indefaultClasses(). -
Type specified via
.RestContext.Builder.staticFiles().type(Class) -
Bean specified via
.RestContext.Builder.staticFiles().impl(Object)
Example:
// Create a static file finder that looks for files in the /files working subdirectory, but // overrides the find() and resolve methods for special handling of special cases and adds a // Foo header to all requests. public class MyStaticFilesextends BasicStaticFiles {public MyStaticFiles() {super ( StaticFiles .create () .dir("/files" ) .headers(BasicStringHeader.of ("Foo" ,"bar" )) ); } }@Rest (staticFiles=MyStaticFiles.class )public class MyResource {...}See Also:
- Returns:
- The static files bean creator.
-
The
-
staticFiles
Specifies the static files resource finder for this class.Equivalent to calling:
builder .staticFiles().type(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
staticFiles
Specifies the static files resource finder for this class.Equivalent to calling:
builder .staticFiles().impl(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
swaggerProvider
Returns the swagger provider sub-builder.- Returns:
- The swagger provider sub-builder.
-
swaggerProvider
Specifies the swagger provider for this class.Equivalent to calling:
builder .swaggerProvider().type(value );- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
swaggerProvider
Specifies the swagger provider for this class.Equivalent to calling:
builder .swaggerProvider().impl(value );- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
thrownStore
Returns the thrown-store sub-builder.The thrown store is an in-memory cache of thrown exceptions. It is used to store thrown exceptions when
MethodExecStats.error(Throwable)is called from theMethodExecStorebean of this resource. It can also be accessed directly viaRestContext.getThrownStore()or passed in as a parameter on aRestOp-annotated method.The default thrown store is inherited from the parent context and can be overridden via any of the following:
- Injected via bean store.
@RestInject-annotated method:
Args can be any injected bean including ThrownStore.Builder, the default builder.@RestInject public [static ] ThrownStore myMethod(<args>) {...}
See Also:
- Returns:
- The builder for the
ThrownStoreobject in the REST context.
-
thrownStore
Specifies the thrown store for this class.Equivalent to calling:
builder .thrownStore().type(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
thrownStore
Specifies the thrown store for this class.Equivalent to calling:
builder .thrownStore().impl(value );See Also:
- Parameters:
value- The new value.
Cannot benull .- Returns:
- This object.
-
type
Description 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.
If
null is set,Context.Builder.build()will throw an exception. The default constructor automatically sets this to the outer class, sonull should only be set explicitly if you want to override the default.- Overrides:
typein classContext.Builder- Parameters:
value- The context class that this builder should create.
Can benull (will causeContext.Builder.build()to throw an exception).- Returns:
- This object.
-
uriAuthority
Resource authority path.Overrides the authority path value for this resource and any child resources.
This setting is useful if you want to resolve relative URIs to absolute paths and want to explicitly specify the hostname/port.
Affects the following methods:
If you do not specify the authority, it is automatically calculated via the following:
String
scheme =request .getScheme();int port =request .getServerPort(); StringBuildersb =new StringBuilder(request .getScheme()).append("://" ).append(request .getServerName());if (! (port == 80 &&"http" .equals(scheme ) || port == 443 &&"https" .equals(scheme )))sb .append(':' ).append(port );authorityPath =sb .toString();Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest ( path="/servlet" , uriAuthority="$C{REST/authorityPathOverride,http://localhost:10000}" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .uriAuthority("http://localhost:10000" ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .uriAuthority("http://localhost:10000" ); } }See Also:
- Parameters:
value- The new value for this setting.
The default is the first value found:- System property
"RestContext.uriAuthority" - Environment variable
"RESTCONTEXT_URIAUTHORITY" null - Environment variable
Cannot benull .- System property
- Returns:
- This object.
-
uriContext
Resource context path.Overrides the context path value for this resource and any child resources.
This setting is useful if you want to use
"context:/child/path" URLs in child resource POJOs but the context path is not actually specified on the servlet container.Affects the following methods:
RestRequest.getContextPath()- Returns the overridden context path for the resource.RestRequest.getServletPath()- Includes the overridden context path for the resource.
Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest ( path="/servlet" , uriContext="$C{REST/contextPathOverride,/foo}" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .uriContext("/foo" ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .uriContext("/foo" ); } }See Also:
- Parameters:
value- The new value for this setting.
The default is the first value found:- System property
"RestContext.uriContext" - Environment variable
"RESTCONTEXT_URICONTEXT" null - Environment variable
Cannot benull .- System property
- Returns:
- This object.
-
uriRelativity
URI resolution relativity.Specifies how relative URIs should be interpreted by serializers.
See
UriResolutionfor possible values.Affects the following methods:
Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest ( path="/servlet" , uriRelativity="$C{REST/uriRelativity,PATH_INFO}" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .uriRelativity(PATH_INFO ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .uriRelativity(PATH_INFO ); } }See Also:
- Parameters:
value- The new value for this setting.
The default is the first value found:- System property
"RestContext.uriRelativity" - Environment variable
"RESTCONTEXT_URIRELATIVITY" UriRelativity.RESOURCE - Environment variable
Cannot benull .- System property
- Returns:
- This object.
-
uriResolution
URI resolution.Specifies how relative URIs should be interpreted by serializers.
See
UriResolutionfor possible values.Affects the following methods:
Example:
// Option #1 - Defined via annotation resolving to a config file setting with default value. @Rest ( path="/servlet" , uriResolution="$C{REST/uriResolution,ABSOLUTE}" )public class MyResource {// Option #2 - Defined via builder passed in through resource constructor. public MyResource(RestContext.Builderbuilder )throws Exception {// Using method on builder. builder .uriResolution(ABSOLUTE ); }// Option #3 - Defined via builder passed in through init method. @RestInit public void init(RestContext.Builderbuilder )throws Exception {builder .uriResolution(ABSOLUTE ); } }See Also:
- Parameters:
value- The new value for this setting.
The default is the first value found:- System property
"RestContext.uriResolution" - Environment variable
"RESTCONTEXT_URIRESOLUTION" UriResolution.ROOT_RELATIVE - Environment variable
Cannot benull .- System property
- Returns:
- This object.
-
varResolver
Returns the variable resolver sub-builder.The variable resolver is used to resolve string variables of the form
"$X{...}" in various places such as annotations on the REST class and methods.Can be used to add more variables or context objects to the variable resolver. These variables affect the variable resolver returned by
RestRequest.getVarResolverSession().The var resolver is created by the constructor using the
createVarResolver(BeanStore,Supplier,Class)method and is initialized with the following variables:ArgsVarCoalesceVarConfigVarEnvVariablesVarFileVarHtmlWidgetVarIfVarLenVarLocalizationVarLowerCaseVarManifestFileVarNotEmptyVarPatternExtractVarPatternMatchVarPatternReplaceVarRequestAttributeVarRequestFormDataVarRequestHeaderVarRequestPathVarRequestQueryVarRequestSwaggerVarRequestVarSerializedRequestAttrVarServletInitParamVarSubstringVarSwaggerVarSwitchVarSystemPropertiesVarUpperCaseVarUrlEncodeVarUrlVar
The default var resolver can be overridden via any of the following:
- Injected via bean store.
@RestInject-annotated methods:
Args can be any injected bean including@RestInject public [static ] VarResolver myMethod(<args>) {...}VarResolver.Builder, the default builder.
See Also:
- Returns:
- The variable resolver sub-builder.
-
vars
Adds one or more variables to the var resolver of this class.Equivalent to calling:
builder .vars().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
vars
Adds one or more variables to the var resolver of this class.Equivalent to calling:
builder .vars().add(value );See Also:
- Parameters:
value- The values to add.
Cannot containnull values.- Returns:
- This object.
-
createBeanContext
Instantiates the bean context sub-builder.- 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 bean context sub-builder.
-
createBeanStore
Creates the bean store in this builder.- Parameters:
resource- The REST servlet/bean instance that this context is defined against.- Returns:
- A new bean store builder.
-
createCallLogger
Instantiates the call logger sub-builder.See Also:
- 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 call logger sub-builder.
-
createConfig
Creates the config for this builder.See Also:
- Parameters:
beanStore- The factory used for creating beans and retrieving injected beans.resource- The REST servlet/bean instance that this context is defined against.resourceClass- The REST servlet/bean type that this context is defined against.- Returns:
- A new config.
-
createDebugEnablement
protected BeanCreator<DebugEnablement> createDebugEnablement(BeanStore beanStore, Supplier<?> resource) Instantiates the debug enablement bean creator.- 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 debug enablement bean creator.
-
createDefaultRequestAttributes
protected NamedAttributeMap createDefaultRequestAttributes(BeanStore beanStore, Supplier<?> resource) Instantiates the default request attributes sub-builder.- 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 default request attributes sub-builder.
-
createDefaultRequestHeaders
Instantiates the default request headers sub-builder.- 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 default request headers sub-builder.
-
createDefaultResponseHeaders
Instantiates the default response headers sub-builder.- 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 default response headers sub-builder.
-
createDestroyMethods
Instantiates the destroy method list.- 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 destroy method list.
-
createEncoders
Instantiates the encoder group sub-builder.See Also:
- Parameters:
resource- The REST servlet/bean instance that this context is defined against.beanStore- The factory used for creating beans and retrieving injected beans.
Created bybeanStore().- Returns:
- A new encoder group sub-builder.
-
createEndCallMethods
Instantiates the end call method list.- 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 end call method list.
-
createJsonSchemaGenerator
protected JsonSchemaGenerator.Builder createJsonSchemaGenerator(BeanStore beanStore, Supplier<?> resource) Instantiates the JSON schema generator sub-builder.See Also:
- 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 JSON schema generator sub-builder.
-
createLogger
Instantiates the logger for this resource.See Also:
- Parameters:
beanStore- The factory used for creating beans and retrieving injected beans.resource- The REST servlet/bean instance that this context is defined against.resourceClass- The REST servlet/bean class that this context is defined against.- Returns:
- A new logger.
-
createMessages
Instantiates the messages sub-builder.See Also:
- 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 messages sub-builder.
-
createMethodExecStore
Instantiates the method execution statistics store sub-builder.See Also:
- 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 method execution statistics store sub-builder.
-
createParsers
Instantiates the parser group sub-builder.See Also:
- Parameters:
resource- The REST servlet/bean instance that this context is defined against.beanStore- The factory used for creating beans and retrieving injected beans.
Created bybeanStore().- Returns:
- A new parser group sub-builder.
-
createPartParser
Instantiates the part parser sub-builder.See Also:
- 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 part parser sub-builder.
-
createPartSerializer
protected HttpPartSerializer.Creator createPartSerializer(BeanStore beanStore, Supplier<?> resource) Instantiates the part serializer sub-builder.See Also:
- 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 part serializer sub-builder.
-
createPostCallMethods
Instantiates the post-call method list.- 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 post-call method list.
-
createPostInitChildFirstMethods
Instantiates the post-init-child-first method list.- 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 post-init-child-first method list.
-
createPostInitMethods
Instantiates the post-init method list.- 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 post-init method list.
-
createPreCallMethods
Instantiates the pre-call method list.- 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 pre-call method list.
-
createResponseProcessors
protected ResponseProcessorList.Builder createResponseProcessors(BeanStore beanStore, Supplier<?> resource) Instantiates the response processor list sub-builder.See Also:
- 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 processor list sub-builder.
-
createRestChildren
protected RestChildren.Builder createRestChildren(BeanStore beanStore, Supplier<?> resource, RestContext restContext) throws Exception Instantiates the REST children list.- Parameters:
restContext- The rest context.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 REST children list.
- Throws:
Exception- If a problem occurred instantiating one of the child rest contexts.
-
createRestOpArgs
Instantiates the REST operation args sub-builder.Instantiates based on the following logic:
- Looks for REST op args set via any of the following:
- Looks for a static or non-static
createRestParams() method that returns .Class[] - Resolves it via the bean store registered in this context.
- Instantiates a default set of parameters.
- 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 REST operation args sub-builder.
-
createRestOperations
protected RestOperations.Builder createRestOperations(BeanStore beanStore, Supplier<?> resource, RestContext restContext) throws jakarta.servlet.ServletException Instantiates the REST operations list.The set of
RestOpContextobjects that represent the methods on this resource.- Parameters:
restContext- The rest context.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 REST operations list.
- Throws:
jakarta.servlet.ServletException- If a problem occurred instantiating one of the child rest contexts.
-
createSerializers
Instantiates the serializer group sub-builder.See Also:
- Parameters:
resource- The REST servlet/bean instance that this context is defined against.beanStore- The factory used for creating beans and retrieving injected beans.
Created bybeanStore().- Returns:
- A new serializer group sub-builder.
-
createStartCallMethods
Instantiates the start call method list.- 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 start call method list.
-
createStaticFiles
Instantiates the static files bean creator.See Also:
- 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 static files sub-builder.
-
createSwaggerProvider
protected BeanCreator<SwaggerProvider> createSwaggerProvider(BeanStore beanStore, Supplier<?> resource) Instantiates the swagger provider sub-builder.Instantiates based on the following logic:
- Returns the resource class itself is an instance of
SwaggerProvider. - Looks for swagger provider set via any of the following:
- Looks for a static or non-static
createSwaggerProvider() method that returnsSwaggerProvideron the resource class with any of the following arguments: - Resolves it via the bean store registered in this context.
- Instantiates a default
BasicSwaggerProvider.
See Also:
- 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 swagger provider sub-builder.
- Returns the resource class itself is an instance of
-
createThrownStore
protected ThrownStore.Builder createThrownStore(BeanStore beanStore, Supplier<?> resource, RestContext parent) Instantiates the thrown-store sub-builder.See Also:
- Parameters:
resource- The REST servlet/bean instance that this context is defined against.parent- The parent context if the REST bean was registered viaRest.children().
Will benull if the bean is a top-level resource.beanStore- The factory used for creating beans and retrieving injected beans.
Created bybeanStore().- Returns:
- A new thrown-store sub-builder.
-
createVarResolver
protected VarResolver.Builder createVarResolver(BeanStore beanStore, Supplier<?> resource, Class<?> resourceClass) Creates the variable resolver sub-builder.See Also:
- Parameters:
beanStore- The factory used for creating beans and retrieving injected beans.resource- The REST servlet/bean instance that this context is defined against.resourceClass- The REST servlet/bean type that this context is defined against.- Returns:
- A new variable resolver sub-builder.
-