Class SimpleEventHandler
java.lang.Object
com.github.philippheuer.events4j.simple.SimpleEventHandler
- All Implemented Interfaces:
com.github.philippheuer.events4j.api.service.IEventHandler,java.lang.AutoCloseable
public class SimpleEventHandler
extends java.lang.Object
implements com.github.philippheuer.events4j.api.service.IEventHandler
-
Constructor Summary
Constructors Constructor Description SimpleEventHandler() -
Method Summary
Modifier and Type Method Description voidclose()Shutdownjava.util.concurrent.ConcurrentMap<java.lang.Class<?>,java.util.List<java.util.function.Consumer<java.lang.Object>>>getConsumerBasedHandlers()Consumer based handlers<E> com.github.philippheuer.events4j.api.domain.IDisposableonEvent(java.lang.Class<E> eventClass, java.util.function.Consumer<E> consumer)Registers a new consumer based event handlervoidpublish(java.lang.Object event)Dispatched a event to the simple based method listeners.voidregisterListener(java.lang.Object eventListener)Registers a listener usingEventSubscribermethod annotations.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
SimpleEventHandler
public SimpleEventHandler()
-
-
Method Details
-
registerListener
public void registerListener(java.lang.Object eventListener)Registers a listener usingEventSubscribermethod annotations.- Parameters:
eventListener- The class instance annotated withEventSubscriberannotations.
-
onEvent
public <E> com.github.philippheuer.events4j.api.domain.IDisposable onEvent(java.lang.Class<E> eventClass, java.util.function.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
public void publish(java.lang.Object event)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 interfacejava.lang.AutoCloseable
-
getConsumerBasedHandlers
public java.util.concurrent.ConcurrentMap<java.lang.Class<?>,java.util.List<java.util.function.Consumer<java.lang.Object>>> getConsumerBasedHandlers()Consumer based handlers
-