Class SseEventSourceImpl
- java.lang.Object
-
- org.jboss.resteasy.plugins.providers.sse.client.SseEventSourceImpl
-
- All Implemented Interfaces:
SseEventSource,AutoCloseable
public class SseEventSourceImpl extends Object implements SseEventSource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSseEventSourceImpl.SourceBuilder-
Nested classes/interfaces inherited from interface jakarta.ws.rs.sse.SseEventSource
SseEventSource.Builder
-
-
Field Summary
Fields Modifier and Type Field Description static longRECONNECT_DEFAULT
-
Constructor Summary
Constructors Constructor Description SseEventSourceImpl(WebTarget target)SseEventSourceImpl(WebTarget target, boolean open)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanclose(long timeout, TimeUnit unit)Close 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.voidopen(String lastEventId)voidopen(String lastEventId, String verb, Entity<?> entity, MediaType... mediaTypes)voidregister(Consumer<InboundSseEvent> onEvent)Register aInboundSseEventconsumer.voidregister(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError)RegisterInboundSseEventandThrowableconsumers.voidregister(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError, Runnable onComplete)RegisterInboundSseEventandThrowableconsumers and onComplete callback.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.ws.rs.sse.SseEventSource
close
-
-
-
-
Field Detail
-
RECONNECT_DEFAULT
public static final long RECONNECT_DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public void open(String lastEventId)
-
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
public void register(Consumer<InboundSseEvent> onEvent)
Description copied from interface:SseEventSourceRegister aInboundSseEventconsumer.Given consumer is invoked once per each received event.
- Specified by:
registerin interfaceSseEventSource- Parameters:
onEvent- event consumer.
-
register
public void register(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError)
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
public boolean close(long timeout, TimeUnit unit)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.
-
-