3737import org .springframework .expression .Expression ;
3838import org .springframework .integration .expression .ExpressionUtils ;
3939import org .springframework .integration .expression .FunctionExpression ;
40- import org .springframework .integration .handler .AbstractReplyProducingMessageHandler ;
4140import org .springframework .integration .support .AbstractIntegrationMessageBuilder ;
4241import org .springframework .lang .Nullable ;
4342import org .springframework .messaging .Message ;
4443import org .springframework .util .Assert ;
44+ import org .springframework .util .ClassUtils ;
4545import org .springframework .util .ObjectUtils ;
4646import org .springframework .util .ReflectionUtils ;
4747
4848/**
4949 * The {@link AbstractRequestHandlerAdvice} implementation for caching
50- * {@link AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)} results.
50+ * {@code AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)} results.
5151 * Supports all the cache operations - cacheable, put, evict.
5252 * By default only cacheable is applied for the provided {@code cacheNames}.
5353 * The default cache {@code key} is {@code payload} of the request message.
5656 *
5757 * @since 5.2
5858 *
59- * @see AbstractReplyProducingMessageHandler.RequestHandler
6059 * @see CacheAspectSupport
6160 * @see CacheOperation
6261 */
6362public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice
6463 implements SmartInitializingSingleton {
6564
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+ }
6987
7088 private final IntegrationCacheAspect delegate = new IntegrationCacheAspect ();
7189
@@ -91,7 +109,7 @@ public CacheRequestHandlerAdvice(String... cacheNames) {
91109
92110 /**
93111 * 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)}
95113 * method via {@link IntegrationCacheAspect}.
96114 * This is similar to the technique provided by the
97115 * {@link org.springframework.cache.annotation.Caching} annotation.
0 commit comments