Package eu.cloudnetservice.driver.event
Class DefaultRegisteredEventListener
java.lang.Object
eu.cloudnetservice.driver.event.DefaultRegisteredEventListener
- All Implemented Interfaces:
RegisteredEventListener,Comparable<RegisteredEventListener>
The default implementation of a registered event listener.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class<?>private final EventListenerprivate final InjectionLayer<?>private final Objectprivate static final eu.cloudnetservice.common.log.Loggerprivate final dev.derklaro.reflexion.MethodAccessor<?>private final dev.derklaro.aerogel.Element[]private final String -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRegisteredEventListener(@NonNull Object instance, @NonNull Method targetMethod, @NonNull EventListener eventListener, @NonNull InjectionLayer<?> injectionLayer) Constructs a new default registered event listener instance. -
Method Summary
Modifier and TypeMethodDescriptionchannel()Get the channel this event is listening to.Get the class type of the event the underlying listener is listening to.Get the annotation used on the original listener method to identify it as a listener method.voidFires the event by invoking the underlying method with the given event.instance()Get the instance of the listener class used to register all listeners in it.order()Get the priority defined in the @EventListener annotation on the original listener method.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.driver.event.RegisteredEventListener
compareTo
-
Field Details
-
LOGGER
private static final eu.cloudnetservice.common.log.Logger LOGGER -
instance
-
eventClass
-
eventListener
-
methodName
-
methodArguments
private final dev.derklaro.aerogel.Element[] methodArguments -
methodAccessor
private final dev.derklaro.reflexion.MethodAccessor<?> methodAccessor -
injectionLayer
-
-
Constructor Details
-
DefaultRegisteredEventListener
DefaultRegisteredEventListener(@NonNull @NonNull Object instance, @NonNull @NonNull Method targetMethod, @NonNull @NonNull EventListener eventListener, @NonNull @NonNull InjectionLayer<?> injectionLayer) Constructs a new default registered event listener instance.- Parameters:
instance- the instance all event listener methods should get called on.targetMethod- the method of the event listener.eventListener- the annotation used to identify the target method.injectionLayer- the injection layer to use when additional parameters are present on the target method.- Throws:
NullPointerException- if one of the given arguments is null.
-
-
Method Details
-
fireEvent
Fires the event by invoking the underlying method with the given event. The event type is ensured to only be the same type the listener defined in the method. Event execution is not concurrent as per the event manager contract, therefore there is no need for locking before event execution.- Specified by:
fireEventin interfaceRegisteredEventListener- Parameters:
event- the event to fire.
-
channel
Get the channel this event is listening to. Defaults to * meaning that the listener listens to all channels.- Specified by:
channelin interfaceRegisteredEventListener- Returns:
- the channel this event is listening to.
-
order
Get the priority defined in the @EventListener annotation on the original listener method.- Specified by:
orderin interfaceRegisteredEventListener- Returns:
- the priority of the underlying event listener.
-
instance
Get the instance of the listener class used to register all listeners in it.- Specified by:
instancein interfaceRegisteredEventListener- Returns:
- the instance of the listener class.
-
eventClass
Get the class type of the event the underlying listener is listening to.- Specified by:
eventClassin interfaceRegisteredEventListener- Returns:
- the class type of the event this listener listens to.
-
eventListener
Get the annotation used on the original listener method to identify it as a listener method.- Specified by:
eventListenerin interfaceRegisteredEventListener- Returns:
- the annotation used on the original listener method.
-