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.header.Accept}
    - {@link oaj.http.header.AcceptCharset}
    - {@link oaj.http.header.AcceptEncoding}
    - {@link oaj.http.header.AcceptLanguage}
    - {@link oaj.http.header.Authorization}
    - {@link oaj.http.header.CacheControl}
    - {@link oaj.http.header.Connection}
    - {@link oaj.http.header.ContentLength}
    - {@link oaj.http.header.ContentType}
    - {@link oaj.http.header.Date}
    - {@link oaj.http.header.Expect}
    - {@link oaj.http.header.From}
    - {@link oaj.http.header.Host}
    - {@link oaj.http.header.IfMatch}
    - {@link oaj.http.header.IfModifiedSince}
    - {@link oaj.http.header.IfNoneMatch}
    - {@link oaj.http.header.IfRange}
    - {@link oaj.http.header.IfUnmodifiedSince}
    - {@link oaj.http.header.MaxForwards}
    - {@link oaj.http.header.Pragma}
    - {@link oaj.http.header.ProxyAuthorization}
    - {@link oaj.http.header.Range}
    - {@link oaj.http.header.Referer}
    - {@link oaj.http.header.TE}
    - {@link oaj.http.header.UserAgent}
    - {@link oaj.http.header.Upgrade}
    - {@link oaj.http.header.Via}
    - {@link oaj.http.header.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.

##### Example:

@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.