Uploaded image for project: 'Isis'
  1. Isis
  2. ISIS-1960

Action background execution: provide built-in default implementation

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0-M3
    • Component/s: Isis Core
    • Labels:
      None

      Description

      We want this code to run out-of the box (without the need for developers to provide their own implementation of BackgroundCommandService) ...

      @Inject BackgroundService backgroundService;
      @Inject RepositoryService repositoryService;
      @Inject MessageService messageService;
      
      @Action
      public SimpleObject runInBackground(){
          backgroundService.execute(this).backgroundTask();
          return this;
      }
          
      @Programmatic
      public void backgroundTask(){
          messageService.informUser("backgroundTask started");	
      
          try {
              Thread.sleep(8000); // wait 8s
          } catch (InterruptedException e) {
              e.printStackTrace();
          }	
      	
          val dummy = new SimpleObject();
          dummy.setName("Dummy");
      	
          repositoryService.persist(dummy);
      	
          messageService.informUser("backgroundTask finished");	
      }
      

      We solve this using a default ExecutorService to run Action invocations in the background.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hobrom Andi Huber
                Reporter:
                hobrom Andi Huber
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: