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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()ShutdownConcurrentMap<Class<?>,List<Consumer<Object>>> Consumer based handlers<E> com.github.philippheuer.events4j.api.domain.IDisposableRegisters a new consumer based event handlervoidDispatched a event to the simple based method listeners.voidregisterListener(Object eventListener) Registers a listener usingEventSubscribermethod annotations.
-
Constructor Details
-
SimpleEventHandler
public SimpleEventHandler()
-
-
Method Details
-
registerListener
Registers a listener usingEventSubscribermethod annotations.- Parameters:
eventListener- The class instance annotated withEventSubscriberannotations.
-
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:
onEventin 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:
publishin 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:
closein interfaceAutoCloseable
-
getConsumerBasedHandlers
Consumer based handlers
-