Class JaxrsItemStoreResource
- java.lang.Object
-
- org.glassfish.jersey.examples.sseitemstore.jaxrs.JaxrsItemStoreResource
-
-
Constructor Summary
Constructors Constructor Description JaxrsItemStoreResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItem(String name)Add new item to the item store.voiditemEvents(int lastEventId, SseEventSink eventSink)TODO - rewrite Connect or re-connect to SSE event stream.StringlistItems()List all stored items.StringprocessCommand(String command)Receive & process commands sent by the test client that control the internal resource state.
-
-
-
Method Detail
-
listItems
@GET @Produces("text/plain") public String listItems()
List all stored items.- Returns:
- list of all stored items.
-
processCommand
@POST @Path("commands") public String processCommand(String command)
Receive & process commands sent by the test client that control the internal resource state.Following is the list of recognized commands:
- disconnect - disconnect all registered event streams.
- reconnect now - enable client reconnecting.
- reconnect <seconds> - disable client reconnecting. Reconnecting clients will receive a HTTP 503 response with "Retry-After" set to the amount of milliseconds specified.
- Parameters:
command- command to be processed.- Returns:
- message about processing result.
- Throws:
BadRequestException- in case the command is not recognized or not specified.
-
itemEvents
@GET @Path("events") @Produces("text/event-stream") public void itemEvents(@HeaderParam("Last-Event-ID") @DefaultValue("-1") int lastEventId, @Context SseEventSink eventSink)
TODO - rewrite Connect or re-connect to SSE event stream.- Parameters:
lastEventId- Value of custom SSE HTTP "Last-Event-ID" header. Defaults to-1if not set.- Throws:
InternalServerErrorException- in case replaying missed events to the reconnected output stream fails.ServiceUnavailableException- in case the reconnect delay is set to a positive value.
-
addItem
@POST public void addItem(@FormParam("name") String name)
Add new item to the item store.Invoking this method will fire 2 new SSE events - 1st about newly added item and 2nd about the new item store size.
- Parameters:
name- item name.
-
-