Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Replacement for PhaseListener in RAP 3.0 - execute code on the UI thread(Find a method to execute code on the UI thread before and after a request.)
Replacement for PhaseListener in RAP 3.0 - execute code on the UI thread [message #1699925] Mon, 29 June 2015 09:56 Go to next message
Ken Wenzel is currently offline Ken WenzelFriend
Messages: 51
Registered: July 2009
Member
Hello,

we've used a PhaseListener to open/close a database connection for each request.
The database connection is tied to the current UI thread.

Do you have any suggestion how to realize this without using a phase listener in RAP 3.0?
I've tried to use a MessageFilter but the handleMessage method is not executed on the UI thread.

Thank you,
Ken
Re: Replacement for PhaseListener in RAP 3.0 - execute code on the UI thread [message #1700644 is a reply to message #1699925] Mon, 06 July 2015 07:59 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Ken,

opening/closing a database connection was indeed the case we imagined
for PhaseListeners. However, we never heard of anyone who actually used
them for this purpose and began to doubt that they were really useful.

Since many requests will never require a database connection, I wonder
if the overhead of opening a database connection for every request can
be avoided. Would it be an option to open connections on demand?

Why do you need a UISession for opening a database connection? If user
authentication is based on the HttpSession, you should also be able to
use a servlet filter.

Regards,
Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Replacement for PhaseListener in RAP 3.0 - execute code on the UI thread [message #1700934 is a reply to message #1700644] Wed, 08 July 2015 09:36 Go to previous messageGo to next message
Ken Wenzel is currently offline Ken WenzelFriend
Messages: 51
Registered: July 2009
Member
Hi Ralf,

thank you for the explanation.

We actually do not open a connection for each request. We just start a "unit of work" for the current thread that is able to track the database connections that are created on demand. This unit of work (and hence the underlying connections) is closed after a request.

Now the problem is that we need to execute the code that starts and stops the unit of work within the UI thread. This is due to the fact that our model objects (that are displayed by JFace viewers for example) are bound to an entity manager that requires an active unit of work for the current thread to open an underlying database connection.

I don't see any other solutions as using a phase listener for the start and stop events of the UI thread or starting/stopping the unit of work for any individual interaction with the model objects. It is practically impossible to implement the latter in a clean way.

Any comments or suggestions are welcome.

Best regards,
Ken
Re: Replacement for PhaseListener in RAP 3.0 - execute code on the UI thread [message #1701131 is a reply to message #1700934] Thu, 09 July 2015 13:27 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

I see.

Would you mind opening a bug to request a PhaseListener replacement?

In the meantime, you should still be able to use the PhaseListener from
the internal package.

Regards,
Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Replacement for PhaseListener in RAP 3.0 - execute code on the UI thread [message #1701251 is a reply to message #1701131] Fri, 10 July 2015 09:07 Go to previous message
Ken Wenzel is currently offline Ken WenzelFriend
Messages: 51
Registered: July 2009
Member
I've created bug 472345:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=472345

Best regards,
Ken
Previous Topic:Migrating QFTest support from RAP 2.0 to 3.0: id attribute?
Next Topic:RWT.BADGE support for CTabItem
Goto Forum:
  


Current Time: Tue Oct 03 17:48:10 GMT 2023

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

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

Back to the top