@Documented @Target(value=TYPE) @Retention(value=RUNTIME) @Inherited public @interface RestResource
Usually used on a subclass of RestServlet
, but can be used to annotate any class that you want to expose as
a REST resource.
Modifier and Type | Optional Element and Description |
---|---|
String |
allowBodyParam
Allow body URL parameter.
|
String |
allowedMethodParams
Allowed method parameters.
|
String |
allowHeaderParams
Allow header URL parameters.
|
Class<?>[] |
beanFilters
Class-level bean filters.
|
Class<? extends RestCallHandler> |
callHandler
REST call handler.
|
Class<?>[] |
children
Children.
|
Class<? extends ClasspathResourceFinder> |
classpathResourceFinder
Classpath resource finder.
|
String |
clientVersionHeader
Client version header.
|
String |
config
Optional location of configuration file for this servlet.
|
String[] |
consumes
Supported content media types.
|
String |
contextPath
Resource context path.
|
Class<? extends RestConverter>[] |
converters
Class-level response converters.
|
String |
defaultCharset
Default character encoding.
|
String[] |
defaultRequestHeaders
Default request headers.
|
String[] |
defaultResponseHeaders
Default response headers.
|
String |
description
Optional servlet description.
|
Class<? extends Encoder>[] |
encoders
Compression encoders.
|
String[] |
flags
Shortcut for setting
properties() of simple boolean types. |
Class<? extends RestGuard>[] |
guards
Class-level guards.
|
HtmlDoc |
htmldoc
Provides HTML-doc-specific metadata on this method.
|
Class<? extends RestInfoProvider> |
infoProvider
Configuration property: REST info provider.
|
Class<? extends RestLogger> |
logger
REST logger.
|
String |
maxInput
The maximum allowed input size (in bytes) on HTTP requests.
|
String |
messages
Messages.
|
String[] |
mimeTypes
Configuration property: MIME types.
|
Class<? extends RestParam>[] |
paramResolvers
Java method parameter resolvers.
|
Class<? extends ParserListener> |
parserListener
Parser listener.
|
Class<? extends Parser>[] |
parsers
Parsers.
|
Class<? extends HttpPartParser> |
partParser
HTTP part parser.
|
Class<? extends HttpPartSerializer> |
partSerializer
HTTP part serializer.
|
String |
path
Resource path.
|
Class<?>[] |
pojoSwaps
Class-level POJO swaps.
|
String[] |
produces
Supported accept media types.
|
Property[] |
properties
Class-level properties.
|
String |
renderResponseStackTraces
Render response stack traces in responses.
|
Class<? extends RestResourceResolver> |
resourceResolver
REST resource resolver.
|
Class<? extends ResponseHandler>[] |
responseHandlers
Response handlers.
|
Class<? extends SerializerListener> |
serializerListener
Serializer listener.
|
Class<? extends Serializer>[] |
serializers
Serializers.
|
String |
siteName
Optional site name.
|
String[] |
staticFileResponseHeaders
Static file response headers.
|
String[] |
staticFiles
Static file mappings.
|
String[] |
swagger
Provides swagger-specific metadata on this resource.
|
String |
title
Optional servlet title.
|
String |
useClasspathResourceCaching
Configuration property: Use classpath resource caching.
|
String |
useStackTraceHashes
Use stack trace hashes.
|
public abstract String allowBodyParam
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)
public abstract String allowedMethodParams
When specified, the HTTP method can be overridden by passing in a
For example:
?method=OPTIONS
public abstract String allowHeaderParams
When enabled, headers such as
For example:
?Accept=text/json&Content-Type=text/json
public abstract Class<?>[] beanFilters
Shortcut to add bean filters to the bean contexts of the objects returned by the following methods:
public abstract Class<? extends RestCallHandler> callHandler
This class handles the basic lifecycle of an HTTP REST call.
public abstract Class<? extends ClasspathResourceFinder> classpathResourceFinder
Used to retrieve localized files from the classpath.
public abstract String clientVersionHeader
Specifies the name of the header used to denote the client version on HTTP requests.
public abstract String config
The configuration file .
public abstract String contextPath
Overrides the context path value for this resource and any child resources.
public abstract Class<? extends RestConverter>[] converters
Associates one or more converters
with a resource class.
public abstract String defaultCharset
The default character encoding for the request and response if not specified on the request.
public abstract String[] defaultRequestHeaders
Specifies default values for request headers if they're not passed in through the request.
public abstract String[] defaultResponseHeaders
Specifies default values for response headers if they're not set after the Java REST method is called.
public abstract String description
It is used to populate the Swagger description field.
This value can be retrieved programmatically through the RestRequest.getResourceDescription()
method.
/info/description
.
public abstract String[] flags
properties()
of simple boolean types.
public abstract Class<? extends RestGuard>[] guards
Associates one or more RestGuards
with all REST methods defined in this class.
public abstract HtmlDoc htmldoc
Used to customize the output from the HTML Doc serializer.
public abstract Class<? extends RestInfoProvider> infoProvider
Class used to retrieve title/description/swagger information about a resource.
public abstract Class<? extends RestLogger> logger
public abstract String maxInput
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.
public abstract String messages
public abstract String[] mimeTypes
Defines MIME-type file type mappings.
public abstract Class<? extends RestParam>[] paramResolvers
By default, the Juneau framework will automatically Java method parameters of various types (e.g.
RestRequest
, Accept
, Reader
).
This setting allows you to provide your own resolvers for your own class types that you want resolved.
public abstract Class<? extends ParserListener> parserListener
Specifies the parser listener class to use for listening to non-fatal parsing errors.
public abstract Class<? extends HttpPartParser> partParser
Specifies the HttpPartParser
to use for parsing headers, query/form parameters, and URI parts.
public abstract Class<? extends HttpPartSerializer> partSerializer
Specifies the HttpPartSerializer
to use for serializing headers, query/form parameters, and URI parts.
public abstract Property[] properties
Shortcut for specifying class-level properties on this servlet to the objects returned by the following methods:
Any of the properties defined on RestContext
or any of the serializers and parsers can be specified.
Property values will be converted to the appropriate type.
In some cases, properties can be overridden at runtime through the
RestResponse.prop(String, Object)
method or through an RequestProperties
method parameter.
public abstract String renderResponseStackTraces
Render stack traces in HTTP response bodies when errors occur.
public abstract Class<? extends RestResourceResolver> resourceResolver
The resolver used for resolving child resources.
public abstract Class<? extends ResponseHandler>[] responseHandlers
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.
public abstract Class<? extends SerializerListener> serializerListener
Specifies the serializer listener class to use for listening to non-fatal serialization errors.
public abstract Class<? extends Serializer>[] serializers
public abstract String siteName
The site name is intended to be a title that can be applied to the entire site.
This value can be retrieved programmatically through the RestRequest.getSiteName()
method.
One possible use is if you want to add the same title to the top of all pages by defining a header on a common parent class like so:
htmldoc=
public abstract String[] staticFileResponseHeaders
Used to customize the headers on responses returned for statically-served files.
public abstract String[] staticFiles
Used to define paths and locations of statically-served files such as images or HTML documents.
public abstract String[] produces
Overrides the media types inferred from the serializers that identify what media types can be produced by the resource.
public abstract String[] consumes
Overrides the media types inferred from the parsers that identify what media types can be consumed by the resource.
public abstract String[] swagger
Used to populate the auto-generated OPTIONS swagger documentation.
The format of this annotation is JSON when all individual parts are concatenated.
The starting and ending
public abstract String title
It is used to populate the Swagger title field.
This value can be retrieved programmatically through the RestRequest.getResourceTitle()
method.
/info/title
.
public abstract String useClasspathResourceCaching
When enabled, resources retrieved via RestRequest.getClasspathReaderResource(String, boolean)
(and related
methods) will be cached in memory to speed subsequent lookups.
public abstract String useStackTraceHashes
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.
Copyright © 2018 Apache. All rights reserved.