Polishing

This commit is contained in:
Juergen Hoeller
2018-01-19 19:35:02 +01:00
parent a73d9bbed5
commit 8b5a013423
12 changed files with 108 additions and 128 deletions

View File

@@ -22,7 +22,6 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.cache.CacheManager;
/**
* Proxy factory bean for simplified declarative caching handling.
@@ -54,7 +53,7 @@ public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean
/**
* Set the sources used to find cache operations.
* Set one or more sources to find cache operations.
* @see CacheInterceptor#setCacheOperationSources
*/
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources) {
@@ -62,42 +61,9 @@ public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean
}
/**
* Set the default {@link KeyGenerator} that this cache aspect should delegate to
* if no specific key generator has been set for the operation.
* <p>The default is a {@link SimpleKeyGenerator}.
* @since 5.0.3
* @see CacheInterceptor#setKeyGenerator
*/
public void setKeyGenerator(KeyGenerator keyGenerator) {
this.cacheInterceptor.setKeyGenerator(keyGenerator);
}
/**
* Set the default {@link CacheResolver} that this cache aspect should delegate
* to if no specific cache resolver has been set for the operation.
* <p>The default resolver resolves the caches against their names and the
* default cache manager.
* @since 5.0.3
* @see CacheInterceptor#setCacheResolver
*/
public void setCacheResolver(CacheResolver cacheResolver) {
this.cacheInterceptor.setCacheResolver(cacheResolver);
}
/**
* Set the {@link CacheManager} to use to create a default {@link CacheResolver}.
* Replace the current {@link CacheResolver}, if any.
* @since 5.0.3
* @see CacheInterceptor#setCacheManager
*/
public void setCacheManager(CacheManager cacheManager) {
this.cacheInterceptor.setCacheManager(cacheManager);
}
/**
* Set a pointcut, i.e a bean that can cause conditional invocation
* of the CacheInterceptor depending on method and attributes passed.
* Note: Additional interceptors are always invoked.
* Set a pointcut, i.e. a bean that triggers conditional invocation of the
* {@link CacheInterceptor} depending on the method and attributes passed.
* <p>Note: Additional interceptors are always invoked.
* @see #setPreInterceptors
* @see #setPostInterceptors
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -84,7 +84,8 @@ import org.springframework.util.StringUtils;
* @see ResourceBundleMessageSource
* @see java.util.ResourceBundle
*/
public class ReloadableResourceBundleMessageSource extends AbstractResourceBasedMessageSource implements ResourceLoaderAware {
public class ReloadableResourceBundleMessageSource extends AbstractResourceBasedMessageSource
implements ResourceLoaderAware {
private static final String PROPERTIES_SUFFIX = ".properties";
@@ -99,15 +100,15 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
private ResourceLoader resourceLoader = new DefaultResourceLoader();
/** Cache to hold filename lists per Locale */
// Cache to hold filename lists per Locale
private final ConcurrentMap<String, Map<Locale, List<String>>> cachedFilenames =
new ConcurrentHashMap<String, Map<Locale, List<String>>>();
/** Cache to hold already loaded properties per filename */
// Cache to hold already loaded properties per filename
private final ConcurrentMap<String, PropertiesHolder> cachedProperties =
new ConcurrentHashMap<String, PropertiesHolder>();
/** Cache to hold merged loaded properties per locale */
// Cache to hold merged loaded properties per locale
private final ConcurrentMap<Locale, PropertiesHolder> cachedMergedProperties =
new ConcurrentHashMap<Locale, PropertiesHolder>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -387,9 +387,13 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou
}
@Override
public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) {
public boolean needsReload(
String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) {
if (super.needsReload(baseName, locale, format, loader, bundle, loadTime)) {
cachedBundleMessageFormats.remove(bundle);
synchronized (cachedBundleMessageFormats) {
cachedBundleMessageFormats.remove(bundle);
}
return true;
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2018 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.
@@ -67,6 +67,7 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
setBeanClassLoader(beanClassLoader);
}
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader);
@@ -84,8 +85,10 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
else {
try {
this.loadTimeWeaver = new ReflectiveLoadTimeWeaver(classLoader);
logger.info("Using a reflective load-time weaver for class loader: " +
this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
if (logger.isInfoEnabled()) {
logger.info("Using a reflective load-time weaver for class loader: " +
this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
}
}
catch (IllegalStateException ex) {
throw new IllegalStateException(ex.getMessage() + " Specify a custom LoadTimeWeaver or start your " +
@@ -106,24 +109,26 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
protected LoadTimeWeaver createServerSpecificLoadTimeWeaver(ClassLoader classLoader) {
String name = classLoader.getClass().getName();
try {
if (name.startsWith("weblogic")) {
return new WebLogicLoadTimeWeaver(classLoader);
if (name.startsWith("org.apache.catalina")) {
return new TomcatLoadTimeWeaver(classLoader);
}
else if (name.startsWith("org.glassfish")) {
return new GlassFishLoadTimeWeaver(classLoader);
}
else if (name.startsWith("org.apache.catalina")) {
return new TomcatLoadTimeWeaver(classLoader);
}
else if (name.startsWith("org.jboss")) {
return new JBossLoadTimeWeaver(classLoader);
}
else if (name.startsWith("com.ibm")) {
return new WebSphereLoadTimeWeaver(classLoader);
}
else if (name.startsWith("weblogic")) {
return new WebLogicLoadTimeWeaver(classLoader);
}
}
catch (IllegalStateException ex) {
logger.info("Could not obtain server-specific LoadTimeWeaver: " + ex.getMessage());
catch (Exception ex) {
if (logger.isInfoEnabled()) {
logger.info("Could not obtain server-specific LoadTimeWeaver: " + ex.getMessage());
}
}
return null;
}
@@ -131,8 +136,10 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
@Override
public void destroy() {
if (this.loadTimeWeaver instanceof InstrumentationLoadTimeWeaver) {
logger.info("Removing all registered transformers for class loader: " +
this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
if (logger.isInfoEnabled()) {
logger.info("Removing all registered transformers for class loader: " +
this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
}
((InstrumentationLoadTimeWeaver) this.loadTimeWeaver).removeTransformers();
}
}