Code example for AtomicInteger

Methods: incrementAndGet

0
 
   @POST 
   @Consumes("application/xml") 
   public Response createCustomer(Customer customer)
   { 
      customer.setId(idCounter.incrementAndGet());
      customerDB.put(customer.getId(), customer);
      System.out.println("Created customer " + customer.getId());
      return Response.created(URI.create("/customers/" + customer.getId())).build();
 
   } 
 
   @GET 
   @Path("{id}") 
   @Produces("application/xml") 
   @MaxAge(500) 
   public Customer getCustomer(@PathParam("id") int id)
   { 
      Customer customer = customerDB.get(id);
      if (customer == null)
      {