Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "E4/RAP Integration/Jobs"
< E4 | RAP Integration
(New page: 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 exa...) |
m |
||
Line 36: | Line 36: | ||
} ); | } ); | ||
} | } | ||
+ | |||
+ | [[Category:E4]] |
Revision as of 17:11, 29 July 2008
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(); [...] } } } ); }