Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » get IHandlerService from background thread(How to get IHandlerService from background thread in RAP)
get IHandlerService from background thread [message #878481] Tue, 29 May 2012 08:04 Go to next message
Eclipse UserFriend
How can I access Services from background jobs in RAP?

Usually you get IHandlerService throgh workbench instance like this:
public static IHandlerService getHandlerService(){
	IWorkbench workbench = PlatformUI.getWorkbench();
	if(workbench==null)
		return null;
	IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);
	return handlerService;
}


But if you want to get IHandlerService from a background job to fire some events you can't do it because you can't access Display object.
Display.getDefault();

doesn't work in RAP!

Best Regards
Andreas Hollmann


[Updated on: Tue, 29 May 2012 08:05] by Moderator

Re: get IHandlerService from background thread [message #878541 is a reply to message #878481] Tue, 29 May 2012 09:48 Go to previous messageGo to next message
Eclipse UserFriend
Andreas,

unlike in RCP, in RAP there is more than one display. Each session has
its own display (and Workbench).
The UI thread (the one that services the requests) has a context
assigned that associates it with the session/display it belongs to.
Hence, calling Display#getDefault() from this thread will return the
associated display.
Any other thread you'll have to associate to a session yourself. Usually
the display or workbench is passed as a parameter to the thread.
Given hat you have a reference to the display within your background
thread, you can use the method described here [1] to access any other
per-session singleton (i.e. the Workbench).

HTH
Rüdiger

[1]
http://wiki.eclipse.org/RAP/FAQ#How_to_access_the_HTTP_session_.2F_session_store.3F

On 29.05.2012 14:05, Andrej Mising name wrote:
> How can I access Services from background jobs in RAP?
>
> Usually you get IHandlerService throgh workbench instance like this:
>
> public static IHandlerService getHandlerService(){
> IWorkbench workbench = PlatformUI.getWorkbench();
> if(workbench==null)
> return null;
> IHandlerService handlerService = (IHandlerService)
> workbench.getService(IHandlerService.class);
> return handlerService;
> }
>
>
> But if you want to get IHandlerService from a background job to fire
> some events you can't do it because you can't access Display object.
>
> Display.getDefault();
>
> doesn't work in RAP!
>
> Best Regards
> Andreas Hollmann
>
>
>
--
Rüdiger Herrmann
http://codeaffine.com
Re: get IHandlerService from background thread [message #878560 is a reply to message #878541] Tue, 29 May 2012 10:24 Go to previous message
Eclipse UserFriend
Thank you for your reply!

I'll do like your advice.

I think in the future the IWorkbench.getService() method should be moved to Platform-API, thus it becomes independend of Display class. For example some background work started from NON-UI threads can fire events and UI-components can react on fired events and update its content.

Best Regards
Andreas Hollmann
Previous Topic:RAP 1.5m7 + FORMS
Next Topic:HTTP ERROR 500 when a table tooltip raises an exception
Goto Forum:
  


Current Time: Tue Jun 24 01:21:58 EDT 2025

Powered by FUDForum. Page generated in 0.05198 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top