Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » how to gracefully shut down a RAP application?
how to gracefully shut down a RAP application? [message #140868] Tue, 21 July 2009 09:57 Go to next message
Eclipse UserFriend
Is there a preferred way to shut down a RAP application?
Thanks!
David Donohue
Re: how to gracefully shut down a RAP application? [message #140879 is a reply to message #140868] Tue, 21 July 2009 10:28 Go to previous messageGo to next message
Eclipse UserFriend
Great question!

I was about to ask that myself at the moment... I would like to add one.

Where would the right place for some cleanup code (like DB connection
reset, etc) be?

David Donohue schrieb:
> Is there a preferred way to shut down a RAP application?
> Thanks!
> David Donohue
>
Re: how to gracefully shut down a RAP application? [message #140889 is a reply to message #140879] Tue, 21 July 2009 10:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benjamin.wolff.web.de

Hi,

do you refer to a shutdown of the whole application (shutdown the plug-ins/bundles)
or do you refer to the shutdown of a single user session?

in case of application shutdown you should take a look at Activator#start() and #stop() methods
of the plug-in(s).
but it is important to keep the execution time of these methods short, long tasks could be
delegated to background thread...

i'd also like to hear other ideas about tidy up spots!


HTH,
-ben



Thomas Haskes schrieb:
> Great question!
>
> I was about to ask that myself at the moment... I would like to add one.
>
> Where would the right place for some cleanup code (like DB connection
> reset, etc) be?
>
> David Donohue schrieb:
>> Is there a preferred way to shut down a RAP application?
>> Thanks!
>> David Donohue
>>
Re: how to gracefully shut down a RAP application? [message #140953 is a reply to message #140889] Tue, 21 July 2009 16:34 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Ben and Thomas,
I am asking about how to shut down the RAP server. I would like to have a
script like shutdown.sh or shutdown.bat. What would go inside such a
script? Presumably we could call out own static method to perform
database cleanup, etc? Any best practices?
Thanks again.
David
Re: how to gracefully shut down a RAP application? [message #140975 is a reply to message #140889] Wed, 22 July 2009 02:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ben,

In my case I spoke of the shut down of a single user session. As every
user in my application uses a database connection, i would like to know
where I can out the cleanup code when the user suddenly closes the
browser or hits F5 etc.

Benjamin Wolff schrieb:
> Hi,
>
> do you refer to a shutdown of the whole application (shutdown the
> plug-ins/bundles)
> or do you refer to the shutdown of a single user session?
>
> in case of application shutdown you should take a look at
> Activator#start() and #stop() methods
> of the plug-in(s).
> but it is important to keep the execution time of these methods short,
> long tasks could be
> delegated to background thread...
>
> i'd also like to hear other ideas about tidy up spots!
>
>
> HTH,
> -ben
>
>
>
> Thomas Haskes schrieb:
>> Great question!
>>
>> I was about to ask that myself at the moment... I would like to add one.
>>
>> Where would the right place for some cleanup code (like DB connection
>> reset, etc) be?
>>
>> David Donohue schrieb:
>>> Is there a preferred way to shut down a RAP application?
>>> Thanks!
>>> David Donohue
>>>
Re: how to gracefully shut down a RAP application? [message #140986 is a reply to message #140975] Wed, 22 July 2009 04:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi Thomas,

you could use a SessionStoreListener for clean-up action after the
webapp container signals that the session is destroyed.

Regards,
Stefan.

Thomas Haskes schrieb:
> Hi Ben,
>
> In my case I spoke of the shut down of a single user session. As every
> user in my application uses a database connection, i would like to know
> where I can out the cleanup code when the user suddenly closes the
> browser or hits F5 etc.
>
> Benjamin Wolff schrieb:
>> Hi,
>>
>> do you refer to a shutdown of the whole application (shutdown the
>> plug-ins/bundles)
>> or do you refer to the shutdown of a single user session?
>>
>> in case of application shutdown you should take a look at
>> Activator#start() and #stop() methods
>> of the plug-in(s).
>> but it is important to keep the execution time of these methods short,
>> long tasks could be
>> delegated to background thread...
>>
>> i'd also like to hear other ideas about tidy up spots!
>>
>>
>> HTH,
>> -ben
>>
>>
>>
>> Thomas Haskes schrieb:
>>> Great question!
>>>
>>> I was about to ask that myself at the moment... I would like to add one.
>>>
>>> Where would the right place for some cleanup code (like DB connection
>>> reset, etc) be?
>>>
>>> David Donohue schrieb:
>>>> Is there a preferred way to shut down a RAP application?
>>>> Thanks!
>>>> David Donohue
>>>>
Re: how to gracefully shut down a RAP application? [message #141019 is a reply to message #140986] Wed, 22 July 2009 05:49 Go to previous messageGo to next message
Eclipse UserFriend
Stefan is right, you should use a SessionStoreListener. In a perfect
world you could use the Display#disposeExec / Display DisposeListener.
But this is not yet supported :(
See:
253763: DisposeEvent not fired on session timeout
https://bugs.eclipse.org/bugs/show_bug.cgi?id=253763

228351: Display#disposeExec() missing
https://bugs.eclipse.org/bugs/show_bug.cgi?id=228351

Greets
Ben

Stefan Roeck wrote:
> Hi Thomas,
>
> you could use a SessionStoreListener for clean-up action after the
> webapp container signals that the session is destroyed.
>
> Regards,
> Stefan.
>
> Thomas Haskes schrieb:
>> Hi Ben,
>>
>> In my case I spoke of the shut down of a single user session. As every
>> user in my application uses a database connection, i would like to know
>> where I can out the cleanup code when the user suddenly closes the
>> browser or hits F5 etc.
>>
>> Benjamin Wolff schrieb:
>>> Hi,
>>>
>>> do you refer to a shutdown of the whole application (shutdown the
>>> plug-ins/bundles)
>>> or do you refer to the shutdown of a single user session?
>>>
>>> in case of application shutdown you should take a look at
>>> Activator#start() and #stop() methods
>>> of the plug-in(s).
>>> but it is important to keep the execution time of these methods short,
>>> long tasks could be
>>> delegated to background thread...
>>>
>>> i'd also like to hear other ideas about tidy up spots!
>>>
>>>
>>> HTH,
>>> -ben
>>>
>>>
>>>
>>> Thomas Haskes schrieb:
>>>> Great question!
>>>>
>>>> I was about to ask that myself at the moment... I would like to add
>>>> one.
>>>>
>>>> Where would the right place for some cleanup code (like DB connection
>>>> reset, etc) be?
>>>>
>>>> David Donohue schrieb:
>>>>> Is there a preferred way to shut down a RAP application?
>>>>> Thanks!
>>>>> David Donohue
>>>>>


--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141041 is a reply to message #140986] Wed, 22 July 2009 07:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
I tried implementing the SessionStoreListener like the following when o user
open a "connection" that need to be stopped on cleanup:

//register listener to clean up
RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener() {
public void beforeDestroy(SessionStoreEvent event) {
try {
System.out.println("MyConnection.beforeDestroy() was called");
stop();
}
catch (Throwable exception) {
//error handling
}
RWT.getSessionStore().removeSessionStoreListener(this);
}
});

Now, as the user closes the tab, for example, then the beforeDestroy method
is not called. It gets only called, if I open the application in my browser
again!
This is not good, as the user might not do it.

Also, I get the following error that should be known by you:
java.lang.IllegalStateException: The session store is about to be unbound.

Hope some can help...

Regards,
Markus

"Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
news:h46j7i$mac$1@build.eclipse.org...
> Hi Thomas,
>
> you could use a SessionStoreListener for clean-up action after the webapp
> container signals that the session is destroyed.
>
> Regards,
> Stefan.
>
> Thomas Haskes schrieb:
>> Hi Ben,
>>
>> In my case I spoke of the shut down of a single user session. As every
>> user in my application uses a database connection, i would like to know
>> where I can out the cleanup code when the user suddenly closes the
>> browser or hits F5 etc.
>>
>> Benjamin Wolff schrieb:
>>> Hi,
>>>
>>> do you refer to a shutdown of the whole application (shutdown the
>>> plug-ins/bundles)
>>> or do you refer to the shutdown of a single user session?
>>>
>>> in case of application shutdown you should take a look at
>>> Activator#start() and #stop() methods
>>> of the plug-in(s).
>>> but it is important to keep the execution time of these methods short,
>>> long tasks could be
>>> delegated to background thread...
>>>
>>> i'd also like to hear other ideas about tidy up spots!
>>>
>>>
>>> HTH,
>>> -ben
>>>
>>>
>>>
>>> Thomas Haskes schrieb:
>>>> Great question!
>>>>
>>>> I was about to ask that myself at the moment... I would like to add
>>>> one.
>>>>
>>>> Where would the right place for some cleanup code (like DB connection
>>>> reset, etc) be?
>>>>
>>>> David Donohue schrieb:
>>>>> Is there a preferred way to shut down a RAP application?
>>>>> Thanks!
>>>>> David Donohue
>>>>>
Re: how to gracefully shut down a RAP application? [message #141052 is a reply to message #141041] Wed, 22 July 2009 07:28 Go to previous messageGo to next message
Eclipse UserFriend
Hi Markus,

the session is only destroyed when it gets the timeout. Just closing the
browser does not invalidate the session as this is not supported by all
browsers. Just use a small session timeout value to test this.

See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)

And do not catch Throwables without rethrowing a ThreadDeathError as RAP
relies on this to kill the UI thread. But this just as a side note.

Regarding why the session is destroyed when the user access the
application the second time: a user accessing the same application with
the same browser the servlet spec says that he can get the same session
(from an application server POV). In RAP we clear the session at this
point (and thus invalidating the old one) so you (as RAP app developer)
don't need to care about this.

Hope that helps to clarify things a bit.

Greets
Ben

wrote:
> Hi,
> I tried implementing the SessionStoreListener like the following when o user
> open a "connection" that need to be stopped on cleanup:
>
> //register listener to clean up
> RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener() {
> public void beforeDestroy(SessionStoreEvent event) {
> try {
> System.out.println("MyConnection.beforeDestroy() was called");
> stop();
> }
> catch (Throwable exception) {
> //error handling
> }
> RWT.getSessionStore().removeSessionStoreListener(this);
> }
> });
>
> Now, as the user closes the tab, for example, then the beforeDestroy method
> is not called. It gets only called, if I open the application in my browser
> again!
> This is not good, as the user might not do it.
>
> Also, I get the following error that should be known by you:
> java.lang.IllegalStateException: The session store is about to be unbound.
>
> Hope some can help...
>
> Regards,
> Markus
>
> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
> news:h46j7i$mac$1@build.eclipse.org...
>> Hi Thomas,
>>
>> you could use a SessionStoreListener for clean-up action after the webapp
>> container signals that the session is destroyed.
>>
>> Regards,
>> Stefan.
>>
>> Thomas Haskes schrieb:
>>> Hi Ben,
>>>
>>> In my case I spoke of the shut down of a single user session. As every
>>> user in my application uses a database connection, i would like to know
>>> where I can out the cleanup code when the user suddenly closes the
>>> browser or hits F5 etc.
>>>
>>> Benjamin Wolff schrieb:
>>>> Hi,
>>>>
>>>> do you refer to a shutdown of the whole application (shutdown the
>>>> plug-ins/bundles)
>>>> or do you refer to the shutdown of a single user session?
>>>>
>>>> in case of application shutdown you should take a look at
>>>> Activator#start() and #stop() methods
>>>> of the plug-in(s).
>>>> but it is important to keep the execution time of these methods short,
>>>> long tasks could be
>>>> delegated to background thread...
>>>>
>>>> i'd also like to hear other ideas about tidy up spots!
>>>>
>>>>
>>>> HTH,
>>>> -ben
>>>>
>>>>
>>>>
>>>> Thomas Haskes schrieb:
>>>>> Great question!
>>>>>
>>>>> I was about to ask that myself at the moment... I would like to add
>>>>> one.
>>>>>
>>>>> Where would the right place for some cleanup code (like DB connection
>>>>> reset, etc) be?
>>>>>
>>>>> David Donohue schrieb:
>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>> Thanks!
>>>>>> David Donohue
>>>>>>
>
>


--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141063 is a reply to message #141052] Wed, 22 July 2009 07:43 Go to previous messageGo to next message
Eclipse UserFriend
after setting setMaxInactiveInterval to 60 seconds it calls the method
corretly after one minute.
Isn't there a way to directly call some cleanup code when the user i.e.
closes the browser tab?
We actually wanted the user to be able to be inactive for some hours, but
this time would now also
be used for "dead" session...

Any ideas?

Regards,
Markus



"Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
news:h46t56$9hi$1@build.eclipse.org...
> Hi Markus,
>
> the session is only destroyed when it gets the timeout. Just closing the
> browser does not invalidate the session as this is not supported by all
> browsers. Just use a small session timeout value to test this.
>
> See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)
>
> And do not catch Throwables without rethrowing a ThreadDeathError as RAP
> relies on this to kill the UI thread. But this just as a side note.
>
> Regarding why the session is destroyed when the user access the
> application the second time: a user accessing the same application with
> the same browser the servlet spec says that he can get the same session
> (from an application server POV). In RAP we clear the session at this
> point (and thus invalidating the old one) so you (as RAP app developer)
> don't need to care about this.
>
> Hope that helps to clarify things a bit.
>
> Greets
> Ben
>
> wrote:
>> Hi,
>> I tried implementing the SessionStoreListener like the following when o
>> user open a "connection" that need to be stopped on cleanup:
>>
>> //register listener to clean up
>> RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener()
>> {
>> public void beforeDestroy(SessionStoreEvent event) {
>> try {
>> System.out.println("MyConnection.beforeDestroy() was called");
>> stop();
>> }
>> catch (Throwable exception) {
>> //error handling
>> }
>> RWT.getSessionStore().removeSessionStoreListener(this);
>> }
>> });
>>
>> Now, as the user closes the tab, for example, then the beforeDestroy
>> method is not called. It gets only called, if I open the application in
>> my browser again!
>> This is not good, as the user might not do it.
>>
>> Also, I get the following error that should be known by you:
>> java.lang.IllegalStateException: The session store is about to be
>> unbound.
>>
>> Hope some can help...
>>
>> Regards,
>> Markus
>>
>> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
>> news:h46j7i$mac$1@build.eclipse.org...
>>> Hi Thomas,
>>>
>>> you could use a SessionStoreListener for clean-up action after the
>>> webapp container signals that the session is destroyed.
>>>
>>> Regards,
>>> Stefan.
>>>
>>> Thomas Haskes schrieb:
>>>> Hi Ben,
>>>>
>>>> In my case I spoke of the shut down of a single user session. As every
>>>> user in my application uses a database connection, i would like to know
>>>> where I can out the cleanup code when the user suddenly closes the
>>>> browser or hits F5 etc.
>>>>
>>>> Benjamin Wolff schrieb:
>>>>> Hi,
>>>>>
>>>>> do you refer to a shutdown of the whole application (shutdown the
>>>>> plug-ins/bundles)
>>>>> or do you refer to the shutdown of a single user session?
>>>>>
>>>>> in case of application shutdown you should take a look at
>>>>> Activator#start() and #stop() methods
>>>>> of the plug-in(s).
>>>>> but it is important to keep the execution time of these methods short,
>>>>> long tasks could be
>>>>> delegated to background thread...
>>>>>
>>>>> i'd also like to hear other ideas about tidy up spots!
>>>>>
>>>>>
>>>>> HTH,
>>>>> -ben
>>>>>
>>>>>
>>>>>
>>>>> Thomas Haskes schrieb:
>>>>>> Great question!
>>>>>>
>>>>>> I was about to ask that myself at the moment... I would like to add
>>>>>> one.
>>>>>>
>>>>>> Where would the right place for some cleanup code (like DB connection
>>>>>> reset, etc) be?
>>>>>>
>>>>>> David Donohue schrieb:
>>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>>> Thanks!
>>>>>>> David Donohue
>>>>>>>
>>
>>
>
>
> --
> Benjamin Muskalla | EclipseSource Karlsruhe
> http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141074 is a reply to message #141052] Wed, 22 July 2009 07:48 Go to previous messageGo to next message
Eclipse UserFriend
Forgot to tell that I still keep getting this warning and exception:
2009-07-22 13:40:50.03:/:WARN: Could not execute
ag.ion.axion.nfm.rap.ui.NFMIonicConnection$1.beforeDestroy(S essionStoreEvent).
java.lang.IllegalStateException: The session store is about to be unbound.



"Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
news:h46t56$9hi$1@build.eclipse.org...
> Hi Markus,
>
> the session is only destroyed when it gets the timeout. Just closing the
> browser does not invalidate the session as this is not supported by all
> browsers. Just use a small session timeout value to test this.
>
> See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)
>
> And do not catch Throwables without rethrowing a ThreadDeathError as RAP
> relies on this to kill the UI thread. But this just as a side note.
>
> Regarding why the session is destroyed when the user access the
> application the second time: a user accessing the same application with
> the same browser the servlet spec says that he can get the same session
> (from an application server POV). In RAP we clear the session at this
> point (and thus invalidating the old one) so you (as RAP app developer)
> don't need to care about this.
>
> Hope that helps to clarify things a bit.
>
> Greets
> Ben
>
> wrote:
>> Hi,
>> I tried implementing the SessionStoreListener like the following when o
>> user open a "connection" that need to be stopped on cleanup:
>>
>> //register listener to clean up
>> RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener()
>> {
>> public void beforeDestroy(SessionStoreEvent event) {
>> try {
>> System.out.println("MyConnection.beforeDestroy() was called");
>> stop();
>> }
>> catch (Throwable exception) {
>> //error handling
>> }
>> RWT.getSessionStore().removeSessionStoreListener(this);
>> }
>> });
>>
>> Now, as the user closes the tab, for example, then the beforeDestroy
>> method is not called. It gets only called, if I open the application in
>> my browser again!
>> This is not good, as the user might not do it.
>>
>> Also, I get the following error that should be known by you:
>> java.lang.IllegalStateException: The session store is about to be
>> unbound.
>>
>> Hope some can help...
>>
>> Regards,
>> Markus
>>
>> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
>> news:h46j7i$mac$1@build.eclipse.org...
>>> Hi Thomas,
>>>
>>> you could use a SessionStoreListener for clean-up action after the
>>> webapp container signals that the session is destroyed.
>>>
>>> Regards,
>>> Stefan.
>>>
>>> Thomas Haskes schrieb:
>>>> Hi Ben,
>>>>
>>>> In my case I spoke of the shut down of a single user session. As every
>>>> user in my application uses a database connection, i would like to know
>>>> where I can out the cleanup code when the user suddenly closes the
>>>> browser or hits F5 etc.
>>>>
>>>> Benjamin Wolff schrieb:
>>>>> Hi,
>>>>>
>>>>> do you refer to a shutdown of the whole application (shutdown the
>>>>> plug-ins/bundles)
>>>>> or do you refer to the shutdown of a single user session?
>>>>>
>>>>> in case of application shutdown you should take a look at
>>>>> Activator#start() and #stop() methods
>>>>> of the plug-in(s).
>>>>> but it is important to keep the execution time of these methods short,
>>>>> long tasks could be
>>>>> delegated to background thread...
>>>>>
>>>>> i'd also like to hear other ideas about tidy up spots!
>>>>>
>>>>>
>>>>> HTH,
>>>>> -ben
>>>>>
>>>>>
>>>>>
>>>>> Thomas Haskes schrieb:
>>>>>> Great question!
>>>>>>
>>>>>> I was about to ask that myself at the moment... I would like to add
>>>>>> one.
>>>>>>
>>>>>> Where would the right place for some cleanup code (like DB connection
>>>>>> reset, etc) be?
>>>>>>
>>>>>> David Donohue schrieb:
>>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>>> Thanks!
>>>>>>> David Donohue
>>>>>>>
>>
>>
>
>
> --
> Benjamin Muskalla | EclipseSource Karlsruhe
> http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141085 is a reply to message #141041] Wed, 22 July 2009 07:53 Go to previous messageGo to next message
Eclipse UserFriend
I know about both problems (java.lang.IllegalStateException and lack of
session invalidation in the case where browser or tab closes).

I can provide a patch to RAP, that can fix these problems. I will be very
glad to help you and if you will have some problems I will try to help
you. But I do not think that RAP team will apply this patch in CVS.

You will have to rebuild RAP platfrom with my patch.

Some things about solution:
- There is no session invalidation on reopening tab event
- There is used a single virtual session per opened RAP instance (in tab
or frame, so there is a multiframe/multitab support in my patch)
- There is a special code (UIThreadTerminator thread) that checks if last
access from client was a long time ago, tries to stop user session (after
some time) and tries to terminate thread if it is impossible (to
invalidate normally, it is very helpfull in the case of some special kind
of deadlocks in RAP).
- There is a ping-strategy based on UICallBack mechanism that used to
check if the user still online.

There are also a lot of micro-patches to make RAP better (about all of
them I reported to developers and attached relative patches), but I cannot
provide such support as RAP team can (so you will have to watch on the
changes from RAP team).

For the RAP team: I really want to see as much of my changes in the main
CVS of the RAP project as it possible, so I will be glad to get some
review from RAP team.

Do you want to get it?
Re: how to gracefully shut down a RAP application? [message #141096 is a reply to message #141085] Wed, 22 July 2009 07:59 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the info Igor, but we do not want to change anything in RAP code.
Although your solutions/patches sound very good!

Could someone of the RAP team give a statement on if and when these patches
could be applied to CVS?

Regards,
Markus

"Igor Pavlenko" <dopperst@inbox.ru> schrieb im Newsbeitrag
news:4efce398aa2a6ea5d27f923e4315ccc4$1@www.eclipse.org...
>I know about both problems (java.lang.IllegalStateException and lack of
>session invalidation in the case where browser or tab closes).
>
> I can provide a patch to RAP, that can fix these problems. I will be very
> glad to help you and if you will have some problems I will try to help
> you. But I do not think that RAP team will apply this patch in CVS.
>
> You will have to rebuild RAP platfrom with my patch.
>
> Some things about solution:
> - There is no session invalidation on reopening tab event
> - There is used a single virtual session per opened RAP instance (in tab
> or frame, so there is a multiframe/multitab support in my patch)
> - There is a special code (UIThreadTerminator thread) that checks if last
> access from client was a long time ago, tries to stop user session (after
> some time) and tries to terminate thread if it is impossible (to
> invalidate normally, it is very helpfull in the case of some special kind
> of deadlocks in RAP).
> - There is a ping-strategy based on UICallBack mechanism that used to
> check if the user still online.
>
> There are also a lot of micro-patches to make RAP better (about all of
> them I reported to developers and attached relative patches), but I cannot
> provide such support as RAP team can (so you will have to watch on the
> changes from RAP team).
>
> For the RAP team: I really want to see as much of my changes in the main
> CVS of the RAP project as it possible, so I will be glad to get some
> review from RAP team.
>
> Do you want to get it?
>
Re: how to gracefully shut down a RAP application? [message #141107 is a reply to message #141052] Wed, 22 July 2009 08:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benjamin.wolff.web.de

Hi,

i also have a long story about session invalidation and database connection cleanup etc.

first, as benjamin stated, there is no reliable mechanism that notices when the browser is closed
or another url is entered. you can observe this by overriding the WorkbenchWindowAdvisor#postWindowClose().
just put an sysout in it and observe the output using FF and IE and closing the tab/browser etc.
FF seems to be more reliable, you could put a small session timeout in this method like:

RWT.getRequest().getSession().setMaxInactiveInterval(10);

thus the user session is invalidated in 10 seconds after postWindowClose() has been called.
don't choose a too little value for the timeout, i observed in the past that it may occur that a new session
is created when the timeout is too little (1 second) and this session is then reliant on the timeout.

you should further keep in mind, that the servlet container is reponsible for the lifetime of the session,
since a RAP user session is basically a wrapped HTTP session. In the IDE the container is the embedded
jetty, in productive environment this may be a tomcat e.g. and so these containers also control the timeout
and destroying of these session.

so we're back at the beginning, the problem is that there isn't a reliable mechanism to trigger when the browser
is closed.

but i always wondered, in the branding there is an option to provide an exit confirmation message that is always
called when the browser closes etc. this is achieved by a simple javascript method (confirmOnClose() or something
like that). this method seems to be always called. wouldn't it be possible to use a similar mechanism to trigger
a signal to the server on browser close?! just a question, i'm not into javascript, unfortunately.

nevertheless, these are all things that i experienced and learned during my RAP projects, if i stated something
wrong please feel free to enlighten me!!! :))

HTH,
-ben


P.S: as a side note, in the past i also used the 'database connection per user session' approach and therefore was
reliant on a clean shutdown handling and ressource clean up. now i'm using hibernate and spring in conjunction in
an JavaSE (tomcat) environment and this way the database connection are obtained when they are need and released
subsequently. this way i'm not reliant on a special resource clean up mechanism, the session timeout is fine.
but that is a completely other story and can be very complex as well :P.





Benjamin Muskalla schrieb:
> Hi Markus,
>
> the session is only destroyed when it gets the timeout. Just closing the
> browser does not invalidate the session as this is not supported by all
> browsers. Just use a small session timeout value to test this.
>
> See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)
>
> And do not catch Throwables without rethrowing a ThreadDeathError as RAP
> relies on this to kill the UI thread. But this just as a side note.
>
> Regarding why the session is destroyed when the user access the
> application the second time: a user accessing the same application with
> the same browser the servlet spec says that he can get the same session
> (from an application server POV). In RAP we clear the session at this
> point (and thus invalidating the old one) so you (as RAP app developer)
> don't need to care about this.
>
> Hope that helps to clarify things a bit.
>
> Greets
> Ben
>
> wrote:
>> Hi,
>> I tried implementing the SessionStoreListener like the following when
>> o user open a "connection" that need to be stopped on cleanup:
>>
>> //register listener to clean up
>> RWT.getSessionStore().addSessionStoreListener(new
>> SessionStoreListener() {
>> public void beforeDestroy(SessionStoreEvent event) {
>> try {
>> System.out.println("MyConnection.beforeDestroy() was called");
>> stop();
>> }
>> catch (Throwable exception) {
>> //error handling
>> }
>> RWT.getSessionStore().removeSessionStoreListener(this);
>> }
>> });
>>
>> Now, as the user closes the tab, for example, then the beforeDestroy
>> method is not called. It gets only called, if I open the application
>> in my browser again!
>> This is not good, as the user might not do it.
>>
>> Also, I get the following error that should be known by you:
>> java.lang.IllegalStateException: The session store is about to be
>> unbound.
>>
>> Hope some can help...
>>
>> Regards,
>> Markus
>>
>> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
>> news:h46j7i$mac$1@build.eclipse.org...
>>> Hi Thomas,
>>>
>>> you could use a SessionStoreListener for clean-up action after the
>>> webapp container signals that the session is destroyed.
>>>
>>> Regards,
>>> Stefan.
>>>
>>> Thomas Haskes schrieb:
>>>> Hi Ben,
>>>>
>>>> In my case I spoke of the shut down of a single user session. As every
>>>> user in my application uses a database connection, i would like to know
>>>> where I can out the cleanup code when the user suddenly closes the
>>>> browser or hits F5 etc.
>>>>
>>>> Benjamin Wolff schrieb:
>>>>> Hi,
>>>>>
>>>>> do you refer to a shutdown of the whole application (shutdown the
>>>>> plug-ins/bundles)
>>>>> or do you refer to the shutdown of a single user session?
>>>>>
>>>>> in case of application shutdown you should take a look at
>>>>> Activator#start() and #stop() methods
>>>>> of the plug-in(s).
>>>>> but it is important to keep the execution time of these methods short,
>>>>> long tasks could be
>>>>> delegated to background thread...
>>>>>
>>>>> i'd also like to hear other ideas about tidy up spots!
>>>>>
>>>>>
>>>>> HTH,
>>>>> -ben
>>>>>
>>>>>
>>>>>
>>>>> Thomas Haskes schrieb:
>>>>>> Great question!
>>>>>>
>>>>>> I was about to ask that myself at the moment... I would like to
>>>>>> add one.
>>>>>>
>>>>>> Where would the right place for some cleanup code (like DB connection
>>>>>> reset, etc) be?
>>>>>>
>>>>>> David Donohue schrieb:
>>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>>> Thanks!
>>>>>>> David Donohue
>>>>>>>
>>
>>
>
>
Re: how to gracefully shut down a RAP application? [message #141154 is a reply to message #141107] Wed, 22 July 2009 10:19 Go to previous messageGo to next message
Eclipse UserFriend
HI,
thanks for input, I also thought about the exit confirmation, but it seems
that this is also called if the user not leaves the site, i.e. by opening an
editor (at least the method showExitConfirmation). Maybe RAP team could
implement a method addCloseListener somewhere. The registered CloseListeners
should the be excecuted when JavaScript "confirmOnClose" finished, or
smething like this.
This would be the best way, I think.

"Benjamin Wolff" <benjamin.wolff@web.de> schrieb im Newsbeitrag
news:h46v1u$ioj$1@build.eclipse.org...
> Hi,
>
> i also have a long story about session invalidation and database
> connection cleanup etc.
>
> first, as benjamin stated, there is no reliable mechanism that notices
> when the browser is closed
> or another url is entered. you can observe this by overriding the
> WorkbenchWindowAdvisor#postWindowClose().
> just put an sysout in it and observe the output using FF and IE and
> closing the tab/browser etc.
> FF seems to be more reliable, you could put a small session timeout in
> this method like:
>
> RWT.getRequest().getSession().setMaxInactiveInterval(10);
>
> thus the user session is invalidated in 10 seconds after postWindowClose()
> has been called.
> don't choose a too little value for the timeout, i observed in the past
> that it may occur that a new session
> is created when the timeout is too little (1 second) and this session is
> then reliant on the timeout.
>
> you should further keep in mind, that the servlet container is reponsible
> for the lifetime of the session,
> since a RAP user session is basically a wrapped HTTP session. In the IDE
> the container is the embedded
> jetty, in productive environment this may be a tomcat e.g. and so these
> containers also control the timeout
> and destroying of these session.
>
> so we're back at the beginning, the problem is that there isn't a reliable
> mechanism to trigger when the browser
> is closed.
>
> but i always wondered, in the branding there is an option to provide an
> exit confirmation message that is always
> called when the browser closes etc. this is achieved by a simple
> javascript method (confirmOnClose() or something
> like that). this method seems to be always called. wouldn't it be possible
> to use a similar mechanism to trigger
> a signal to the server on browser close?! just a question, i'm not into
> javascript, unfortunately.
>
> nevertheless, these are all things that i experienced and learned during
> my RAP projects, if i stated something
> wrong please feel free to enlighten me!!! :))
>
> HTH,
> -ben
>
>
> P.S: as a side note, in the past i also used the 'database connection per
> user session' approach and therefore was
> reliant on a clean shutdown handling and ressource clean up. now i'm using
> hibernate and spring in conjunction in
> an JavaSE (tomcat) environment and this way the database connection are
> obtained when they are need and released
> subsequently. this way i'm not reliant on a special resource clean up
> mechanism, the session timeout is fine.
> but that is a completely other story and can be very complex as well :P.
>
>
>
>
>
> Benjamin Muskalla schrieb:
>> Hi Markus,
>>
>> the session is only destroyed when it gets the timeout. Just closing the
>> browser does not invalidate the session as this is not supported by all
>> browsers. Just use a small session timeout value to test this.
>>
>> See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)
>>
>> And do not catch Throwables without rethrowing a ThreadDeathError as RAP
>> relies on this to kill the UI thread. But this just as a side note.
>>
>> Regarding why the session is destroyed when the user access the
>> application the second time: a user accessing the same application with
>> the same browser the servlet spec says that he can get the same session
>> (from an application server POV). In RAP we clear the session at this
>> point (and thus invalidating the old one) so you (as RAP app developer)
>> don't need to care about this.
>>
>> Hope that helps to clarify things a bit.
>>
>> Greets
>> Ben
>>
>> wrote:
>>> Hi,
>>> I tried implementing the SessionStoreListener like the following when o
>>> user open a "connection" that need to be stopped on cleanup:
>>>
>>> //register listener to clean up
>>> RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener()
>>> {
>>> public void beforeDestroy(SessionStoreEvent event) {
>>> try {
>>> System.out.println("MyConnection.beforeDestroy() was called");
>>> stop();
>>> }
>>> catch (Throwable exception) {
>>> //error handling
>>> }
>>> RWT.getSessionStore().removeSessionStoreListener(this);
>>> }
>>> });
>>>
>>> Now, as the user closes the tab, for example, then the beforeDestroy
>>> method is not called. It gets only called, if I open the application in
>>> my browser again!
>>> This is not good, as the user might not do it.
>>>
>>> Also, I get the following error that should be known by you:
>>> java.lang.IllegalStateException: The session store is about to be
>>> unbound.
>>>
>>> Hope some can help...
>>>
>>> Regards,
>>> Markus
>>>
>>> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
>>> news:h46j7i$mac$1@build.eclipse.org...
>>>> Hi Thomas,
>>>>
>>>> you could use a SessionStoreListener for clean-up action after the
>>>> webapp container signals that the session is destroyed.
>>>>
>>>> Regards,
>>>> Stefan.
>>>>
>>>> Thomas Haskes schrieb:
>>>>> Hi Ben,
>>>>>
>>>>> In my case I spoke of the shut down of a single user session. As every
>>>>> user in my application uses a database connection, i would like to
>>>>> know
>>>>> where I can out the cleanup code when the user suddenly closes the
>>>>> browser or hits F5 etc.
>>>>>
>>>>> Benjamin Wolff schrieb:
>>>>>> Hi,
>>>>>>
>>>>>> do you refer to a shutdown of the whole application (shutdown the
>>>>>> plug-ins/bundles)
>>>>>> or do you refer to the shutdown of a single user session?
>>>>>>
>>>>>> in case of application shutdown you should take a look at
>>>>>> Activator#start() and #stop() methods
>>>>>> of the plug-in(s).
>>>>>> but it is important to keep the execution time of these methods
>>>>>> short,
>>>>>> long tasks could be
>>>>>> delegated to background thread...
>>>>>>
>>>>>> i'd also like to hear other ideas about tidy up spots!
>>>>>>
>>>>>>
>>>>>> HTH,
>>>>>> -ben
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thomas Haskes schrieb:
>>>>>>> Great question!
>>>>>>>
>>>>>>> I was about to ask that myself at the moment... I would like to add
>>>>>>> one.
>>>>>>>
>>>>>>> Where would the right place for some cleanup code (like DB
>>>>>>> connection
>>>>>>> reset, etc) be?
>>>>>>>
>>>>>>> David Donohue schrieb:
>>>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>>>> Thanks!
>>>>>>>> David Donohue
>>>>>>>>
>>>
>>>
>>
Re: how to gracefully shut down a RAP application? [message #141174 is a reply to message #141063] Wed, 22 July 2009 10:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi Markus,

we thought the same and already implemented something like that for 1.0
as far as I remember. This mechanism was removed afterwards as not all
browsers allow us to listen to these situations (browser close, tab
close, etc). If we cannot rely on the fact that the browser calls us
this could get a little tricky.

Nonetheless I see that we should take a look again at this to see what
we can do. Opened the following bug to track the progress:

284273: Session kill mechanism on browser close
https://bugs.eclipse.org/bugs/show_bug.cgi?id=284273

Greets
Ben

wrote:
> after setting setMaxInactiveInterval to 60 seconds it calls the method
> corretly after one minute.
> Isn't there a way to directly call some cleanup code when the user i.e.
> closes the browser tab?
> We actually wanted the user to be able to be inactive for some hours, but
> this time would now also
> be used for "dead" session...
>
> Any ideas?
>
> Regards,
> Markus
>
>
>
> "Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
> news:h46t56$9hi$1@build.eclipse.org...
>> Hi Markus,
>>
>> the session is only destroyed when it gets the timeout. Just closing the
>> browser does not invalidate the session as this is not supported by all
>> browsers. Just use a small session timeout value to test this.
>>
>> See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)
>>
>> And do not catch Throwables without rethrowing a ThreadDeathError as RAP
>> relies on this to kill the UI thread. But this just as a side note.
>>
>> Regarding why the session is destroyed when the user access the
>> application the second time: a user accessing the same application with
>> the same browser the servlet spec says that he can get the same session
>> (from an application server POV). In RAP we clear the session at this
>> point (and thus invalidating the old one) so you (as RAP app developer)
>> don't need to care about this.
>>
>> Hope that helps to clarify things a bit.
>>
>> Greets
>> Ben
>>
>> wrote:
>>> Hi,
>>> I tried implementing the SessionStoreListener like the following when o
>>> user open a "connection" that need to be stopped on cleanup:
>>>
>>> //register listener to clean up
>>> RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener()
>>> {
>>> public void beforeDestroy(SessionStoreEvent event) {
>>> try {
>>> System.out.println("MyConnection.beforeDestroy() was called");
>>> stop();
>>> }
>>> catch (Throwable exception) {
>>> //error handling
>>> }
>>> RWT.getSessionStore().removeSessionStoreListener(this);
>>> }
>>> });
>>>
>>> Now, as the user closes the tab, for example, then the beforeDestroy
>>> method is not called. It gets only called, if I open the application in
>>> my browser again!
>>> This is not good, as the user might not do it.
>>>
>>> Also, I get the following error that should be known by you:
>>> java.lang.IllegalStateException: The session store is about to be
>>> unbound.
>>>
>>> Hope some can help...
>>>
>>> Regards,
>>> Markus
>>>
>>> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
>>> news:h46j7i$mac$1@build.eclipse.org...
>>>> Hi Thomas,
>>>>
>>>> you could use a SessionStoreListener for clean-up action after the
>>>> webapp container signals that the session is destroyed.
>>>>
>>>> Regards,
>>>> Stefan.
>>>>
>>>> Thomas Haskes schrieb:
>>>>> Hi Ben,
>>>>>
>>>>> In my case I spoke of the shut down of a single user session. As every
>>>>> user in my application uses a database connection, i would like to know
>>>>> where I can out the cleanup code when the user suddenly closes the
>>>>> browser or hits F5 etc.
>>>>>
>>>>> Benjamin Wolff schrieb:
>>>>>> Hi,
>>>>>>
>>>>>> do you refer to a shutdown of the whole application (shutdown the
>>>>>> plug-ins/bundles)
>>>>>> or do you refer to the shutdown of a single user session?
>>>>>>
>>>>>> in case of application shutdown you should take a look at
>>>>>> Activator#start() and #stop() methods
>>>>>> of the plug-in(s).
>>>>>> but it is important to keep the execution time of these methods short,
>>>>>> long tasks could be
>>>>>> delegated to background thread...
>>>>>>
>>>>>> i'd also like to hear other ideas about tidy up spots!
>>>>>>
>>>>>>
>>>>>> HTH,
>>>>>> -ben
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thomas Haskes schrieb:
>>>>>>> Great question!
>>>>>>>
>>>>>>> I was about to ask that myself at the moment... I would like to add
>>>>>>> one.
>>>>>>>
>>>>>>> Where would the right place for some cleanup code (like DB connection
>>>>>>> reset, etc) be?
>>>>>>>
>>>>>>> David Donohue schrieb:
>>>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>>>> Thanks!
>>>>>>>> David Donohue
>>>>>>>>
>>>
>>
>> --
>> Benjamin Muskalla | EclipseSource Karlsruhe
>> http://www.eclipsesource.com | http://twitter.com/eclipsesource
>
>


--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141207 is a reply to message #141174] Wed, 22 July 2009 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Damn, can't vote for it ;-) but thanks for adding the bug.


"Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
news:h477jl$qjs$1@build.eclipse.org...
> Hi Markus,
>
> we thought the same and already implemented something like that for 1.0 as
> far as I remember. This mechanism was removed afterwards as not all
> browsers allow us to listen to these situations (browser close, tab close,
> etc). If we cannot rely on the fact that the browser calls us this could
> get a little tricky.
>
> Nonetheless I see that we should take a look again at this to see what we
> can do. Opened the following bug to track the progress:
>
> 284273: Session kill mechanism on browser close
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=284273
>
> Greets
> Ben
>
> wrote:
>> after setting setMaxInactiveInterval to 60 seconds it calls the method
>> corretly after one minute.
>> Isn't there a way to directly call some cleanup code when the user i.e.
>> closes the browser tab?
>> We actually wanted the user to be able to be inactive for some hours, but
>> this time would now also
>> be used for "dead" session...
>>
>> Any ideas?
>>
>> Regards,
>> Markus
>>
>>
>>
>> "Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
>> news:h46t56$9hi$1@build.eclipse.org...
>>> Hi Markus,
>>>
>>> the session is only destroyed when it gets the timeout. Just closing the
>>> browser does not invalidate the session as this is not supported by all
>>> browsers. Just use a small session timeout value to test this.
>>>
>>> See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)
>>>
>>> And do not catch Throwables without rethrowing a ThreadDeathError as RAP
>>> relies on this to kill the UI thread. But this just as a side note.
>>>
>>> Regarding why the session is destroyed when the user access the
>>> application the second time: a user accessing the same application with
>>> the same browser the servlet spec says that he can get the same session
>>> (from an application server POV). In RAP we clear the session at this
>>> point (and thus invalidating the old one) so you (as RAP app developer)
>>> don't need to care about this.
>>>
>>> Hope that helps to clarify things a bit.
>>>
>>> Greets
>>> Ben
>>>
>>> wrote:
>>>> Hi,
>>>> I tried implementing the SessionStoreListener like the following when o
>>>> user open a "connection" that need to be stopped on cleanup:
>>>>
>>>> //register listener to clean up
>>>> RWT.getSessionStore().addSessionStoreListener(new
>>>> SessionStoreListener() {
>>>> public void beforeDestroy(SessionStoreEvent event) {
>>>> try {
>>>> System.out.println("MyConnection.beforeDestroy() was called");
>>>> stop();
>>>> }
>>>> catch (Throwable exception) {
>>>> //error handling
>>>> }
>>>> RWT.getSessionStore().removeSessionStoreListener(this);
>>>> }
>>>> });
>>>>
>>>> Now, as the user closes the tab, for example, then the beforeDestroy
>>>> method is not called. It gets only called, if I open the application in
>>>> my browser again!
>>>> This is not good, as the user might not do it.
>>>>
>>>> Also, I get the following error that should be known by you:
>>>> java.lang.IllegalStateException: The session store is about to be
>>>> unbound.
>>>>
>>>> Hope some can help...
>>>>
>>>> Regards,
>>>> Markus
>>>>
>>>> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
>>>> news:h46j7i$mac$1@build.eclipse.org...
>>>>> Hi Thomas,
>>>>>
>>>>> you could use a SessionStoreListener for clean-up action after the
>>>>> webapp container signals that the session is destroyed.
>>>>>
>>>>> Regards,
>>>>> Stefan.
>>>>>
>>>>> Thomas Haskes schrieb:
>>>>>> Hi Ben,
>>>>>>
>>>>>> In my case I spoke of the shut down of a single user session. As
>>>>>> every
>>>>>> user in my application uses a database connection, i would like to
>>>>>> know
>>>>>> where I can out the cleanup code when the user suddenly closes the
>>>>>> browser or hits F5 etc.
>>>>>>
>>>>>> Benjamin Wolff schrieb:
>>>>>>> Hi,
>>>>>>>
>>>>>>> do you refer to a shutdown of the whole application (shutdown the
>>>>>>> plug-ins/bundles)
>>>>>>> or do you refer to the shutdown of a single user session?
>>>>>>>
>>>>>>> in case of application shutdown you should take a look at
>>>>>>> Activator#start() and #stop() methods
>>>>>>> of the plug-in(s).
>>>>>>> but it is important to keep the execution time of these methods
>>>>>>> short,
>>>>>>> long tasks could be
>>>>>>> delegated to background thread...
>>>>>>>
>>>>>>> i'd also like to hear other ideas about tidy up spots!
>>>>>>>
>>>>>>>
>>>>>>> HTH,
>>>>>>> -ben
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thomas Haskes schrieb:
>>>>>>>> Great question!
>>>>>>>>
>>>>>>>> I was about to ask that myself at the moment... I would like to add
>>>>>>>> one.
>>>>>>>>
>>>>>>>> Where would the right place for some cleanup code (like DB
>>>>>>>> connection
>>>>>>>> reset, etc) be?
>>>>>>>>
>>>>>>>> David Donohue schrieb:
>>>>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>>>>> Thanks!
>>>>>>>>> David Donohue
>>>>>>>>>
>>>>
>>>
>>> --
>>> Benjamin Muskalla | EclipseSource Karlsruhe
>>> http://www.eclipsesource.com | http://twitter.com/eclipsesource
>>
>>
>
>
> --
> Benjamin Muskalla | EclipseSource Karlsruhe
> http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141229 is a reply to message #141207] Wed, 22 July 2009 10:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bjoern.bjoernfischer.de

Hi Markus,
I added my vote in your place :D

Thanks for opening the bug Benny, I hope there will be a solution soon.

Regards,
Björn

Markus Krüger schrieb:
> Damn, can't vote for it ;-) but thanks for adding the bug.
>
>
> "Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
> news:h477jl$qjs$1@build.eclipse.org...
>> Hi Markus,
>>
>> we thought the same and already implemented something like that for 1.0 as
>> far as I remember. This mechanism was removed afterwards as not all
>> browsers allow us to listen to these situations (browser close, tab close,
>> etc). If we cannot rely on the fact that the browser calls us this could
>> get a little tricky.
>>
>> Nonetheless I see that we should take a look again at this to see what we
>> can do. Opened the following bug to track the progress:
>>
>> 284273: Session kill mechanism on browser close
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=284273
>>
>> Greets
>> Ben
>>
>> wrote:
>>> after setting setMaxInactiveInterval to 60 seconds it calls the method
>>> corretly after one minute.
>>> Isn't there a way to directly call some cleanup code when the user i.e.
>>> closes the browser tab?
>>> We actually wanted the user to be able to be inactive for some hours, but
>>> this time would now also
>>> be used for "dead" session...
>>>
>>> Any ideas?
>>>
>>> Regards,
>>> Markus
>>>
>>>
>>>
>>> "Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
>>> news:h46t56$9hi$1@build.eclipse.org...
>>>> Hi Markus,
>>>>
>>>> the session is only destroyed when it gets the timeout. Just closing the
>>>> browser does not invalidate the session as this is not supported by all
>>>> browsers. Just use a small session timeout value to test this.
>>>>
>>>> See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)
>>>>
>>>> And do not catch Throwables without rethrowing a ThreadDeathError as RAP
>>>> relies on this to kill the UI thread. But this just as a side note.
>>>>
>>>> Regarding why the session is destroyed when the user access the
>>>> application the second time: a user accessing the same application with
>>>> the same browser the servlet spec says that he can get the same session
>>>> (from an application server POV). In RAP we clear the session at this
>>>> point (and thus invalidating the old one) so you (as RAP app developer)
>>>> don't need to care about this.
>>>>
>>>> Hope that helps to clarify things a bit.
>>>>
>>>> Greets
>>>> Ben
>>>>
>>>> wrote:
>>>>> Hi,
>>>>> I tried implementing the SessionStoreListener like the following when o
>>>>> user open a "connection" that need to be stopped on cleanup:
>>>>>
>>>>> //register listener to clean up
>>>>> RWT.getSessionStore().addSessionStoreListener(new
>>>>> SessionStoreListener() {
>>>>> public void beforeDestroy(SessionStoreEvent event) {
>>>>> try {
>>>>> System.out.println("MyConnection.beforeDestroy() was called");
>>>>> stop();
>>>>> }
>>>>> catch (Throwable exception) {
>>>>> //error handling
>>>>> }
>>>>> RWT.getSessionStore().removeSessionStoreListener(this);
>>>>> }
>>>>> });
>>>>>
>>>>> Now, as the user closes the tab, for example, then the beforeDestroy
>>>>> method is not called. It gets only called, if I open the application in
>>>>> my browser again!
>>>>> This is not good, as the user might not do it.
>>>>>
>>>>> Also, I get the following error that should be known by you:
>>>>> java.lang.IllegalStateException: The session store is about to be
>>>>> unbound.
>>>>>
>>>>> Hope some can help...
>>>>>
>>>>> Regards,
>>>>> Markus
>>>>>
>>>>> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
>>>>> news:h46j7i$mac$1@build.eclipse.org...
>>>>>> Hi Thomas,
>>>>>>
>>>>>> you could use a SessionStoreListener for clean-up action after the
>>>>>> webapp container signals that the session is destroyed.
>>>>>>
>>>>>> Regards,
>>>>>> Stefan.
>>>>>>
>>>>>> Thomas Haskes schrieb:
>>>>>>> Hi Ben,
>>>>>>>
>>>>>>> In my case I spoke of the shut down of a single user session. As
>>>>>>> every
>>>>>>> user in my application uses a database connection, i would like to
>>>>>>> know
>>>>>>> where I can out the cleanup code when the user suddenly closes the
>>>>>>> browser or hits F5 etc.
>>>>>>>
>>>>>>> Benjamin Wolff schrieb:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> do you refer to a shutdown of the whole application (shutdown the
>>>>>>>> plug-ins/bundles)
>>>>>>>> or do you refer to the shutdown of a single user session?
>>>>>>>>
>>>>>>>> in case of application shutdown you should take a look at
>>>>>>>> Activator#start() and #stop() methods
>>>>>>>> of the plug-in(s).
>>>>>>>> but it is important to keep the execution time of these methods
>>>>>>>> short,
>>>>>>>> long tasks could be
>>>>>>>> delegated to background thread...
>>>>>>>>
>>>>>>>> i'd also like to hear other ideas about tidy up spots!
>>>>>>>>
>>>>>>>>
>>>>>>>> HTH,
>>>>>>>> -ben
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Thomas Haskes schrieb:
>>>>>>>>> Great question!
>>>>>>>>>
>>>>>>>>> I was about to ask that myself at the moment... I would like to add
>>>>>>>>> one.
>>>>>>>>>
>>>>>>>>> Where would the right place for some cleanup code (like DB
>>>>>>>>> connection
>>>>>>>>> reset, etc) be?
>>>>>>>>>
>>>>>>>>> David Donohue schrieb:
>>>>>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>>>>>> Thanks!
>>>>>>>>>> David Donohue
>>>>>>>>>>
>>>> --
>>>> Benjamin Muskalla | EclipseSource Karlsruhe
>>>> http://www.eclipsesource.com | http://twitter.com/eclipsesource
>>>
>>
>> --
>> Benjamin Muskalla | EclipseSource Karlsruhe
>> http://www.eclipsesource.com | http://twitter.com/eclipsesource
>
>
Re: how to gracefully shut down a RAP application? [message #141240 is a reply to message #141229] Wed, 22 July 2009 10:38 Go to previous messageGo to next message
Eclipse UserFriend
Just to be sure, the bug is to investigate if we can provide this
mechanism - not yet sure if we will do this. We removed the old
mechanism by intention - we just don't remember why :P

Greets
Benny

Björn Fischer wrote:
> Hi Markus,
> I added my vote in your place :D
>
> Thanks for opening the bug Benny, I hope there will be a solution soon.
>
> Regards,
> Björn
>
> Markus Krüger schrieb:
>> Damn, can't vote for it ;-) but thanks for adding the bug.
>>
>>
>> "Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
>> news:h477jl$qjs$1@build.eclipse.org...
>>> Hi Markus,
>>>
>>> we thought the same and already implemented something like that for 1.0 as
>>> far as I remember. This mechanism was removed afterwards as not all
>>> browsers allow us to listen to these situations (browser close, tab close,
>>> etc). If we cannot rely on the fact that the browser calls us this could
>>> get a little tricky.
>>>
>>> Nonetheless I see that we should take a look again at this to see what we
>>> can do. Opened the following bug to track the progress:
>>>
>>> 284273: Session kill mechanism on browser close
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=284273
>>>
>>> Greets
>>> Ben
>>>
>>> wrote:
>>>> after setting setMaxInactiveInterval to 60 seconds it calls the method
>>>> corretly after one minute.
>>>> Isn't there a way to directly call some cleanup code when the user i.e.
>>>> closes the browser tab?
>>>> We actually wanted the user to be able to be inactive for some hours, but
>>>> this time would now also
>>>> be used for "dead" session...
>>>>
>>>> Any ideas?
>>>>
>>>> Regards,
>>>> Markus
>>>>
>>>>
>>>>
>>>> "Benjamin Muskalla" <bmuskalla@eclipsesource.com> schrieb im Newsbeitrag
>>>> news:h46t56$9hi$1@build.eclipse.org...
>>>>> Hi Markus,
>>>>>
>>>>> the session is only destroyed when it gets the timeout. Just closing the
>>>>> browser does not invalidate the session as this is not supported by all
>>>>> browsers. Just use a small session timeout value to test this.
>>>>>
>>>>> See RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(seks)
>>>>>
>>>>> And do not catch Throwables without rethrowing a ThreadDeathError as RAP
>>>>> relies on this to kill the UI thread. But this just as a side note.
>>>>>
>>>>> Regarding why the session is destroyed when the user access the
>>>>> application the second time: a user accessing the same application with
>>>>> the same browser the servlet spec says that he can get the same session
>>>>> (from an application server POV). In RAP we clear the session at this
>>>>> point (and thus invalidating the old one) so you (as RAP app developer)
>>>>> don't need to care about this.
>>>>>
>>>>> Hope that helps to clarify things a bit.
>>>>>
>>>>> Greets
>>>>> Ben
>>>>>
>>>>> wrote:
>>>>>> Hi,
>>>>>> I tried implementing the SessionStoreListener like the following when o
>>>>>> user open a "connection" that need to be stopped on cleanup:
>>>>>>
>>>>>> //register listener to clean up
>>>>>> RWT.getSessionStore().addSessionStoreListener(new
>>>>>> SessionStoreListener() {
>>>>>> public void beforeDestroy(SessionStoreEvent event) {
>>>>>> try {
>>>>>> System.out.println("MyConnection.beforeDestroy() was called");
>>>>>> stop();
>>>>>> }
>>>>>> catch (Throwable exception) {
>>>>>> //error handling
>>>>>> }
>>>>>> RWT.getSessionStore().removeSessionStoreListener(this);
>>>>>> }
>>>>>> });
>>>>>>
>>>>>> Now, as the user closes the tab, for example, then the beforeDestroy
>>>>>> method is not called. It gets only called, if I open the application in
>>>>>> my browser again!
>>>>>> This is not good, as the user might not do it.
>>>>>>
>>>>>> Also, I get the following error that should be known by you:
>>>>>> java.lang.IllegalStateException: The session store is about to be
>>>>>> unbound.
>>>>>>
>>>>>> Hope some can help...
>>>>>>
>>>>>> Regards,
>>>>>> Markus
>>>>>>
>>>>>> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
>>>>>> news:h46j7i$mac$1@build.eclipse.org...
>>>>>>> Hi Thomas,
>>>>>>>
>>>>>>> you could use a SessionStoreListener for clean-up action after the
>>>>>>> webapp container signals that the session is destroyed.
>>>>>>>
>>>>>>> Regards,
>>>>>>> Stefan.
>>>>>>>
>>>>>>> Thomas Haskes schrieb:
>>>>>>>> Hi Ben,
>>>>>>>>
>>>>>>>> In my case I spoke of the shut down of a single user session. As
>>>>>>>> every
>>>>>>>> user in my application uses a database connection, i would like to
>>>>>>>> know
>>>>>>>> where I can out the cleanup code when the user suddenly closes the
>>>>>>>> browser or hits F5 etc.
>>>>>>>>
>>>>>>>> Benjamin Wolff schrieb:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> do you refer to a shutdown of the whole application (shutdown the
>>>>>>>>> plug-ins/bundles)
>>>>>>>>> or do you refer to the shutdown of a single user session?
>>>>>>>>>
>>>>>>>>> in case of application shutdown you should take a look at
>>>>>>>>> Activator#start() and #stop() methods
>>>>>>>>> of the plug-in(s).
>>>>>>>>> but it is important to keep the execution time of these methods
>>>>>>>>> short,
>>>>>>>>> long tasks could be
>>>>>>>>> delegated to background thread...
>>>>>>>>>
>>>>>>>>> i'd also like to hear other ideas about tidy up spots!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> HTH,
>>>>>>>>> -ben
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thomas Haskes schrieb:
>>>>>>>>>> Great question!
>>>>>>>>>>
>>>>>>>>>> I was about to ask that myself at the moment... I would like to add
>>>>>>>>>> one.
>>>>>>>>>>
>>>>>>>>>> Where would the right place for some cleanup code (like DB
>>>>>>>>>> connection
>>>>>>>>>> reset, etc) be?
>>>>>>>>>>
>>>>>>>>>> David Donohue schrieb:
>>>>>>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>>>>>>> Thanks!
>>>>>>>>>>> David Donohue
>>>>>>>>>>>
>>>>> --
>>>>> Benjamin Muskalla | EclipseSource Karlsruhe
>>>>> http://www.eclipsesource.com | http://twitter.com/eclipsesource
>>> --
>>> Benjamin Muskalla | EclipseSource Karlsruhe
>>> http://www.eclipsesource.com | http://twitter.com/eclipsesource
>>


--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141273 is a reply to message #141041] Wed, 22 July 2009 11:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benjamin.wolff.web.de

Hi Markus,


you mustn't remove the SessionStoreListener within the Listener itself, this is causing the
IllegalStateException exception.


HTH,
-ben



Markus Krüger schrieb:
> Hi,
> I tried implementing the SessionStoreListener like the following when o user
> open a "connection" that need to be stopped on cleanup:
>
> //register listener to clean up
> RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener() {
> public void beforeDestroy(SessionStoreEvent event) {
> try {
> System.out.println("MyConnection.beforeDestroy() was called");
> stop();
> }
> catch (Throwable exception) {
> //error handling
> }
> RWT.getSessionStore().removeSessionStoreListener(this);
> }
> });
>
> Now, as the user closes the tab, for example, then the beforeDestroy method
> is not called. It gets only called, if I open the application in my browser
> again!
> This is not good, as the user might not do it.
>
> Also, I get the following error that should be known by you:
> java.lang.IllegalStateException: The session store is about to be unbound.
>
> Hope some can help...
>
> Regards,
> Markus
>
> "Stefan Roeck" <stefan.roeck@cas.de> schrieb im Newsbeitrag
> news:h46j7i$mac$1@build.eclipse.org...
>> Hi Thomas,
>>
>> you could use a SessionStoreListener for clean-up action after the webapp
>> container signals that the session is destroyed.
>>
>> Regards,
>> Stefan.
>>
>> Thomas Haskes schrieb:
>>> Hi Ben,
>>>
>>> In my case I spoke of the shut down of a single user session. As every
>>> user in my application uses a database connection, i would like to know
>>> where I can out the cleanup code when the user suddenly closes the
>>> browser or hits F5 etc.
>>>
>>> Benjamin Wolff schrieb:
>>>> Hi,
>>>>
>>>> do you refer to a shutdown of the whole application (shutdown the
>>>> plug-ins/bundles)
>>>> or do you refer to the shutdown of a single user session?
>>>>
>>>> in case of application shutdown you should take a look at
>>>> Activator#start() and #stop() methods
>>>> of the plug-in(s).
>>>> but it is important to keep the execution time of these methods short,
>>>> long tasks could be
>>>> delegated to background thread...
>>>>
>>>> i'd also like to hear other ideas about tidy up spots!
>>>>
>>>>
>>>> HTH,
>>>> -ben
>>>>
>>>>
>>>>
>>>> Thomas Haskes schrieb:
>>>>> Great question!
>>>>>
>>>>> I was about to ask that myself at the moment... I would like to add
>>>>> one.
>>>>>
>>>>> Where would the right place for some cleanup code (like DB connection
>>>>> reset, etc) be?
>>>>>
>>>>> David Donohue schrieb:
>>>>>> Is there a preferred way to shut down a RAP application?
>>>>>> Thanks!
>>>>>> David Donohue
>>>>>>
>
>
Re: how to gracefully shut down a RAP application? [message #141360 is a reply to message #141052] Fri, 24 July 2009 03:20 Go to previous messageGo to next message
Eclipse UserFriend
Benny,
just to make sure that I understand you correct. You "clear" the session
but the session itself is the same (same session ID) - correct?

If so, that means that the UIThread is reused, too.

I wasn't aware of this part of ServletSpec and I think it is important
to consider when dealing with Thread-based authentication or any other
Thread-base data (e.g. MDC for logging).

To avoid troubles with this, we always invalidate the Session on login.

Regards,
Stefan.


Benjamin Muskalla schrieb:
>
> Regarding why the session is destroyed when the user access the
> application the second time: a user accessing the same application with
> the same browser the servlet spec says that he can get the same session
> (from an application server POV). In RAP we clear the session at this
> point (and thus invalidating the old one) so you (as RAP app developer)
> don't need to care about this.
>
Re: how to gracefully shut down a RAP application? [message #141389 is a reply to message #141360] Fri, 24 July 2009 04:52 Go to previous messageGo to next message
Eclipse UserFriend
Stefan,

sorry for the confusion. It's not about the servlet spec but about
cookie handling. When reloading the page the session cookie is still
alive and so we get the same session from the application server.
That's the reason why we clear these things again so you as application
developer seam to get a new session. The UIThread is killed and a new
one is created. So besides the sessionid you really have no clue if this
was just a page reload or a new user. And I think this is the way to go
as you should generally not need to care about these things.

Greets
Benny

Stefan Roeck wrote:
> Benny,
> just to make sure that I understand you correct. You "clear" the session
> but the session itself is the same (same session ID) - correct?
>
> If so, that means that the UIThread is reused, too.
>
> I wasn't aware of this part of ServletSpec and I think it is important
> to consider when dealing with Thread-based authentication or any other
> Thread-base data (e.g. MDC for logging).
>
> To avoid troubles with this, we always invalidate the Session on login.
>
> Regards,
> Stefan.
>
>
> Benjamin Muskalla schrieb:
>>
>> Regarding why the session is destroyed when the user access the
>> application the second time: a user accessing the same application
>> with the same browser the servlet spec says that he can get the same
>> session (from an application server POV). In RAP we clear the session
>> at this point (and thus invalidating the old one) so you (as RAP app
>> developer) don't need to care about this.
>>


--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141400 is a reply to message #141085] Fri, 24 July 2009 05:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi Igor,

> For the RAP team: I really want to see as much of my changes in the main
> CVS of the RAP project as it possible, so I will be glad to get some
> review from RAP team.
>

We are glad about every patch but please understand that most areas
you're working on are pretty sensitive. So it may take some time to
review all the patches. But I think now is the right time to come up
with these things as we are very early in the release cycle.

That said, I'm looking forward to feature requests and patches ;-)

Cheers
Ben

--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: how to gracefully shut down a RAP application? [message #141524 is a reply to message #141273] Mon, 27 July 2009 02:01 Go to previous message
Eclipse UserFriend
Thanks, that worked.

"Benjamin Wolff" <benjamin.wolff@web.de> schrieb im Newsbeitrag
news:h47buu$sm3$1@build.eclipse.org...
> Hi Markus,
>
>
> you mustn't remove the SessionStoreListener within the Listener itself,
> this is causing the
> IllegalStateException exception.
>
>
> HTH,
> -ben
>
>
>
> Markus Kr
Previous Topic:Move Views
Next Topic:Listener Dilemma
Goto Forum:
  


Current Time: Sat Jul 19 18:26:06 EDT 2025

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

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

Back to the top