{8.1.0-new} RequestAttributes

The {@link oajr.RequestAttributes} object is the API for accessing the standard servlet attributes on an HTTP request (i.e. {@link javax.servlet.ServletRequest#getAttribute(String)}. It wraps the request attributes in a {@link java.util.Map} interface and provides several convenience methods.

The RequestAttributes object extends from {@link oaj.ObjectMap} so all the convenience methods defined on that API are also available when working with request attributes:

@RestMethod(...) public Object myMethod(RequestAttributes attributes) {...}

Example:

@RestMethod(...) public Object myMethod(RequestAttributes attributes) { // Add a default value. attributes.putIfNotExists("Foo", 123); // Get an attribute value as a POJO. UUID etag = attributes.get("ETag", UUID.class); }

Modifications made to request attributes through the RequestAttributes bean are automatically reflected in the underlying servlet request attributes making it possible to mix the usage of both APIs.