Class ServerEvent<T extends ServerEventListener>
java.lang.Object
com.oorian.messaging.events.Event<T>
com.oorian.messaging.events.server.ServerEvent<T>
- Type Parameters:
T- the type of listener that handles this event
Abstract base class for server-originated events that carry an event ID and source element.
Server events are created on the server side and dispatched to registered
ServerEventListener implementations. They provide a mechanism for
components to communicate internally without client involvement.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new ServerEvent with bubbling enabled.protectedServerEvent(boolean bubbles) Creates a new ServerEvent with the specified bubbling behavior.protectedServerEvent(int id) Creates a new ServerEvent with the specified ID.protectedServerEvent(int id, boolean bubbles) Creates a new ServerEvent with the specified ID and bubbling behavior. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispatchTo(T listener) Dispatches this event to the specified listener.intgetId()Returns the event identifier.Returns the source element that originated this event.voidsetId(int id) Sets the event identifier.voidSets the source element that originated this event.
-
Constructor Details
-
ServerEvent
protected ServerEvent()Creates a new ServerEvent with bubbling enabled. -
ServerEvent
protected ServerEvent(boolean bubbles) Creates a new ServerEvent with the specified bubbling behavior.- Parameters:
bubbles-trueif this event should bubble,falseotherwise
-
ServerEvent
protected ServerEvent(int id) Creates a new ServerEvent with the specified ID.- Parameters:
id- the event identifier
-
ServerEvent
protected ServerEvent(int id, boolean bubbles) Creates a new ServerEvent with the specified ID and bubbling behavior.- Parameters:
id- the event identifierbubbles-trueif this event should bubble,falseotherwise
-
-
Method Details
-
setId
public void setId(int id) Sets the event identifier.- Parameters:
id- the event ID
-
setSource
Sets the source element that originated this event.- Parameters:
source- the source element
-
getId
public int getId()Returns the event identifier.- Returns:
- the event ID
-
getSource
Returns the source element that originated this event.- Returns:
- the source element
-
dispatchTo
Dispatches this event to the specified listener.Subclasses implement this method to call the appropriate handler method on the listener interface.
- Specified by:
dispatchToin classEvent<T extends ServerEventListener>- Parameters:
listener- the listener to dispatch this event to
-