37
37
import org .springframework .expression .Expression ;
38
38
import org .springframework .integration .expression .ExpressionUtils ;
39
39
import org .springframework .integration .expression .FunctionExpression ;
40
- import org .springframework .integration .handler .AbstractReplyProducingMessageHandler ;
41
40
import org .springframework .integration .support .AbstractIntegrationMessageBuilder ;
42
41
import org .springframework .lang .Nullable ;
43
42
import org .springframework .messaging .Message ;
44
43
import org .springframework .util .Assert ;
44
+ import org .springframework .util .ClassUtils ;
45
45
import org .springframework .util .ObjectUtils ;
46
46
import org .springframework .util .ReflectionUtils ;
47
47
48
48
/**
49
49
* The {@link AbstractRequestHandlerAdvice} implementation for caching
50
- * {@link AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)} results.
50
+ * {@code AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)} results.
51
51
* Supports all the cache operations - cacheable, put, evict.
52
52
* By default only cacheable is applied for the provided {@code cacheNames}.
53
53
* The default cache {@code key} is {@code payload} of the request message.
56
56
*
57
57
* @since 5.2
58
58
*
59
- * @see AbstractReplyProducingMessageHandler.RequestHandler
60
59
* @see CacheAspectSupport
61
60
* @see CacheOperation
62
61
*/
63
62
public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice
64
63
implements SmartInitializingSingleton {
65
64
66
- private static final Method HANDLE_REQUEST_METHOD =
67
- ReflectionUtils .findMethod (AbstractReplyProducingMessageHandler .RequestHandler .class ,
68
- "handleRequestMessage" , Message .class );
65
+ private static final Method HANDLE_REQUEST_METHOD ;
66
+
67
+ static {
68
+ Class <?> requestHandlerClass = null ;
69
+ try {
70
+ requestHandlerClass = ClassUtils .forName (
71
+ "org.springframework.integration.handler.AbstractReplyProducingMessageHandler.RequestHandler" ,
72
+ null );
73
+ }
74
+ catch (ClassNotFoundException ex ) {
75
+ throw new IllegalStateException (ex );
76
+ }
77
+ finally {
78
+ if (requestHandlerClass != null ) {
79
+ HANDLE_REQUEST_METHOD =
80
+ ReflectionUtils .findMethod (requestHandlerClass , "handleRequestMessage" , Message .class );
81
+ }
82
+ else {
83
+ HANDLE_REQUEST_METHOD = null ;
84
+ }
85
+ }
86
+ }
69
87
70
88
private final IntegrationCacheAspect delegate = new IntegrationCacheAspect ();
71
89
@@ -91,7 +109,7 @@ public CacheRequestHandlerAdvice(String... cacheNames) {
91
109
92
110
/**
93
111
* Configure a set of {@link CacheOperation} which are going to be applied to the
94
- * {@link AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)}
112
+ * {@code AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)}
95
113
* method via {@link IntegrationCacheAspect}.
96
114
* This is similar to the technique provided by the
97
115
* {@link org.springframework.cache.annotation.Caching} annotation.
0 commit comments