类 ApplicationListenerMethodAdapter
- 所有已实现的接口:
ApplicationListener<ApplicationEvent>,GenericApplicationListener,SmartApplicationListener,cn.taketoday.core.Ordered,EventListener
GenericApplicationListener adapter that delegates the processing of
an event to an EventListener annotated method.
Delegates to onApplicationEvent(ApplicationEvent) to give subclasses
a chance to deviate from the default. Unwraps the content of a
PayloadApplicationEvent if necessary to allow a method declaration
to define any arbitrary event type. If a condition is defined, it is
evaluated prior to invoking the underlying method.
- 从以下版本开始:
- 4.0
- 作者:
- Stephane Nicoll, Juergen Hoeller, Sam Brannen, TODAY 2021/11/5 11:51
-
字段概要
从接口继承的字段 cn.taketoday.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
构造器概要
构造器构造器说明ApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method) Construct a new MethodApplicationListener. -
方法概要
修饰符和类型方法说明protected ObjectInvoke the event listener method with the given argument values.protected StringReturn the condition to use.protected StringDetermine the default id for the target listener, to be applied in case of noannotation-specified id value.protected StringgetDetailedErrorMessage(Object bean, String message) Add additional details such as the bean type and method signature to the given error message.Return an optional identifier for the listener.intgetOrder()Determine this listener's order in a set of listeners for the same event.protected ObjectReturn the target bean instance to use.protected MethodReturn the target listener method.protected voidprotected voidhandleResult(Object result) protected voidinit(ApplicationContext context, cn.taketoday.context.event.EventExpressionEvaluator evaluator) voidProcess the specifiedObject, checking if the condition matches and handling a non-null result, if any.protected Object[]resolveArguments(ApplicationEvent event) Resolve the method arguments to use for the specifiedApplicationEvent.booleansupportsEventType(cn.taketoday.core.ResolvableType eventType) Determine whether this listener actually supports the given event type.booleansupportsSourceType(Class<?> sourceType) Determine whether this listener actually supports the given source type.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.context.event.GenericApplicationListener
supportsEventType
-
构造器详细资料
-
ApplicationListenerMethodAdapter
Construct a new MethodApplicationListener.- 参数:
beanName- the name of the bean to invoke the listener method ontargetClass- the target class that the method is declared onmethod- the listener method to invoke
-
-
方法详细资料
-
init
protected void init(ApplicationContext context, @Nullable cn.taketoday.context.event.EventExpressionEvaluator evaluator) -
getOrder
public int getOrder()从接口复制的说明:SmartApplicationListenerDetermine this listener's order in a set of listeners for the same event.The default implementation returns
Ordered.LOWEST_PRECEDENCE.- 指定者:
getOrder在接口中cn.taketoday.core.Ordered- 指定者:
getOrder在接口中SmartApplicationListener
-
getTargetBean
Return the target bean instance to use. -
getTargetMethod
Return the target listener method. -
getCondition
Return the condition to use.Matches the
conditionattribute of theEventListenerannotation or any matching attribute on a composed annotation that is meta-annotated with@EventListener. -
supportsEventType
public boolean supportsEventType(cn.taketoday.core.ResolvableType eventType) 从接口复制的说明:GenericApplicationListenerDetermine whether this listener actually supports the given event type.- 指定者:
supportsEventType在接口中GenericApplicationListener- 参数:
eventType- the event type (nevernull)
-
supportsSourceType
从接口复制的说明:SmartApplicationListenerDetermine whether this listener actually supports the given source type.The default implementation always returns
true.- 指定者:
supportsSourceType在接口中SmartApplicationListener- 参数:
sourceType- the source type, ornullif no source
-
onApplicationEvent
Process the specifiedObject, checking if the condition matches and handling a non-null result, if any.- 指定者:
onApplicationEvent在接口中ApplicationListener<ApplicationEvent>- 参数:
event- the event to respond to
-
resolveArguments
Resolve the method arguments to use for the specifiedApplicationEvent.These arguments will be used to invoke the method handled by this instance. Can return
nullto indicate that no suitable arguments could be resolved and therefore the method should not be invoked at all for the specified event. -
doInvoke
Invoke the event listener method with the given argument values. -
getListenerId
从接口复制的说明:SmartApplicationListenerReturn an optional identifier for the listener.The default value is an empty String.
-
getDefaultListenerId
Determine the default id for the target listener, to be applied in case of noannotation-specified id value.The default implementation builds a method name with parameter types.
- 另请参阅:
-
handleResult
-
handleAsyncError
-
getDetailedErrorMessage
Add additional details such as the bean type and method signature to the given error message.- 参数:
message- error message to append the HandlerMethod details to
-