Class EventProcessor
java.lang.Object
org.glassfish.jersey.media.sse.internal.EventProcessor
- All Implemented Interfaces:
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 ClassesModifier and TypeClassDescriptionstatic classEventProcessorbuilder.static interfaceUsed to signal that theEventProcessorreached terminal stage.static enumEvent processor state, which is shared with the owner (to be able to control bootstrap and shutdown). -
Method Summary
Modifier and TypeMethodDescriptionvoidAwait 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 Details
-
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.
-
run
public void run() -
onEvent
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.
-