Switch back to Java 1.6
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -209,8 +209,8 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.springframework.aop.IntroductionInterceptor;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.retry.RetryPolicy;
|
||||
import org.springframework.retry.backoff.BackOffPolicy;
|
||||
@@ -44,14 +45,14 @@ import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.ReflectionUtils.MethodCallback;
|
||||
|
||||
/**
|
||||
* Wrapper interceptor that interprets the retry metadata on the method it is invoking and
|
||||
* WrappeMethodInterceptorr interceptor that interprets the retry metadata on the method it is invoking and
|
||||
* delegates to an appropriate RetryOperationsInterceptor.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*
|
||||
*/
|
||||
public class AnnotationAwareRetryOperationsInterceptor implements MethodInterceptor {
|
||||
public class AnnotationAwareRetryOperationsInterceptor implements IntroductionInterceptor {
|
||||
|
||||
private Map<Method, MethodInterceptor> delegates = new HashMap<Method, MethodInterceptor>();
|
||||
|
||||
@@ -99,6 +100,11 @@ public class AnnotationAwareRetryOperationsInterceptor implements MethodIntercep
|
||||
return delegate.invoke(invocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implementsInterface(Class<?> intf) {
|
||||
return Retryable.class.isAssignableFrom(intf);
|
||||
}
|
||||
|
||||
private MethodInterceptor getDelegate(Object target, Method method) {
|
||||
if (!delegates.containsKey(method)) {
|
||||
synchronized (delegates) {
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.Arrays;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.springframework.aop.IntroductionInterceptor;
|
||||
import org.springframework.aop.ProxyMethodInvocation;
|
||||
import org.springframework.retry.RecoveryCallback;
|
||||
import org.springframework.retry.RetryCallback;
|
||||
@@ -42,7 +41,7 @@ import org.springframework.util.Assert;
|
||||
* @author Rob Harrop
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class RetryOperationsInterceptor implements IntroductionInterceptor {
|
||||
public class RetryOperationsInterceptor implements MethodInterceptor {
|
||||
|
||||
private RetryOperations retryOperations = new RetryTemplate();
|
||||
private MethodInvocationRecoverer<?> recoverer;
|
||||
@@ -56,11 +55,6 @@ public class RetryOperationsInterceptor implements IntroductionInterceptor {
|
||||
this.recoverer = recoverer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implementsInterface(Class<?> intf) {
|
||||
return Retryable.class.isAssignableFrom(intf);
|
||||
}
|
||||
|
||||
public Object invoke(final MethodInvocation invocation) throws Throwable {
|
||||
|
||||
RetryCallback<Object, Throwable> retryCallback = new RetryCallback<Object, Throwable>() {
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.aop.IntroductionInterceptor;
|
||||
import org.springframework.retry.RecoveryCallback;
|
||||
import org.springframework.retry.RetryCallback;
|
||||
import org.springframework.retry.RetryContext;
|
||||
@@ -52,7 +51,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class StatefulRetryOperationsInterceptor implements IntroductionInterceptor {
|
||||
public class StatefulRetryOperationsInterceptor implements MethodInterceptor {
|
||||
|
||||
private transient Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -106,11 +105,6 @@ public class StatefulRetryOperationsInterceptor implements IntroductionIntercept
|
||||
this.newMethodArgumentsIdentifier = newMethodArgumentsIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implementsInterface(Class<?> intf) {
|
||||
return Retryable.class.isAssignableFrom(intf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the method invocation in a stateful retry with the policy and other helpers
|
||||
* provided. If there is a failure the exception will generally be re-thrown. The only
|
||||
|
||||
@@ -28,9 +28,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.retry.backoff.Sleeper;
|
||||
|
||||
/**
|
||||
@@ -45,7 +42,8 @@ public class EnableRetryWithBackoffTests {
|
||||
TestConfiguration.class);
|
||||
Service service = context.getBean(Service.class);
|
||||
service.service();
|
||||
assertEquals("[1000, 1000]", context.getBean(TestConfiguration.class).periods.toString());
|
||||
assertEquals("[1000, 1000]", context.getBean(PeriodSleeper.class)
|
||||
.getPeriods().toString());
|
||||
assertEquals(3, service.getCount());
|
||||
context.close();
|
||||
}
|
||||
@@ -56,8 +54,8 @@ public class EnableRetryWithBackoffTests {
|
||||
TestConfiguration.class);
|
||||
RandomService service = context.getBean(RandomService.class);
|
||||
service.service();
|
||||
List<Long> periods = context.getBean(TestConfiguration.class).periods;
|
||||
assertTrue("Wrong periods: " + periods, periods.get(0)>1000);
|
||||
List<Long> periods = context.getBean(PeriodSleeper.class).getPeriods();
|
||||
assertTrue("Wrong periods: " + periods, periods.get(0) > 1000);
|
||||
assertEquals(3, service.getCount());
|
||||
context.close();
|
||||
}
|
||||
@@ -69,7 +67,8 @@ public class EnableRetryWithBackoffTests {
|
||||
ExponentialService service = context.getBean(ExponentialService.class);
|
||||
service.service();
|
||||
assertEquals(3, service.getCount());
|
||||
assertEquals("[1000, 1100]", context.getBean(TestConfiguration.class).periods.toString());
|
||||
assertEquals("[1000, 1100]", context.getBean(PeriodSleeper.class)
|
||||
.getPeriods().toString());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -81,10 +80,12 @@ public class EnableRetryWithBackoffTests {
|
||||
.getBean(ExponentialRandomService.class);
|
||||
service.service(1);
|
||||
assertEquals(3, service.getCount());
|
||||
List<Long> periods = context.getBean(TestConfiguration.class).periods;
|
||||
assertNotEquals("[1000, 1100]", context.getBean(TestConfiguration.class).periods.toString());
|
||||
assertTrue("Wrong periods: " + periods, periods.get(0)>1000);
|
||||
assertTrue("Wrong periods: " + periods, periods.get(1)>1100 && periods.get(1)<1210);
|
||||
List<Long> periods = context.getBean(PeriodSleeper.class).getPeriods();
|
||||
assertNotEquals("[1000, 1100]", context.getBean(PeriodSleeper.class)
|
||||
.getPeriods().toString());
|
||||
assertTrue("Wrong periods: " + periods, periods.get(0) > 1000);
|
||||
assertTrue("Wrong periods: " + periods, periods.get(1) > 1100
|
||||
&& periods.get(1) < 1210);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -92,17 +93,10 @@ public class EnableRetryWithBackoffTests {
|
||||
@EnableRetry
|
||||
@EnableAspectJAutoProxy(proxyTargetClass = true)
|
||||
protected static class TestConfiguration {
|
||||
|
||||
private List<Long> periods = new ArrayList<Long>();
|
||||
|
||||
|
||||
@Bean
|
||||
public Sleeper sleper() {
|
||||
return new Sleeper() {
|
||||
@Override
|
||||
public void sleep(long period) throws InterruptedException {
|
||||
periods.add(period);
|
||||
}
|
||||
};
|
||||
public PeriodSleeper sleper() {
|
||||
return new PeriodSleeper();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -127,6 +121,21 @@ public class EnableRetryWithBackoffTests {
|
||||
|
||||
}
|
||||
|
||||
protected static class PeriodSleeper implements Sleeper {
|
||||
|
||||
private List<Long> periods = new ArrayList<Long>();
|
||||
|
||||
@Override
|
||||
public void sleep(long period) throws InterruptedException {
|
||||
periods.add(period);
|
||||
}
|
||||
|
||||
private List<Long> getPeriods() {
|
||||
return periods;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class Service {
|
||||
|
||||
private int count = 0;
|
||||
@@ -182,7 +191,7 @@ public class EnableRetryWithBackoffTests {
|
||||
|
||||
private int count = 0;
|
||||
|
||||
@Retryable(backoff = @Backoff(delay = 1000, maxDelay = 2000, multiplier = 1.1, random=true))
|
||||
@Retryable(backoff = @Backoff(delay = 1000, maxDelay = 2000, multiplier = 1.1, random = true))
|
||||
public void service(int value) {
|
||||
if (count++ < 2) {
|
||||
throw new RuntimeException("Planned");
|
||||
|
||||
Reference in New Issue
Block a user