| <!-- |
| /*************************************************************************************************************************** |
| * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations under the License. |
| ***************************************************************************************************************************/ |
| --> |
| |
| {new} RequestAttributes |
| |
| <p> |
| 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. |
| </p> |
| <p> |
| The <c>RequestAttributes</c> object extends from {@link oaj.ObjectMap} so all the convenience methods defined on |
| that API are also available when working with request attributes: |
| </p> |
| <p class='bpcode w800'> |
| <ja>@RestMethod</ja>(...) |
| <jk>public</jk> Object myMethod(RequestAttributes attributes) {...} |
| </p> |
| <h5 class='figure'>Example:</h5> |
| <p class='bpcode w800'> |
| <ja>@RestMethod</ja>(...) |
| <jk>public</jk> Object myMethod(RequestAttributes attributes) { |
| |
| <jc>// Add a default value.</jc> |
| attributes.putIfNotExists(<js>"Foo"</js>, 123); |
| |
| <jc>// Get an attribute value as a POJO.</jc> |
| UUID etag = attributes.get(<js>"ETag"</js>, UUID.<jk>class</jk>); |
| } |
| </p> |
| <p> |
| Modifications made to request attributes through the <c>RequestAttributes</c> bean are automatically reflected in |
| the underlying servlet request attributes making it possible to mix the usage of both APIs. |
| </p> |