Class EventProcessor
- java.lang.Object
-
- org.glassfish.jersey.media.sse.internal.EventProcessor
-
- All Implemented Interfaces:
Runnable,EventListener
public class EventProcessor extends Object implements Runnable, EventListener
Private event processor task responsible for connecting to the SSE stream and processing incoming SSE events as well as handling any connection issues.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEventProcessor.BuilderEventProcessorbuilder.static interfaceEventProcessor.ShutdownHandlerUsed to signal that theEventProcessorreached terminal stage.static classEventProcessor.StateEvent processor state, which is shared with the owner (to be able to control bootstrap and shutdown).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaitFirstContact()Await the initial contact with the SSE endpoint.static EventProcessor.Builderbuilder(WebTarget target, AtomicReference<EventProcessor.State> state, ClientExecutor clientExecutor, EventListener eventListener, EventProcessor.ShutdownHandler shutdownHandler)Create new Event processor builder.voidonEvent(InboundEvent event)Called by the event source when an inbound event is received.voidrun()
-
-
-
Method Detail
-
builder
public static EventProcessor.Builder builder(WebTarget target, AtomicReference<EventProcessor.State> state, ClientExecutor clientExecutor, EventListener eventListener, EventProcessor.ShutdownHandler shutdownHandler)
Create new Event processor builder.- Parameters:
target- web target to be used to call remote resource.state- state shared with the owner of event processor instance.clientExecutor- executor service used for consuming events and scheduling reconnects.eventListener- event listener.shutdownHandler- shutdown callback.- Returns:
- new
EventProcessor.Builderinstance.
-
onEvent
public void onEvent(InboundEvent event)
Called by the event source when an inbound event is received. This listener aggregator method is responsible for invokingEventSource.onEvent(InboundEvent)method on the owning event source as well as for notifying all registeredevent listeners.- Specified by:
onEventin interfaceEventListener- Parameters:
event- incominginbound event.
-
awaitFirstContact
public void awaitFirstContact()
Await the initial contact with the SSE endpoint.
-
-