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.
E4/RAP Integration/Jobs
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();
[...]
}
}
} );
}