Home » Eclipse Projects » Remote Application Platform (RAP) » Again Singletons
Again Singletons [message #59468] |
Mon, 12 November 2007 20:06 |
Eclipse User |
|
|
|
Originally posted by: benny.allgaeu.org
Hi RAP Team,
I know, there are already some threads on singleton and Sessiontopics,
but I really try to understand how this stuff works, and thats not the
case yet;).
I must admin, IŽm yet not very experienced in Java and Eclipse stuff, but
nevertheless IŽm getting better and better:)
I currently trying to migrate an RCP App to an RAP App. I have a
Singleton-Instance in my Application which is used to Locate dynamic
Services.
Now I tried to reimplement the Singleton-Class using the
SessionSingletonBase-Superclass provided by RAP.
Well, as expected, it doesnŽt work everywhere in the Application.
Especially there are problems on using Background-Serverthreads and
accessing the Singleton - Instance.
So nothing new up to now, BUT now I really want to know WHY this is a
problem.
This is what I think how it works:
The Context of a Usersession is bound to the UI - Thread (the thread which
created the UI). If IŽm doing a task in a background-thread on the server,
this context is not accessible, because the thread cannot know which
User-Session he is curently working on. So as long IŽm not currently in a
Backgroundthread, I have access to the current Usersession.
This also refers to Updating the UI such as disabling a button or
something like that.
There is also the possibility to use DIsplay.asyncExec...
which delegates to UICallBack.runWithFakeContext.. (or something like
that, I have no access to an eclipse currently), but where does the
context in this context come from?
I hope this is not too special for this newsgroup.
Thank you very much for your hints, I really appreciate this newsgroup and
watching the whole community around rap growing.
Also I would really like to read some documentation on this, so if there
is some Docu somewhere, please let me know.
See you
Benny
|
|
|
Re: Again Singletons [message #59542 is a reply to message #59468] |
Wed, 14 November 2007 08:32 |
Stefan Messages: 316 Registered: July 2009 |
Senior Member |
|
|
Hi Benny,
you're saying that you are migrating a RCP app to an RAP app. Are your
sure, that your singletons should be singletons on session scope only?
If so, the only possibility I see is to pass this the current display
(Display#getCurrent()) to your background-thread so that he can access
it when necessary. You can then call syncExec(), for instance, to
perform operations in session scope.
As stated in recent postings getting a valid session singleton from a
background thread directly doesn't make sense because theres a 1 to n
relationship between the background and the UI threads.
If not, you maybe need a real application wide singleton which is the
same as in the RCP app (should be made thread safe).
Hope this helps,
Stefan.
Benny schrieb:
> Hi RAP Team,
>
> I know, there are already some threads on singleton and Sessiontopics,
> but I really try to understand how this stuff works, and thats not the
> case yet;).
> I must admin, IŽm yet not very experienced in Java and Eclipse stuff, but
> nevertheless IŽm getting better and better:)
> I currently trying to migrate an RCP App to an RAP App. I have a
> Singleton-Instance in my Application which is used to Locate dynamic
> Services.
> Now I tried to reimplement the Singleton-Class using the
> SessionSingletonBase-Superclass provided by RAP.
> Well, as expected, it doesnŽt work everywhere in the Application.
> Especially there are problems on using Background-Serverthreads and
> accessing the Singleton - Instance.
> So nothing new up to now, BUT now I really want to know WHY this is a
> problem.
>
> This is what I think how it works:
> The Context of a Usersession is bound to the UI - Thread (the thread
> which created the UI). If IŽm doing a task in a background-thread on the
> server,
> this context is not accessible, because the thread cannot know which
> User-Session he is curently working on. So as long IŽm not currently in
> a Backgroundthread, I have access to the current Usersession.
> This also refers to Updating the UI such as disabling a button or
> something like that.
>
> There is also the possibility to use DIsplay.asyncExec...
> which delegates to UICallBack.runWithFakeContext.. (or something like
> that, I have no access to an eclipse currently), but where does the
> context in this context come from?
>
> I hope this is not too special for this newsgroup.
>
> Thank you very much for your hints, I really appreciate this newsgroup
> and watching the whole community around rap growing.
> Also I would really like to read some documentation on this, so if there
> is some Docu somewhere, please let me know.
>
> See you
>
> Benny
>
|
|
|
Goto Forum:
Current Time: Fri Apr 19 19:35:27 GMT 2024
Powered by FUDForum. Page generated in 0.02951 seconds
|