Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-3966

Improve the concurrency management

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 2.0.0.RC2
    • Fix Version/s: 2.0.0.RC3
    • Component/s: WEB MVC
    • Labels:
      None

      Description

      Checking the current generation of the concurrency management in the update method of the *ItemThymeleafController we have noticed that we could improve it. Also, after apply the solution for the https://jira.spring.io/browse/ROO-3950 ticket.

      Create utility classes to manage Concurrency easily replacing:

      // Concurrency control
              Pet existingPet = getPetService().findOne(pet.getId());
              if (!Objects.equals(pet.getVersion(), existingPet.getVersion())) {
                  if (StringUtils.isEmpty(concurrencyControl)){
                      populateForm(model);
                      model.addAttribute("pet", pet);
                      model.addAttribute("concurrency", true);
                      return new ModelAndView("pets/edit");
                  } else if("discard".equals(concurrencyControl)){
                      populateForm(model);
                      model.addAttribute("pet", existingPet);
                      model.addAttribute("concurrency", false);
                      return new ModelAndView("pets/edit");
                  } else if("apply".equals(concurrencyControl)){
                      // Update the version field to be able to override the existing values
                      pet.setVersion(existingPet.getVersion());
                  } else {
                      // Invalid concurrencyControlValue
                      throw new IllegalArgumentException("Invalid concurrencyControlValue");
                  }
              }
      

      with the following structure:

           Pet savedPet = concurrencyTemplate.execute(pet, model, new ConcurrencyCallback<Pet>() {
              @Override
              public Pet doInConcurrency(Pet pet) throws Exception {
                return getPetService().save(pet);
              }
            });
      

        Attachments

          Activity

            People

            • Assignee:
              jcgarcia Juan Carlos García del Canto
              Reporter:
              jcgarcia Juan Carlos García del Canto
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: