diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java b/spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java index 7131651c6e18006db0a66db29172b3c1878f259a..437a450c614497482f23835e181e7d5cf5fe5fe0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -48,6 +48,19 @@ import java.beans.PropertyDescriptor; */ public interface BeanWrapper extends ConfigurablePropertyAccessor { + /** + * Specify a limit for array and collection auto-growing. + *

Default is unlimited on a plain BeanWrapper. + * @since 4.1 + */ + void setAutoGrowCollectionLimit(int autoGrowCollectionLimit); + + /** + * Return the limit for array and collection auto-growing. + * @since 4.1 + */ + int getAutoGrowCollectionLimit(); + /** * Return the bean instance wrapped by this object, if any. * @return the bean instance, or {@code null} if none set @@ -78,15 +91,4 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor { */ PropertyDescriptor getPropertyDescriptor(String propertyName) throws InvalidPropertyException; - /** - * Specify a limit for array and collection auto-growing. - *

Default is unlimited on a plain BeanWrapper. - */ - void setAutoGrowCollectionLimit(int autoGrowCollectionLimit); - - /** - * Return the limit for array and collection auto-growing. - */ - int getAutoGrowCollectionLimit(); - } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java index 6a0f737e607e769f62783e37c069cb8dc4589920..e4dbef0d3e7a97ae54cfdacfb3eb2c9d7a186812 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -72,8 +72,8 @@ public class SpringBeanJobFactory extends AdaptableJobFactory implements Schedul @Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { Object job = super.createJobInstance(bundle); - BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job); - if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) { + if (isEligibleForPropertyPopulation(job)) { + BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job); MutablePropertyValues pvs = new MutablePropertyValues(); if (this.schedulerContext != null) { pvs.addPropertyValues(this.schedulerContext); diff --git a/spring-context/src/main/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParser.java index 1448b3e4aa89ccf267f1639ce40f52f536b2a7dc..98a46843147703945bf081f393ecd7a3af66c536 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2016 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. @@ -61,9 +61,6 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa return; } String prefix = "java.util.concurrent.ThreadPoolExecutor."; - if (builder.getRawBeanDefinition().getBeanClassName().contains("backport")) { - prefix = "edu.emory.mathcs.backport." + prefix; - } String policyClassName; if (rejectionPolicy.equals("ABORT")) { policyClassName = prefix + "AbortPolicy"; diff --git a/spring-context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java b/spring-context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java index d655a84e5540c4a8e18566faf9722c5df370c164..7ed6bef3294d5be7817782aadd1cf7585c15648d 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -16,8 +16,8 @@ package org.springframework.scheduling.config; -import org.springframework.beans.BeanWrapper; -import org.springframework.beans.BeanWrapperImpl; +import java.util.concurrent.RejectedExecutionHandler; + import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.FactoryBean; @@ -27,8 +27,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.util.StringUtils; /** - * FactoryBean for creating ThreadPoolTaskExecutor instances, choosing - * between the standard concurrent and the backport-concurrent variant. + * {@link FactoryBean} for creating {@link ThreadPoolTaskExecutor} instances, + * primarily used behind the XML task namespace. * * @author Mark Fisher * @author Juergen Hoeller @@ -41,13 +41,13 @@ public class TaskExecutorFactoryBean implements private Integer queueCapacity; - private Object rejectedExecutionHandler; + private RejectedExecutionHandler rejectedExecutionHandler; private Integer keepAliveSeconds; private String beanName; - private TaskExecutor target; + private ThreadPoolTaskExecutor target; public void setPoolSize(String poolSize) { @@ -58,7 +58,7 @@ public class TaskExecutorFactoryBean implements this.queueCapacity = queueCapacity; } - public void setRejectedExecutionHandler(Object rejectedExecutionHandler) { + public void setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) { this.rejectedExecutionHandler = rejectedExecutionHandler; } @@ -73,28 +73,25 @@ public class TaskExecutorFactoryBean implements @Override - public void afterPropertiesSet() throws Exception { - BeanWrapper bw = new BeanWrapperImpl(ThreadPoolTaskExecutor.class); - determinePoolSizeRange(bw); + public void afterPropertiesSet() { + this.target = new ThreadPoolTaskExecutor(); + determinePoolSizeRange(); if (this.queueCapacity != null) { - bw.setPropertyValue("queueCapacity", this.queueCapacity); + this.target.setQueueCapacity(this.queueCapacity); } if (this.keepAliveSeconds != null) { - bw.setPropertyValue("keepAliveSeconds", this.keepAliveSeconds); + this.target.setKeepAliveSeconds(this.keepAliveSeconds); } if (this.rejectedExecutionHandler != null) { - bw.setPropertyValue("rejectedExecutionHandler", this.rejectedExecutionHandler); + this.target.setRejectedExecutionHandler(this.rejectedExecutionHandler); } if (this.beanName != null) { - bw.setPropertyValue("threadNamePrefix", this.beanName + "-"); - } - this.target = (TaskExecutor) bw.getWrappedInstance(); - if (this.target instanceof InitializingBean) { - ((InitializingBean) this.target).afterPropertiesSet(); + this.target.setThreadNamePrefix(this.beanName + "-"); } + this.target.afterPropertiesSet(); } - private void determinePoolSizeRange(BeanWrapper bw) { + private void determinePoolSizeRange() { if (StringUtils.hasText(this.poolSize)) { try { int corePoolSize; @@ -108,15 +105,15 @@ public class TaskExecutorFactoryBean implements "Lower bound of pool-size range must not exceed the upper bound"); } if (this.queueCapacity == null) { - // no queue-capacity provided, so unbounded + // No queue-capacity provided, so unbounded if (corePoolSize == 0) { - // actually set 'corePoolSize' to the upper bound of the range - // but allow core threads to timeout - bw.setPropertyValue("allowCoreThreadTimeOut", true); + // Actually set 'corePoolSize' to the upper bound of the range + // but allow core threads to timeout... + this.target.setAllowCoreThreadTimeOut(true); corePoolSize = maxPoolSize; } else { - // non-zero lower bound implies a core-max size range + // Non-zero lower bound implies a core-max size range... throw new IllegalArgumentException( "A non-zero lower bound for the size range requires a queue-capacity value"); } @@ -127,8 +124,8 @@ public class TaskExecutorFactoryBean implements corePoolSize = value; maxPoolSize = value; } - bw.setPropertyValue("corePoolSize", corePoolSize); - bw.setPropertyValue("maxPoolSize", maxPoolSize); + this.target.setCorePoolSize(corePoolSize); + this.target.setMaxPoolSize(maxPoolSize); } catch (NumberFormatException ex) { throw new IllegalArgumentException("Invalid pool-size value [" + this.poolSize + "]: only single " + @@ -155,10 +152,8 @@ public class TaskExecutorFactoryBean implements @Override - public void destroy() throws Exception { - if (this.target instanceof DisposableBean) { - ((DisposableBean) this.target).destroy(); - } + public void destroy() { + this.target.destroy(); } }