Renamed the 'size' attribute to 'pool-size' for the <executor/> and <scheduler/> elements in the task namespace.

This commit is contained in:
Mark Fisher 2009-09-25 14:19:42 +00:00
parent cafc106ccc
commit 80ac130dfe
5 changed files with 20 additions and 20 deletions

View File

@ -53,20 +53,20 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
builder.addPropertyValue("queueCapacity", queueCapacity); builder.addPropertyValue("queueCapacity", queueCapacity);
} }
this.configureRejectionPolicy(element, builder); this.configureRejectionPolicy(element, builder);
String size = element.getAttribute("size"); String poolSize = element.getAttribute("pool-size");
if (!StringUtils.hasText(size)) { if (!StringUtils.hasText(poolSize)) {
return; return;
} }
Integer[] range = null; Integer[] range = null;
try { try {
int separatorIndex = size.indexOf('-'); int separatorIndex = poolSize.indexOf('-');
if (separatorIndex != -1) { if (separatorIndex != -1) {
range = new Integer[2]; range = new Integer[2];
range[0] = Integer.valueOf(size.substring(0, separatorIndex)); range[0] = Integer.valueOf(poolSize.substring(0, separatorIndex));
range[1] = Integer.valueOf(size.substring(separatorIndex + 1, size.length())); range[1] = Integer.valueOf(poolSize.substring(separatorIndex + 1, poolSize.length()));
if (range[0] > range[1]) { if (range[0] > range[1]) {
parserContext.getReaderContext().error( 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)) { if (!StringUtils.hasText(queueCapacity)) {
// no queue-capacity provided, so unbounded // no queue-capacity provided, so unbounded
@ -84,13 +84,13 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
} }
} }
else { else {
Integer value = Integer.valueOf(size); Integer value = Integer.valueOf(poolSize);
range = new Integer[] {value, value}; range = new Integer[] {value, value};
} }
} }
catch (NumberFormatException ex) { catch (NumberFormatException ex) {
parserContext.getReaderContext().error("Invalid size value [" + size + "]: only " + parserContext.getReaderContext().error("Invalid pool-size value [" + poolSize + "]: only single " +
"single maximum integer (e.g. \"5\") and minimum-maximum combo (e.g. \"3-5\") supported.", "maximum integer (e.g. \"5\") and minimum-maximum range (e.g. \"3-5\") are supported.",
element, ex); element, ex);
} }
if (range != null) { if (range != null) {
@ -138,8 +138,8 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
} }
private boolean shouldUseBackport(Element element) { private boolean shouldUseBackport(Element element) {
String size = element.getAttribute("size"); String poolSize = element.getAttribute("pool-size");
return StringUtils.hasText(size) && size.startsWith("0") return StringUtils.hasText(poolSize) && poolSize.startsWith("0")
&& JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16; && JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16;
} }

View File

@ -37,9 +37,9 @@ public class SchedulerBeanDefinitionParser extends AbstractSingleBeanDefinitionP
@Override @Override
protected void doParse(Element element, BeanDefinitionBuilder builder) { protected void doParse(Element element, BeanDefinitionBuilder builder) {
String size = element.getAttribute("size"); String poolSize = element.getAttribute("pool-size");
if (StringUtils.hasText(size)) { if (StringUtils.hasText(poolSize)) {
builder.addPropertyValue("poolSize", size); builder.addPropertyValue("poolSize", poolSize);
} }
} }

View File

@ -62,7 +62,7 @@
]]></xsd:documentation> ]]></xsd:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:attribute> </xsd:attribute>
<xsd:attribute name="size" type="xsd:string" use="optional"> <xsd:attribute name="pool-size" type="xsd:string" use="optional">
<xsd:annotation> <xsd:annotation>
<xsd:documentation><![CDATA[ <xsd:documentation><![CDATA[
The size of the ScheduledExecutorService's thread pool. The default is 1. The size of the ScheduledExecutorService's thread pool. The default is 1.
@ -88,7 +88,7 @@
]]></xsd:documentation> ]]></xsd:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:attribute> </xsd:attribute>
<xsd:attribute name="size" type="xsd:string" use="optional"> <xsd:attribute name="pool-size" type="xsd:string" use="optional">
<xsd:annotation> <xsd:annotation>
<xsd:documentation><![CDATA[ <xsd:documentation><![CDATA[
The size of the executor's thread pool as either a single value or a range The size of the executor's thread pool as either a single value or a range

View File

@ -9,10 +9,10 @@
<task:executor id="default"/> <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> </beans>

View File

@ -9,6 +9,6 @@
<task:scheduler id="defaultScheduler"/> <task:scheduler id="defaultScheduler"/>
<task:scheduler id="customScheduler" size="42"/> <task:scheduler id="customScheduler" pool-size="42"/>
</beans> </beans>