16
16
17
17
package org .springframework .messaging .core ;
18
18
19
+ import java .util .Map ;
19
20
import java .util .concurrent .ConcurrentHashMap ;
20
21
21
22
import org .springframework .beans .factory .InitializingBean ;
34
35
*/
35
36
public class CachingDestinationResolverProxy <D > implements DestinationResolver <D >, InitializingBean {
36
37
37
- private final ConcurrentHashMap <String , D > resolvedDestinationCache = new ConcurrentHashMap <String , D >();
38
+ private final Map <String , D > resolvedDestinationCache = new ConcurrentHashMap <String , D >();
38
39
39
- private DestinationResolver <D > targetDestinationResolver ;
40
+ private DestinationResolver <D > targetDestinationResolver ;
40
41
41
42
42
43
/**
@@ -47,14 +48,14 @@ public CachingDestinationResolverProxy() {
47
48
}
48
49
49
50
/**
50
- * Create a new CachingDestinationResolverProxy using the given target
51
+ * Create a new CachingDestinationResolverProxy using the given target
51
52
* DestinationResolver to actually resolve destinations.
52
- * @param targetDestinationResolver the target DestinationResolver to delegate to
53
- */
54
- public CachingDestinationResolverProxy (DestinationResolver <D > targetDestinationResolver ) {
55
- Assert .notNull (targetDestinationResolver , "Target DestinationResolver must not be null" );
56
- this .targetDestinationResolver = targetDestinationResolver ;
57
- }
53
+ * @param targetDestinationResolver the target DestinationResolver to delegate to
54
+ */
55
+ public CachingDestinationResolverProxy (DestinationResolver <D > targetDestinationResolver ) {
56
+ Assert .notNull (targetDestinationResolver , "Target DestinationResolver must not be null" );
57
+ this .targetDestinationResolver = targetDestinationResolver ;
58
+ }
58
59
59
60
60
61
/**
@@ -73,22 +74,21 @@ public void afterPropertiesSet() {
73
74
74
75
75
76
/**
76
- *
77
- * Resolves and caches destinations if successfully resolved by the target
78
- * DestinationResolver implementation.
79
- * @param name the destination name to be resolved
80
- * @return the currently resolved destination or an already cached destination
81
- * @throws DestinationResolutionException if the target DestinationResolver
82
- * reports an error during destination resolution
83
- */
84
- @ Override
85
- public D resolveDestination (String name ) throws DestinationResolutionException {
86
- D destination = this .resolvedDestinationCache .get (name );
77
+ * Resolves and caches destinations if successfully resolved by the target
78
+ * DestinationResolver implementation.
79
+ * @param name the destination name to be resolved
80
+ * @return the currently resolved destination or an already cached destination
81
+ * @throws DestinationResolutionException if the target DestinationResolver
82
+ * reports an error during destination resolution
83
+ */
84
+ @ Override
85
+ public D resolveDestination (String name ) throws DestinationResolutionException {
86
+ D destination = this .resolvedDestinationCache .get (name );
87
87
if (destination == null ) {
88
- destination = this .targetDestinationResolver .resolveDestination (name );
89
- this .resolvedDestinationCache .putIfAbsent (name , destination );
90
- }
91
- return destination ;
92
- }
88
+ destination = this .targetDestinationResolver .resolveDestination (name );
89
+ this .resolvedDestinationCache .put (name , destination );
90
+ }
91
+ return destination ;
92
+ }
93
93
94
94
}
0 commit comments