}
@SuppressWarnings("unchecked")
@Override
protected ContextMap createMapForScope(String scope) {
ContextMap map = null;
switch (scope) {
case SCOPE_SESSION: {
HttpServletRequest request = getRequest();
map = new SessionMap(request);
}
break;
case SCOPE_HEADER: {
HttpServletRequest request = getRequest();
map = DelegatedContextMap.createByNonThreadSafeHashMap();
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
String[] values = getHeaderValues(request.getHeaders(name));
map.put(name, values);
}
map = new UnmodifiableContextMap(map);
}
break;
case SCOPE_COOKIE: {
HttpServletRequest request = getRequest();
map = DelegatedContextMap.createByNonThreadSafeHashMap();
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
String name = cookie.getName();
String[] values = mergeCookieValues(cookie, (String[]) map.get(name));
map.put(name, values);
}
}
map = new UnmodifiableContextMap(map);
}
break;
case SCOPE_REQUEST:
map = super.acquireMapForScope(SCOPE_DEFAULT);
break;
case SCOPE_QUERYPARAM_ALIAS:
case SCOPE_QUERYPARAM: {
HttpServletRequest request = getRequest();
map = DelegatedContextMap.createByNonThreadSafeHashMap();
Enumeration<String> paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String name = paramNames.nextElement();
String[] values = request.getParameterValues(name);
map.put(name, values);
}
map = new UnmodifiableContextMap(map);
}
break;
case SCOPE_PATHVAR: