Java Method Parameters
Java methods can contain any of the following parameters in any order:
-
Parameters based on class types:
- Request/response objects:
- {@link oajr.RestRequest} - The request object.
- {@link javax.servlet.http.HttpServletRequest} - The superclass of RestRequest.
- {@link oajr.RestResponse} - The response object.
- {@link javax.servlet.http.HttpServletResponse} - The superclass of RestResponse.
- Parsed request header values:
- {@link oaj.http.Accept}
- {@link oaj.http.AcceptCharset}
- {@link oaj.http.AcceptEncoding}
- {@link oaj.http.AcceptLanguage}
- {@link oaj.http.Authorization}
- {@link oaj.http.CacheControl}
- {@link oaj.http.Connection}
- {@link oaj.http.ContentLength}
- {@link oaj.http.ContentType}
- {@link oaj.http.Date}
- {@link oaj.http.Expect}
- {@link oaj.http.From}
- {@link oaj.http.Host}
- {@link oaj.http.IfMatch}
- {@link oaj.http.IfModifiedSince}
- {@link oaj.http.IfNoneMatch}
- {@link oaj.http.IfRange}
- {@link oaj.http.IfUnmodifiedSince}
- {@link oaj.http.MaxForwards}
- {@link oaj.http.Pragma}
- {@link oaj.http.ProxyAuthorization}
- {@link oaj.http.Range}
- {@link oaj.http.Referer}
- {@link oaj.http.TE}
- {@link oaj.http.UserAgent}
- {@link oaj.http.Upgrade}
- {@link oaj.http.Via}
- {@link oaj.http.Warning}
- {@link java.util.TimeZone}
- Direct streams on request/response:
- {@link java.io.InputStream}
- {@link javax.servlet.ServletInputStream}
- {@link java.io.Reader}
- {@link java.io.OutputStream}
- {@link javax.servlet.ServletOutputStream}
- {@link java.io.Writer}
- Localization:
- {@link java.util.ResourceBundle} - Client-localized resource bundle.
- {@link oaj.utils.MessageBundle} - A resource bundle with additional features.
- {@link java.util.Locale} - Client locale.
- Request APIs:
- {@link oajr.RequestHeaders} - API for accessing request headers.
- {@link oajr.RequestQuery} - API for accessing request query parameters.
- {@link oajr.RequestFormData} - API for accessing request form data.
- {@link oajr.RequestPath} - API for accessing path variables.
- {@link oajr.RequestBody} - API for accessing request body.
- Other:
- {@link oaj.http.HttpMethod} - The method name matched (when using @RestMethod(name="*"))
- {@link oajr.RestLogger} - Logger with additional features.
- {@link oajr.RestContext} - The resource read-only context.
- {@link oaj.parser.Parser} - The parser matching the request content type.
- {@link oaj.parser.ReaderParser} - The reader parser matching the request content type.
- {@link oaj.parser.InputStreamParser} - The input stream parser matching the request content type.
- {@link oaj.dto.swagger.Swagger} - The auto-generated Swagger doc.
- {@link oaj.config.Config} - The external config for the resource.
- {@link oajr.RequestProperties} - API for modifying request-time configuration properties.
- Annotated parameters:
- {@link oaj.http.annotation.Path} - Variables in matched URL path patterns.
- {@link oaj.http.annotation.FormData} - Multipart form post parameter values.
- {@link oaj.http.annotation.HasFormData} - Denotes whether the form data parameter exists.
- {@link oaj.http.annotation.Query} - Query parameters. Using this prevents the HTTP body from being processed as a URL-Encoded form post.
- {@link oaj.http.annotation.HasQuery} - Denotes whether the query parameter exists.
- {@link oaj.http.annotation.Header} - A header value.
- {@link oaj.http.annotation.Body} - The HTTP content parsed as a POJO.
- {@link oajr.annotation.Method} - The HTTP method name.
- {@link oaj.http.annotation.Request} - HTTP request parts available through a proxy bean interface.
- {@link oaj.http.annotation.Response} - HTTP response parts available through a POJO.
- {@link oaj.http.annotation.ResponseHeader} - HTTP response header.
- {@link oaj.http.annotation.ResponseStatus} - HTTP response status code.
@RestMethod(name=GET, path="/example1/{a1}/{a2}/{a3}/*")
public String doGetExample1(
RestRequest req,
RestResponse res,
@Method String method,
@Path("a1") String a1,
@Path("a2") int a2,
@Path("a3") UUID a3,
@Query("p1") int p1,
@Query("p2") String p2,
@Query("p3") UUID p3,
@HasQuery("p3") boolean hasP3,
@Path("/*") String remainder,
@Header("Accept-Language") String lang,
@Header("Accept") String accept,
@Header("DNT") int doNotTrack,
RequestProperties properties,
ResourceBundle nls
) {
// Do something with all of those
}
- All annotations have programmatic equivalents on the {@link oajr.RestRequest} class.
- {@link oajr.RestContext#REST_paramResolvers} - For configuring custom parameter types.