Home » Eclipse Projects » Remote Application Platform (RAP) » how to gracefully shut down a RAP application?
| | | | | |
Re: how to gracefully shut down a RAP application? [message #141019 is a reply to message #140986] |
Wed, 22 July 2009 05:49   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #141107 is a reply to message #141052] |
Wed, 22 July 2009 08:01   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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
>>>>>>
>
>
|
|
| | | | |
Goto Forum:
Current Time: Sat Jul 19 18:26:06 EDT 2025
Powered by FUDForum. Page generated in 0.07368 seconds
|