Directory

VaadinWorker - Vaadin Add-on Directory

Eases the use of background-threads for building slick UIs. VaadinWorker - Vaadin Add-on Directory
VaadinWorker's purpose is it to provide an easy to use interface for both executing tasks in background-threads and displaying their progress towards the user. The addon consists of a class "VaadinWorker", which exposes the two methods "runInBackground()" and "updateUI()". The runInBackground()-method should be used for executing the long-running logic, whose result can be communicated towards the Client using the updateUI()-method. Proper synchronization on the Application-class will be done by the VaadinWorker-template-class. For in-between-updates you can use a ProgressListener. The updateProgress()-method of that interface will also called in a synchronized-block, so that it is safe to do arbitrary UI-updates from that method. To trigger the ProgressListeners you just need to call VaadinWorker#updateProgress(int,String). The int-Parameter communicates the actual progress in form of a procentual progress, while the String is just a description of the work currently done. The second important part of the Addon is the BackgroundExecutor-component, which not only communicates the progress towards the User but also keeps the UI updating itself using the "Spinning-ProgressIndicator-Pattern". VaadinWorkers get submitted for execution in background by calling BackgroundExecutor#submit(VaadinWorker). They are then handed over towards an ExecutorService. This ExecutorService is retrieved by an ExecutorServiceProvider. This way you can decide for example to reuse an ExecutorService your ApplicationServer already provides. For Servlet-environments the addon contains a mechanism to register an ExecutorService with the ServletContext and later on retrieving it from there again. I'm not using Portals at home, so I didn't had the chance to build a neat solution for portlets as well, but maybe I will get to do that in my day-job ... At the moment the Addon is marked as experimental as the documentation is lacking and the code has not been tested in any bigger project so far. Let me know what you think about VaadinWorker!
Online Demo
Issue Tracker
Source Code
Wiki
Discussion
Javadoc

VaadinWorker version 0.0.6
Fixed licensing issues.