Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jun 10, 2020
1 parent 7f87eb5 commit a045574
Show file tree
Hide file tree
Showing 38 changed files with 284 additions and 268 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -76,9 +76,8 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
new InstanceComparator<>(
Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class),
(Converter<Method, Annotation>) method -> {
AspectJAnnotation<?> annotation =
AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
return (annotation != null ? annotation.getAnnotation() : null);
AspectJAnnotation<?> ann = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
return (ann != null ? ann.getAnnotation() : null);
});
Comparator<Method> methodNameComparator = new ConvertingComparator<>(Method::getName);
METHOD_COMPARATOR = adviceKindComparator.thenComparing(methodNameComparator);
Expand Down Expand Up @@ -153,8 +152,10 @@ private List<Method> getAdvisorMethods(Class<?> aspectClass) {
if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) {
methods.add(method);
}
});
methods.sort(METHOD_COMPARATOR);
}, ReflectionUtils.USER_DECLARED_METHODS);
if (methods.size() > 1) {
methods.sort(METHOD_COMPARATOR);
}
return methods;
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -138,14 +138,8 @@ private String getAspectName(Advisor anAdvisor) {
}

private int getAspectDeclarationOrder(Advisor anAdvisor) {
AspectJPrecedenceInformation precedenceInfo =
AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor);
if (precedenceInfo != null) {
return precedenceInfo.getDeclarationOrder();
}
else {
return 0;
}
AspectJPrecedenceInformation precedenceInfo = AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor);
return (precedenceInfo != null ? precedenceInfo.getDeclarationOrder() : 0);
}

}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -61,12 +61,12 @@ public class AopNamespaceHandler extends NamespaceHandlerSupport {
*/
@Override
public void init() {
// In 2.0 XSD as well as in 2.1 XSD.
// In 2.0 XSD as well as in 2.5+ XSDs
registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
registerBeanDefinitionParser("aspectj-autoproxy", new AspectJAutoProxyBeanDefinitionParser());
registerBeanDefinitionDecorator("scoped-proxy", new ScopedProxyBeanDefinitionDecorator());

// Only in 2.0 XSD: moved to context namespace as of 2.1
// Only in 2.0 XSD: moved to context namespace in 2.5+
registerBeanDefinitionParser("spring-configured", new SpringConfiguredBeanDefinitionParser());
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -43,9 +43,9 @@
* Internal class that caches JavaBeans {@link java.beans.PropertyDescriptor}
* information for a Java class. Not intended for direct use by application code.
*
* <p>Necessary for own caching of descriptors within the application's
* ClassLoader, rather than rely on the JDK's system-wide BeanInfo cache
* (in order to avoid leaks on ClassLoader shutdown).
* <p>Necessary for Spring's own caching of bean descriptors within the application
* {@link ClassLoader}, rather than relying on the JDK's system-wide {@link BeanInfo}
* cache (in order to avoid leaks on individual application shutdown in a shared JVM).
*
* <p>Information is cached statically, so we don't need to create new
* objects of this class for every JavaBean we manipulate. Hence, this class
Expand Down Expand Up @@ -97,7 +97,7 @@ public class CachedIntrospectionResults {
SpringProperties.getFlag(IGNORE_BEANINFO_PROPERTY_NAME);

/** Stores the BeanInfoFactory instances */
private static List<BeanInfoFactory> beanInfoFactories = SpringFactoriesLoader.loadFactories(
private static final List<BeanInfoFactory> beanInfoFactories = SpringFactoriesLoader.loadFactories(
BeanInfoFactory.class, CachedIntrospectionResults.class.getClassLoader());

private static final Log logger = LogFactory.getLog(CachedIntrospectionResults.class);
Expand Down Expand Up @@ -163,7 +163,6 @@ public static void clearClassLoader(@Nullable ClassLoader classLoader) {
* @return the corresponding CachedIntrospectionResults
* @throws BeansException in case of introspection failure
*/
@SuppressWarnings("unchecked")
static CachedIntrospectionResults forClass(Class<?> beanClass) throws BeansException {
CachedIntrospectionResults results = strongClassCache.get(beanClass);
if (results != null) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -41,12 +41,11 @@
* regular constructors: i.e. lookup methods cannot get replaced on beans returned
* from factory methods where we cannot dynamically provide a subclass for them.
*
* <p><b>Concrete limitations in typical Spring configuration scenarios:</b>
* When used with component scanning or any other mechanism that filters out abstract
* beans, provide stub implementations of your lookup methods to be able to declare
* them as concrete classes. And please remember that lookup methods won't work on
* beans returned from {@code @Bean} methods in configuration classes; you'll have
* to resort to {@code @Inject Provider<TargetBean>} or the like instead.
* <p><b>Recommendations for typical Spring configuration scenarios:</b>
* When a concrete class may be needed in certain scenarios, consider providing stub
* implementations of your lookup methods. And please remember that lookup methods
* won't work on beans returned from {@code @Bean} methods in configuration classes;
* you'll have to resort to {@code @Inject Provider<TargetBean>} or the like instead.
*
* @author Juergen Hoeller
* @since 4.1
Expand Down
Expand Up @@ -884,7 +884,7 @@ public List<BeanPostProcessor> getBeanPostProcessors() {

/**
* Return whether this factory holds a InstantiationAwareBeanPostProcessor
* that will get applied to singleton beans on shutdown.
* that will get applied to singleton beans on creation.
* @see #addBeanPostProcessor
* @see org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
*/
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -35,6 +35,7 @@
* @author Juergen Hoeller
* @author Stephane Nicoll
* @since 4.3
* @see CaffeineCacheManager
*/
public class CaffeineCache extends AbstractValueAdaptingCache {

Expand Down Expand Up @@ -159,10 +160,10 @@ public LoadFunction(Callable<?> valueLoader) {
@Override
public Object apply(Object o) {
try {
return toStoreValue(valueLoader.call());
return toStoreValue(this.valueLoader.call());
}
catch (Exception ex) {
throw new ValueRetrievalException(o, valueLoader, ex);
throw new ValueRetrievalException(o, this.valueLoader, ex);
}
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -34,6 +34,7 @@
* @author Juergen Hoeller
* @author Stephane Nicoll
* @since 3.1
* @see EhCacheCacheManager
*/
public class EhCacheCache implements Cache {

Expand Down Expand Up @@ -95,7 +96,6 @@ public <T> T get(Object key, Callable<T> valueLoader) {
this.cache.releaseWriteLockOnKey(key);
}
}

}

private <T> T loadValue(Object key, Callable<T> valueLoader) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -34,6 +34,7 @@
* @author Juergen Hoeller
* @author Stephane Nicoll
* @since 3.1
* @see EhCacheCache
*/
public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManager {

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -28,29 +28,30 @@

/**
* {@link org.springframework.cache.Cache} implementation on top of a
* {@link javax.cache.Cache} instance.
* {@link Cache javax.cache.Cache} instance.
*
* <p>Note: This class has been updated for JCache 1.0, as of Spring 4.0.
*
* @author Juergen Hoeller
* @author Stephane Nicoll
* @since 3.2
* @see JCacheCacheManager
*/
public class JCacheCache extends AbstractValueAdaptingCache {

private final Cache<Object, Object> cache;


/**
* Create an {@link org.springframework.cache.jcache.JCacheCache} instance.
* Create a {@code JCacheCache} instance.
* @param jcache backing JCache Cache instance
*/
public JCacheCache(Cache<Object, Object> jcache) {
this(jcache, true);
}

/**
* Create an {@link org.springframework.cache.jcache.JCacheCache} instance.
* Create a {@code JCacheCache} instance.
* @param jcache backing JCache Cache instance
* @param allowNullValues whether to accept and convert null values for this cache
*/
Expand Down Expand Up @@ -128,7 +129,7 @@ public T process(MutableEntry<Object, Object> entry, Object... arguments) throws
}
catch (Exception ex) {
throw new EntryProcessorException("Value loader '" + valueLoader + "' failed " +
"to compute value for key '" + entry.getKey() + "'", ex);
"to compute value for key '" + entry.getKey() + "'", ex);
}
entry.setValue(toStoreValue(value));
return value;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -28,13 +28,14 @@

/**
* {@link org.springframework.cache.CacheManager} implementation
* backed by a JCache {@link javax.cache.CacheManager}.
* backed by a JCache {@link CacheManager javax.cache.CacheManager}.
*
* <p>Note: This class has been updated for JCache 1.0, as of Spring 4.0.
*
* @author Juergen Hoeller
* @author Stephane Nicoll
* @since 3.2
* @see JCacheCache
*/
public class JCacheCacheManager extends AbstractTransactionSupportingCacheManager {

Expand All @@ -45,30 +46,33 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage


/**
* Create a new JCacheCacheManager, setting the target JCache CacheManager
* through the {@link #setCacheManager} bean property.
* Create a new {@code JCacheCacheManager} without a backing JCache
* {@link CacheManager javax.cache.CacheManager}.
* <p>The backing JCache {@code javax.cache.CacheManager} can be set via the
* {@link #setCacheManager} bean property.
*/
public JCacheCacheManager() {
}

/**
* Create a new JCacheCacheManager for the given backing JCache.
* @param cacheManager the backing JCache {@link javax.cache.CacheManager}
* Create a new {@code JCacheCacheManager} for the given backing JCache
* {@link CacheManager javax.cache.CacheManager}.
* @param cacheManager the backing JCache {@code javax.cache.CacheManager}
*/
public JCacheCacheManager(CacheManager cacheManager) {
this.cacheManager = cacheManager;
}


/**
* Set the backing JCache {@link javax.cache.CacheManager}.
* Set the backing JCache {@link CacheManager javax.cache.CacheManager}.
*/
public void setCacheManager(@Nullable CacheManager cacheManager) {
this.cacheManager = cacheManager;
}

/**
* Return the backing JCache {@link javax.cache.CacheManager}.
* Return the backing JCache {@link CacheManager javax.cache.CacheManager}.
*/
@Nullable
public CacheManager getCacheManager() {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -141,7 +141,7 @@ protected Object lookup(Object key) {
@Override
@Nullable
public <T> T get(Object key, Callable<T> valueLoader) {
return (T) fromStoreValue(this.store.computeIfAbsent(key, r -> {
return (T) fromStoreValue(this.store.computeIfAbsent(key, k -> {
try {
return toStoreValue(valueLoader.call());
}
Expand Down Expand Up @@ -191,7 +191,7 @@ protected Object toStoreValue(@Nullable Object userValue) {
}

private Object serializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
try {
serialization.serialize(storeValue, out);
return out.toByteArray();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -190,9 +190,7 @@ private void recreateCaches() {
*/
protected Cache createConcurrentMapCache(String name) {
SerializationDelegate actualSerialization = (isStoreByValue() ? this.serialization : null);
return new ConcurrentMapCache(name, new ConcurrentHashMap<>(256),
isAllowNullValues(), actualSerialization);

return new ConcurrentMapCache(name, new ConcurrentHashMap<>(256), isAllowNullValues(), actualSerialization);
}

}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -30,14 +30,15 @@
* @author Costin Leau
* @author Stephane Nicoll
* @since 4.3.4
* @see NoOpCacheManager
*/
public class NoOpCache implements Cache {

private final String name;


/**
* Create a {@link NoOpCache} instance with the specified name
* Create a {@link NoOpCache} instance with the specified name.
* @param name the name of the cache
*/
public NoOpCache(String name) {
Expand Down

0 comments on commit a045574

Please sign in to comment.