|
|||||||||
| 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 Events.
When EventSource is created, it makes GET request to given URI and waits for incoming Events.
Whenever any event is received, onEvent(Event) 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(Target target)
Create new instance and start processing incoming Events in newly created ExecutorService (Executors.newCachedThreadPool(). |
|
EventSource(Target target,
java.util.concurrent.ExecutorService executorService)
Create new instance and start processing incoming Events 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 Event with certain name is received. |
void |
onEvent(Event event)
Called when Event is received. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EventSource(Target target)
Events in newly created ExecutorService (Executors.newCachedThreadPool().
target - JAX-RS Target instance which will be used to obtain Events.
public EventSource(Target target,
java.util.concurrent.ExecutorService executorService)
Events in provided ExecutorService.
target - JAX-RS Target instance which will be used to obtain 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 Event with certain name is received.
eventName - Event name.listener - EventListener to add to current instance.public void onEvent(Event event)
Event is received.
Empty implementations, users can override this method to handle incoming Events. Please note that this
is the ONLY way how to be absolutely sure that you won't miss any incoming Event. Initial request is made
right after EventSource is created and processing starts immediately. EventListeners registered
after Event is received won't be notified.
onEvent in interface EventListenerevent - received event.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||