public class RestContextBuilder extends BeanContextBuilder implements javax.servlet.ServletConfig
RestServlet
or @RestResource
annotated object.
An extension of the ServletConfig
object used during servlet initialization.
Provides access to the following initialized resources:
getConfig()
- The external configuration for this resource.
getProperties()
- The modifiable configuration properties for this resource.
getVarResolverBuilder()
- The variable resolver for this resource.
Methods are provided for overriding or augmenting the information provided by the
To interact with this object, simply pass it in as a constructor argument or in an INIT hook.
psb
Constructor and Description |
---|
RestContextBuilder(javax.servlet.ServletConfig config,
Class<?> resourceClass)
Deprecated.
Unused.
|
Modifier and Type | Method and Description |
---|---|
RestContextBuilder |
add(Map<String,Object> properties)
Adds multiple configuration properties on this object.
|
RestContextBuilder |
addTo(String name,
Object value)
Adds a value to a SET or LIST property.
|
RestContextBuilder |
addTo(String name,
String key,
Object value)
Adds or overwrites a value to a SET, LIST, or MAP property.
|
RestContextBuilder |
allowBodyParam(boolean value)
Configuration property: Allow body URL parameter.
|
RestContextBuilder |
allowedMethodParams(String... value)
Configuration property: Allowed method parameters.
|
RestContextBuilder |
allowHeaderParams(boolean value)
Configuration property: Allow header URL parameters.
|
RestContextBuilder |
apply(PropertyStore copyFrom)
Copies the settings from the specified property store into this builder.
|
RestContextBuilder |
beanClassVisibility(Visibility value)
Configuration property: Minimum bean class visibility.
|
RestContextBuilder |
beanConstructorVisibility(Visibility value)
Configuration property: Minimum bean constructor visibility.
|
RestContextBuilder |
beanDictionary(boolean append,
Object... values)
Configuration property: Bean dictionary.
|
RestContextBuilder |
beanDictionary(Class<?>... values)
Configuration property: Bean dictionary.
|
RestContextBuilder |
beanDictionary(Object... values)
Configuration property: Bean dictionary.
|
RestContextBuilder |
beanDictionaryRemove(Object... values)
Configuration property: Bean dictionary.
|
RestContextBuilder |
beanFieldVisibility(Visibility value)
Configuration property: Minimum bean field visibility.
|
RestContextBuilder |
beanFilters(boolean append,
Object... values)
Configuration property: Bean filters.
|
RestContextBuilder |
beanFilters(Class<?>... values)
Configuration property: Bean filters.
|
RestContextBuilder |
beanFilters(Object... values)
Configuration property: Bean filters.
|
RestContextBuilder |
beanFiltersRemove(Object... values)
Configuration property: Bean filters.
|
RestContextBuilder |
beanMapPutReturnsOldValue()
Configuration property: BeanMap.put() returns old property value.
|
RestContextBuilder |
beanMapPutReturnsOldValue(boolean value)
Configuration property: BeanMap.put() returns old property value.
|
RestContextBuilder |
beanMethodVisibility(Visibility value)
Configuration property: Minimum bean method visibility.
|
RestContextBuilder |
beansRequireDefaultConstructor()
Configuration property: Beans require no-arg constructors.
|
RestContextBuilder |
beansRequireDefaultConstructor(boolean value)
Configuration property: Beans require no-arg constructors.
|
RestContextBuilder |
beansRequireSerializable()
Configuration property: Beans require Serializable interface.
|
RestContextBuilder |
beansRequireSerializable(boolean value)
Configuration property: Beans require Serializable interface.
|
RestContextBuilder |
beansRequireSettersForGetters()
Configuration property: Beans require setters for getters.
|
RestContextBuilder |
beansRequireSettersForGetters(boolean value)
Configuration property: Beans require setters for getters.
|
RestContextBuilder |
beansRequireSomeProperties(boolean value)
Configuration property: Beans require at least one property.
|
RestContextBuilder |
beanTypePropertyName(String value)
Configuration property: Bean type property name.
|
RestContext |
build()
Build the object.
|
RestContextBuilder |
callHandler(Class<? extends RestCallHandler> value)
Configuration property: REST call handler.
|
RestContextBuilder |
callHandler(RestCallHandler value)
Configuration property: REST call handler.
|
RestContextBuilder |
child(String path,
Object child)
Configuration property: Children.
|
RestContextBuilder |
children(Class<?>... values)
Configuration property: Children.
|
RestContextBuilder |
children(Object... values)
Configuration property: Children.
|
RestContextBuilder |
classpathResourceFinder(Class<? extends ClasspathResourceFinder> value)
Configuration property: Classpath resource finder.
|
RestContextBuilder |
classpathResourceFinder(ClasspathResourceFinder value)
Configuration property: Classpath resource finder.
|
RestContextBuilder |
clientVersionHeader(String value)
Configuration property: Client version header.
|
RestContextBuilder |
config(Config config)
Overwrites the default config file with a custom config file.
|
RestContextBuilder |
consumes(boolean append,
MediaType... values)
Configuration property: Supported content media types.
|
RestContextBuilder |
consumes(boolean append,
String... values)
Configuration property: Supported content media types.
|
RestContextBuilder |
contextPath(String value)
Deprecated.
Use
uriContext(String) . |
RestContextBuilder |
converters(Class<?>... values)
Configuration property: Class-level response converters.
|
RestContextBuilder |
converters(RestConverter... values)
Configuration property: Response converters.
|
protected PropertyStoreBuilder |
createPropertyStore()
Creates a new
PropertyStore object initialized with the properties defined in this config. |
RestContextBuilder |
debug()
Configuration property: Debug mode.
|
RestContextBuilder |
debug(boolean value)
Configuration property: Debug mode.
|
RestContextBuilder |
defaultAccept(String value)
Specifies a default
Accept header value if not specified on a request. |
RestContextBuilder |
defaultCharset(Charset value)
Configuration property: Default character encoding.
|
RestContextBuilder |
defaultCharset(String value)
Configuration property: Default character encoding.
|
RestContextBuilder |
defaultContentType(String value)
Specifies a default
Content-Type header value if not specified on a request. |
RestContextBuilder |
defaultRequestHeader(String name,
Object value)
Configuration property: Default request headers.
|
RestContextBuilder |
defaultRequestHeaders(String... headers)
Configuration property: Default request headers.
|
RestContextBuilder |
defaultResponseHeader(String name,
Object value)
Configuration property: Default response headers.
|
RestContextBuilder |
defaultResponseHeaders(String... headers)
Configuration property: Default response headers.
|
RestContextBuilder |
encoders(Class<?>... values)
Configuration property: Compression encoders.
|
RestContextBuilder |
encoders(Encoder... values)
Configuration property: Compression encoders.
|
<T> RestContextBuilder |
example(Class<T> c,
T o)
Configuration property: POJO example.
|
Config |
getConfig()
Returns the external configuration file for this resource.
|
HtmlDocBuilder |
getHtmlDocBuilder()
Returns an instance of an HTMLDOC builder for setting HTMLDOC-related properties.
|
String |
getInitParameter(String name) |
Enumeration<String> |
getInitParameterNames() |
RestContextProperties |
getProperties()
Returns the configuration properties for this resource.
|
javax.servlet.ServletContext |
getServletContext() |
String |
getServletName() |
VarResolverBuilder |
getVarResolverBuilder()
Creates the variable resolver for this resource.
|
RestContextBuilder |
guards(Class<?>... values)
Configuration property: Class-level guards.
|
RestContextBuilder |
guards(RestGuard... values)
Configuration property: Class-level guards.
|
RestContextBuilder |
ignoreInvocationExceptionsOnGetters()
Configuration property: Ignore invocation errors on getters.
|
RestContextBuilder |
ignoreInvocationExceptionsOnGetters(boolean value)
Configuration property: Ignore invocation errors on getters.
|
RestContextBuilder |
ignoreInvocationExceptionsOnSetters()
Configuration property: Ignore invocation errors on setters.
|
RestContextBuilder |
ignoreInvocationExceptionsOnSetters(boolean value)
Configuration property: Ignore invocation errors on setters.
|
RestContextBuilder |
ignorePropertiesWithoutSetters(boolean value)
Configuration property: Ignore properties without setters.
|
RestContextBuilder |
ignoreUnknownBeanProperties()
Configuration property: Ignore unknown properties.
|
RestContextBuilder |
ignoreUnknownBeanProperties(boolean value)
Configuration property: Ignore unknown properties.
|
RestContextBuilder |
ignoreUnknownNullBeanProperties(boolean value)
Configuration property: Ignore unknown properties with null values.
|
<T> RestContextBuilder |
implClass(Class<T> interfaceClass,
Class<? extends T> implClass)
Configuration property: Implementation classes.
|
RestContextBuilder |
implClasses(Map<String,Class<?>> values)
Configuration property: Implementation classes.
|
RestContextBuilder |
infoProvider(Class<? extends RestInfoProvider> value)
Configuration property: REST info provider.
|
RestContextBuilder |
infoProvider(RestInfoProvider value)
Configuration property: REST info provider.
|
RestContextBuilder |
locale(Locale value)
Configuration property: Locale.
|
RestContextBuilder |
logger(Class<? extends RestLogger> value)
Configuration property: REST logger.
|
RestContextBuilder |
logger(RestLogger value)
Configuration property: REST logger.
|
RestContextBuilder |
maxInput(String value)
Configuration property: The maximum allowed input size (in bytes) on HTTP requests.
|
RestContextBuilder |
mediaType(MediaType value)
Configuration property: Media type.
|
RestContextBuilder |
messages(Class<?> baseClass,
String bundlePath)
Configuration property: Messages.
|
RestContextBuilder |
messages(MessageBundleLocation... values)
Configuration property: Messages.
|
RestContextBuilder |
messages(String bundlePath)
Configuration property: Messages.
|
RestContextBuilder |
mimeTypes(String... values)
Configuration property: MIME types.
|
RestContextBuilder |
notBeanClasses(boolean append,
Object... values)
Configuration property: Bean class exclusions.
|
RestContextBuilder |
notBeanClasses(Class<?>... values)
Configuration property: Bean class exclusions.
|
RestContextBuilder |
notBeanClasses(Object... values)
Configuration property: Bean class exclusions.
|
RestContextBuilder |
notBeanClassesRemove(Object... values)
Configuration property: Bean class exclusions.
|
RestContextBuilder |
notBeanPackages(boolean append,
Object... values)
Configuration property: Bean package exclusions.
|
RestContextBuilder |
notBeanPackages(Object... values)
Configuration property: Bean package exclusions.
|
RestContextBuilder |
notBeanPackages(String... values)
Configuration property: Bean package exclusions.
|
RestContextBuilder |
notBeanPackagesRemove(Object... values)
Configuration property: Bean package exclusions.
|
RestContextBuilder |
paramResolvers(Class<? extends RestMethodParam>... values)
Configuration property: Java method parameter resolvers.
|
RestContextBuilder |
paramResolvers(RestMethodParam... values)
Configuration property: Java method parameter resolvers.
|
RestContextBuilder |
paramResolvers(RestParam... values)
Deprecated.
|
RestContextBuilder |
parserListener(Class<? extends ParserListener> value)
Configuration property: Parser listener.
|
RestContextBuilder |
parsers(boolean append,
Object... values)
Configuration property: Parsers.
|
RestContextBuilder |
parsers(Class<?>... values)
Configuration property: Parsers.
|
RestContextBuilder |
parsers(Object... values)
Configuration property: Parsers.
|
RestContextBuilder |
partParser(Class<? extends HttpPartParser> value)
Configuration property: HTTP part parser.
|
RestContextBuilder |
partParser(HttpPartParser value)
Configuration property: HTTP part parser.
|
RestContextBuilder |
partSerializer(Class<? extends HttpPartSerializer> value)
Configuration property: HTTP part serializer.
|
RestContextBuilder |
partSerializer(HttpPartSerializer value)
Configuration property: HTTP part serializer.
|
RestContextBuilder |
path(String value)
Configuration property: Resource path.
|
RestContextBuilder |
pojoSwaps(boolean append,
Object... values)
Configuration property: POJO swaps.
|
RestContextBuilder |
pojoSwaps(Class<?>... values)
Configuration property: POJO swaps.
|
RestContextBuilder |
pojoSwaps(Object... values)
Configuration property: POJO swaps.
|
RestContextBuilder |
pojoSwapsRemove(Object... values)
Configuration property: POJO swaps.
|
RestContextBuilder |
produces(boolean append,
MediaType... values)
Configuration property: Supported accept media types.
|
RestContextBuilder |
produces(boolean append,
String... values)
Configuration property: Supported accept media types.
|
RestContextBuilder |
removeFrom(String name,
Object value)
Removes a value from a SET, LIST, or MAP property.
|
RestContextBuilder |
renderResponseStackTraces()
Configuration property: Render response stack traces in responses.
|
RestContextBuilder |
renderResponseStackTraces(boolean value)
Configuration property: Render response stack traces in responses.
|
RestContextBuilder |
resourceResolver(Class<? extends RestResourceResolver> value)
REST resource resolver.
|
RestContextBuilder |
resourceResolver(RestResourceResolver value)
REST resource resolver.
|
RestContextBuilder |
responseHandlers(Class<?>... values)
Configuration property: Response handlers.
|
RestContextBuilder |
responseHandlers(ResponseHandler... values)
Configuration property: Response handlers.
|
RestContextBuilder |
serializerListener(Class<? extends SerializerListener> value)
Configuration property: Serializer listener.
|
RestContextBuilder |
serializers(boolean append,
Object... values)
Configuration property: Serializers.
|
RestContextBuilder |
serializers(Class<?>... values)
Configuration property: Serializers.
|
RestContextBuilder |
serializers(Object... values)
Configuration property: Serializers.
|
RestContextBuilder |
set(boolean append,
String name,
Object value)
Sets or adds to a SET or LIST property.
|
RestContextBuilder |
set(Map<String,Object> properties)
Sets multiple configuration properties on this object.
|
RestContextBuilder |
set(String name,
Object value)
Sets a configuration property on this object.
|
RestContextBuilder |
sortProperties()
Configuration property: Sort bean properties.
|
RestContextBuilder |
sortProperties(boolean value)
Configuration property: Sort bean properties.
|
RestContextBuilder |
staticFileResponseHeader(String name,
String value)
Configuration property: Static file response headers.
|
RestContextBuilder |
staticFileResponseHeaders(boolean append,
Map<String,String> headers)
Configuration property: Static file response headers.
|
RestContextBuilder |
staticFileResponseHeaders(String... headers)
Configuration property: Static file response headers.
|
RestContextBuilder |
staticFiles(Class<?> baseClass,
String mappingString)
Configuration property: Static file mappings.
|
RestContextBuilder |
staticFiles(Class<?> baseClass,
String path,
String location)
Configuration property: Static file mappings.
|
RestContextBuilder |
staticFiles(StaticFileMapping... values)
Configuration property: Static file mappings.
|
RestContextBuilder |
staticFiles(String mappingString)
Configuration property: Static file mappings.
|
RestContextBuilder |
staticFiles(String path,
String location)
Configuration property: Static file mappings.
|
RestContextBuilder |
timeZone(TimeZone value)
Configuration property: TimeZone.
|
RestContextBuilder |
uriAuthority(String value)
Configuration property: Resource authority path.
|
RestContextBuilder |
uriContext(String value)
Configuration property: Resource context path.
|
RestContextBuilder |
uriRelativity(String value)
Configuration property: URI resolution relativity.
|
RestContextBuilder |
uriResolution(String value)
Configuration property: URI resolution.
|
RestContextBuilder |
useClasspathResourceCaching(boolean value)
Configuration property: Use classpath resource caching.
|
RestContextBuilder |
useEnumNames()
Configuration property: Use enum names.
|
RestContextBuilder |
useInterfaceProxies(boolean value)
Configuration property: Use interface proxies.
|
RestContextBuilder |
useJavaBeanIntrospector()
Configuration property: Use Java Introspector.
|
RestContextBuilder |
useJavaBeanIntrospector(boolean value)
Configuration property: Use Java Introspector.
|
RestContextBuilder |
useStackTraceHashes(boolean value)
Configuration property: Use stack trace hashes.
|
RestContextBuilder |
varContextObject(String name,
Object object)
Adds a var context object to this config.
|
RestContextBuilder |
vars(Class<?>... vars)
Adds the specified
Var classes to this config. |
RestContextBuilder |
widgets(boolean append,
Widget... values)
Configuration property: HTML Widgets.
|
RestContextBuilder |
widgets(Class<? extends Widget>... values)
Configuration property: HTML Widgets.
|
RestContextBuilder |
widgets(Widget... values)
Configuration property: HTML Widgets.
|
excludeProperties, excludeProperties, excludeProperties, fluentSetters, fluentSetters, includeProperties, includeProperties, includeProperties, propertyNamer
build, getPropertyStore, getPropertyStoreBuilder
@Deprecated public RestContextBuilder(javax.servlet.ServletConfig config, Class<?> resourceClass) throws javax.servlet.ServletException
javax.servlet.ServletException
public RestContext build()
ContextBuilder
build
in class BeanContextBuilder
public RestContextBuilder vars(Class<?>... vars)
Var
classes to this config.
These variables affect the variable resolver returned by RestRequest.getVarResolverSession()
which is
used to resolve string variables of the form
See RestContext.getVarResolver()
for a list of predefined variables.
vars
- The Var
classes to add to this config.public RestContextBuilder varContextObject(String name, Object object)
Var context objects are read-only objects associated with the variable resolver for vars that require external information.
For example, the ConfigVar
needs access to this resource's Config
through the
ConfigVar.SESSION_config
object that can be specified as either a session object (temporary) or
context object (permanent).
In this case, we call the following code to add it to the context map:
config.addVarContextObject(
name
- The context object key (i.e. the name that the Var class looks for).object
- The context object.public RestContextBuilder config(Config config)
By default, the config file is determined using the @RestResource(config)
annotation.
This method allows you to programmatically override it with your own custom config file.
config
- The new config file.public HtmlDocBuilder getHtmlDocBuilder()
protected PropertyStoreBuilder createPropertyStore()
PropertyStore
object initialized with the properties defined in this config.public Config getConfig()
The configuration file location is determined via the @RestResource(config)
annotation on the resource.
The config file can be programmatically overridden by adding the following method to your resource:
If a config file is not set up, then an empty config file will be returned that is not backed by any file.
public RestContextProperties getProperties()
The configuration properties are determined via the @RestResource(properties)
annotation on the resource.
The configuration properties can be augmented programmatically by adding the following method to your resource:
These properties can be modified during servlet initialization.
However, any modifications made after RestServlet.init(ServletConfig)
has been called will have no effect.
public VarResolverBuilder getVarResolverBuilder()
The variable resolver returned by this method can resolve the following variables:
Note that the variables supported here are only a subset of those returned by
RestRequest.getVarResolverSession()
.
public RestContextBuilder allowBodyParam(boolean value)
When enabled, the HTTP body content on PUT and POST requests can be passed in as text using the
For example:
?body=(name='John%20Smith',age=45)
value
- The new value for this setting.
public RestContextBuilder allowedMethodParams(String... value)
When specified, the HTTP method can be overridden by passing in a
For example:
?method=OPTIONS
value
- The new value for this setting.
["HEAD" ,"OPTIONS" ]
.
public RestContextBuilder allowHeaderParams(boolean value)
When enabled, headers such as
For example:
?Accept=text/json&Content-Type=text/json
value
- The new value for this setting.
public RestContextBuilder callHandler(Class<? extends RestCallHandler> value)
This class handles the basic lifecycle of an HTTP REST call.
Subclasses can be used to customize how these HTTP calls are handled.
value
- The new value for this setting.
BasicRestCallHandler
.public RestContextBuilder callHandler(RestCallHandler value)
Same as callHandler(Class)
except input is a pre-constructed instance.
value
- The new value for this setting.
BasicRestCallHandler
.public RestContextBuilder children(Class<?>... values)
Defines children of this resource.
A REST child resource is simply another servlet that is initialized as part of the parent resource and has a servlet path directly under the parent servlet path.
values
- The values to add to this setting.public RestContextBuilder children(Object... values)
Same as children(Class...)
except input is pre-constructed instances.
values
- The values to add to this setting.public RestContextBuilder child(String path, Object child)
Shortcut for adding a single child to this resource.
This can be used for resources that don't have a @RestResource(path)
annotation.
path
- The child path relative to the parent resource URI.child
- The child to add to this resource.public RestContextBuilder classpathResourceFinder(Class<? extends ClasspathResourceFinder> value)
Used to retrieve localized files from the classpath.
value
- The new value for this setting.
ClasspathResourceFinderBasic
.public RestContextBuilder classpathResourceFinder(ClasspathResourceFinder value)
Same as classpathResourceFinder(ClasspathResourceFinder)
except input is a pre-constructed instance.
value
- The new value for this setting.
ClasspathResourceFinderBasic
.public RestContextBuilder clientVersionHeader(String value)
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 @RestMethod(clientVersion)
annotation.
value
- The new value for this setting.
public RestContextBuilder converters(Class<?>... values)
Associates one or more converters
with a resource class.
values
- The values to add to this setting.public RestContextBuilder converters(RestConverter... values)
Same as converters(Class...)
except input is pre-constructed instances.
values
- The values to add to this setting.public RestContextBuilder debug(boolean value)
debug
in class BeanContextBuilder
value
- The new value for this setting.public RestContextBuilder defaultCharset(String value)
The default character encoding for the request and response if not specified on the request.
value
- The new value for this setting.
public RestContextBuilder defaultCharset(Charset value)
Same as defaultCharset(Charset)
but takes in an instance of Charset
.
value
- The new value for this setting.
public RestContextBuilder defaultRequestHeaders(String... headers) throws RestServletException
Specifies default values for request headers if they're not passed in through the request.
headers
- The headers in the format RestServletException
- If malformed header is found.public RestContextBuilder defaultAccept(String value)
Accept
header value if not specified on a request.value
- The default value of the Accept
header.
public RestContextBuilder defaultContentType(String value)
Content-Type
header value if not specified on a request.value
- The default value of the Content-Type
header.
public RestContextBuilder defaultRequestHeader(String name, Object value)
Same as defaultRequestHeaders(String...)
but adds a single header name/value pair.
name
- The HTTP header name.value
- The HTTP header value.public RestContextBuilder defaultResponseHeaders(String... headers) throws RestServletException
Specifies default values for response headers if they're not set after the Java REST method is called.
headers
- The headers in the format RestServletException
- If malformed header is found.public RestContextBuilder defaultResponseHeader(String name, Object value)
Same as defaultResponseHeaders(String...)
but adds a single header name/value pair.
name
- The HTTP header name.value
- The HTTP header value.public RestContextBuilder encoders(Class<?>... values)
These can be used to enable various kinds of compression (e.g.
values
- The values to add to this setting.public RestContextBuilder encoders(Encoder... values)
Same as encoders(Class...)
except input a pre-constructed instances.
values
- The values to add to this setting.public RestContextBuilder guards(Class<?>... values)
Associates one or more RestGuards
with all REST methods defined in this class.
values
- The values to add to this setting.public RestContextBuilder guards(RestGuard... values)
Same as guards(Class...)
except input is pre-constructed instances.
values
- The values to add to this setting.public RestContextBuilder infoProvider(Class<? extends RestInfoProvider> value)
Class used to retrieve title/description/swagger information about a resource.
value
- The new value for this setting.
BasicRestInfoProvider
.public RestContextBuilder infoProvider(RestInfoProvider value)
Same as infoProvider(Class)
except input is a pre-constructed instance.
value
- The new value for this setting.
BasicRestInfoProvider
.public RestContextBuilder logger(Class<? extends RestLogger> value)
Specifies the logger to use for logging.
value
- The new value for this setting.
BasicRestLogger
.
public RestContextBuilder logger(RestLogger value)
Same as logger(Class)
except input is a pre-constructed instance.
value
- The new value for this setting.
BasicRestLogger
.
public RestContextBuilder maxInput(String value)
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.
value
- The new value for this setting.
public RestContextBuilder messages(MessageBundleLocation... values)
Identifies the location of the resource bundle for this class.
values
- The values to add to this setting.public RestContextBuilder messages(Class<?> baseClass, String bundlePath)
Same as messages(MessageBundleLocation...)
except allows you to pass in the base class and bundle
path separately.
baseClass
- The base class that the bundle path is relative to.
bundlePath
- The bundle path relative to the base class.public RestContextBuilder messages(String bundlePath)
Same as messages(Class,String)
except assumes the base class is the resource class itself.
bundlePath
- The bundle path relative to the base class.public RestContextBuilder mimeTypes(String... values)
Defines MIME-type file type mappings.
values
- The values to add to this setting.public RestContextBuilder paramResolvers(Class<? extends RestMethodParam>... values)
By default, the Juneau framework will automatically Java method parameters of various types (e.g.
RestRequest
, Accept
, Reader
).
This annotation allows you to provide your own resolvers for your own class types that you want resolved.
values
- The values to add to this setting.public RestContextBuilder paramResolvers(RestMethodParam... values)
Same as paramResolvers(Class...)
except input is pre-constructed instances.
values
- The values to add to this setting.public RestContextBuilder parserListener(Class<? extends ParserListener> value)
Specifies the parser listener class to use for listening to non-fatal parsing errors.
value
- The new value for this setting.public RestContextBuilder parsers(Class<?>... values)
Adds class-level parsers to this resource.
values
- The values to add to this setting.public RestContextBuilder parsers(boolean append, Object... values)
Same as parsers(Class...)
except allows you to overwrite the previous value.
append
- If values
- The values to add to this setting.public RestContextBuilder parsers(Object... values)
Same as parsers(Class...)
except input is pre-constructed instances.
Parser instances are considered set-in-stone and do NOT inherit properties and transforms defined on the resource class or method.
values
- The values to add to this setting.public RestContextBuilder partParser(Class<? extends HttpPartParser> value)
Specifies the HttpPartParser
to use for parsing headers, query/form parameters, and URI parts.
value
- The new value for this setting.
OpenApiParser
.public RestContextBuilder partParser(HttpPartParser value)
Same as partParser(Class)
except input is a pre-constructed instance.
value
- The new value for this setting.
OpenApiParser
.public RestContextBuilder partSerializer(Class<? extends HttpPartSerializer> value)
Specifies the HttpPartSerializer
to use for serializing headers, query/form parameters, and URI parts.
value
- The new value for this setting.
OpenApiSerializer
.public RestContextBuilder partSerializer(HttpPartSerializer value)
Same as partSerializer(Class)
except input is a pre-constructed instance.
value
- The new value for this setting.
OpenApiSerializer
.public RestContextBuilder path(String value)
Identifies the URL subpath relative to the parent resource.
value
- The new value for this setting.public RestContextBuilder renderResponseStackTraces(boolean value)
Render stack traces in HTTP response bodies when errors occur.
value
- The new value for this setting.
public RestContextBuilder renderResponseStackTraces()
Shortcut for calling renderResponseStackTraces(
.
public RestContextBuilder resourceResolver(Class<? extends RestResourceResolver> value)
The resolver used for resolving child resources.
Can be used to provide customized resolution of REST resource class instances (e.g. resources retrieve from Spring).
value
- The new value for this setting.
BasicRestResourceResolver
.public RestContextBuilder resourceResolver(RestResourceResolver value)
Same as resourceResolver(Class)
except input is a pre-constructed instance.
value
- The new value for this setting.
BasicRestResourceResolver
.public RestContextBuilder responseHandlers(Class<?>... values)
Specifies a list of ResponseHandler
classes that know how to convert POJOs returned by REST methods or
set via RestResponse.setOutput(Object)
into appropriate HTTP responses.
values
- The values to add to this setting.public RestContextBuilder responseHandlers(ResponseHandler... values)
Same as responseHandlers(Class...)
except input is pre-constructed instances.
values
- The values to add to this setting.public RestContextBuilder serializerListener(Class<? extends SerializerListener> value)
Specifies the serializer listener class to use for listening to non-fatal serialization errors.
value
- The new value for this setting.public RestContextBuilder serializers(Class<?>... values)
Adds class-level serializers to this resource.
values
- The values to add to this setting.public RestContextBuilder serializers(boolean append, Object... values)
Same as serializers(Class...)
except allows you to overwrite the previous value.
append
- If values
- The values to add to this setting.public RestContextBuilder serializers(Object... values)
Same as serializers(Class...)
except input is pre-constructed instances.
Serializer instances are considered set-in-stone and do NOT inherit properties and transforms defined on the resource class or method.
values
- The values to add to this setting.public RestContextBuilder staticFileResponseHeaders(boolean append, Map<String,String> headers)
Used to customize the headers on responses returned for statically-served files.
append
- If headers
- The headers to add to this list.
{'Cache-Control' : 'max-age=86400, public }
.public RestContextBuilder staticFileResponseHeaders(String... headers) throws RestServletException
Same as staticFileResponseHeaders(boolean, Map)
with append=
headers
- The headers in the format RestServletException
- If malformed header is found.public RestContextBuilder staticFileResponseHeader(String name, String value)
Same as staticFileResponseHeaders(String...)
except header is broken into name/value pair.
name
- The HTTP header name.value
- The HTTP header value.public RestContextBuilder staticFiles(StaticFileMapping... values)
Used to define paths and locations of statically-served files such as images or HTML documents.
values
- The values to append to this setting.public RestContextBuilder staticFiles(String mappingString)
Same as staticFiles(StaticFileMapping...)
except input is in the form of a mapping string.
Mapping string must be one of these formats:
mappingString
- The static file mapping string.public RestContextBuilder staticFiles(Class<?> baseClass, String mappingString)
Same as staticFiles(String)
except overrides the base class for retrieving the resource.
Mapping string must be one of these formats:
baseClass
- Overrides the default class to use for retrieving the classpath resource.
mappingString
- The static file mapping string.public RestContextBuilder staticFiles(String path, String location)
Same as staticFiles(String)
except path and location are already split values.
path
- The mapped URI path.
location
- The location relative to the resource class.
public RestContextBuilder staticFiles(Class<?> baseClass, String path, String location)
Same as staticFiles(String,String)
except overrides the base class for retrieving the resource.
baseClass
- Overrides the default class to use for retrieving the classpath resource.
path
- The mapped URI path.
location
- The location relative to the resource class.
public RestContextBuilder produces(boolean append, String... values)
Overrides the media types inferred from the serializers that identify what media types can be produced by the resource.
append
- If values
- The values to add to this setting.public RestContextBuilder produces(boolean append, MediaType... values)
Same as produces(boolean, String...)
except input is MediaType
instances.
append
- If values
- The values to add to this setting.public RestContextBuilder consumes(boolean append, String... values)
Overrides the media types inferred from the parsers that identify what media types can be consumed by the resource.
append
- If values
- The values to add to this setting.public RestContextBuilder consumes(boolean append, MediaType... values)
Same as consumes(boolean, String...)
except input is MediaType
instances.
append
- If values
- The values to add to this setting.public RestContextBuilder uriAuthority(String value)
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.
value
- The new value for this setting.public RestContextBuilder uriContext(String value)
Overrides the context path value for this resource and any child resources.
This setting is useful if you want to use
value
- The new value for this setting.public RestContextBuilder uriRelativity(String value)
Specifies how relative URIs should be interpreted by serializers.
See UriResolution
for possible values.
value
- The new value for this setting.public RestContextBuilder uriResolution(String value)
Specifies how relative URIs should be interpreted by serializers.
See UriResolution
for possible values.
value
- The new value for this setting.public RestContextBuilder useClasspathResourceCaching(boolean value)
When enabled, resources retrieved via RestContext.getClasspathResource(String, Locale)
(and related
methods) will be cached in memory to speed subsequent lookups.
value
- The new value for this setting.
public RestContextBuilder useStackTraceHashes(boolean value)
When enabled, the number of times an exception has occurred will be determined based on stack trace hashsums,
made available through the RestException.getOccurrence()
method.
value
- The new value for this setting.
public RestContextBuilder widgets(Class<? extends Widget>... values)
Defines widgets that can be used in conjunction with string variables of the form
values
- The values to add to this setting.public RestContextBuilder widgets(Widget... values)
Same as widgets(Class...)
except input is pre-constructed instances.
values
- The values to add to this setting.public RestContextBuilder widgets(boolean append, Widget... values)
Same as widgets(Widget...)
except allows you to overwrite the previous value.
append
- If values
- The values to add to this setting.public RestContextBuilder beanClassVisibility(Visibility value)
BeanContextBuilder
Classes are not considered beans unless they meet the minimum visibility requirements.
For example, if the visibility is PUBLIC
and the bean class is
beanClassVisibility
in class BeanContextBuilder
value
- The new value for this property.
Visibility.PUBLIC
.public RestContextBuilder beanConstructorVisibility(Visibility value)
BeanContextBuilder
Only look for constructors with the specified minimum visibility.
beanConstructorVisibility
in class BeanContextBuilder
value
- The new value for this property.
Visibility.PUBLIC
.public RestContextBuilder beanDictionary(boolean append, Object... values)
BeanContextBuilder
Same as BeanContextBuilder.beanDictionary(Object...)
but allows you to optionally overwrite the previous value.
beanDictionary
in class BeanContextBuilder
append
- If values
- The new values for this property.public RestContextBuilder beanDictionary(Class<?>... values)
BeanContextBuilder
Same as BeanContextBuilder.beanDictionary(Object...)
but takes in an array of classes.
beanDictionary
in class BeanContextBuilder
values
- The values to add to this property.public RestContextBuilder beanDictionary(Object... values)
BeanContextBuilder
Adds to the list of classes that make up the bean dictionary in this bean context.
beanDictionary
in class BeanContextBuilder
values
- The values to add to this property.public RestContextBuilder beanDictionaryRemove(Object... values)
BeanContextBuilder
Removes from the list of classes that make up the bean dictionary in this bean context.
beanDictionaryRemove
in class BeanContextBuilder
values
- The values to remove from this property.public RestContextBuilder beanFieldVisibility(Visibility value)
BeanContextBuilder
Only look for bean fields with the specified minimum visibility.
beanFieldVisibility
in class BeanContextBuilder
value
- The new value for this property.
Visibility.PUBLIC
.public RestContextBuilder beanFilters(boolean append, Object... values)
BeanContextBuilder
Same as BeanContextBuilder.beanFilters(Object...)
but allows you to optionally overwrite the previous value.
beanFilters
in class BeanContextBuilder
append
- If values
- The new values for this property.
@Bean(typeName)
.
BeanDictionaryList
containing a collection of bean classes with type name annotations.
BeanDictionaryMap
containing a mapping of type names to classes without type name annotations.
public RestContextBuilder beanFilters(Class<?>... values)
BeanContextBuilder
Same as BeanContextBuilder.beanFilters(Object...)
but takes in an array of classes.
beanFilters
in class BeanContextBuilder
values
- The values to add to this property.public RestContextBuilder beanFilters(Object... values)
BeanContextBuilder
This is a programmatic equivalent to the @Bean
annotation.
It's useful when you want to use the Bean annotation functionality, but you don't have the ability to alter
the bean classes.
beanFilters
in class BeanContextBuilder
values
- The values to add to this property.
@Bean(typeName)
.
BeanDictionaryList
containing a collection of bean classes with type name annotations.
BeanDictionaryMap
containing a mapping of type names to classes without type name annotations.
public RestContextBuilder beanFiltersRemove(Object... values)
BeanContextBuilder
Removes from the list of classes that make up the bean filters in this bean context.
beanFiltersRemove
in class BeanContextBuilder
values
- The values to remove from this property.
@Bean(typeName)
.
BeanDictionaryList
containing a collection of bean classes with type name annotations.
BeanDictionaryMap
containing a mapping of type names to classes without type name annotations.
public RestContextBuilder beanMapPutReturnsOldValue(boolean value)
BeanContextBuilder
If BeanMap.put()
method will return old property
values.
Otherwise, it returns
beanMapPutReturnsOldValue
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder beanMapPutReturnsOldValue()
BeanContextBuilder
Shortcut for calling beanMapPutReturnsOldValue(
.
beanMapPutReturnsOldValue
in class BeanContextBuilder
public RestContextBuilder beanMethodVisibility(Visibility value)
BeanContextBuilder
Only look for bean methods with the specified minimum visibility.
beanMethodVisibility
in class BeanContextBuilder
value
- The new value for this property.
Visibility.PUBLIC
public RestContextBuilder beansRequireDefaultConstructor(boolean value)
BeanContextBuilder
If
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
beansRequireDefaultConstructor
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder beansRequireDefaultConstructor()
BeanContextBuilder
Shortcut for calling beansRequireDefaultConstructor(
.
beansRequireDefaultConstructor
in class BeanContextBuilder
public RestContextBuilder beansRequireSerializable(boolean value)
BeanContextBuilder
If Serializable
interface to be considered a bean.
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
beansRequireSerializable
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder beansRequireSerializable()
BeanContextBuilder
Shortcut for calling beansRequireSerializable(
.
beansRequireSerializable
in class BeanContextBuilder
public RestContextBuilder beansRequireSettersForGetters(boolean value)
BeanContextBuilder
If
Otherwise, they will be ignored.
beansRequireSettersForGetters
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder beansRequireSettersForGetters()
BeanContextBuilder
Shortcut for calling beansRequireSettersForGetters(
.
beansRequireSettersForGetters
in class BeanContextBuilder
public RestContextBuilder beansRequireSomeProperties(boolean value)
BeanContextBuilder
If
Otherwise, the bean will be serialized as a string using the Object.toString()
method.
beansRequireSomeProperties
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder beanTypePropertyName(String value)
BeanContextBuilder
This specifies the name of the bean property used to store the dictionary name of a bean type so that the parser knows the data type to reconstruct.
beanTypePropertyName
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder debug()
BeanContextBuilder
Shortcut for calling debug(
.
debug
in class BeanContextBuilder
public <T> RestContextBuilder example(Class<T> c, T o)
BeanContextBuilder
Specifies an example of the specified class.
example
in class BeanContextBuilder
c
- The POJO class.o
- An instance of the POJO class used for examples.public RestContextBuilder ignoreInvocationExceptionsOnGetters(boolean value)
BeanContextBuilder
If BeanRuntimeException
is thrown.
ignoreInvocationExceptionsOnGetters
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder ignoreInvocationExceptionsOnGetters()
BeanContextBuilder
Shortcut for calling ignoreInvocationExceptionsOnGetters(
.
ignoreInvocationExceptionsOnGetters
in class BeanContextBuilder
public RestContextBuilder ignoreInvocationExceptionsOnSetters(boolean value)
BeanContextBuilder
If
Otherwise, a BeanRuntimeException
is thrown.
ignoreInvocationExceptionsOnSetters
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder ignoreInvocationExceptionsOnSetters()
BeanContextBuilder
Shortcut for calling ignoreInvocationExceptionsOnSetters(
.
ignoreInvocationExceptionsOnSetters
in class BeanContextBuilder
public RestContextBuilder ignorePropertiesWithoutSetters(boolean value)
BeanContextBuilder
If
Otherwise, a BeanRuntimeException
is thrown.
ignorePropertiesWithoutSetters
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder ignoreUnknownBeanProperties(boolean value)
BeanContextBuilder
If
Otherwise, a BeanRuntimeException
is thrown.
ignoreUnknownBeanProperties
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder ignoreUnknownBeanProperties()
BeanContextBuilder
Shortcut for calling ignoreUnknownBeanProperties(
.
ignoreUnknownBeanProperties
in class BeanContextBuilder
public RestContextBuilder ignoreUnknownNullBeanProperties(boolean value)
BeanContextBuilder
If
Otherwise, a BeanRuntimeException
is thrown.
ignoreUnknownNullBeanProperties
in class BeanContextBuilder
value
- The new value for this property.
public <T> RestContextBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass)
BeanContextBuilder
implClass
in class BeanContextBuilder
T
- The class type of the interface.interfaceClass
- The interface class.implClass
- The implementation class.public RestContextBuilder implClasses(Map<String,Class<?>> values)
BeanContextBuilder
For interfaces and abstract classes this method can be used to specify an implementation class for the interface/abstract class so that instances of the implementation class are used when instantiated (e.g. during a parse).
implClasses
in class BeanContextBuilder
values
- The new value for this property.public RestContextBuilder locale(Locale value)
BeanContextBuilder
Specifies a default locale for serializer and parser sessions.
locale
in class BeanContextBuilder
value
- The new value for this property.public RestContextBuilder mediaType(MediaType value)
BeanContextBuilder
Specifies a default media type value for serializer and parser sessions.
mediaType
in class BeanContextBuilder
value
- The new value for this property.public RestContextBuilder notBeanClasses(boolean append, Object... values)
BeanContextBuilder
Not-bean classes are converted to Strings
during serialization even if they appear to be
bean-like.
notBeanClasses
in class BeanContextBuilder
append
- If values
- The new value for this property.
public RestContextBuilder notBeanClasses(Class<?>... values)
BeanContextBuilder
List of classes that should not be treated as beans even if they appear to be bean-like.
Not-bean classes are converted to Strings
during serialization.
notBeanClasses
in class BeanContextBuilder
values
- The values to add to this property.public RestContextBuilder notBeanClasses(Object... values)
BeanContextBuilder
List of classes that should not be treated as beans even if they appear to be bean-like.
Not-bean classes are converted to Strings
during serialization.
notBeanClasses
in class BeanContextBuilder
values
- The values to add to this property.
public RestContextBuilder notBeanClassesRemove(Object... values)
BeanContextBuilder
notBeanClassesRemove
in class BeanContextBuilder
values
- The values to remove from this property.
public RestContextBuilder notBeanPackages(boolean append, Object... values)
BeanContextBuilder
When specified, the current list of ignore packages are appended to.
notBeanPackages
in class BeanContextBuilder
append
- If values
- The new values for this property.
public RestContextBuilder notBeanPackages(Object... values)
BeanContextBuilder
notBeanPackages
in class BeanContextBuilder
values
- The values to add to this property.
public RestContextBuilder notBeanPackages(String... values)
BeanContextBuilder
notBeanPackages
in class BeanContextBuilder
values
- The values to add to this property.public RestContextBuilder notBeanPackagesRemove(Object... values)
BeanContextBuilder
notBeanPackagesRemove
in class BeanContextBuilder
values
- public RestContextBuilder pojoSwaps(boolean append, Object... values)
BeanContextBuilder
POJO swaps are used to "swap out" non-serializable classes with serializable equivalents during serialization, and "swap in" the non-serializable class during parsing.
An example of a POJO swap would be a Calendar
object that gets swapped out for an ISO8601 string.
pojoSwaps
in class BeanContextBuilder
append
- If values
- The new value for this property.
public RestContextBuilder pojoSwaps(Class<?>... values)
BeanContextBuilder
pojoSwaps
in class BeanContextBuilder
values
- The values to add to this property.public RestContextBuilder pojoSwaps(Object... values)
BeanContextBuilder
pojoSwaps
in class BeanContextBuilder
values
- The values to add to this property.
PojoSwap
.
SurrogateSwap
.
public RestContextBuilder pojoSwapsRemove(Object... values)
BeanContextBuilder
pojoSwapsRemove
in class BeanContextBuilder
values
- The values to remove from this property.
PojoSwap
.
SurrogateSwap
.
public RestContextBuilder sortProperties(boolean value)
BeanContextBuilder
When
sortProperties
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder sortProperties()
BeanContextBuilder
Shortcut for calling sortProperties(
.
sortProperties
in class BeanContextBuilder
public RestContextBuilder timeZone(TimeZone value)
BeanContextBuilder
timeZone
in class BeanContextBuilder
value
- The new value for this property.public RestContextBuilder useEnumNames()
BeanContextBuilder
When enabled, enums are always serialized by name instead of using Object.toString()
.
useEnumNames
in class BeanContextBuilder
public RestContextBuilder useInterfaceProxies(boolean value)
BeanContextBuilder
If InvocationHandler
if there is no other way of instantiating them.
useInterfaceProxies
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder useJavaBeanIntrospector(boolean value)
BeanContextBuilder
Using the built-in Java bean introspector will not pick up fields or non-standard getters/setters.
@Bean
annotations will be ignored if you enable this setting.
useJavaBeanIntrospector
in class BeanContextBuilder
value
- The new value for this property.
public RestContextBuilder useJavaBeanIntrospector()
BeanContextBuilder
Shortcut for calling useJavaBeanIntrospector(
.
useJavaBeanIntrospector
in class BeanContextBuilder
public RestContextBuilder set(String name, Object value)
ContextBuilder
set
in class BeanContextBuilder
name
- The property name.value
- The property value.PropertyStoreBuilder.set(String, Object)
public RestContextBuilder set(boolean append, String name, Object value)
ContextBuilder
set
in class BeanContextBuilder
append
- If name
- The property name.value
- The property value.PropertyStoreBuilder.set(String, Object)
public RestContextBuilder set(Map<String,Object> properties)
ContextBuilder
set
in class BeanContextBuilder
properties
- The properties to set on this class.PropertyStoreBuilder.set(java.util.Map)
public RestContextBuilder add(Map<String,Object> properties)
ContextBuilder
add
in class BeanContextBuilder
properties
- The properties to set on this class.PropertyStoreBuilder.add(java.util.Map)
public RestContextBuilder addTo(String name, Object value)
ContextBuilder
addTo
in class BeanContextBuilder
name
- The property name.value
- The new value to add to the SET property.public RestContextBuilder addTo(String name, String key, Object value)
ContextBuilder
addTo
in class BeanContextBuilder
name
- The property name.key
- The property value map key.value
- The property value map value.public RestContextBuilder removeFrom(String name, Object value)
ContextBuilder
removeFrom
in class BeanContextBuilder
name
- The property name.value
- The property value in the SET property.public RestContextBuilder apply(PropertyStore copyFrom)
ContextBuilder
apply
in class BeanContextBuilder
copyFrom
- The factory whose settings are being copied.public String getInitParameter(String name)
getInitParameter
in interface javax.servlet.ServletConfig
public Enumeration<String> getInitParameterNames()
getInitParameterNames
in interface javax.servlet.ServletConfig
public javax.servlet.ServletContext getServletContext()
getServletContext
in interface javax.servlet.ServletConfig
public String getServletName()
getServletName
in interface javax.servlet.ServletConfig
@Deprecated public RestContextBuilder contextPath(String value)
uriContext(String)
.@Deprecated public RestContextBuilder paramResolvers(RestParam... values)
paramResolvers(RestMethodParam...)
.Copyright © 2018 Apache. All rights reserved.