Skip to content

Commit 5291258

Browse files
committed
Polishing
1 parent c573eca commit 5291258

File tree

6 files changed

+85
-61
lines changed

6 files changed

+85
-61
lines changed

spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,14 +25,16 @@
2525
import org.springframework.util.Assert;
2626

2727
/**
28-
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and {@link #clear}
29-
* operations with Spring-managed transactions (through Spring's {@link TransactionSynchronizationManager},
30-
* performing the actual cache put/evict/clear operation only in the after-commit phase of a
31-
* successful transaction. If no transaction is active, {@link #put}, {@link #evict} and
28+
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and
29+
* {@link #clear} operations with Spring-managed transactions (through Spring's
30+
* {@link TransactionSynchronizationManager}, performing the actual cache
31+
* put/evict/clear operation only in the after-commit phase of a successful
32+
* transaction. If no transaction is active, {@link #put}, {@link #evict} and
3233
* {@link #clear} operations will be performed immediately, as usual.
3334
*
34-
* <p>Use of more aggressive operations such as {@link #putIfAbsent} cannot be deferred
35-
* to the after-commit phase of a running transaction. Use these with care.
35+
* <p><b>Note:</b> Use of immediate operations such as {@link #putIfAbsent}
36+
* cannot be deferred to the after-commit phase of a running transaction.
37+
* Use these with care in a transactional environment.
3638
*
3739
* @author Juergen Hoeller
3840
* @author Stephane Nicoll
@@ -54,6 +56,7 @@ public TransactionAwareCacheDecorator(Cache targetCache) {
5456
this.targetCache = targetCache;
5557
}
5658

59+
5760
/**
5861
* Return the target Cache that this Cache should delegate to.
5962
*/

spring-context/src/main/java/org/springframework/cache/CacheManager.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,23 +22,28 @@
2222

2323
/**
2424
* Spring's central cache manager SPI.
25-
* Allows for retrieving named {@link Cache} regions.
25+
*
26+
* <p>Allows for retrieving named {@link Cache} regions.
2627
*
2728
* @author Costin Leau
29+
* @author Sam Brannen
2830
* @since 3.1
2931
*/
3032
public interface CacheManager {
3133

3234
/**
33-
* Return the cache associated with the given name.
35+
* Get the cache associated with the given name.
36+
* <p>Note that the cache may be lazily created at runtime if the
37+
* native provider supports it.
3438
* @param name the cache identifier (must not be {@code null})
35-
* @return the associated cache, or {@code null} if none found
39+
* @return the associated cache, or {@code null} if such a cache
40+
* does not exist or could be not created
3641
*/
3742
@Nullable
3843
Cache getCache(String name);
3944

4045
/**
41-
* Return a collection of the cache names known by this manager.
46+
* Get a collection of the cache names known by this manager.
4247
* @return the names of all caches known by the cache manager
4348
*/
4449
Collection<String> getCacheNames();

spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -174,15 +174,15 @@ protected Cache decorateCache(Cache cache) {
174174
}
175175

176176
/**
177-
* Return a missing cache with the specified {@code name} or {@code null} if
178-
* such cache does not exist or could not be created on the fly.
179-
* <p>Some caches may be created at runtime if the native provider supports
180-
* it. If a lookup by name does not yield any result, a subclass gets a chance
181-
* to register such a cache at runtime. The returned cache will be automatically
182-
* added to this instance.
177+
* Return a missing cache with the specified {@code name}, or {@code null} if
178+
* such a cache does not exist or could not be created on demand.
179+
* <p>Caches may be lazily created at runtime if the native provider supports it.
180+
* If a lookup by name does not yield any result, an {@code AbstractCacheManager}
181+
* subclass gets a chance to register such a cache at runtime. The returned cache
182+
* will be automatically added to this cache manager.
183183
* @param name the name of the cache to retrieve
184-
* @return the missing cache or {@code null} if no such cache exists or could be
185-
* created
184+
* @return the missing cache, or {@code null} if no such cache exists or could be
185+
* created on demand
186186
* @since 4.1
187187
* @see #getCache(String)
188188
*/

spring-context/src/main/java/org/springframework/context/MessageSource.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,10 +26,10 @@
2626
*
2727
* <p>Spring provides two out-of-the-box implementations for production:
2828
* <ul>
29-
* <li>{@link org.springframework.context.support.ResourceBundleMessageSource},
30-
* built on top of the standard {@link java.util.ResourceBundle}
31-
* <li>{@link org.springframework.context.support.ReloadableResourceBundleMessageSource},
32-
* being able to reload message definitions without restarting the VM
29+
* <li>{@link org.springframework.context.support.ResourceBundleMessageSource}: built
30+
* on top of the standard {@link java.util.ResourceBundle}, sharing its limitations.
31+
* <li>{@link org.springframework.context.support.ReloadableResourceBundleMessageSource}:
32+
* highly configurable, in particular with respect to reloading message definitions.
3333
* </ul>
3434
*
3535
* @author Rod Johnson
@@ -41,30 +41,34 @@ public interface MessageSource {
4141

4242
/**
4343
* Try to resolve the message. Return default message if no message was found.
44-
* @param code the code to lookup up, such as 'calculator.noRateSet'. Users of
45-
* this class are encouraged to base message names on the relevant fully
46-
* qualified class name, thus avoiding conflict and ensuring maximum clarity.
44+
* @param code the message code to look up, e.g. 'calculator.noRateSet'.
45+
* MessageSource users are encouraged to base message names on qualified class
46+
* or package names, avoiding potential conflicts and ensuring maximum clarity.
4747
* @param args an array of arguments that will be filled in for params within
4848
* the message (params look like "{0}", "{1,date}", "{2,time}" within a message),
49-
* or {@code null} if none.
49+
* or {@code null} if none
5050
* @param defaultMessage a default message to return if the lookup fails
5151
* @param locale the locale in which to do the lookup
52-
* @return the resolved message if the lookup was successful;
53-
* otherwise the default message passed as a parameter
52+
* @return the resolved message if the lookup was successful, otherwise
53+
* the default message passed as a parameter (which may be {@code null})
54+
* @see #getMessage(MessageSourceResolvable, Locale)
5455
* @see java.text.MessageFormat
5556
*/
5657
@Nullable
5758
String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale);
5859

5960
/**
6061
* Try to resolve the message. Treat as an error if the message can't be found.
61-
* @param code the code to lookup up, such as 'calculator.noRateSet'
62+
* @param code the message code to look up, e.g. 'calculator.noRateSet'.
63+
* MessageSource users are encouraged to base message names on qualified class
64+
* or package names, avoiding potential conflicts and ensuring maximum clarity.
6265
* @param args an array of arguments that will be filled in for params within
6366
* the message (params look like "{0}", "{1,date}", "{2,time}" within a message),
64-
* or {@code null} if none.
67+
* or {@code null} if none
6568
* @param locale the locale in which to do the lookup
66-
* @return the resolved message
67-
* @throws NoSuchMessageException if the message wasn't found
69+
* @return the resolved message (never {@code null})
70+
* @throws NoSuchMessageException if no corresponding message was found
71+
* @see #getMessage(MessageSourceResolvable, Locale)
6872
* @see java.text.MessageFormat
6973
*/
7074
String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException;
@@ -76,9 +80,15 @@ public interface MessageSource {
7680
* since at the time of calling this method we aren't able to determine if the
7781
* {@code defaultMessage} property of the resolvable is {@code null} or not.
7882
* @param resolvable the value object storing attributes required to resolve a message
83+
* (may include a default message)
7984
* @param locale the locale in which to do the lookup
80-
* @return the resolved message
81-
* @throws NoSuchMessageException if the message wasn't found
85+
* @return the resolved message (never {@code null} since even a
86+
* {@code MessageSourceResolvable}-provided default message needs to be non-null)
87+
* @throws NoSuchMessageException if no corresponding message was found
88+
* (and no default message was provided by the {@code MessageSourceResolvable})
89+
* @see MessageSourceResolvable#getCodes()
90+
* @see MessageSourceResolvable#getArguments()
91+
* @see MessageSourceResolvable#getDefaultMessage()
8292
* @see java.text.MessageFormat
8393
*/
8494
String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException;

spring-core/src/main/java/org/springframework/core/PriorityOrdered.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,14 +18,19 @@
1818

1919
/**
2020
* Extension of the {@link Ordered} interface, expressing a <em>priority</em>
21-
* ordering: order values expressed by {@code PriorityOrdered} objects
22-
* always apply before same order values expressed by <em>plain</em>
23-
* {@link Ordered} objects.
21+
* ordering: {@code PriorityOrdered} objects are always applied before
22+
* <em>plain</em> {@link Ordered} objects regardless of their order values.
2423
*
25-
* <p>This is primarily a special-purpose interface, used for objects where
26-
* it is particularly important to recognize <em>prioritized</em> objects
27-
* first, without even obtaining the remaining objects. A typical example:
28-
* prioritized post-processors in a Spring
24+
* <p>When sorting a set of {@code Ordered} objects, {@code PriorityOrdered}
25+
* objects and <em>plain</em> {@code Ordered} objects are effectively treated as
26+
* two separate subsets, with the set of {@code PriorityOrdered} objects preceding
27+
* the set of <em>plain</em> {@code Ordered} objects and with relative
28+
* ordering applied within those subsets.
29+
*
30+
* <p>This is primarily a special-purpose interface, used within the framework
31+
* itself for objects where it is particularly important to recognize
32+
* <em>prioritized</em> objects first, potentially without even obtaining the
33+
* remaining objects. A typical example: prioritized post-processors in a Spring
2934
* {@link org.springframework.context.ApplicationContext}.
3035
*
3136
* <p>Note: {@code PriorityOrdered} post-processor beans are initialized in
@@ -34,10 +39,10 @@
3439
* beans which do not require eager initialization for type matching.
3540
*
3641
* @author Juergen Hoeller
42+
* @author Sam Brannen
3743
* @since 2.5
3844
* @see org.springframework.beans.factory.config.PropertyOverrideConfigurer
3945
* @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
4046
*/
4147
public interface PriorityOrdered extends Ordered {
42-
4348
}

spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -327,6 +327,7 @@ public void write(EvaluationContext context, @Nullable Object target, String nam
327327
}
328328

329329
/**
330+
* Get the last read invoker pair.
330331
* @deprecated as of 4.3.15 since it is not used within the framework anymore
331332
*/
332333
@Deprecated
@@ -384,10 +385,10 @@ private Method findSetterForProperty(String propertyName, Class<?> clazz, Object
384385
@Nullable
385386
protected Method findGetterForProperty(String propertyName, Class<?> clazz, boolean mustBeStatic) {
386387
Method method = findMethodForProperty(getPropertyMethodSuffixes(propertyName),
387-
"get", clazz, mustBeStatic, 0, ANY_TYPES);
388+
"get", clazz, mustBeStatic, 0, ANY_TYPES);
388389
if (method == null) {
389390
method = findMethodForProperty(getPropertyMethodSuffixes(propertyName),
390-
"is", clazz, mustBeStatic, 0, BOOLEAN_TYPES);
391+
"is", clazz, mustBeStatic, 0, BOOLEAN_TYPES);
391392
}
392393
return method;
393394
}
@@ -419,6 +420,17 @@ private Method findMethodForProperty(String[] methodSuffixes, String prefix, Cla
419420
return null;
420421
}
421422

423+
/**
424+
* Return class methods ordered with non-bridge methods appearing higher.
425+
*/
426+
private Method[] getSortedMethods(Class<?> clazz) {
427+
return this.sortedMethodsCache.computeIfAbsent(clazz, key -> {
428+
Method[] methods = key.getMethods();
429+
Arrays.sort(methods, (o1, o2) -> (o1.isBridge() == o2.isBridge() ? 0 : (o1.isBridge() ? 1 : -1)));
430+
return methods;
431+
});
432+
}
433+
422434
/**
423435
* Determine whether the given {@code Method} is a candidate for property access
424436
* on an instance of the given target class.
@@ -432,17 +444,6 @@ protected boolean isCandidateForProperty(Method method, Class<?> targetClass) {
432444
return true;
433445
}
434446

435-
/**
436-
* Return class methods ordered with non-bridge methods appearing higher.
437-
*/
438-
private Method[] getSortedMethods(Class<?> clazz) {
439-
return this.sortedMethodsCache.computeIfAbsent(clazz, key -> {
440-
Method[] methods = key.getMethods();
441-
Arrays.sort(methods, (o1, o2) -> (o1.isBridge() == o2.isBridge() ? 0 : (o1.isBridge() ? 1 : -1)));
442-
return methods;
443-
});
444-
}
445-
446447
/**
447448
* Return the method suffixes for a given property name. The default implementation
448449
* uses JavaBean conventions with additional support for properties of the form 'xY'

0 commit comments

Comments
 (0)