diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-09-12 02:11:38 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-09-12 02:11:38 +0000 |
commit | bfc88da99f2fc516f2eb4df50b136a71ee82ee1e (patch) | |
tree | 155c0413abc67903b0227b6613c12026461cea7f /java/demo/IcePack/hello/HelloFactoryI.java | |
parent | bugfix to the icepack hello demo. (diff) | |
download | ice-bfc88da99f2fc516f2eb4df50b136a71ee82ee1e.tar.bz2 ice-bfc88da99f2fc516f2eb4df50b136a71ee82ee1e.tar.xz ice-bfc88da99f2fc516f2eb4df50b136a71ee82ee1e.zip |
bug fix to the icepack hello demo.
Diffstat (limited to 'java/demo/IcePack/hello/HelloFactoryI.java')
-rw-r--r-- | java/demo/IcePack/hello/HelloFactoryI.java | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/java/demo/IcePack/hello/HelloFactoryI.java b/java/demo/IcePack/hello/HelloFactoryI.java index 6894ccb79d3..9e01bcacfe9 100644 --- a/java/demo/IcePack/hello/HelloFactoryI.java +++ b/java/demo/IcePack/hello/HelloFactoryI.java @@ -22,27 +22,54 @@ public class HelloFactoryI extends _HelloFactoryDisp // Create the servant and add it to the object adapter using the // given name as the identity. // - Ice.Object hello = new HelloI(name); - Ice.ObjectPrx object = adapter.add(hello, Ice.Util.stringToIdentity(name)); + Ice.ObjectPrx object; + try + { + object = adapter.add(new HelloI(name), Ice.Util.stringToIdentity(name)); + } + catch(Ice.AlreadyRegisteredException ex) + { + // + // The object is already registered. + // + throw new NameExistsException(); + } // // Get the IcePack Admin interface and register the newly created // Hello object with the IcePack object registry. // + IcePack.AdminPrx admin = IcePack.AdminPrxHelper.checkedCast(communicator.stringToProxy("IcePack/Admin")); try { - IcePack.AdminPrx admin = IcePack.AdminPrxHelper.checkedCast(communicator.stringToProxy("IcePack/Admin")); admin.addObject(object); } catch(IcePack.ObjectExistsException ex) { - // - // An object with the same identity is already registered with - // the registry. Remove the object from the object adapter and - // throw. - // - adapter.remove(object.ice_getIdentity()); - throw new NameExistsException(); + // + // This should only occur if the server has been restarted and + // the server objects haven't been removed from the object + // registry. + // + // In this case remove the current object, and re-add. + // + try + { + admin.removeObject(object.ice_getIdentity()); + admin.addObject(object); + } + catch(IcePack.ObjectNotExistException e) + { + assert(false); + } + catch(IcePack.ObjectExistsException e) + { + assert(false); + } + catch(IcePack.DeploymentException e) + { + assert(false); + } } catch(IcePack.DeploymentException ex) { |