Merge pull request #585 from sdutry/issue/WW-5196

WW-5196 use generics for RequestMap and ApplicationMap and correct SessionMap to also be of type <String, Object>
This commit is contained in:
Lukasz Lenart
2023-03-13 07:05:37 +01:00
committed by GitHub
14 changed files with 242 additions and 165 deletions
@@ -18,9 +18,13 @@
*/
package org.apache.struts2.dispatcher;
import javax.servlet.ServletContext;
import java.io.Serializable;
import java.util.*;
import java.util.AbstractMap;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.ServletContext;
/**
* A simple implementation of the {@link java.util.Map} interface to handle a collection of attributes and
@@ -28,12 +32,12 @@ import java.util.*;
* enumerates over all servlet context attributes and init parameters and returns a collection of both.
* Note, this will occur lazily - only when the entry set is asked for.
*/
public class ApplicationMap extends AbstractMap implements Serializable {
public class ApplicationMap extends AbstractMap<String, Object> implements Serializable {
private static final long serialVersionUID = 9136809763083228202L;
private ServletContext context;
private Set<Object> entries;
private Set<Entry<String, Object>> entries;
/**
@@ -41,7 +45,7 @@ public class ApplicationMap extends AbstractMap implements Serializable {
*
* @param ctx the servlet context
*/
public ApplicationMap(ServletContext ctx) {
public ApplicationMap(final ServletContext ctx) {
this.context = ctx;
}
@@ -49,13 +53,14 @@ public class ApplicationMap extends AbstractMap implements Serializable {
/**
* Removes all entries from the Map and removes all attributes from the servlet context.
*/
@Override
public void clear() {
entries = null;
Enumeration e = context.getAttributeNames();
Enumeration<String> e = context.getAttributeNames();
while (e.hasMoreElements()) {
context.removeAttribute(e.nextElement().toString());
context.removeAttribute(e.nextElement());
}
}
@@ -64,39 +69,20 @@ public class ApplicationMap extends AbstractMap implements Serializable {
*
* @return a Set of all servlet context attributes as well as context init parameters.
*/
public Set entrySet() {
@Override
public Set<Entry<String, Object>> entrySet() {
if (entries == null) {
entries = new HashSet<>();
// Add servlet context attributes
Enumeration enumeration = context.getAttributeNames();
Enumeration<String> enumeration = context.getAttributeNames();
while (enumeration.hasMoreElements()) {
final String key = enumeration.nextElement().toString();
final String key = enumeration.nextElement();
final Object value = context.getAttribute(key);
entries.add(new Map.Entry() {
public boolean equals(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
return ((key == null) ? (entry.getKey() == null) : key.equals(entry.getKey())) && ((value == null) ? (entry.getValue() == null) : value.equals(entry.getValue()));
}
public int hashCode() {
return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode());
}
public Object getKey() {
return key;
}
public Object getValue() {
return value;
}
public Object setValue(Object obj) {
entries.add(new StringObjectEntry(key, value) {
@Override
public Object setValue(final Object obj) {
context.setAttribute(key, obj);
return value;
@@ -108,31 +94,11 @@ public class ApplicationMap extends AbstractMap implements Serializable {
enumeration = context.getInitParameterNames();
while (enumeration.hasMoreElements()) {
final String key = enumeration.nextElement().toString();
final String key = enumeration.nextElement();
final Object value = context.getInitParameter(key);
entries.add(new Map.Entry() {
public boolean equals(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
return ((key == null) ? (entry.getKey() == null) : key.equals(entry.getKey())) && ((value == null) ? (entry.getValue() == null) : value.equals(entry.getValue()));
}
public int hashCode() {
return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode());
}
public Object getKey() {
return key;
}
public Object getValue() {
return value;
}
public Object setValue(Object obj) {
entries.add(new StringObjectEntry(key, value) {
@Override
public Object setValue(final Object obj) {
context.setAttribute(key, obj);
return value;
@@ -151,13 +117,12 @@ public class ApplicationMap extends AbstractMap implements Serializable {
* @param key the entry key.
* @return the servlet context attribute or init parameter or <tt>null</tt> if the entry is not found.
*/
public Object get(Object key) {
public Object get(final String key) {
// Try context attributes first, then init params
// This gives the proper shadowing effects
String keyString = key.toString();
Object value = context.getAttribute(keyString);
Object value = context.getAttribute(key);
return (value == null) ? context.getInitParameter(keyString) : value;
return (value == null) ? context.getInitParameter(key) : value;
}
/**
@@ -167,10 +132,13 @@ public class ApplicationMap extends AbstractMap implements Serializable {
* @param value the value to set.
* @return the attribute that was just set.
*/
public Object put(Object key, Object value) {
@Override
public Object put(final String key, final Object value) {
Object oldValue = get(key);
entries = null;
context.setAttribute(key.toString(), value);
context.setAttribute(key, value);
return oldValue;
}
@@ -180,11 +148,11 @@ public class ApplicationMap extends AbstractMap implements Serializable {
* @param key the attribute to remove.
* @return the entry that was just removed.
*/
public Object remove(Object key) {
public Object remove(final String key) {
entries = null;
Object value = get(key);
context.removeAttribute(key.toString());
context.removeAttribute(key);
return value;
}
@@ -28,11 +28,11 @@ import java.util.Set;
/**
* A simple implementation of the {@link java.util.Map} interface to handle a collection of request attributes.
*/
public class RequestMap extends AbstractMap implements Serializable {
public class RequestMap extends AbstractMap<String, Object> implements Serializable {
private static final long serialVersionUID = -7675640869293787926L;
private Set<Object> entries;
private Set<Entry<String, Object>> entries;
private HttpServletRequest request;
/**
@@ -48,12 +48,13 @@ public class RequestMap extends AbstractMap implements Serializable {
/**
* Removes all attributes from the request as well as clears entries in this map.
*/
@Override
public void clear() {
entries = null;
Enumeration keys = request.getAttributeNames();
Enumeration<String> keys = request.getAttributeNames();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
String key = keys.nextElement();
request.removeAttribute(key);
}
}
@@ -63,38 +64,19 @@ public class RequestMap extends AbstractMap implements Serializable {
*
* @return a Set of attributes from the http request.
*/
public Set entrySet() {
@Override
public Set<Entry<String, Object>> entrySet() {
if (entries == null) {
entries = new HashSet<>();
Enumeration enumeration = request.getAttributeNames();
Enumeration<String> enumeration = request.getAttributeNames();
while (enumeration.hasMoreElements()) {
final String key = enumeration.nextElement().toString();
final String key = enumeration.nextElement();
final Object value = request.getAttribute(key);
entries.add(new Entry() {
public boolean equals(Object obj) {
if (!(obj instanceof Entry)) {
return false;
}
Entry entry = (Entry) obj;
return ((key == null) ? (entry.getKey() == null) : key.equals(entry.getKey())) && ((value == null) ? (entry.getValue() == null) : value.equals(entry.getValue()));
}
public int hashCode() {
return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode());
}
public Object getKey() {
return key;
}
public Object getValue() {
return value;
}
public Object setValue(Object obj) {
entries.add(new StringObjectEntry(key, value) {
@Override
public Object setValue(final Object obj) {
request.setAttribute(key, obj);
return value;
@@ -112,8 +94,8 @@ public class RequestMap extends AbstractMap implements Serializable {
* @param key the name of the request attribute.
* @return the request attribute or <tt>null</tt> if it doesn't exist.
*/
public Object get(Object key) {
return request.getAttribute(key.toString());
public Object get(final String key) {
return request.getAttribute(key);
}
/**
@@ -123,10 +105,13 @@ public class RequestMap extends AbstractMap implements Serializable {
* @param value the value to set.
* @return the object that was just set.
*/
public Object put(Object key, Object value) {
@Override
public Object put(final String key, final Object value) {
Object oldValue = get(key);
entries = null;
request.setAttribute(key.toString(), value);
request.setAttribute(key, value);
return oldValue;
}
@@ -136,11 +121,11 @@ public class RequestMap extends AbstractMap implements Serializable {
* @param key the name of the attribute to remove.
* @return the value that was removed or <tt>null</tt> if the value was not found (and hence, not removed).
*/
public Object remove(Object key) {
public Object remove(final String key) {
entries = null;
Object value = get(key);
request.removeAttribute(key.toString());
request.removeAttribute(key);
return value;
}
@@ -21,19 +21,23 @@ package org.apache.struts2.dispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.Serializable;
import java.util.*;
import java.util.AbstractMap;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
/**
* A simple implementation of the {@link java.util.Map} interface to handle a collection of HTTP session
* attributes. The {@link #entrySet()} method enumerates over all session attributes and creates a Set of entries.
* Note, this will occur lazily - only when the entry set is asked for.
*/
public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable {
public class SessionMap extends AbstractMap<String, Object> implements Serializable {
private static final long serialVersionUID = 4678843241638046854L;
protected HttpSession session;
protected Set<Map.Entry<K, V>> entries;
protected Set<Entry<String, Object>> entries;
protected HttpServletRequest request;
@@ -43,7 +47,7 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
*
* @param request the http servlet request object.
*/
public SessionMap(HttpServletRequest request) {
public SessionMap(final HttpServletRequest request) {
// note, holding on to this request and relying on lazy session initalization will not work
// if you are running your action invocation in a background task, such as using the
// "execAndWait" interceptor
@@ -70,7 +74,7 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
* Removes all attributes from the session as well as clears entries in this
* map.
*/
@SuppressWarnings("unchecked")
@Override
public void clear() {
if (session == null) {
return;
@@ -91,8 +95,8 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
*
* @return a Set of attributes from the http session.
*/
@SuppressWarnings("unchecked")
public Set<java.util.Map.Entry<K, V>> entrySet() {
@Override
public Set<Entry<String, Object>> entrySet() {
if (session == null) {
return Collections.emptySet();
}
@@ -101,37 +105,17 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
if (entries == null) {
entries = new HashSet<>();
Enumeration<?> enumeration = session.getAttributeNames();
Enumeration<String> enumeration = session.getAttributeNames();
while (enumeration.hasMoreElements()) {
final String key = enumeration.nextElement().toString();
final String key = enumeration.nextElement();
final Object value = session.getAttribute(key);
entries.add(new Map.Entry<K, V>() {
public boolean equals(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry<K, V> entry = (Map.Entry<K, V>) obj;
return ((key == null) ? (entry.getKey() == null) : key.equals(entry.getKey())) && ((value == null) ? (entry.getValue() == null) : value.equals(entry.getValue()));
}
public int hashCode() {
return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode());
}
public K getKey() {
return (K) key;
}
public V getValue() {
return (V) value;
}
public V setValue(Object obj) {
entries.add(new StringObjectEntry(key, value) {
@Override
public Object setValue(final Object obj) {
session.setAttribute(key, obj);
return (V) value;
return value;
}
});
}
@@ -147,14 +131,13 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
* @param key the name of the session attribute.
* @return the session attribute or <tt>null</tt> if it doesn't exist.
*/
@SuppressWarnings("unchecked")
public V get(Object key) {
public Object get(final String key) {
if (session == null) {
return null;
}
synchronized (session.getId().intern()) {
return (V) session.getAttribute(key.toString());
return session.getAttribute(key);
}
}
@@ -165,16 +148,17 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
* @param value the value to set.
* @return the object that was just set.
*/
public V put(K key, V value) {
@Override
public Object put(final String key, final Object value) {
synchronized (this) {
if (session == null) {
session = request.getSession(true);
}
}
synchronized (session.getId().intern()) {
V oldValue = get(key);
Object oldValue = get(key);
entries = null;
session.setAttribute(key.toString(), value);
session.setAttribute(key, value);
return oldValue;
}
}
@@ -185,7 +169,7 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
* @param key the name of the attribute to remove.
* @return the value that was removed or <tt>null</tt> if the value was not found (and hence, not removed).
*/
public V remove(Object key) {
public Object remove(final String key) {
if (session == null) {
return null;
}
@@ -193,8 +177,8 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
synchronized (session.getId().intern()) {
entries = null;
V value = get(key);
session.removeAttribute(key.toString());
Object value = get(key);
session.removeAttribute(key);
return value;
}
@@ -207,7 +191,7 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
* @param key the name of the session attribute.
* @return <tt>true</tt> if the session attribute exits or <tt>false</tt> if it doesn't exist.
*/
public boolean containsKey(Object key) {
public boolean containsKey(final String key) {
if (session == null) {
return false;
}
@@ -0,0 +1,64 @@
/*
* 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.
*/
package org.apache.struts2.dispatcher;
import java.util.Map.Entry;
abstract class StringObjectEntry implements Entry<String, Object> {
private String key;
private Object value;
StringObjectEntry(final String key, final Object value) {
this.key = key;
this.value = value;
}
@Override
public String getKey() {
return key;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof Entry)) {
return false;
}
Entry<?, ?> entry = (Entry<?, ?>) obj;
return keyEquals(entry) && valueEquals(entry);
}
private boolean keyEquals(final Entry<?, ?> entry) {
return (key == null) ? (entry.getKey() == null) : key.equals(entry.getKey());
}
private boolean valueEquals(Entry<?, ?> entry) {
return (value == null) ? (entry.getValue() == null) : value.equals(entry.getValue());
}
@Override
public int hashCode() {
return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode());
}
}
@@ -93,7 +93,7 @@ public class CreateSessionInterceptor extends AbstractInterceptor {
if (httpSession == null) {
LOG.debug("Creating new HttpSession and new SessionMap in ServletActionContext");
servletRequest.getSession(true);
invocation.getInvocationContext().withSession(new SessionMap<>(servletRequest));
invocation.getInvocationContext().withSession(new SessionMap(servletRequest));
}
return invocation.invoke();
}
@@ -273,7 +273,7 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
invocation.addPreResultListener(this);
Map<String, Object> session = ActionContext.getContext().getSession();
if (session == null && autoCreateSession) {
session = new SessionMap<>(ServletActionContext.getRequest());
session = new SessionMap(ServletActionContext.getRequest());
ActionContext.getContext().withSession(session);
}
@@ -64,7 +64,7 @@ public class TagUtils {
Map<String, Object> extraContext = du.createContextMap(new RequestMap(req),
params,
new SessionMap<>(req),
new SessionMap(req),
new ApplicationMap(pageContext.getServletContext()),
req,
res);
@@ -50,13 +50,21 @@ public class SessionMapTest extends TestCase {
List<String> attributeNames = new ArrayList<String>();
attributeNames.add("test");
attributeNames.add("anotherTest");
Enumeration attributeNamesEnum = Collections.enumeration(attributeNames);
Enumeration<String> attributeNamesEnum = Collections.enumeration(attributeNames);
MockSessionMap sessionMap = new MockSessionMap((HttpServletRequest) requestMock.proxy());
sessionMock.expect("getAttribute",
new Constraint[] {
new IsEqual("test")
});
sessionMock.expect("setAttribute",
new Constraint[] {
new IsEqual("test"), new IsEqual("test value")
});
sessionMock.expect("getAttribute",
new Constraint[] {
new IsEqual("anotherTest")
});
sessionMock.expect("setAttribute",
new Constraint[] {
new IsEqual("anotherTest"), new IsEqual("another test value")
@@ -70,6 +78,14 @@ public class SessionMapTest extends TestCase {
new Constraint[]{
new IsEqual("anotherTest")
});
sessionMock.expect("getAttribute",
new Constraint[] {
new IsEqual("test")
});
sessionMock.expect("getAttribute",
new Constraint[] {
new IsEqual("anotherTest")
});
sessionMap.put("test", "test value");
sessionMap.put("anotherTest", "another test value");
sessionMap.clear();
@@ -102,7 +118,7 @@ public class SessionMapTest extends TestCase {
}
public void testGetObjectOnSessionMapUsesWrappedSessionsGetAttributeWithStringValue() throws Exception {
Object key = new Object();
String key = "theKey";
Object value = new Object();
sessionMock.expectAndReturn("getAttribute", new Constraint[]{
new IsEqual(key.toString())
@@ -114,7 +130,7 @@ public class SessionMapTest extends TestCase {
}
public void testPutObjectOnSessionMapUsesWrappedSessionsSetsAttributeWithStringValue() throws Exception {
Object key = new Object();
String key = "theKey";
Object value = new Object();
sessionMock.expect("getAttribute", new Constraint[]{new IsAnything()});
sessionMock.expect("setAttribute", new Constraint[]{
@@ -130,10 +146,10 @@ public class SessionMapTest extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest();
Object key = new Object();
String key = "theKey";
Object value = new Object();
SessionMap<Object, Object> sessionMap = new SessionMap<Object, Object>(request);
SessionMap sessionMap = new SessionMap(request);
sessionMap.put(key, value);
assertTrue(sessionMap.containsKey(key));
}
@@ -142,11 +158,11 @@ public class SessionMapTest extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest();
Object key = new Object();
Object someOtherKey = new Object();
String key = "theKey";
Object someOtherKey = "someOtherKey";
Object value = new Object();
SessionMap<Object, Object> sessionMap = new SessionMap<Object, Object>(request);
SessionMap sessionMap = new SessionMap(request);
sessionMap.put(key, value);
assertFalse(sessionMap.containsKey(someOtherKey));
@@ -219,7 +235,7 @@ public class SessionMapTest extends TestCase {
private static final long serialVersionUID = 8783604360786273764L;
private Map map = new HashMap();
private Map<String, Object> map = new HashMap<>();
public MockSessionMap(HttpServletRequest request) {
super(request);
@@ -228,8 +244,8 @@ public class SessionMapTest extends TestCase {
public Object get(Object key) {
return map.get(key);
}
public Object put(Object key, Object value) {
public Object put(String key, Object value) {
Object originalValue = super.put(key, value);
map.put(key, value); //put the value into our map after putting it in the superclass map to avoid polluting the get call.
@@ -0,0 +1,61 @@
/*
* 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.
*/
package org.apache.struts2.dispatcher;
import static org.junit.Assert.assertNotEquals;
import junit.framework.TestCase;
public class StringObjectEntryTest extends TestCase {
public void testGetKey() {
StringObjectEntry entry = new StringObjectEntryTestImpl("theKey", "theValue");
assertEquals("theKey", entry.getKey());
}
public void testGetValue() {
StringObjectEntry entry = new StringObjectEntryTestImpl("theKey", "theValue");
assertEquals("theValue", entry.getValue());
}
public void testEquals() {
StringObjectEntry entry = new StringObjectEntryTestImpl("theKey", "theValue");
assertEquals(entry, new StringObjectEntryTestImpl("theKey", "theValue"));
assertNotEquals(entry, new StringObjectEntryTestImpl("theKey", "differentValue"));
assertNotEquals(entry, new StringObjectEntryTestImpl("differentKey", "theValue"));
assertNotEquals(entry, new StringObjectEntryTestImpl("differentKey", "differentValue"));
}
public void testHashCode() {
StringObjectEntry entry = new StringObjectEntryTestImpl("theKey", "theValue");
assertEquals(-1962296402, entry.hashCode());
}
static class StringObjectEntryTestImpl extends StringObjectEntry {
StringObjectEntryTestImpl(final String key, final Object value) {
super(key, value);
}
@Override
public Object setValue(final Object value) {
return value;
}
}
}
@@ -180,7 +180,7 @@ public class CspInterceptorTest extends StrutsInternalTestCase {
ActionContext context = ActionContext.getContext()
.withServletRequest(request)
.withServletResponse(response)
.withSession(new SessionMap<>(request))
.withSession(new SessionMap(request))
.bind();
mai.setInvocationContext(context);
session = request.getSession();
@@ -38,7 +38,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import static org.apache.struts2.views.jsp.AbstractUITagTest.normalize;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
@@ -260,8 +259,8 @@ public class FreemarkerResultMockedTest extends StrutsInternalTestCase {
EasyMock.replay(servletContext);
init();
// create session
request.getSession();
// create session and add nonce
request.getSession().setAttribute("nonce", "aNonce");
request.setRequestURI("/tutorial/test10.action");
ActionMapping mapping = container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
@@ -107,7 +107,7 @@ public abstract class AbstractTagTest extends StrutsInternalTestCase {
MockDispatcher du = new MockDispatcher(pageContext.getServletContext(), new HashMap<>(), configurationManager);
du.init();
Dispatcher.setInstance(du);
session = new SessionMap<>(request);
session = new SessionMap(request);
Map<String, Object> extraContext = du.createContextMap(new RequestMap(request),
HttpParameters.create(request.getParameterMap()).build(),
session,
@@ -1674,7 +1674,7 @@ public class URLTagTest extends AbstractUITagTest {
mockContainer = new Mock(Container.class);
session = new SessionMap<>(request);
session = new SessionMap(request);
Map<String, Object> extraContext = du.createContextMap(new RequestMap(request),
HttpParameters.create(request.getParameterMap()).build(),
session,
@@ -76,7 +76,7 @@ public class DWRValidator {
requestParams = requestParams.withExtraParams(params);
}
Map<String, Object> requestMap = new RequestMap(req);
Map<String, Object> session = new SessionMap<>(req);
Map<String, Object> session = new SessionMap(req);
Map<String, Object> application = new ApplicationMap(servletContext);
Dispatcher du = Dispatcher.getInstance();
Map<String, Object> ctx = du.createContextMap(requestMap,