Jump to: navigation, search

E4/RAP Integration/Jobs

< E4‎ | RAP Integration
Revision as of 09:07, 14 August 2008 by Rsternberg.innoopract.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

5) Jobs

To support background jobs that are associated with certain sessions we introduced the JobManagerAdapater and needed to make a lot of changes around Job implementations. As an example I provide some code snippets from the org.eclipse.ui.internal.progress.AnimationManager:

The first snippet shows how we provided session access during scheduling of the job, this is something we have to do a lot.

 // RAP [fappel]: map job to session
 // void setAnimated(final boolean bool) {
 //   animated = bool;
 //   animationUpdateJob.schedule(100);
 // }
 void setAnimated(final boolean bool) {
   animated = bool;
   Runnable scheduler = new Runnable() {
     public void run() {
       animationUpdateJob.schedule(100);
     }
   };
   UICallBack.runNonUIThreadWithFakeContext( display, scheduler );
 }

The second snippet shows some handling in case the job is still running in case of a session timeout. It's quite ugly, but the basic idea is to listen to the session invalidation and cancel the job if it's still running.

 ISessionStore session = RWT.getSessionStore();
 String watchDogKey = getClass().getName() + ".watchDog";
 if( session.getAttribute( watchDogKey ) == null ) {
   session.setAttribute( watchDogKey, new HttpSessionBindingListener() {
     public void valueBound( final HttpSessionBindingEvent event ) {
     }
     public void valueUnbound( final HttpSessionBindingEvent event ) {
       if( animationUpdateJob != null ) {
         animationUpdateJob.cancel();
         [...]
       }
     }
   } );
 }