Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to gracefully shut down a RAP user Session?( how to gracefully shut down a RAP application? part 2)
How to gracefully shut down a RAP user Session? [message #540230] Tue, 15 June 2010 12:52 Go to next message
Martijn Cremer is currently offline Martijn CremerFriend
Messages: 77
Registered: January 2010
Location: Breda
Member

Hello Rap enthusiasts,

A while back I asked around how to get session related data for User information. I ended up making a Static class that checks the HTTPSession of the session the user is in and binding the User tot hat session. This works like a charm. And I just made the same class in RCP so that we ask the store the user. It seems the best way without to much work you cant single source every thing. Now got it working and it works good. I know the users and even can see how many users are using the web system.

Now i run in to an already known problem you want to remove the user when he closes/or surfs away from the site that you clean up the connection information. I tried a few approaches as mentioned in the how to gracefully shut down a RAP application?

The one that seems to work best is:

public class Application implements IEntryPoint {

	public int createUI() {
		Display display = PlatformUI.createDisplay();
		WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
		
		if (authenticate(display)) {
			System.out.println("" + RWT.getSessionStore());
			RWT.getSessionStore().getHttpSession().setMaxInactiveInterval(30);
			
			RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener() {
				
				@Override
				public void beforeDestroy(SessionStoreEvent event) {
					System.out.println("End of this life cycle");
					
				}
			});
			return PlatformUI.createAndRunWorkbench(display, advisor);
			}

		return 0;

	}
}

or
public class Application implements IEntryPoint {

	public int createUI() {
		Display display = PlatformUI.createDisplay();
		WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
		
		if (authenticate(display)) {
			System.out.println("" + RWT.getSessionStore());
			RWT.getSessionStore().getHttpSession().setMaxInactiveInterval(30);
			display.disposeExec(new Runnable() {
				
				@Override
				public void run() {
					System.out.println("Put your clean up code here.");
					
				}
			});
			return PlatformUI.createAndRunWorkbench(display, advisor);
			}

		return 0;

	}

}


I found the biggest downside of these solutions is that first of you set a time limit to something that should replace or substitute a rich client. And also throwing a lot of Widgetdisposed to early errors.

I also tried putting the
    public void WorkbenchWindowAdvisor.postWindowClose(){
    	System.out.println("postWindowClose");
    }


However this does not show up in any of my test as being used when closing a tab in Chorme, Firefox 3.6.3 and IE8. As mentioned in the mentioned in the how to gracefully shut down a RAP application? there were a few attempts to it but as far as i can see non are available or am I over looking something?

I know this problem in general is quite tricky in web world seeing that the only event you really can catch killing the session from the Browser side. I'm hoping that some of you have a good idea to get this working or a way to monitor if the session is active (seeing I dont like setting the session time out). I know the RAP protocol probably would aid in this solution but that's still ways to go I guess.



hm. I've lost a machine.. literally _lost_. it responds to ping, it works completely, I just can't figure out where in my apartment it is.
Re: How to gracefully shut down a RAP user Session? [message #540977 is a reply to message #540230] Thu, 17 June 2010 20:24 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Martijn,

I'd suggest that you remove the user from this list when the session
expires, just as you already outlined. Can you explain why this doesn't
work for you? I didn't get your argument wrt. the timeout.

There is currently no support for tracking when the user leaves/closes
the browser. The mechanisms known to do so seem not to be reliable. If
you have a use case for this, you can leave some input on this bug:

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

Regards, Ralf

Martijn Cremer wrote:
> Hello Rap enthusiasts,
>
> A while back I asked around how to
> http://www.eclipse.org/forums/index.php?t=msg&goto=53962 2&#msg_539622 I
> ended up making a Static class that checks the HTTPSession of the
> session the user is in and binding the User tot hat session. This works
> like a charm. And I just made the same class in RCP so that we ask the
> store the user. It seems the best way without to much work you cant
> single source every thing. Now got it working and it works good. I know
> the users and even can see how many users are using the web system.
>
> Now i run in to an already known problem you want to remove the user
> when he closes/or surfs away from the site that you clean up the
> connection information. I tried a few approaches as
> http://www.eclipse.org/forums/index.php?t=msg&goto=14086 8&#msg_140868
>
> The one that seems to work best is:
>
> public class Application implements IEntryPoint {
>
> public int createUI() {
> Display display = PlatformUI.createDisplay();
> WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
>
> if (authenticate(display)) {
> System.out.println("" + RWT.getSessionStore());
>
> RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(30);
>
> RWT.getSessionStore().addSessionStoreListener(new
> SessionStoreListener() {
>
> @Override
> public void beforeDestroy(SessionStoreEvent event) {
> System.out.println("End of this life cycle");
>
> }
> });
> return PlatformUI.createAndRunWorkbench(display, advisor);
> }
>
> return 0;
>
> }
> }
> or public class Application implements IEntryPoint {
>
> public int createUI() {
> Display display = PlatformUI.createDisplay();
> WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
>
> if (authenticate(display)) {
> System.out.println("" + RWT.getSessionStore());
>
> RWT.getSessionStore().getHttpSession().setMaxInactiveInterva l(30);
> display.disposeExec(new Runnable() {
>
> @Override
> public void run() {
> System.out.println("Put your clean up code here.");
>
> }
> });
> return PlatformUI.createAndRunWorkbench(display, advisor);
> }
>
> return 0;
>
> }
>
> }
>
> I found the biggest downside of these solutions is that first of you set
> a time limit to something that should replace or substitute a rich
> client. And also throwing a lot of Widgetdisposed to early errors.
>
> I also tried putting the
> public void WorkbenchWindowAdvisor.postWindowClose(){
> System.out.println("postWindowClose");
> }
>
>
> However this does not show up in any of my test as being used when
> closing a tab in Chorme, Firefox 3.6.3 and IE8. As mentioned in the
> http://www.eclipse.org/forums/index.php?t=msg&goto=14086 8&#msg_140868
> there were a few attempts to it but as far as i can see non are
> available or am I over looking something?
>
> I know this problem in general is quite tricky in web world seeing that
> the only event you really can catch killing the session from the Browser
> side. I'm hoping that some of you have a good idea to get this working
> or a way to monitor if the session is active (seeing I dont like setting
> the session time out). I know the RAP protocol probably would aid in
> this solution but that's still ways to go I guess.
>
>
Re: How to gracefully shut down a RAP user Session? [message #541060 is a reply to message #540977] Fri, 18 June 2010 08:12 Go to previous messageGo to next message
Martijn Cremer is currently offline Martijn CremerFriend
Messages: 77
Registered: January 2010
Location: Breda
Member

Hi Ralf,

The error is coursed by a combination of technology the user binds a dynamic OSGi service when he go's to the perspective (this already gave me some headache http://www.eclipse.org/forums/index.php?t=msg&goto=54085 8&#msg_540858) the problem is the unbind doesn't really happen cleanly becouse the user stays as it were signed in. This only happens of course when the same users wants to bind again after he closed his browser and reopens before the time out. The work around could be for now that I allow more then one session binded to a user (it gives no real complications just isnt a neat way to do things in my honest opinion). Its more that the sessions are managed correctly.

I also wonder is it possible to read a cookie at the moment as far as I can tell the default cookie RAP uses is named "settingStore" I want to inherit the Cookie from a PHP session for the system I am creating (not sure if this is even posible) eny one an idea?


[quote title=Ralf Sternberg wrote on Thu, 17 June 2010 22:24]Hi Martijn,

I'd suggest that you remove the user from this list when the session
expires, just as you already outlined. Can you explain why this doesn't
work for you? I didn't get your argument wrt. the timeout.

There is currently no support for tracking when the user leaves/closes
the browser. The mechanisms known to do so seem not to be reliable. If
you have a use case for this, you can leave some input on this bug:

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

Regards, Ralf/quote]


hm. I've lost a machine.. literally _lost_. it responds to ping, it works completely, I just can't figure out where in my apartment it is.
Re: How to gracefully shut down a RAP user Session? [message #541117 is a reply to message #541060] Fri, 18 June 2010 12:07 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

The unbind does happen cleanly, but not when the user leaves the browser
but when the session times out. If you experience anything different,
you should report a bug.

Martijn Cremer wrote:
> Hi Ralf,
>
> The error is coursed by a combination of technology the user binds a
> dynamic OSGi service when he go's to the perspective (this already gave
> me some headache
> http://www.eclipse.org/forums/index.php?t=msg&goto=54085 8&#msg_540858)
> the problem is the unbind doesn't really happen cleanly becouse the user
> stays as it were signed in. This only happens of course when the same
> users wants to bind again after he closed his browser and reopens before
> the time out. The work around could be for now that I allow more then
> one session binded to a user (it gives no real complications just isnt a
> neat way to do things in my honest opinion). Its more that the sessions
> are managed correctly.
>
> I also wonder is it possible to read a cookie at the moment as far as I
> can tell the default cookie RAP uses is named "settingStore" I want to
> inherit the Cookie from a PHP session for the system I am creating (not
> sure if this is even posible) eny one an idea?
>
>
> [quote title=Ralf Sternberg wrote on Thu, 17 June 2010 22:24]Hi Martijn,
>
> I'd suggest that you remove the user from this list when the session
> expires, just as you already outlined. Can you explain why this doesn't
> work for you? I didn't get your argument wrt. the timeout.
>
> There is currently no support for tracking when the user leaves/closes
> the browser. The mechanisms known to do so seem not to be reliable. If
> you have a use case for this, you can leave some input on this bug:
>
> 284273: Session kill mechanism on browser close
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=284273
>
> Regards, Ralf/quote]
>
Previous Topic:Thread per connected client?
Next Topic:UICallback broken in RAP 1.3 ?
Goto Forum:
  


Current Time: Tue Apr 23 12:22:46 GMT 2024

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

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

Back to the top