11package fr .loicmathieu .bookmarkit ;
22
3+ import io .smallrye .reactive .messaging .annotations .Emitter ;
4+ import io .smallrye .reactive .messaging .annotations .Stream ;
35import org .eclipse .microprofile .config .inject .ConfigProperty ;
46import org .eclipse .microprofile .metrics .annotation .Counted ;
57import org .eclipse .microprofile .metrics .annotation .Timed ;
810import org .slf4j .LoggerFactory ;
911
1012import javax .annotation .PostConstruct ;
13+ import javax .inject .Inject ;
1114import javax .transaction .Transactional ;
1215import javax .ws .rs .Consumes ;
1316import javax .ws .rs .DELETE ;
2528@ Produces (MediaType .APPLICATION_JSON )
2629@ Consumes (MediaType .APPLICATION_JSON )
2730public class BookmarkResource {
31+ @ ConfigProperty (name ="greeting" ) String greeting ;
2832
29- private static final Logger LOGGER = LoggerFactory . getLogger ( BookmarkResource . class ) ;
33+ @ Inject @ Stream ( "bookmarks" ) Emitter < Bookmark > emitter ;
3034
31- @ ConfigProperty (name = "greeting" )
32- private String greeting ;
35+ private static final Logger LOGGER = LoggerFactory .getLogger (BookmarkResource .class );
3336
3437 @ PostConstruct
3538 void init () {
@@ -61,11 +64,12 @@ public Bookmark getBookmark(@PathParam("id") Long id) {
6164 @ Timed (name = "createBookmark.time" )
6265 public Response createBookmark (Bookmark bookmark ) {
6366 bookmark .persist ();
67+ emitter .send (bookmark );
6468 return Response .status (Response .Status .CREATED ).entity (bookmark ).build ();
6569 }
6670
6771 @ PUT
68- @ Path ("/ {id}" )
72+ @ Path ("{id}" )
6973 @ Transactional
7074 @ Operation (summary = "Update a bookmark" )
7175 @ Counted (name = "updateBookmark.count" )
@@ -79,7 +83,7 @@ public void updateBookmark(Bookmark bookmark, @PathParam("id") Long id) {
7983 }
8084
8185 @ DELETE
82- @ Path ("/ {id}" )
86+ @ Path ("{id}" )
8387 @ Transactional
8488 @ Operation (summary = "Delete a bookmark" )
8589 @ Counted (name = "deleteBookmark.count" )
0 commit comments