Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
4af36454
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,发现更多精彩内容 >>
提交
4af36454
编写于
8月 07, 2010
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PortletWrappingController supports Portlet 2.0 resource and event requests as well (SPR-7430)
上级
753cda3d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
67 addition
and
2 deletion
+67
-2
org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/mvc/PortletWrappingController.java
...gframework/web/portlet/mvc/PortletWrappingController.java
+67
-2
未找到文件。
org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/mvc/PortletWrappingController.java
浏览文件 @
4af36454
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
10
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.
...
...
@@ -25,11 +25,19 @@ import java.util.Map;
import
java.util.ResourceBundle
;
import
javax.portlet.ActionRequest
;
import
javax.portlet.ActionResponse
;
import
javax.portlet.EventPortlet
;
import
javax.portlet.EventRequest
;
import
javax.portlet.EventResponse
;
import
javax.portlet.Portlet
;
import
javax.portlet.PortletConfig
;
import
javax.portlet.PortletContext
;
import
javax.portlet.PortletSession
;
import
javax.portlet.RenderRequest
;
import
javax.portlet.RenderResponse
;
import
javax.portlet.ResourceRequest
;
import
javax.portlet.ResourceResponse
;
import
javax.portlet.ResourceServingPortlet
;
import
javax.portlet.UnavailableException
;
import
javax.xml.XMLConstants
;
import
javax.xml.namespace.QName
;
...
...
@@ -39,6 +47,7 @@ import org.springframework.beans.factory.InitializingBean;
import
org.springframework.web.portlet.ModelAndView
;
import
org.springframework.web.portlet.context.PortletConfigAware
;
import
org.springframework.web.portlet.context.PortletContextAware
;
import
org.springframework.web.portlet.util.PortletUtils
;
/**
* {@link Controller} implementation that wraps a portlet instance which it manages
...
...
@@ -71,7 +80,8 @@ import org.springframework.web.portlet.context.PortletContextAware;
* @since 2.0
*/
public
class
PortletWrappingController
extends
AbstractController
implements
BeanNameAware
,
InitializingBean
,
DisposableBean
,
PortletContextAware
,
PortletConfigAware
{
implements
ResourceAwareController
,
EventAwareController
,
BeanNameAware
,
InitializingBean
,
DisposableBean
,
PortletContextAware
,
PortletConfigAware
{
private
boolean
useSharedPortletConfig
=
true
;
...
...
@@ -176,6 +186,61 @@ public class PortletWrappingController extends AbstractController
return
null
;
}
public
ModelAndView
handleResourceRequest
(
ResourceRequest
request
,
ResourceResponse
response
)
throws
Exception
{
if
(!(
this
.
portletInstance
instanceof
ResourceServingPortlet
))
{
throw
new
UnavailableException
(
"Cannot handle resource request - target portlet ["
+
this
.
portletInstance
.
getClass
()
+
" does not implement ResourceServingPortlet"
);
}
ResourceServingPortlet
resourcePortlet
=
(
ResourceServingPortlet
)
this
.
portletInstance
;
// Delegate to PortletContentGenerator for checking and preparing.
checkAndPrepare
(
request
,
response
);
// Execute in synchronized block if required.
if
(
isSynchronizeOnSession
())
{
PortletSession
session
=
request
.
getPortletSession
(
false
);
if
(
session
!=
null
)
{
Object
mutex
=
PortletUtils
.
getSessionMutex
(
session
);
synchronized
(
mutex
)
{
resourcePortlet
.
serveResource
(
request
,
response
);
return
null
;
}
}
}
resourcePortlet
.
serveResource
(
request
,
response
);
return
null
;
}
public
void
handleEventRequest
(
EventRequest
request
,
EventResponse
response
)
throws
Exception
{
if
(!(
this
.
portletInstance
instanceof
EventPortlet
))
{
logger
.
debug
(
"Ignoring event request for non-event target portlet: "
+
this
.
portletInstance
.
getClass
());
return
;
}
EventPortlet
eventPortlet
=
(
EventPortlet
)
this
.
portletInstance
;
// Delegate to PortletContentGenerator for checking and preparing.
check
(
request
,
response
);
// Execute in synchronized block if required.
if
(
isSynchronizeOnSession
())
{
PortletSession
session
=
request
.
getPortletSession
(
false
);
if
(
session
!=
null
)
{
Object
mutex
=
PortletUtils
.
getSessionMutex
(
session
);
synchronized
(
mutex
)
{
eventPortlet
.
processEvent
(
request
,
response
);
return
;
}
}
}
eventPortlet
.
processEvent
(
request
,
response
);
}
public
void
destroy
()
{
this
.
portletInstance
.
destroy
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录