Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
1fe742ad
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,发现更多精彩内容 >>
提交
1fe742ad
编写于
7月 29, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MessagingExceptionTranslator lives in support subpackage now
Issue: SPR-12038
上级
9be04b38
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
31 addition
and
24 deletion
+31
-24
spring-jms/src/main/java/org/springframework/jms/core/JmsMessagingTemplate.java
...va/org/springframework/jms/core/JmsMessagingTemplate.java
+10
-9
spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java
...main/java/org/springframework/jms/core/JmsOperations.java
+3
-0
spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java
...c/main/java/org/springframework/jms/core/JmsTemplate.java
+2
-1
spring-jms/src/main/java/org/springframework/jms/support/JmsMessagingExceptionTranslator.java
...ramework/jms/support/JmsMessagingExceptionTranslator.java
+4
-6
spring-jms/src/test/java/org/springframework/jms/support/JmsMessagingExceptionTranslatorTests.java
...ork/jms/support/JmsMessagingExceptionTranslatorTests.java
+2
-1
spring-messaging/src/main/java/org/springframework/messaging/support/MessagingExceptionTranslator.java
...ework/messaging/support/MessagingExceptionTranslator.java
+10
-7
未找到文件。
spring-jms/src/main/java/org/springframework/jms/core/JmsMessagingTemplate.java
浏览文件 @
1fe742ad
...
...
@@ -23,15 +23,16 @@ import javax.jms.Session;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.jms.JmsException
;
import
org.springframework.jms.support.JmsMessagingExceptionTranslator
;
import
org.springframework.jms.support.converter.MessageConverter
;
import
org.springframework.jms.support.converter.MessagingMessageConverter
;
import
org.springframework.jms.support.converter.SimpleMessageConverter
;
import
org.springframework.messaging.Message
;
import
org.springframework.messaging.MessagingException
;
import
org.springframework.messaging.MessagingExceptionTranslator
;
import
org.springframework.messaging.converter.MessageConversionException
;
import
org.springframework.messaging.core.AbstractMessagingTemplate
;
import
org.springframework.messaging.core.MessagePostProcessor
;
import
org.springframework.messaging.support.MessagingExceptionTranslator
;
import
org.springframework.util.Assert
;
/**
...
...
@@ -230,14 +231,14 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
public
Message
<?>
sendAndReceive
(
String
destinationName
,
Message
<?>
requestMessage
)
throws
MessagingException
{
public
Message
<?>
sendAndReceive
(
String
destinationName
,
Message
<?>
requestMessage
)
throws
MessagingException
{
return
doSendAndReceive
(
destinationName
,
requestMessage
);
}
@Override
public
<
T
>
T
convertSendAndReceive
(
String
destinationName
,
Object
request
,
Class
<
T
>
targetClass
)
throws
MessagingException
{
return
convertSendAndReceive
(
destinationName
,
request
,
null
,
targetClass
);
}
...
...
@@ -324,8 +325,8 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
@Override
protected
Message
<?>
doSendAndReceive
(
Destination
destination
,
Message
<?>
requestMessage
)
{
try
{
javax
.
jms
.
Message
jmsMessage
=
this
.
jmsTemplate
.
sendAndReceive
(
destination
,
createMessageCreator
(
requestMessage
));
javax
.
jms
.
Message
jmsMessage
=
this
.
jmsTemplate
.
sendAndReceive
(
destination
,
createMessageCreator
(
requestMessage
));
return
doConvert
(
jmsMessage
);
}
catch
(
JmsException
ex
)
{
...
...
@@ -335,8 +336,8 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
protected
Message
<?>
doSendAndReceive
(
String
destinationName
,
Message
<?>
requestMessage
)
{
try
{
javax
.
jms
.
Message
jmsMessage
=
this
.
jmsTemplate
.
sendAndReceive
(
destinationName
,
createMessageCreator
(
requestMessage
));
javax
.
jms
.
Message
jmsMessage
=
this
.
jmsTemplate
.
sendAndReceive
(
destinationName
,
createMessageCreator
(
requestMessage
));
return
doConvert
(
jmsMessage
);
}
catch
(
JmsException
ex
)
{
...
...
@@ -396,10 +397,10 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
return
this
.
messageConverter
.
toMessage
(
this
.
message
,
session
);
}
catch
(
JMSException
ex
)
{
throw
new
MessageConversionException
(
"Could not convert '"
+
message
+
"'"
,
ex
);
throw
new
MessageConversionException
(
"Could not convert '"
+
this
.
message
+
"'"
,
ex
);
}
catch
(
JmsException
ex
)
{
throw
new
MessageConversionException
(
"Could not convert '"
+
message
+
"'"
,
ex
);
throw
new
MessageConversionException
(
"Could not convert '"
+
this
.
message
+
"'"
,
ex
);
}
}
}
...
...
spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java
浏览文件 @
1fe742ad
...
...
@@ -367,6 +367,7 @@ public interface JmsOperations {
* @return the reply, possibly {@code null} if the message could not be received,
* for example due to a timeout
* @throws JmsException checked JMSException converted to unchecked
* @since 4.1
*/
Message
sendAndReceive
(
MessageCreator
messageCreator
)
throws
JmsException
;
...
...
@@ -380,6 +381,7 @@ public interface JmsOperations {
* @return the reply, possibly {@code null} if the message could not be received,
* for example due to a timeout
* @throws JmsException checked JMSException converted to unchecked
* @since 4.1
*/
Message
sendAndReceive
(
Destination
destination
,
MessageCreator
messageCreator
)
throws
JmsException
;
...
...
@@ -394,6 +396,7 @@ public interface JmsOperations {
* @return the reply, possibly {@code null} if the message could not be received,
* for example due to a timeout
* @throws JmsException checked JMSException converted to unchecked
* @since 4.1
*/
Message
sendAndReceive
(
String
destinationName
,
MessageCreator
messageCreator
)
throws
JmsException
;
...
...
spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java
浏览文件 @
1fe742ad
...
...
@@ -936,6 +936,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
*/
protected
Message
doSendAndReceive
(
Session
session
,
Destination
destination
,
MessageCreator
messageCreator
)
throws
JMSException
{
Assert
.
notNull
(
messageCreator
,
"MessageCreator must not be null"
);
TemporaryQueue
responseQueue
=
null
;
MessageProducer
producer
=
null
;
...
...
@@ -963,7 +964,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
/**
* A variant of {@link #execute(SessionCallback, boolean)} that explicitly
* creates a non
transactional session
. The given {@link SessionCallback}
* creates a non
-transactional {@link Session}
. The given {@link SessionCallback}
* does not participate in an existing transaction.
*/
private
<
T
>
T
executeLocal
(
SessionCallback
<
T
>
action
,
boolean
startConnection
)
throws
JmsException
{
...
...
spring-jms/src/main/java/org/springframework/jms/
core
/JmsMessagingExceptionTranslator.java
→
spring-jms/src/main/java/org/springframework/jms/
support
/JmsMessagingExceptionTranslator.java
浏览文件 @
1fe742ad
...
...
@@ -14,14 +14,14 @@
* limitations under the License.
*/
package
org.springframework.jms.
core
;
package
org.springframework.jms.
support
;
import
org.springframework.jms.InvalidDestinationException
;
import
org.springframework.jms.JmsException
;
import
org.springframework.jms.support.converter.MessageConversionException
;
import
org.springframework.jms.support.destination.DestinationResolutionException
;
import
org.springframework.messaging.MessagingException
;
import
org.springframework.messaging.MessagingExceptionTranslator
;
import
org.springframework.messaging.
support.
MessagingExceptionTranslator
;
/**
* {@link MessagingExceptionTranslator} capable of translating {@link JmsException}
...
...
@@ -41,16 +41,14 @@ public class JmsMessagingExceptionTranslator implements MessagingExceptionTransl
}
private
MessagingException
convertJmsException
(
JmsException
ex
)
{
if
(
ex
instanceof
DestinationResolutionException
||
ex
instanceof
InvalidDestinationException
)
{
if
(
ex
instanceof
DestinationResolutionException
||
ex
instanceof
InvalidDestinationException
)
{
return
new
org
.
springframework
.
messaging
.
core
.
DestinationResolutionException
(
ex
.
getMessage
(),
ex
);
}
if
(
ex
instanceof
MessageConversionException
)
{
return
new
org
.
springframework
.
messaging
.
converter
.
MessageConversionException
(
ex
.
getMessage
(),
ex
);
}
// Fallback
return
new
MessagingException
(
ex
.
getMessage
(),
ex
);
}
}
spring-jms/src/test/java/org/springframework/jms/
core
/JmsMessagingExceptionTranslatorTests.java
→
spring-jms/src/test/java/org/springframework/jms/
support
/JmsMessagingExceptionTranslatorTests.java
浏览文件 @
1fe742ad
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org.springframework.jms.
core
;
package
org.springframework.jms.
support
;
import
org.junit.Test
;
...
...
@@ -31,4 +31,5 @@ public class JmsMessagingExceptionTranslatorTests {
public
void
translateNonJmsException
()
{
assertNull
(
translator
.
translateExceptionIfPossible
(
new
NullPointerException
()));
}
}
spring-messaging/src/main/java/org/springframework/messaging/MessagingExceptionTranslator.java
→
spring-messaging/src/main/java/org/springframework/messaging/
support/
MessagingExceptionTranslator.java
浏览文件 @
1fe742ad
...
...
@@ -14,7 +14,9 @@
* limitations under the License.
*/
package
org.springframework.messaging
;
package
org.springframework.messaging.support
;
import
org.springframework.messaging.MessagingException
;
/**
* Interface implemented by Spring integrations with messaging technologies
...
...
@@ -31,14 +33,15 @@ public interface MessagingExceptionTranslator {
/**
* Translate the given runtime exception thrown by a messaging implementation
* to a corresponding exception from Spring's generic
{@link MessagingException}
* hierarchy, if possible.
* <p>Do not translate exceptions that are not underst
an
d by this translator:
* for example, if resulting from user code
and
unrelated to messaging.
* @param ex a RuntimeException t
hrown
* to a corresponding exception from Spring's generic
*
{@link org.springframework.messaging.MessagingException}
hierarchy, if possible.
* <p>Do not translate exceptions that are not underst
oo
d by this translator:
* for example, if resulting from user code
or otherwise
unrelated to messaging.
* @param ex a RuntimeException t
o translate
* @return the corresponding MessagingException (or {@code null} if the
* exception could not be translated, as in this case it may result from
* user code rather than an actual messaging problem)
* user code rather than
from
an actual messaging problem)
*/
MessagingException
translateExceptionIfPossible
(
RuntimeException
ex
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录