Class SimpleEventHandler
java.lang.Object
com.github.philippheuer.events4j.simple.SimpleEventHandler
- All Implemented Interfaces:
com.github.philippheuer.events4j.api.service.IEventHandler
,AutoCloseable
public class SimpleEventHandler
extends Object
implements com.github.philippheuer.events4j.api.service.IEventHandler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
ShutdownConcurrentMap<Class<?>,
List<Consumer<Object>>> Consumer based handlers<E> com.github.philippheuer.events4j.api.domain.IDisposable
Registers a new consumer based event handlervoid
Dispatched a event to the simple based method listeners.void
registerListener
(Object eventListener) Registers a listener usingEventSubscriber
method annotations.
-
Constructor Details
-
SimpleEventHandler
public SimpleEventHandler()
-
-
Method Details
-
registerListener
Registers a listener usingEventSubscriber
method annotations.- Parameters:
eventListener
- The class instance annotated withEventSubscriber
annotations.
-
onEvent
public <E> com.github.philippheuer.events4j.api.domain.IDisposable onEvent(Class<E> eventClass, Consumer<E> consumer) Registers a new consumer based event handler- Specified by:
onEvent
in interfacecom.github.philippheuer.events4j.api.service.IEventHandler
- Type Parameters:
E
- the event type- Parameters:
eventClass
- the event class to obtain events fromconsumer
- the event consumer / handler method- Returns:
- a new Disposable of the given eventType
-
publish
Dispatched a event to the simple based method listeners.- Specified by:
publish
in interfacecom.github.philippheuer.events4j.api.service.IEventHandler
- Parameters:
event
- The event that will be dispatched to the simple based method listeners.
-
close
public void close()Shutdown- Specified by:
close
in interfaceAutoCloseable
-
getConsumerBasedHandlers
Consumer based handlers
-