|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.glassfish.jersey.media.sse.EventSource
public class EventSource
Client for reading and processing Server Sent inbound events.
When EventSource is created, it makes GET request to given URI and waits for incoming inbound events.
Whenever any event is received, onEvent(InboundEvent) is called and listeners (if any) are notified
(see addEventListener(String, EventListener) and
addEventListener(String, EventListener).
Instances of this class are thread safe.
| Constructor Summary | |
|---|---|
EventSource(WebTarget target)
Create new instance and start processing incoming InboundEvents in newly created
single thread executor. |
|
EventSource(WebTarget target,
java.util.concurrent.ExecutorService executorService)
Create new instance and start processing incoming InboundEvents in provided ExecutorService. |
|
| Method Summary | |
|---|---|
void |
addEventListener(EventListener listener)
Add EventListener. |
void |
addEventListener(java.lang.String eventName,
EventListener listener)
Add EventListener which will be called only when InboundEvent with certain name is received. |
void |
close()
Close this event source. |
void |
onEvent(InboundEvent inboundEvent)
Called when InboundEvent is received. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EventSource(WebTarget target)
InboundEvents in newly created
single thread executor.
target - JAX-RS WebTarget instance which will be used to obtain inbound events.
public EventSource(WebTarget target,
java.util.concurrent.ExecutorService executorService)
InboundEvents in provided ExecutorService.
target - JAX-RS WebTarget instance which will be used to obtain inbound events.executorService - used for processing events.| Method Detail |
|---|
public void addEventListener(EventListener listener)
EventListener.
listener - EventListener to add to current instance.
public void addEventListener(java.lang.String eventName,
EventListener listener)
EventListener which will be called only when InboundEvent with certain name is received.
eventName - inbound event name.listener - event listener to register with this event source.public void onEvent(InboundEvent inboundEvent)
InboundEvent is received.
Empty implementations, users can override this method to handle incoming InboundEvents. Please note that this
is the ONLY way how to be absolutely sure that you won't miss any incoming InboundEvent. Initial request is made
right after EventSource is created and processing starts immediately. EventListeners registered
after InboundEvent is received won't be notified.
onEvent in interface EventListenerinboundEvent - received inboundEvent.public void close()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||