Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
4385367f
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4385367f
编写于
7月 27, 2011
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimized getMethodResolver implementation to actually benefit from ConcurrentHashMap
上级
e63e6cdb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
33 deletion
+38
-33
org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/mvc/annotation/AnnotationMethodHandlerAdapter.java
...ortlet/mvc/annotation/AnnotationMethodHandlerAdapter.java
+14
-13
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java
...ervlet/mvc/annotation/AnnotationMethodHandlerAdapter.java
+24
-20
未找到文件。
org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/mvc/annotation/AnnotationMethodHandlerAdapter.java
浏览文件 @
4385367f
/*
* Copyright 2002-201
0
the original author or authors.
* Copyright 2002-201
1
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -30,7 +30,6 @@ import java.util.Locale;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
javax.portlet.ActionRequest
;
import
javax.portlet.ActionResponse
;
import
javax.portlet.ClientDataRequest
;
...
...
@@ -152,7 +151,8 @@ public class AnnotationMethodHandlerAdapter extends PortletContentGenerator
private
BeanExpressionContext
expressionContext
;
private
final
Map
<
Class
<?>,
PortletHandlerMethodResolver
>
methodResolverCache
=
new
ConcurrentHashMap
<
Class
<?>,
PortletHandlerMethodResolver
>();
private
final
Map
<
Class
<?>,
PortletHandlerMethodResolver
>
methodResolverCache
=
new
ConcurrentHashMap
<
Class
<?>,
PortletHandlerMethodResolver
>();
/**
...
...
@@ -302,6 +302,7 @@ public class AnnotationMethodHandlerAdapter extends PortletContentGenerator
}
}
protected
ModelAndView
doHandle
(
PortletRequest
request
,
PortletResponse
response
,
Object
handler
)
throws
Exception
{
ExtendedModelMap
implicitModel
=
null
;
...
...
@@ -393,17 +394,19 @@ public class AnnotationMethodHandlerAdapter extends PortletContentGenerator
*/
private
PortletHandlerMethodResolver
getMethodResolver
(
Object
handler
)
{
Class
handlerClass
=
ClassUtils
.
getUserClass
(
handler
);
synchronized
(
this
.
methodResolverCache
)
{
PortletHandlerMethodResolver
resolver
=
this
.
methodResolverCache
.
get
(
handlerClass
);
if
(
resolver
==
null
)
{
resolver
=
new
PortletHandlerMethodResolver
(
handlerClass
);
this
.
methodResolverCache
.
put
(
handlerClass
,
resolver
);
PortletHandlerMethodResolver
resolver
=
this
.
methodResolverCache
.
get
(
handlerClass
);
if
(
resolver
==
null
)
{
synchronized
(
this
.
methodResolverCache
)
{
resolver
=
this
.
methodResolverCache
.
get
(
handlerClass
);
if
(
resolver
==
null
)
{
resolver
=
new
PortletHandlerMethodResolver
(
handlerClass
);
this
.
methodResolverCache
.
put
(
handlerClass
,
resolver
);
}
}
return
resolver
;
}
return
resolver
;
}
/**
* Template method for creating a new PortletRequestDataBinder instance.
* <p>The default implementation creates a standard PortletRequestDataBinder.
...
...
@@ -417,9 +420,7 @@ public class AnnotationMethodHandlerAdapter extends PortletContentGenerator
* @see PortletRequestDataBinder#bind(javax.portlet.PortletRequest)
* @see PortletRequestDataBinder#convertIfNecessary(Object, Class, MethodParameter)
*/
protected
PortletRequestDataBinder
createBinder
(
PortletRequest
request
,
Object
target
,
String
objectName
)
throws
Exception
{
protected
PortletRequestDataBinder
createBinder
(
PortletRequest
request
,
Object
target
,
String
objectName
)
throws
Exception
{
return
new
PortletRequestDataBinder
(
target
,
objectName
);
}
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java
浏览文件 @
4385367f
...
...
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
...
...
@@ -103,7 +104,6 @@ import org.springframework.web.bind.support.WebBindingInitializer;
import
org.springframework.web.context.request.NativeWebRequest
;
import
org.springframework.web.context.request.RequestScope
;
import
org.springframework.web.context.request.ServletWebRequest
;
import
org.springframework.web.context.request.WebRequest
;
import
org.springframework.web.multipart.MultipartRequest
;
import
org.springframework.web.servlet.HandlerAdapter
;
import
org.springframework.web.servlet.HandlerMapping
;
...
...
@@ -183,7 +183,8 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
private
BeanExpressionContext
expressionContext
;
private
final
Map
<
Class
<?>,
ServletHandlerMethodResolver
>
methodResolverCache
=
new
ConcurrentHashMap
<
Class
<?>,
ServletHandlerMethodResolver
>();
private
final
Map
<
Class
<?>,
ServletHandlerMethodResolver
>
methodResolverCache
=
new
ConcurrentHashMap
<
Class
<?>,
ServletHandlerMethodResolver
>();
private
final
Map
<
Class
<?>,
Boolean
>
sessionAnnotatedClassesCache
=
new
ConcurrentHashMap
<
Class
<?>,
Boolean
>();
...
...
@@ -393,12 +394,11 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
throws
Exception
{
Class
<?>
clazz
=
ClassUtils
.
getUserClass
(
handler
);
Boolean
annotated
=
sessionAnnotatedClassesCache
.
get
(
clazz
);
Boolean
annotated
=
this
.
sessionAnnotatedClassesCache
.
get
(
clazz
);
if
(
annotated
==
null
)
{
annotated
=
Boolean
.
valueOf
(
AnnotationUtils
.
findAnnotation
(
handler
.
getClass
(),
SessionAttributes
.
class
)
!=
null
);
sessionAnnotatedClassesCache
.
put
(
clazz
,
annotated
);
annotated
=
(
AnnotationUtils
.
findAnnotation
(
handler
.
getClass
(),
SessionAttributes
.
class
)
!=
null
);
this
.
sessionAnnotatedClassesCache
.
put
(
clazz
,
annotated
);
}
if
(
annotated
)
{
...
...
@@ -442,29 +442,34 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
}
/**
* This method always returns -1 since an annotated controller can have many methods, each
* requiring separate lastModified calculations. Instead an @{@link RequestMapping} method
* can calculate the lastModified value, call {@link WebRequest#checkNotModified(long)} to
* check it, and return {@code null} if that returns {@code true}.
* @see WebRequest#checkNotModified(long)
* This method always returns -1 since an annotated controller can have many methods,
* each requiring separate lastModified calculations. Instead, an
* @{@link RequestMapping}-annotated method can calculate the lastModified value, call
* {@link org.springframework.web.context.request.WebRequest#checkNotModified(long)}
* to check it, and return {@code null} if that returns {@code true}.
* @see org.springframework.web.context.request.WebRequest#checkNotModified(long)
*/
public
long
getLastModified
(
HttpServletRequest
request
,
Object
handler
)
{
return
-
1
;
}
/**
* Build a HandlerMethodResolver for the given handler type.
*/
private
ServletHandlerMethodResolver
getMethodResolver
(
Object
handler
)
{
Class
handlerClass
=
ClassUtils
.
getUserClass
(
handler
);
synchronized
(
this
.
methodResolverCache
)
{
ServletHandlerMethodResolver
resolver
=
this
.
methodResolverCache
.
get
(
handlerClass
);
if
(
resolver
==
null
)
{
resolver
=
new
ServletHandlerMethodResolver
(
handlerClass
);
this
.
methodResolverCache
.
put
(
handlerClass
,
resolver
);
ServletHandlerMethodResolver
resolver
=
this
.
methodResolverCache
.
get
(
handlerClass
);
if
(
resolver
==
null
)
{
synchronized
(
this
.
methodResolverCache
)
{
resolver
=
this
.
methodResolverCache
.
get
(
handlerClass
);
if
(
resolver
==
null
)
{
resolver
=
new
ServletHandlerMethodResolver
(
handlerClass
);
this
.
methodResolverCache
.
put
(
handlerClass
,
resolver
);
}
}
return
resolver
;
}
return
resolver
;
}
...
...
@@ -481,8 +486,7 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
* @see ServletRequestDataBinder#bind(javax.servlet.ServletRequest)
* @see ServletRequestDataBinder#convertIfNecessary(Object, Class, org.springframework.core.MethodParameter)
*/
protected
ServletRequestDataBinder
createBinder
(
HttpServletRequest
request
,
Object
target
,
String
objectName
)
throws
Exception
{
protected
ServletRequestDataBinder
createBinder
(
HttpServletRequest
request
,
Object
target
,
String
objectName
)
throws
Exception
{
return
new
ServletRequestDataBinder
(
target
,
objectName
);
}
...
...
@@ -516,7 +520,7 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
*/
private
class
ServletHandlerMethodResolver
extends
HandlerMethodResolver
{
private
final
Map
<
Method
,
RequestMappingInfo
>
mappings
=
new
Concurrent
HashMap
<
Method
,
RequestMappingInfo
>();
private
final
Map
<
Method
,
RequestMappingInfo
>
mappings
=
new
HashMap
<
Method
,
RequestMappingInfo
>();
private
ServletHandlerMethodResolver
(
Class
<?>
handlerType
)
{
init
(
handlerType
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录