提交 2a733160 编写于 作者: 黄勇

【I】去掉 Handler 实例的缓存控制

上级 25d01cac
package org.smart4j.framework.mvc.impl;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.smart4j.framework.mvc.ActionHelper;
......@@ -17,18 +16,8 @@ import org.smart4j.framework.mvc.Requestor;
*/
public class DefaultHandlerMapping implements HandlerMapping {
/**
* 用于缓存 Handler 实例
*/
private static final Map<String, Handler> cache = new ConcurrentHashMap<String, Handler>();
@Override
public Handler getHandler(String currentRequestMethod, String currentRequestPath) {
// 若缓存中存在对应的实例,则返回该实例
String cacheKey = currentRequestMethod + ":" + currentRequestPath;
if (cache.containsKey(cacheKey)) {
return cache.get(cacheKey);
}
// 定义一个 Handler
Handler handler = null;
// 获取并遍历 Action 映射
......@@ -52,10 +41,6 @@ public class DefaultHandlerMapping implements HandlerMapping {
break;
}
}
// 若该实例不为空,则将其放入缓存
if (handler != null) {
cache.put(cacheKey, handler);
}
// 返回该 Handler
return handler;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册