Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
307fb0ae
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,发现更多精彩内容 >>
提交
307fb0ae
编写于
7月 27, 2009
作者:
A
Arjen Poutsma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SPR-5942: MarshallingHttpMessageConverter should not require both marshaller and unmarshaller
上级
ac56f1f9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
5 addition
and
17 deletion
+5
-17
org.springframework.web/src/main/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverter.java
...k/http/converter/xml/MarshallingHttpMessageConverter.java
+5
-17
未找到文件。
org.springframework.web/src/main/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverter.java
浏览文件 @
307fb0ae
...
...
@@ -20,7 +20,6 @@ import java.io.IOException;
import
javax.xml.transform.Result
;
import
javax.xml.transform.Source
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.converter.HttpMessageNotReadableException
;
import
org.springframework.http.converter.HttpMessageNotWritableException
;
...
...
@@ -44,8 +43,7 @@ import org.springframework.util.Assert;
* @author Arjen Poutsma
* @since 3.0
*/
public
class
MarshallingHttpMessageConverter
extends
AbstractXmlHttpMessageConverter
<
Object
>
implements
InitializingBean
{
public
class
MarshallingHttpMessageConverter
extends
AbstractXmlHttpMessageConverter
<
Object
>
{
private
Marshaller
marshaller
;
...
...
@@ -66,18 +64,11 @@ public class MarshallingHttpMessageConverter extends AbstractXmlHttpMessageConve
* {@code Unmarshaller} interface, so that you can safely use this constructor.
*
* @param marshaller object used as marshaller and unmarshaller
* @throws IllegalArgumentException when <code>marshaller</code> does not implement the {@link Unmarshaller} interface
* as well
*/
public
MarshallingHttpMessageConverter
(
Marshaller
marshaller
)
{
Assert
.
notNull
(
marshaller
,
"marshaller must not be null"
);
if
(!(
marshaller
instanceof
Unmarshaller
))
{
throw
new
IllegalArgumentException
(
"Marshaller ["
+
marshaller
+
"] does not implement the Unmarshaller "
+
"interface. Please set an Unmarshaller explicitely by using the "
+
"MarshallingHttpMessageConverter(Marshaller, Unmarshaller) constructor."
);
}
else
{
this
.
marshaller
=
marshaller
;
this
.
marshaller
=
marshaller
;
if
(
marshaller
instanceof
Unmarshaller
)
{
this
.
unmarshaller
=
(
Unmarshaller
)
marshaller
;
}
}
...
...
@@ -106,17 +97,13 @@ public class MarshallingHttpMessageConverter extends AbstractXmlHttpMessageConve
this
.
unmarshaller
=
unmarshaller
;
}
public
void
afterPropertiesSet
()
{
Assert
.
notNull
(
this
.
marshaller
,
"Property 'marshaller' is required"
);
Assert
.
notNull
(
this
.
unmarshaller
,
"Property 'unmarshaller' is required"
);
}
public
boolean
supports
(
Class
<?>
clazz
)
{
return
unmarshaller
.
supports
(
clazz
);
}
@Override
protected
Object
readFromSource
(
Class
<
Object
>
clazz
,
HttpHeaders
headers
,
Source
source
)
throws
IOException
{
Assert
.
notNull
(
this
.
unmarshaller
,
"Property 'unmarshaller' is required"
);
try
{
return
unmarshaller
.
unmarshal
(
source
);
}
...
...
@@ -127,6 +114,7 @@ public class MarshallingHttpMessageConverter extends AbstractXmlHttpMessageConve
@Override
protected
void
writeToResult
(
Object
o
,
HttpHeaders
headers
,
Result
result
)
throws
IOException
{
Assert
.
notNull
(
this
.
marshaller
,
"Property 'marshaller' is required"
);
try
{
marshaller
.
marshal
(
o
,
result
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录