Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
1fadd1c9
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,发现更多精彩内容 >>
提交
1fadd1c9
编写于
7月 09, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BackOff abstraction lives in util.backoff subpackage now
Issue: SPR-11746
上级
bf9ccc81
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
67 addition
and
54 deletion
+67
-54
spring-core/src/main/java/org/springframework/util/backoff/BackOff.java
...c/main/java/org/springframework/util/backoff/BackOff.java
+14
-16
spring-core/src/main/java/org/springframework/util/backoff/BackOffExecution.java
...va/org/springframework/util/backoff/BackOffExecution.java
+2
-2
spring-core/src/main/java/org/springframework/util/backoff/ExponentialBackOff.java
.../org/springframework/util/backoff/ExponentialBackOff.java
+2
-2
spring-core/src/main/java/org/springframework/util/backoff/FixedBackOff.java
...n/java/org/springframework/util/backoff/FixedBackOff.java
+2
-2
spring-core/src/main/java/org/springframework/util/backoff/package-info.java
...n/java/org/springframework/util/backoff/package-info.java
+8
-0
spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java
...ava/org/springframework/util/ExponentialBackOffTests.java
+3
-0
spring-core/src/test/java/org/springframework/util/FixedBackOffTests.java
...test/java/org/springframework/util/FixedBackOffTests.java
+3
-0
spring-jms/src/main/java/org/springframework/jms/config/DefaultJmsListenerContainerFactory.java
...mework/jms/config/DefaultJmsListenerContainerFactory.java
+13
-11
spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java
...amework/jms/listener/DefaultMessageListenerContainer.java
+3
-3
spring-jms/src/main/resources/org/springframework/jms/config/spring-jms-4.1.xsd
...sources/org/springframework/jms/config/spring-jms-4.1.xsd
+1
-1
spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java
...ramework/jms/config/JmsListenerContainerFactoryTests.java
+5
-5
spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java
.../springframework/jms/config/JmsNamespaceHandlerTests.java
+5
-6
spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java
...rk/jms/listener/DefaultMessageListenerContainerTests.java
+5
-5
spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml
...g/springframework/jms/config/jmsNamespaceHandlerTests.xml
+1
-1
未找到文件。
spring-core/src/main/java/org/springframework/util/BackOff.java
→
spring-core/src/main/java/org/springframework/util/
backoff/
BackOff.java
浏览文件 @
1fadd1c9
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org.springframework.util
;
package
org.springframework.util
.backoff
;
/**
* Provide a {@link BackOffExecution} that indicates the rate at which
...
...
@@ -23,23 +23,21 @@ package org.springframework.util;
* <p>Users of this interface are expected to use it like this:
*
* <pre class="code">
* {@code
*
* BackOffExecution exec = backOff.start();
*
* // In the operation recovery/retry loop:
* long waitInterval = exec.nextBackOffMillis();
* if (waitInterval == BackOffExecution.STOP) {
* // do not retry operation
* }
* else {
* // sleep, e.g. Thread.sleep(waitInterval)
* // retry operation
* }
* BackOffExecution exec = backOff.start();
*
* // In the operation recovery/retry loop:
* long waitInterval = exec.nextBackOffMillis();
* if (waitInterval == BackOffExecution.STOP) {
* // do not retry operation
* }
* else {
* // sleep, e.g. Thread.sleep(waitInterval)
* // retry operation
* }
* }</pre>
*
* Once the underlying operation has completed successfully,
the execution
* instance can be simply discarded.
* Once the underlying operation has completed successfully,
*
the execution
instance can be simply discarded.
*
* @author Stephane Nicoll
* @since 4.1
...
...
spring-core/src/main/java/org/springframework/util/BackOffExecution.java
→
spring-core/src/main/java/org/springframework/util/
backoff/
BackOffExecution.java
浏览文件 @
1fadd1c9
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org.springframework.util
;
package
org.springframework.util
.backoff
;
/**
* Represent a particular back-off execution.
...
...
@@ -23,7 +23,7 @@ package org.springframework.util;
*
* @author Stephane Nicoll
* @since 4.1
* @see
org.springframework.util.
BackOff
* @see BackOff
*/
public
interface
BackOffExecution
{
...
...
spring-core/src/main/java/org/springframework/util/ExponentialBackOff.java
→
spring-core/src/main/java/org/springframework/util/
backoff/
ExponentialBackOff.java
浏览文件 @
1fadd1c9
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org.springframework.util
;
package
org.springframework.util
.backoff
;
/**
* Implementation of {@link BackOff} that increases the back off period for each
...
...
@@ -184,7 +184,7 @@ public class ExponentialBackOff implements BackOff {
@Override
public
long
nextBackOff
()
{
if
(
currentElapsedTime
>=
maxElapsedTime
)
{
return
BackOffExecution
.
STOP
;
return
STOP
;
}
long
nextInterval
=
computeNextInterval
();
...
...
spring-core/src/main/java/org/springframework/util/FixedBackOff.java
→
spring-core/src/main/java/org/springframework/util/
backoff/
FixedBackOff.java
浏览文件 @
1fadd1c9
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org.springframework.util
;
package
org.springframework.util
.backoff
;
/**
* A simple {@link BackOff} implementation that provides a fixed interval
...
...
@@ -102,7 +102,7 @@ public class FixedBackOff implements BackOff {
return
getInterval
();
}
else
{
return
BackOffExecution
.
STOP
;
return
STOP
;
}
}
...
...
spring-core/src/main/java/org/springframework/util/backoff/package-info.java
0 → 100644
浏览文件 @
1fadd1c9
/**
*
* A generic back-off abstraction.
*
*/
package
org.springframework.util.backoff
;
spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java
浏览文件 @
1fadd1c9
...
...
@@ -22,6 +22,9 @@ import org.junit.Rule;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.util.backoff.BackOffExecution
;
import
org.springframework.util.backoff.ExponentialBackOff
;
/**
*
* @author Stephane Nicoll
...
...
spring-core/src/test/java/org/springframework/util/FixedBackOffTests.java
浏览文件 @
1fadd1c9
...
...
@@ -20,6 +20,9 @@ import static org.junit.Assert.*;
import
org.junit.Test
;
import
org.springframework.util.backoff.BackOffExecution
;
import
org.springframework.util.backoff.FixedBackOff
;
/**
* @author Stephane Nicoll
*/
...
...
spring-jms/src/main/java/org/springframework/jms/config/DefaultJmsListenerContainerFactory.java
浏览文件 @
1fadd1c9
...
...
@@ -20,7 +20,7 @@ import java.util.concurrent.Executor;
import
org.springframework.jms.listener.DefaultMessageListenerContainer
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.util.BackOff
;
import
org.springframework.util.
backoff.
BackOff
;
/**
* A {@link JmsListenerContainerFactory} implementation to build regular
...
...
@@ -54,69 +54,71 @@ public class DefaultJmsListenerContainerFactory
private
BackOff
backOff
;
/**
* @see DefaultMessageListenerContainer#setTaskExecutor
(java.util.concurrent.Executor)
* @see DefaultMessageListenerContainer#setTaskExecutor
*/
public
void
setTaskExecutor
(
Executor
taskExecutor
)
{
this
.
taskExecutor
=
taskExecutor
;
}
/**
* @see DefaultMessageListenerContainer#setTransactionManager
(PlatformTransactionManager)
* @see DefaultMessageListenerContainer#setTransactionManager
*/
public
void
setTransactionManager
(
PlatformTransactionManager
transactionManager
)
{
this
.
transactionManager
=
transactionManager
;
}
/**
* @see DefaultMessageListenerContainer#setCacheLevel
(int)
* @see DefaultMessageListenerContainer#setCacheLevel
*/
public
void
setCacheLevel
(
Integer
cacheLevel
)
{
this
.
cacheLevel
=
cacheLevel
;
}
/**
* @see DefaultMessageListenerContainer#setCacheLevelName
(String)
* @see DefaultMessageListenerContainer#setCacheLevelName
*/
public
void
setCacheLevelName
(
String
cacheLevelName
)
{
this
.
cacheLevelName
=
cacheLevelName
;
}
/**
* @see DefaultMessageListenerContainer#setConcurrency
(String)
* @see DefaultMessageListenerContainer#setConcurrency
*/
public
void
setConcurrency
(
String
concurrency
)
{
this
.
concurrency
=
concurrency
;
}
/**
* @see DefaultMessageListenerContainer#setMaxMessagesPerTask
(int)
* @see DefaultMessageListenerContainer#setMaxMessagesPerTask
*/
public
void
setMaxMessagesPerTask
(
Integer
maxMessagesPerTask
)
{
this
.
maxMessagesPerTask
=
maxMessagesPerTask
;
}
/**
* @see DefaultMessageListenerContainer#setReceiveTimeout
(long)
* @see DefaultMessageListenerContainer#setReceiveTimeout
*/
public
void
setReceiveTimeout
(
Long
receiveTimeout
)
{
this
.
receiveTimeout
=
receiveTimeout
;
}
/**
* @see DefaultMessageListenerContainer#setRecoveryInterval
(long)
* @see DefaultMessageListenerContainer#setRecoveryInterval
*/
public
void
setRecoveryInterval
(
Long
recoveryInterval
)
{
this
.
recoveryInterval
=
recoveryInterval
;
}
/**
* @see DefaultMessageListenerContainer#setBackOff
(BackOff)
* @see DefaultMessageListenerContainer#setBackOff
*/
public
void
setBackOff
(
BackOff
backOff
)
{
this
.
backOff
=
backOff
;
}
@Override
protected
DefaultMessageListenerContainer
createContainerInstance
()
{
return
new
DefaultMessageListenerContainer
();
...
...
@@ -151,7 +153,7 @@ public class DefaultJmsListenerContainerFactory
if
(
this
.
backOff
!=
null
)
{
container
.
setBackOff
(
this
.
backOff
);
if
(
this
.
recoveryInterval
!=
null
)
{
logger
.
warn
(
"Ignoring recovery interval
value as a BackOff instance is set.
"
);
logger
.
warn
(
"Ignoring recovery interval
in DefaultJmsListenerContainerFactory in favor of BackOff
"
);
}
}
else
if
(
this
.
recoveryInterval
!=
null
)
{
...
...
spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java
浏览文件 @
1fadd1c9
...
...
@@ -34,10 +34,10 @@ import org.springframework.jms.support.destination.DestinationResolver;
import
org.springframework.scheduling.SchedulingAwareRunnable
;
import
org.springframework.scheduling.SchedulingTaskExecutor
;
import
org.springframework.util.Assert
;
import
org.springframework.util.BackOff
;
import
org.springframework.util.BackOffExecution
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.FixedBackOff
;
import
org.springframework.util.backoff.BackOff
;
import
org.springframework.util.backoff.BackOffExecution
;
import
org.springframework.util.backoff.FixedBackOff
;
/**
* Message listener container variant that uses plain JMS client APIs, specifically
...
...
spring-jms/src/main/resources/org/springframework/jms/config/spring-jms-4.1.xsd
浏览文件 @
1fadd1c9
...
...
@@ -329,7 +329,7 @@
]]>
</xsd:documentation>
<xsd:appinfo>
<tool:annotation
kind=
"ref"
>
<tool:expected-type
type=
"org.springframework.util.BackOff"
/>
<tool:expected-type
type=
"org.springframework.util.
backoff.
BackOff"
/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
...
...
spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java
浏览文件 @
1fadd1c9
...
...
@@ -16,9 +16,6 @@
package
org.springframework.jms.config
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
Mockito
.*;
import
javax.jms.ConnectionFactory
;
import
javax.jms.MessageListener
;
import
javax.jms.Session
;
...
...
@@ -41,8 +38,11 @@ import org.springframework.jms.support.converter.MessageConverter;
import
org.springframework.jms.support.converter.SimpleMessageConverter
;
import
org.springframework.jms.support.destination.DestinationResolver
;
import
org.springframework.jms.support.destination.DynamicDestinationResolver
;
import
org.springframework.util.BackOff
;
import
org.springframework.util.FixedBackOff
;
import
org.springframework.util.backoff.BackOff
;
import
org.springframework.util.backoff.FixedBackOff
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
Mockito
.*;
/**
*
...
...
spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java
浏览文件 @
1fadd1c9
...
...
@@ -16,14 +16,10 @@
package
org.springframework.jms.config
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
BDDMockito
.*;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.Message
;
import
javax.jms.MessageListener
;
...
...
@@ -48,9 +44,12 @@ import org.springframework.jms.listener.DefaultMessageListenerContainer;
import
org.springframework.jms.listener.adapter.MessageListenerAdapter
;
import
org.springframework.jms.listener.endpoint.JmsMessageEndpointManager
;
import
org.springframework.tests.sample.beans.TestBean
;
import
org.springframework.util.BackOff
;
import
org.springframework.util.ErrorHandler
;
import
org.springframework.util.FixedBackOff
;
import
org.springframework.util.backoff.BackOff
;
import
org.springframework.util.backoff.FixedBackOff
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
BDDMockito
.*;
/**
* @author Mark Fisher
...
...
spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java
浏览文件 @
1fadd1c9
...
...
@@ -16,9 +16,6 @@
package
org.springframework.jms.listener
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
BDDMockito
.*;
import
javax.jms.Connection
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.Destination
;
...
...
@@ -28,8 +25,11 @@ import org.junit.Test;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.stubbing.Answer
;
import
org.springframework.util.BackOff
;
import
org.springframework.util.BackOffExecution
;
import
org.springframework.util.backoff.BackOff
;
import
org.springframework.util.backoff.BackOffExecution
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
BDDMockito
.*;
/**
*
...
...
spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml
浏览文件 @
1fadd1c9
...
...
@@ -68,7 +68,7 @@
<bean
id=
"testErrorHandler"
class=
"org.springframework.jms.config.JmsNamespaceHandlerTests$TestErrorHandler"
/>
<bean
id=
"testBackOff"
class=
"org.springframework.util.FixedBackOff"
>
<bean
id=
"testBackOff"
class=
"org.springframework.util.
backoff.
FixedBackOff"
>
<property
name=
"interval"
value=
"1000"
/>
</bean>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录