INT-1451, more refactoring and polishing
This commit is contained in:
@@ -41,7 +41,7 @@ import org.springframework.util.ErrorHandler;
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
*/
|
||||
public abstract class AbstractPollingEndpoint extends AbstractEndpoint implements InitializingBean, BeanClassLoaderAware, Callable<Boolean>{
|
||||
public abstract class AbstractPollingEndpoint extends AbstractEndpoint implements InitializingBean, BeanClassLoaderAware{
|
||||
|
||||
private volatile TaskExecutor taskExecutor = new SyncTaskExecutor();
|
||||
|
||||
@@ -97,11 +97,15 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Runnable createPoller() throws Exception{
|
||||
Callable<Boolean> pollingTask = this;
|
||||
Callable<Boolean> pollingTask = new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
return doPoll();
|
||||
}
|
||||
};
|
||||
Advisor transactionAdvice = this.pollerMetadata.getTransactionAdvisor();
|
||||
List<Advice> adviceChain = this.pollerMetadata.getAdviceChain();
|
||||
if (transactionAdvice != null || !CollectionUtils.isEmpty(adviceChain)){
|
||||
ProxyFactory proxyFactory = new ProxyFactory(this);
|
||||
ProxyFactory proxyFactory = new ProxyFactory(pollingTask);
|
||||
|
||||
// Add Transaction advice first
|
||||
if (transactionAdvice != null){
|
||||
@@ -153,6 +157,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
protected abstract boolean doPoll();
|
||||
/**
|
||||
* Default Poller implementation
|
||||
*/
|
||||
|
||||
@@ -48,8 +48,8 @@ public class PollingConsumer extends AbstractPollingEndpoint {
|
||||
this.receiveTimeout = receiveTimeout;
|
||||
}
|
||||
|
||||
|
||||
public Boolean call() {
|
||||
@Override
|
||||
protected boolean doPoll() {
|
||||
Message<?> message = (this.receiveTimeout >= 0)
|
||||
? this.inputChannel.receive(this.receiveTimeout)
|
||||
: this.inputChannel.receive();
|
||||
|
||||
@@ -83,8 +83,9 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint impleme
|
||||
Assert.notNull(this.outputChannel, "outputChannel must not be null");
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
|
||||
@Override
|
||||
protected boolean doPoll() {
|
||||
Message<?> message = this.source.receive();
|
||||
if (message != null) {
|
||||
if (this.shouldTrack) {
|
||||
|
||||
@@ -30,8 +30,8 @@ public class PollingEndpointStub extends AbstractPollingEndpoint {
|
||||
this.setPollerMetadata(pollerMetadata);
|
||||
}
|
||||
|
||||
//@Override
|
||||
public Boolean call() {
|
||||
@Override
|
||||
protected boolean doPoll() {
|
||||
throw new RuntimeException("intentional test failure");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user