Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
d64bc93e
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,发现更多精彩内容 >>
提交
d64bc93e
编写于
7月 21, 2009
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updated Hessian support for Hessian 3.2 compatibility; general remoting refinements
上级
05903d64
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
140 addition
and
73 deletion
+140
-73
org.springframework.web/src/main/java/org/springframework/remoting/caucho/HessianExporter.java
.../org/springframework/remoting/caucho/HessianExporter.java
+88
-60
org.springframework.web/src/main/java/org/springframework/remoting/caucho/HessianServiceExporter.java
...ringframework/remoting/caucho/HessianServiceExporter.java
+2
-2
org.springframework.web/src/main/java/org/springframework/remoting/caucho/SimpleBurlapServiceExporter.java
...ramework/remoting/caucho/SimpleBurlapServiceExporter.java
+2
-2
org.springframework.web/src/main/java/org/springframework/remoting/caucho/SimpleHessianServiceExporter.java
...amework/remoting/caucho/SimpleHessianServiceExporter.java
+4
-3
org.springframework.web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerServiceExporter.java
...emoting/httpinvoker/SimpleHttpInvokerServiceExporter.java
+3
-2
org.springframework.web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java
.../springframework/remoting/caucho/CauchoRemotingTests.java
+38
-1
org.springframework.web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java
...org/springframework/remoting/jaxws/JaxWsSupportTests.java
+3
-3
未找到文件。
org.springframework.web/src/main/java/org/springframework/remoting/caucho/HessianExporter.java
浏览文件 @
d64bc93e
...
...
@@ -16,6 +16,7 @@
package
org.springframework.remoting.caucho
;
import
java.io.BufferedInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
...
...
@@ -44,7 +45,7 @@ import org.springframework.util.CommonsLogWriter;
* <p>Hessian is a slim, binary RPC protocol.
* For information on Hessian, see the
* <a href="http://www.caucho.com/hessian">Hessian website</a>.
*
This exporter requires Hessian 3.1.3 or above.
*
<b>Note: As of Spring 3.0, this exporter requires Hessian 3.2 or above.</b>
*
* @author Juergen Hoeller
* @since 2.5.1
...
...
@@ -114,81 +115,108 @@ public class HessianExporter extends RemoteExporter implements InitializingBean
*/
public
void
invoke
(
InputStream
inputStream
,
OutputStream
outputStream
)
throws
Throwable
{
Assert
.
notNull
(
this
.
skeleton
,
"Hessian exporter has not been initialized"
);
ClassLoader
originalClassLoader
=
overrideThreadContextClassLoader
();
try
{
doInvoke
(
inputStream
,
outputStream
);
}
finally
{
resetThreadContextClassLoader
(
originalClassLoader
);
}
doInvoke
(
this
.
skeleton
,
inputStream
,
outputStream
);
}
public
void
doInvoke
(
final
InputStream
inputStream
,
final
OutputStream
outputStream
)
throws
Throwable
{
InputStream
isToUse
=
inputStream
;
OutputStream
osToUse
=
outputStream
;
if
(
this
.
debugLogger
!=
null
&&
this
.
debugLogger
.
isDebugEnabled
())
{
PrintWriter
debugWriter
=
new
PrintWriter
(
new
CommonsLogWriter
(
this
.
debugLogger
));
isToUse
=
new
HessianDebugInputStream
(
inputStream
,
debugWriter
);
osToUse
=
new
HessianDebugOutputStream
(
outputStream
,
debugWriter
);
}
/**
* Actually invoke the skeleton with the given streams.
* @param skeleton the skeleton to invoke
* @param inputStream the request stream
* @param outputStream the response stream
* @throws Throwable if invocation failed
*/
protected
void
doInvoke
(
HessianSkeleton
skeleton
,
InputStream
inputStream
,
OutputStream
outputStream
)
throws
Throwable
{
int
code
=
isToUse
.
read
();
int
major
;
int
minor
;
ClassLoader
originalClassLoader
=
overrideThreadContextClassLoader
();
try
{
InputStream
isToUse
=
inputStream
;
OutputStream
osToUse
=
outputStream
;
if
(
this
.
debugLogger
!=
null
&&
this
.
debugLogger
.
isDebugEnabled
())
{
PrintWriter
debugWriter
=
new
PrintWriter
(
new
CommonsLogWriter
(
this
.
debugLogger
));
HessianDebugInputStream
dis
=
new
HessianDebugInputStream
(
inputStream
,
debugWriter
);
dis
.
startTop2
();
HessianDebugOutputStream
dos
=
new
HessianDebugOutputStream
(
outputStream
,
debugWriter
);
dos
.
startTop2
();
isToUse
=
dis
;
osToUse
=
dos
;
}
AbstractHessianInput
in
;
AbstractHessianOutput
out
;
if
(!
isToUse
.
markSupported
())
{
isToUse
=
new
BufferedInputStream
(
isToUse
);
isToUse
.
mark
(
1
);
}
if
(
code
==
'H'
)
{
major
=
isToUse
.
read
();
minor
=
isToUse
.
read
();
if
(
major
!=
0x02
)
{
throw
new
IOException
(
"Version "
+
major
+
"."
+
minor
+
" is not understood"
);
int
code
=
isToUse
.
read
();
int
major
;
int
minor
;
AbstractHessianInput
in
;
AbstractHessianOutput
out
;
if
(
code
==
'H'
)
{
// Hessian 2.0 stream
major
=
isToUse
.
read
();
minor
=
isToUse
.
read
();
if
(
major
!=
0x02
)
{
throw
new
IOException
(
"Version "
+
major
+
"."
+
minor
+
" is not understood"
);
}
in
=
new
Hessian2Input
(
isToUse
);
out
=
new
Hessian2Output
(
osToUse
);
in
.
readCall
();
}
in
=
new
Hessian2Input
(
isToUse
);
out
=
new
Hessian2Output
(
osToUse
);
in
.
readCall
();
}
else
if
(
code
==
'c'
)
{
major
=
isToUse
.
read
();
minor
=
isToUse
.
read
();
in
=
new
HessianInput
(
isToUse
);
if
(
major
>=
2
)
{
else
if
(
code
==
'C'
)
{
// Hessian 2.0 call... for some reason not handled in HessianServlet!
isToUse
.
reset
();
in
=
new
Hessian2Input
(
isToUse
);
out
=
new
Hessian2Output
(
osToUse
);
in
.
readCall
();
}
else
if
(
code
==
'c'
)
{
// Hessian 1.0 call
major
=
isToUse
.
read
();
minor
=
isToUse
.
read
();
in
=
new
HessianInput
(
isToUse
);
if
(
major
>=
2
)
{
out
=
new
Hessian2Output
(
osToUse
);
}
else
{
out
=
new
HessianOutput
(
osToUse
);
}
}
else
{
out
=
new
HessianOutput
(
osToUs
e
);
throw
new
IOException
(
"Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at "
+
cod
e
);
}
}
else
{
throw
new
IOException
(
"Expected 'H' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at "
+
code
);
}
if
(
this
.
serializerFactory
!=
null
)
{
in
.
setSerializerFactory
(
this
.
serializerFactory
);
out
.
setSerializerFactory
(
this
.
serializerFactory
);
}
try
{
this
.
skeleton
.
invoke
(
in
,
out
);
}
finally
{
try
{
in
.
close
();
isToUse
.
close
();
}
catch
(
IOException
ex
)
{
// ignore
if
(
this
.
serializerFactory
!=
null
)
{
in
.
setSerializerFactory
(
this
.
serializerFactory
);
out
.
setSerializerFactory
(
this
.
serializerFactory
);
}
try
{
out
.
close
();
osToUse
.
close
();
skeleton
.
invoke
(
in
,
out
);
}
catch
(
IOException
ex
)
{
// ignore
finally
{
try
{
in
.
close
();
isToUse
.
close
();
}
catch
(
IOException
ex
)
{
// ignore
}
try
{
out
.
close
();
osToUse
.
close
();
}
catch
(
IOException
ex
)
{
// ignore
}
}
}
finally
{
resetThreadContextClassLoader
(
originalClassLoader
);
}
}
}
org.springframework.web/src/main/java/org/springframework/remoting/caucho/HessianServiceExporter.java
浏览文件 @
d64bc93e
...
...
@@ -35,9 +35,9 @@ import org.springframework.web.util.NestedServletException;
* <p>Hessian is a slim, binary RPC protocol.
* For information on Hessian, see the
* <a href="http://www.caucho.com/hessian">Hessian website</a>.
*
This exporter requires Hessian 3.1.3 or above.
*
<b>Note: As of Spring 3.0, this exporter requires Hessian 3.2 or above.</b>
*
* <p>
Note:
Hessian services exported with this class can be accessed by
* <p>Hessian services exported with this class can be accessed by
* any Hessian client, as there isn't any special handling involved.
*
* @author Juergen Hoeller
...
...
org.springframework.web/src/main/java/org/springframework/remoting/caucho/SimpleBurlapServiceExporter.java
浏览文件 @
d64bc93e
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -63,7 +63,7 @@ public class SimpleBurlapServiceExporter extends BurlapExporter implements HttpH
}
catch
(
Throwable
ex
)
{
exchange
.
sendResponseHeaders
(
500
,
-
1
);
throw
new
IOException
(
"Burlap skeleton invocation failed"
,
ex
);
logger
.
error
(
"Burlap skeleton invocation failed"
,
ex
);
}
exchange
.
sendResponseHeaders
(
200
,
output
.
size
());
...
...
org.springframework.web/src/main/java/org/springframework/remoting/caucho/SimpleHessianServiceExporter.java
浏览文件 @
d64bc93e
...
...
@@ -33,9 +33,9 @@ import org.springframework.util.FileCopyUtils;
* <p>Hessian is a slim, binary RPC protocol.
* For information on Hessian, see the
* <a href="http://www.caucho.com/hessian">Hessian website</a>.
*
This exporter requires Hessian 3.1.3 or above.
*
<b>Note: As of Spring 3.0, this exporter requires Hessian 3.2 or above.</b>
*
* <p>
Note:
Hessian services exported with this class can be accessed by
* <p>Hessian services exported with this class can be accessed by
* any Hessian client, as there isn't any special handling involved.
*
* @author Juergen Hoeller
...
...
@@ -63,7 +63,8 @@ public class SimpleHessianServiceExporter extends HessianExporter implements Htt
}
catch
(
Throwable
ex
)
{
exchange
.
sendResponseHeaders
(
500
,
-
1
);
throw
new
IOException
(
"Hessian skeleton invocation failed"
,
ex
);
logger
.
error
(
"Hessian skeleton invocation failed"
,
ex
);
return
;
}
exchange
.
getResponseHeaders
().
set
(
"Content-Type"
,
CONTENT_TYPE_HESSIAN
);
...
...
org.springframework.web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerServiceExporter.java
浏览文件 @
d64bc93e
/*
* Copyright 2002-200
7
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -69,7 +69,8 @@ public class SimpleHttpInvokerServiceExporter extends RemoteInvocationSerializin
exchange
.
close
();
}
catch
(
ClassNotFoundException
ex
)
{
throw
new
IOException
(
"Class not found during deserialization"
,
ex
);
exchange
.
sendResponseHeaders
(
500
,
-
1
);
logger
.
error
(
"Class not found during deserialization"
,
ex
);
}
}
...
...
org.springframework.web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java
浏览文件 @
d64bc93e
/*
* Copyright 2002-200
7
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -16,12 +16,19 @@
package
org.springframework.remoting.caucho
;
import
java.io.IOException
;
import
java.net.InetSocketAddress
;
import
com.caucho.burlap.client.BurlapProxyFactory
;
import
com.caucho.hessian.client.HessianProxyFactory
;
import
com.sun.net.httpserver.HttpServer
;
import
junit.framework.TestCase
;
import
org.junit.Ignore
;
import
org.springframework.aop.framework.ProxyFactory
;
import
org.springframework.beans.ITestBean
;
import
org.springframework.beans.TestBean
;
import
org.springframework.core.JdkVersion
;
import
org.springframework.remoting.RemoteAccessException
;
/**
...
...
@@ -181,6 +188,36 @@ public class CauchoRemotingTests extends TestCase {
}
}
@Ignore
(
"Using the JDK 1.6 HttpServer breaks when running multiple test methods"
)
public
void
testSimpleHessianServiceExporter
()
throws
IOException
{
if
(
JdkVersion
.
getMajorJavaVersion
()
<
JdkVersion
.
JAVA_16
)
{
return
;
}
TestBean
tb
=
new
TestBean
(
"tb"
);
SimpleHessianServiceExporter
exporter
=
new
SimpleHessianServiceExporter
();
exporter
.
setService
(
tb
);
exporter
.
setServiceInterface
(
ITestBean
.
class
);
exporter
.
setDebug
(
true
);
exporter
.
prepare
();
HttpServer
server
=
HttpServer
.
create
(
new
InetSocketAddress
(
8889
),
-
1
);
server
.
createContext
(
"/hessian"
,
exporter
);
server
.
start
();
try
{
HessianClientInterceptor
client
=
new
HessianClientInterceptor
();
client
.
setServiceUrl
(
"http://localhost:8889/hessian"
);
client
.
setServiceInterface
(
ITestBean
.
class
);
//client.setHessian2(true);
client
.
prepare
();
ITestBean
proxy
=
ProxyFactory
.
getProxy
(
ITestBean
.
class
,
client
);
assertEquals
(
"tb"
,
proxy
.
getName
());
proxy
.
setName
(
"test"
);
assertEquals
(
"test"
,
proxy
.
getName
());
}
finally
{
server
.
stop
(
Integer
.
MAX_VALUE
);
}
}
private
static
class
TestHessianProxyFactory
extends
HessianProxyFactory
{
...
...
org.springframework.web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java
浏览文件 @
d64bc93e
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -75,7 +75,7 @@ public class JaxWsSupportTests extends TestCase {
try
{
ac
.
refresh
();
OrderService
orderService
=
(
OrderService
)
ac
.
getBean
(
"client"
,
OrderService
.
class
);
OrderService
orderService
=
ac
.
getBean
(
"client"
,
OrderService
.
class
);
assertTrue
(
orderService
instanceof
BindingProvider
);
((
BindingProvider
)
orderService
).
getRequestContext
();
...
...
@@ -89,7 +89,7 @@ public class JaxWsSupportTests extends TestCase {
// expected
}
ServiceAccessor
serviceAccessor
=
(
ServiceAccessor
)
ac
.
getBean
(
"accessor"
,
ServiceAccessor
.
class
);
ServiceAccessor
serviceAccessor
=
ac
.
getBean
(
"accessor"
,
ServiceAccessor
.
class
);
order
=
serviceAccessor
.
orderService
.
getOrder
(
1000
);
assertEquals
(
"order 1000"
,
order
);
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录