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