diff options
author | Matthew Newhook <matthew@zeroc.com> | 2009-09-09 15:11:18 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2009-09-09 15:11:18 -0230 |
commit | bbda11a7fdbcd6717029d4836e27931250d2360b (patch) | |
tree | a8ab1fe5377baa835c70e986c3313c169f53b362 /java/demo/Glacier2/callback/Client.java | |
parent | Fixed bug 4146 - re-throwing exception with fillInStackTrace (diff) | |
download | ice-bbda11a7fdbcd6717029d4836e27931250d2360b.tar.bz2 ice-bbda11a7fdbcd6717029d4836e27931250d2360b.tar.xz ice-bbda11a7fdbcd6717029d4836e27931250d2360b.zip |
http://bugzilla/bugzilla/show_bug.cgi?id=2839
In the process of fixing this bug I added ice_ping to the Glacier2
router and updated the callback demo as described. I did not update
the VB demo/Glacier2/callback, nor the windows project files.
Diffstat (limited to 'java/demo/Glacier2/callback/Client.java')
-rw-r--r-- | java/demo/Glacier2/callback/Client.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/java/demo/Glacier2/callback/Client.java b/java/demo/Glacier2/callback/Client.java index 8f3eba5a129..17f3590f810 100644 --- a/java/demo/Glacier2/callback/Client.java +++ b/java/demo/Glacier2/callback/Client.java @@ -11,6 +11,52 @@ import Demo.*; public class Client extends Ice.Application { + + static private class SessionRefreshThread extends Thread + { + SessionRefreshThread(Glacier2.RouterPrx router, long timeout) + { + _router = router; + _timeout = timeout; + } + + synchronized public void + run() + { + while(!_terminated) + { + try + { + wait(_timeout); + } + catch(InterruptedException e) + { + } + if(!_terminated) + { + try + { + _router.ice_ping(); + } + catch(Ice.LocalException ex) + { + } + } + } + } + + synchronized private void + terminate() + { + _terminated = true; + notify(); + } + + final private Glacier2.RouterPrx _router; + final private long _timeout; + private boolean _terminated = false; + } + class ShutdownHook extends Thread { public void @@ -110,6 +156,9 @@ public class Client extends Ice.Application } } + SessionRefreshThread refresh = new SessionRefreshThread(router, router.getSessionTimeout() * 500); + refresh.start(); + String category = router.getCategoryForClient(); Ice.Identity callbackReceiverIdent = new Ice.Identity(); callbackReceiverIdent.name = "callbackReceiver"; @@ -246,6 +295,21 @@ public class Client extends Ice.Application } while(!line.equals("x")); + // + // The refresher thread must be terminated before the session + // is destroyed, otherwise it might get + // ObjectNotExistException. + // + refresh.terminate(); + try + { + refresh.join(); + } + catch(InterruptedException e) + { + } + refresh = null; + try { router.destroySession(); |