Polishing
This commit is contained in:
parent
58b22ceddc
commit
a833889c2a
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -33,6 +33,7 @@ import org.springframework.scheduling.Trigger;
|
|||
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
|
||||
import org.springframework.scheduling.support.CronTrigger;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Helper bean for registering tasks with a {@link TaskScheduler}, typically using cron
|
||||
|
|
@ -268,10 +269,10 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
|
|||
* @since 3.2
|
||||
*/
|
||||
public boolean hasTasks() {
|
||||
return (this.fixedRateTasks != null && !this.fixedRateTasks.isEmpty()) ||
|
||||
(this.fixedDelayTasks != null && !this.fixedDelayTasks.isEmpty()) ||
|
||||
(this.cronTasks != null && !this.cronTasks.isEmpty()) ||
|
||||
(this.triggerTasks != null && !this.triggerTasks.isEmpty());
|
||||
return (!CollectionUtils.isEmpty(this.triggerTasks) ||
|
||||
!CollectionUtils.isEmpty(this.cronTasks) ||
|
||||
!CollectionUtils.isEmpty(this.fixedRateTasks) ||
|
||||
!CollectionUtils.isEmpty(this.fixedDelayTasks));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -295,19 +296,19 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
|
|||
this.taskScheduler = new ConcurrentTaskScheduler(this.localExecutor);
|
||||
}
|
||||
if (this.triggerTasks != null) {
|
||||
for (TriggerTask task : triggerTasks) {
|
||||
for (TriggerTask task : this.triggerTasks) {
|
||||
this.scheduledFutures.add(this.taskScheduler.schedule(
|
||||
task.getRunnable(), task.getTrigger()));
|
||||
}
|
||||
}
|
||||
if (this.cronTasks != null) {
|
||||
for (CronTask task : cronTasks) {
|
||||
for (CronTask task : this.cronTasks) {
|
||||
this.scheduledFutures.add(this.taskScheduler.schedule(
|
||||
task.getRunnable(), task.getTrigger()));
|
||||
}
|
||||
}
|
||||
if (this.fixedRateTasks != null) {
|
||||
for (IntervalTask task : fixedRateTasks) {
|
||||
for (IntervalTask task : this.fixedRateTasks) {
|
||||
if (task.getInitialDelay() > 0) {
|
||||
Date startTime = new Date(now + task.getInitialDelay());
|
||||
this.scheduledFutures.add(this.taskScheduler.scheduleAtFixedRate(
|
||||
|
|
@ -320,7 +321,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
|
|||
}
|
||||
}
|
||||
if (this.fixedDelayTasks != null) {
|
||||
for (IntervalTask task : fixedDelayTasks) {
|
||||
for (IntervalTask task : this.fixedDelayTasks) {
|
||||
if (task.getInitialDelay() > 0) {
|
||||
Date startTime = new Date(now + task.getInitialDelay());
|
||||
this.scheduledFutures.add(this.taskScheduler.scheduleWithFixedDelay(
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ import org.springframework.util.StringUtils;
|
|||
*
|
||||
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
|
||||
*
|
||||
* <p><b>NOTE:</b> Requires Apache HttpComponents 4.3 or higher, as of Spring 4.0.
|
||||
*
|
||||
* @author Oleg Kalnichevski
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
|
|
@ -73,16 +75,16 @@ final class HttpComponentsClientHttpRequest extends AbstractBufferingClientHttpR
|
|||
}
|
||||
|
||||
HttpContext getHttpContext() {
|
||||
return httpContext;
|
||||
return this.httpContext;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ClientHttpResponse executeInternal(HttpHeaders headers, byte[] bufferedOutput) throws IOException {
|
||||
addHeaders(this.httpRequest, headers);
|
||||
|
||||
if (this.httpRequest instanceof HttpEntityEnclosingRequest) {
|
||||
HttpEntityEnclosingRequest entityEnclosingRequest =
|
||||
(HttpEntityEnclosingRequest) this.httpRequest;
|
||||
HttpEntityEnclosingRequest entityEnclosingRequest = (HttpEntityEnclosingRequest) this.httpRequest;
|
||||
HttpEntity requestEntity = new ByteArrayEntity(bufferedOutput);
|
||||
entityEnclosingRequest.setEntity(requestEntity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import org.springframework.http.HttpHeaders;
|
|||
*
|
||||
* <p>Created via the {@link HttpComponentsClientHttpRequest}.
|
||||
*
|
||||
* <p><b>NOTE:</b> Requires Apache HttpComponents 4.3 or higher, as of Spring 4.0.
|
||||
*
|
||||
* @author Oleg Kalnichevski
|
||||
* @author Arjen Poutsma
|
||||
* @since 3.1
|
||||
|
|
|
|||
Loading…
Reference in New Issue