@@ -219,13 +219,14 @@ protected String getDefaultListenerId() {
219
219
for (Class <?> paramType : method .getParameterTypes ()) {
220
220
sj .add (paramType .getName ());
221
221
}
222
- return ClassUtils .getQualifiedMethodName (method ) + sj . toString () ;
222
+ return ClassUtils .getQualifiedMethodName (method ) + sj ;
223
223
}
224
224
225
225
226
226
/**
227
227
* Process the specified {@link ApplicationEvent}, checking if the condition
228
228
* matches and handling a non-null result, if any.
229
+ * @param event the event to process through the listener method
229
230
*/
230
231
public void processEvent (ApplicationEvent event ) {
231
232
Object [] args = resolveArguments (event );
@@ -240,6 +241,29 @@ public void processEvent(ApplicationEvent event) {
240
241
}
241
242
}
242
243
244
+ /**
245
+ * Determine whether the listener method would actually handle the given
246
+ * event, checking if the condition matches.
247
+ * @param event the event to process through the listener method
248
+ * @since 6.1
249
+ */
250
+ public boolean shouldHandle (ApplicationEvent event ) {
251
+ return shouldHandle (event , resolveArguments (event ));
252
+ }
253
+
254
+ private boolean shouldHandle (ApplicationEvent event , @ Nullable Object [] args ) {
255
+ if (args == null ) {
256
+ return false ;
257
+ }
258
+ String condition = getCondition ();
259
+ if (StringUtils .hasText (condition )) {
260
+ Assert .notNull (this .evaluator , "EventExpressionEvaluator must not be null" );
261
+ return this .evaluator .condition (
262
+ condition , event , this .targetMethod , this .methodKey , args , this .applicationContext );
263
+ }
264
+ return true ;
265
+ }
266
+
243
267
/**
244
268
* Resolve the method arguments to use for the specified {@link ApplicationEvent}.
245
269
* <p>These arguments will be used to invoke the method handled by this instance.
@@ -319,19 +343,6 @@ protected void handleAsyncError(Throwable t) {
319
343
logger .error ("Unexpected error occurred in asynchronous listener" , t );
320
344
}
321
345
322
- private boolean shouldHandle (ApplicationEvent event , @ Nullable Object [] args ) {
323
- if (args == null ) {
324
- return false ;
325
- }
326
- String condition = getCondition ();
327
- if (StringUtils .hasText (condition )) {
328
- Assert .notNull (this .evaluator , "EventExpressionEvaluator must not be null" );
329
- return this .evaluator .condition (
330
- condition , event , this .targetMethod , this .methodKey , args , this .applicationContext );
331
- }
332
- return true ;
333
- }
334
-
335
346
/**
336
347
* Invoke the event listener method with the given argument values.
337
348
*/
0 commit comments