JDK 1.6+ API baseline across the codebase
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -98,9 +98,6 @@ import org.springframework.util.StringUtils;
|
||||
* <p>The common annotations supported by this post-processor are available in
|
||||
* Java 6 (JDK 1.6) as well as in Java EE 5/6 (which provides a standalone jar for
|
||||
* its common annotations as well, allowing for use in any Java 5 based application).
|
||||
* Hence, this post-processor works out of the box on JDK 1.6, and requires the
|
||||
* JSR-250 API jar (and optionally the JAX-WS API jar and/or the EJB 3 API jar)
|
||||
* to be added to the classpath on JDK 1.5 (when running outside of Java EE 5/6).
|
||||
*
|
||||
* <p>For default usage, resolving resource names as Spring bean names,
|
||||
* simply define the following in your application context:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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,7 +33,6 @@ import java.util.PropertyResourceBundle;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.core.JdkVersion;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -153,8 +152,6 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
|
||||
* Set the default charset to use for parsing resource bundle files.
|
||||
* <p>Default is none, using the {@code java.util.ResourceBundle}
|
||||
* default encoding: ISO-8859-1.
|
||||
* <p><b>NOTE: Only works on JDK 1.6 and higher.</b> Consider using
|
||||
* {@link ReloadableResourceBundleMessageSource} for JDK 1.5 support
|
||||
* and more flexibility in setting of an encoding per file.
|
||||
*/
|
||||
public void setDefaultEncoding(String defaultEncoding) {
|
||||
@@ -170,8 +167,6 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
|
||||
* {@code java.util.ResourceBundle}. However, this is often not desirable
|
||||
* in an application server environment, where the system Locale is not relevant
|
||||
* to the application at all: Set this flag to "false" in such a scenario.
|
||||
* <p><b>NOTE: Only works on JDK 1.6 and higher.</b> Consider using
|
||||
* {@link ReloadableResourceBundleMessageSource} for JDK 1.5 support.
|
||||
*/
|
||||
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) {
|
||||
this.fallbackToSystemLocale = fallbackToSystemLocale;
|
||||
@@ -193,10 +188,6 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
|
||||
* Consider {@link ReloadableResourceBundleMessageSource} in combination
|
||||
* with resource bundle files in a non-classpath location.
|
||||
* </ul>
|
||||
* <p><b>NOTE: Only works on JDK 1.6 and higher.</b> Consider using
|
||||
* {@link ReloadableResourceBundleMessageSource} for JDK 1.5 support
|
||||
* and more flexibility in terms of the kinds of resources to load from
|
||||
* (in particular from outside of the classpath where expiration works reliably).
|
||||
*/
|
||||
public void setCacheSeconds(int cacheSeconds) {
|
||||
this.cacheMillis = (cacheSeconds * 1000);
|
||||
@@ -318,13 +309,7 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
|
||||
protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException {
|
||||
if ((this.defaultEncoding != null && !"ISO-8859-1".equals(this.defaultEncoding)) ||
|
||||
!this.fallbackToSystemLocale || this.cacheMillis >= 0) {
|
||||
// Custom Control required...
|
||||
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
|
||||
throw new IllegalStateException("Cannot use 'defaultEncoding', 'fallbackToSystemLocale' and " +
|
||||
"'cacheSeconds' on the standard ResourceBundleMessageSource when running on Java 5. " +
|
||||
"Consider using ReloadableResourceBundleMessageSource instead.");
|
||||
}
|
||||
return new ControlBasedResourceBundleFactory().getBundle(basename, locale);
|
||||
return ResourceBundle.getBundle(basename, locale, getBundleClassLoader(), new MessageSourceControl());
|
||||
}
|
||||
else {
|
||||
// Good old standard call...
|
||||
@@ -398,20 +383,6 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Factory indirection for runtime isolation of the optional dependencv on
|
||||
* Java 6's Control class.
|
||||
* @see ResourceBundle#getBundle(String, java.util.Locale, ClassLoader, java.util.ResourceBundle.Control)
|
||||
* @see MessageSourceControl
|
||||
*/
|
||||
private class ControlBasedResourceBundleFactory {
|
||||
|
||||
public ResourceBundle getBundle(String basename, Locale locale) {
|
||||
return ResourceBundle.getBundle(basename, locale, getBundleClassLoader(), new MessageSourceControl());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom implementation of Java 6's {@code ResourceBundle.Control},
|
||||
* adding support for custom file encodings, deactivating the fallback to the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -22,7 +22,6 @@ import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.JdkVersion;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -73,10 +72,7 @@ public class TaskExecutorFactoryBean implements
|
||||
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Class<?> executorClass = (shouldUseBackport() ?
|
||||
getClass().getClassLoader().loadClass("org.springframework.scheduling.backportconcurrent.ThreadPoolTaskExecutor") :
|
||||
ThreadPoolTaskExecutor.class);
|
||||
BeanWrapper bw = new BeanWrapperImpl(executorClass);
|
||||
BeanWrapper bw = new BeanWrapperImpl(ThreadPoolTaskExecutor.class);
|
||||
determinePoolSizeRange(bw);
|
||||
if (this.queueCapacity != null) {
|
||||
bw.setPropertyValue("queueCapacity", this.queueCapacity);
|
||||
@@ -96,11 +92,6 @@ public class TaskExecutorFactoryBean implements
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldUseBackport() {
|
||||
return (StringUtils.hasText(this.poolSize) && this.poolSize.startsWith("0") &&
|
||||
JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16);
|
||||
}
|
||||
|
||||
private void determinePoolSizeRange(BeanWrapper bw) {
|
||||
if (StringUtils.hasText(this.poolSize)) {
|
||||
try {
|
||||
@@ -150,10 +141,7 @@ public class TaskExecutorFactoryBean implements
|
||||
}
|
||||
|
||||
public Class<? extends TaskExecutor> getObjectType() {
|
||||
if (this.target != null) {
|
||||
return this.target.getClass();
|
||||
}
|
||||
return (!shouldUseBackport() ? ThreadPoolTaskExecutor.class : TaskExecutor.class);
|
||||
return (this.target != null ? this.target.getClass() : ThreadPoolTaskExecutor.class);
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
|
||||
Reference in New Issue
Block a user