Renamed the 'size' attribute to 'pool-size' for the <executor/> and <scheduler/> elements in the task namespace.
This commit is contained in:
parent
cafc106ccc
commit
80ac130dfe
|
|
@ -53,20 +53,20 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
|
|||
builder.addPropertyValue("queueCapacity", queueCapacity);
|
||||
}
|
||||
this.configureRejectionPolicy(element, builder);
|
||||
String size = element.getAttribute("size");
|
||||
if (!StringUtils.hasText(size)) {
|
||||
String poolSize = element.getAttribute("pool-size");
|
||||
if (!StringUtils.hasText(poolSize)) {
|
||||
return;
|
||||
}
|
||||
Integer[] range = null;
|
||||
try {
|
||||
int separatorIndex = size.indexOf('-');
|
||||
int separatorIndex = poolSize.indexOf('-');
|
||||
if (separatorIndex != -1) {
|
||||
range = new Integer[2];
|
||||
range[0] = Integer.valueOf(size.substring(0, separatorIndex));
|
||||
range[1] = Integer.valueOf(size.substring(separatorIndex + 1, size.length()));
|
||||
range[0] = Integer.valueOf(poolSize.substring(0, separatorIndex));
|
||||
range[1] = Integer.valueOf(poolSize.substring(separatorIndex + 1, poolSize.length()));
|
||||
if (range[0] > range[1]) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Lower bound of size range must not exceed the upper bound.", element);
|
||||
"Lower bound of pool-size range must not exceed the upper bound.", element);
|
||||
}
|
||||
if (!StringUtils.hasText(queueCapacity)) {
|
||||
// no queue-capacity provided, so unbounded
|
||||
|
|
@ -84,13 +84,13 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
|
|||
}
|
||||
}
|
||||
else {
|
||||
Integer value = Integer.valueOf(size);
|
||||
Integer value = Integer.valueOf(poolSize);
|
||||
range = new Integer[] {value, value};
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
parserContext.getReaderContext().error("Invalid size value [" + size + "]: only " +
|
||||
"single maximum integer (e.g. \"5\") and minimum-maximum combo (e.g. \"3-5\") supported.",
|
||||
parserContext.getReaderContext().error("Invalid pool-size value [" + poolSize + "]: only single " +
|
||||
"maximum integer (e.g. \"5\") and minimum-maximum range (e.g. \"3-5\") are supported.",
|
||||
element, ex);
|
||||
}
|
||||
if (range != null) {
|
||||
|
|
@ -138,8 +138,8 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
|
|||
}
|
||||
|
||||
private boolean shouldUseBackport(Element element) {
|
||||
String size = element.getAttribute("size");
|
||||
return StringUtils.hasText(size) && size.startsWith("0")
|
||||
String poolSize = element.getAttribute("pool-size");
|
||||
return StringUtils.hasText(poolSize) && poolSize.startsWith("0")
|
||||
&& JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ public class SchedulerBeanDefinitionParser extends AbstractSingleBeanDefinitionP
|
|||
|
||||
@Override
|
||||
protected void doParse(Element element, BeanDefinitionBuilder builder) {
|
||||
String size = element.getAttribute("size");
|
||||
if (StringUtils.hasText(size)) {
|
||||
builder.addPropertyValue("poolSize", size);
|
||||
String poolSize = element.getAttribute("pool-size");
|
||||
if (StringUtils.hasText(poolSize)) {
|
||||
builder.addPropertyValue("poolSize", poolSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="size" type="xsd:string" use="optional">
|
||||
<xsd:attribute name="pool-size" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The size of the ScheduledExecutorService's thread pool. The default is 1.
|
||||
|
|
@ -88,7 +88,7 @@
|
|||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="size" type="xsd:string" use="optional">
|
||||
<xsd:attribute name="pool-size" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The size of the executor's thread pool as either a single value or a range
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
<task:executor id="default"/>
|
||||
|
||||
<task:executor id="singleSize" size="42"/>
|
||||
<task:executor id="singleSize" pool-size="42"/>
|
||||
|
||||
<task:executor id="rangeWithBoundedQueue" size="7-42" queue-capacity="11"/>
|
||||
<task:executor id="rangeWithBoundedQueue" pool-size="7-42" queue-capacity="11"/>
|
||||
|
||||
<task:executor id="rangeWithUnboundedQueue" size="0-9" keep-alive="37"/>
|
||||
<task:executor id="rangeWithUnboundedQueue" pool-size="0-9" keep-alive="37"/>
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
<task:scheduler id="defaultScheduler"/>
|
||||
|
||||
<task:scheduler id="customScheduler" size="42"/>
|
||||
<task:scheduler id="customScheduler" pool-size="42"/>
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
Loading…
Reference in New Issue