@@ -126,10 +126,10 @@ public ApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, M
126126 }
127127
128128 private static List <ResolvableType > resolveDeclaredEventTypes (Method method , @ Nullable EventListener ann ) {
129- int count = (KotlinDetector .isSuspendingFunction (method ) ? method .getParameterCount () - 1 : method .getParameterCount ());
129+ int count = (KotlinDetector .isSuspendingFunction (method ) ? method .getParameterCount () - 1 :
130+ method .getParameterCount ());
130131 if (count > 1 ) {
131- throw new IllegalStateException (
132- "Maximum one parameter is allowed for event listener method: " + method );
132+ throw new IllegalStateException ("Maximum one parameter is allowed for event listener method: " + method );
133133 }
134134
135135 if (ann != null ) {
@@ -156,6 +156,35 @@ private static int resolveOrder(Method method) {
156156 }
157157
158158
159+ /**
160+ * Return the target listener method.
161+ * @since 7.0.7 in public form (with protected visibility since 5.3)
162+ */
163+ public final Method getTargetMethod () {
164+ return this .targetMethod ;
165+ }
166+
167+ /**
168+ * Return the condition to use.
169+ * <p>Matches the {@code condition} attribute of the {@link EventListener}
170+ * annotation or any matching attribute on a composed annotation that
171+ * is meta-annotated with {@code @EventListener}.
172+ */
173+ protected final @ Nullable String getCondition () {
174+ return this .condition ;
175+ }
176+
177+ /**
178+ * Return whether default execution is applicable for the target listener.
179+ * @since 6.2
180+ * @see #onApplicationEvent
181+ * @see EventListener#defaultExecution()
182+ */
183+ protected final boolean isDefaultExecution () {
184+ return this .defaultExecution ;
185+ }
186+
187+
159188 /**
160189 * Initialize this instance.
161190 */
@@ -167,7 +196,7 @@ void init(ApplicationContext applicationContext, @Nullable EventExpressionEvalua
167196
168197 @ Override
169198 public void onApplicationEvent (ApplicationEvent event ) {
170- if (isDefaultExecution () ) {
199+ if (this . defaultExecution ) {
171200 processEvent (event );
172201 }
173202 }
@@ -222,22 +251,11 @@ public String getListenerId() {
222251 * @see #getListenerId()
223252 */
224253 protected String getDefaultListenerId () {
225- Method method = getTargetMethod ();
226254 StringJoiner sj = new StringJoiner ("," , "(" , ")" );
227- for (Class <?> paramType : method .getParameterTypes ()) {
255+ for (Class <?> paramType : this . targetMethod .getParameterTypes ()) {
228256 sj .add (paramType .getName ());
229257 }
230- return ClassUtils .getQualifiedMethodName (method ) + sj ;
231- }
232-
233- /**
234- * Return whether default execution is applicable for the target listener.
235- * @since 6.2
236- * @see #onApplicationEvent
237- * @see EventListener#defaultExecution()
238- */
239- protected boolean isDefaultExecution () {
240- return this .defaultExecution ;
258+ return ClassUtils .getQualifiedMethodName (this .targetMethod ) + sj ;
241259 }
242260
243261
@@ -274,11 +292,10 @@ private boolean shouldHandle(ApplicationEvent event, @Nullable Object @Nullable
274292 if (args == null ) {
275293 return false ;
276294 }
277- String condition = getCondition ();
278- if (StringUtils .hasText (condition )) {
295+ if (StringUtils .hasText (this .condition )) {
279296 Assert .notNull (this .evaluator , "EventExpressionEvaluator must not be null" );
280297 return this .evaluator .condition (
281- condition , event , this .targetMethod , this .methodKey , args );
298+ this . condition , event , this .targetMethod , this .methodKey , args );
282299 }
283300 return true ;
284301 }
@@ -402,32 +419,14 @@ protected Object getTargetBean() {
402419 return this .applicationContext .getBean (this .beanName );
403420 }
404421
405- /**
406- * Return the target listener method.
407- * @since 5.3
408- */
409- protected Method getTargetMethod () {
410- return this .targetMethod ;
411- }
412-
413- /**
414- * Return the condition to use.
415- * <p>Matches the {@code condition} attribute of the {@link EventListener}
416- * annotation or any matching attribute on a composed annotation that
417- * is meta-annotated with {@code @EventListener}.
418- */
419- protected @ Nullable String getCondition () {
420- return this .condition ;
421- }
422-
423422 /**
424423 * Add additional details such as the bean type and method signature to
425424 * the given error message.
426425 * @param message error message to append the HandlerMethod details to
427426 */
428427 protected String getDetailedErrorMessage (Object bean , @ Nullable String message ) {
429428 StringBuilder sb = (StringUtils .hasLength (message ) ? new StringBuilder (message ).append ('\n' ) : new StringBuilder ());
430- sb .append ("HandlerMethod details: \n " );
429+ sb .append ("ApplicationListenerMethodAdapter details: \n " );
431430 sb .append ("Bean [" ).append (bean .getClass ().getName ()).append ("]\n " );
432431 sb .append ("Method [" ).append (this .method .toGenericString ()).append ("]\n " );
433432 return sb .toString ();
0 commit comments