INT-1451, more refactoring and polishing

This commit is contained in:
Oleg Zhurakousky
2010-09-25 21:25:57 -04:00
parent 5938cd9f52
commit 804d3da932
4 changed files with 15 additions and 9 deletions

View File

@@ -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
*/

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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");
}