Interface RequestStorage
-
- All Known Subinterfaces:
RequestStorageWrite
public interface RequestStorageThis allows access to values which are stored in the current request thread, these values are inaccessible outside of a request and will be destroyed when the thread ends
This also "magically" exposes all the values in the request (attributes and params) as if they were stored in the map as well, if there are conflicts then locally stored data always wins over data from the request
Standard reserved keys have values that are always available:
- _locale :
Locale - _requestEntityReference : String
- _requestActive : [true,false]
- _requestOrigin : ['REST','EXTERNAL','INTERNAL']
- Author:
- Aaron Zeckoski (azeckoski @ gmail.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classRequestStorage.RequestOriginIndicates the origin of the current requeststatic classRequestStorage.ReservedKeysReserved keys with special data in them, seeRequestStorage
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<String,Object>getStorageMapCopy()Get the data as a map for easy access to the full set of keys/values, this is a copy and changing it has no effect on the data in the requestMap<String,Object>getStorageMapCopy(boolean includeInternal, boolean includeHeaders, boolean includeParams, boolean includeAttributes)Special version which allows getting only the parts that are desiredObjectgetStoredValue(String key)Get a value that is stored in the request for a specific key<T> TgetStoredValueAsType(Class<T> type, String key)
-
-
-
Method Detail
-
getStorageMapCopy
Map<String,Object> getStorageMapCopy()
Get the data as a map for easy access to the full set of keys/values, this is a copy and changing it has no effect on the data in the request- Returns:
- a copy of the internal storage of request keys and values as a map, may be empty but will not be null
-
getStorageMapCopy
Map<String,Object> getStorageMapCopy(boolean includeInternal, boolean includeHeaders, boolean includeParams, boolean includeAttributes)
Special version which allows getting only the parts that are desired- Parameters:
includeInternal- include the internal request valuesincludeHeaders- include the request headersincludeParams- include the request parametersincludeAttributes- include the request attributes- Returns:
- the map with the requested values
-
getStoredValue
Object getStoredValue(String key)
Get a value that is stored in the request for a specific key- Parameters:
key- a key for a stored value- Returns:
- the stored value if found OR null if not found
- Throws:
IllegalArgumentException- if the key is null
-
getStoredValueAsType
<T> T getStoredValueAsType(Class<T> type, String key)
- Type Parameters:
T-- Parameters:
type- an object type to attempt to convert the object tokey- a key for the stored value- Returns:
- the stored value converted to the requested type OR null if none found
- Throws:
IllegalArgumentException- if the type or key is nullIllegalFormatConversionException- if the conversion cannot be completed
-
-