Class SseEventSourceImpl
- All Implemented Interfaces:
SseEventSource,AutoCloseable
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface jakarta.ws.rs.sse.SseEventSource
SseEventSource.Builder -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSseEventSourceImpl(WebTarget target) SseEventSourceImpl(WebTarget target, boolean open) -
Method Summary
Modifier and TypeMethodDescriptionbooleanClose this event source and wait for the internal event processing task to complete for up to the specified amount of wait time.booleanisOpen()Check if this event source instance has already beenopened.voidopen()Open the connection to the supplied SSE underlyingweb targetand start processing incomingevents.voidvoidvoidregister(Consumer<InboundSseEvent> onEvent) Register aInboundSseEventconsumer.voidregister(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError) RegisterInboundSseEventandThrowableconsumers.voidRegisterInboundSseEventandThrowableconsumers and onComplete callback.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.ws.rs.sse.SseEventSource
close
-
Field Details
-
RECONNECT_DEFAULT
public static final long RECONNECT_DEFAULT- See Also:
-
-
Constructor Details
-
SseEventSourceImpl
-
SseEventSourceImpl
-
-
Method Details
-
open
public void open()Description copied from interface:SseEventSourceOpen the connection to the supplied SSE underlyingweb targetand start processing incomingevents.- Specified by:
openin interfaceSseEventSource
-
open
-
open
-
isOpen
public boolean isOpen()Description copied from interface:SseEventSourceCheck if this event source instance has already beenopened.- Specified by:
isOpenin interfaceSseEventSource- Returns:
trueif this event source is open,falseotherwise.
-
register
Description copied from interface:SseEventSourceRegister aInboundSseEventconsumer.Given consumer is invoked once per each received event.
- Specified by:
registerin interfaceSseEventSource- Parameters:
onEvent- event consumer.
-
register
Description copied from interface:SseEventSourceRegisterInboundSseEventandThrowableconsumers.Event consumer is invoked once per each received event,
Throwableconsumer is invoked invoked upon a unrecoverable error encountered by aSseEventSource.- Specified by:
registerin interfaceSseEventSource- Parameters:
onEvent- event consumer.onError- error consumer.
-
register
public void register(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError, Runnable onComplete) Description copied from interface:SseEventSourceRegisterInboundSseEventandThrowableconsumers and onComplete callback.Event consumer is invoked once per each received event,
Throwableconsumer is invoked invoked upon a unrecoverable error encountered by aSseEventSource, onComplete callback is invoked after a successful connection and when there are no further events to be received. Note that the onComplete callback will not be invoked if the onError callback has been invoked.- Specified by:
registerin interfaceSseEventSource- Parameters:
onEvent- event consumer.onError- error consumer.onComplete- onComplete handler.
-
close
Description copied from interface:SseEventSourceClose this event source and wait for the internal event processing task to complete for up to the specified amount of wait time.The method blocks until the event processing task has completed execution after a shutdown request, or until the timeout occurs, or the current thread is interrupted, whichever happens first.
In case the waiting for the event processing task has been interrupted, this method restores the
interruptflag on the thread before returningfalse.- Specified by:
closein interfaceSseEventSource- Parameters:
timeout- the maximum time to wait.unit- the time unit of the timeout argument.- Returns:
trueif this executor terminated andfalseif the timeout elapsed before termination or the termination was interrupted.
-