예제 #1
0
 @Path("/book")
 @GET
 public JsonObject getBookByQuery(@QueryParam("id") final Long bookId) {
   final JsonObject book = BookResource.memoryBase.get(bookId);
   BookResource.LOGGER.debug(book);
   return book;
 }
예제 #2
0
 @GET
 public JsonArray getBooks() {
   final JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
   final Set<Map.Entry<Long, JsonObject>> entries = BookResource.memoryBase.entrySet();
   final Iterator<Entry<Long, JsonObject>> iterator = entries.iterator();
   while (iterator.hasNext()) {
     final Entry<Long, JsonObject> cursor = iterator.next();
     Long key = cursor.getKey();
     JsonObject value = cursor.getValue();
     BookResource.LOGGER.debug(key);
     arrayBuilder.add(value);
   }
   JsonArray result = arrayBuilder.build();
   return result;
 }