diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-10-20 05:55:31 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-10-20 05:55:31 +0000 |
commit | 273233e4fff5c7a18ccedfa4fe984740fa4cf3b4 (patch) | |
tree | 764767525c9de80e166cd0328494f7b5ad16dd4f /java/src/IceBox/ServiceManagerI.java | |
parent | http://wiki.zeroc.com/bugzilla/show_bug.cgi?id=528 (diff) | |
download | ice-273233e4fff5c7a18ccedfa4fe984740fa4cf3b4.tar.bz2 ice-273233e4fff5c7a18ccedfa4fe984740fa4cf3b4.tar.xz ice-273233e4fff5c7a18ccedfa4fe984740fa4cf3b4.zip |
http://wiki.zeroc.com/bugzilla/show_bug.cgi?id=528
Diffstat (limited to 'java/src/IceBox/ServiceManagerI.java')
-rw-r--r-- | java/src/IceBox/ServiceManagerI.java | 91 |
1 files changed, 79 insertions, 12 deletions
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java index 86d7246d5ec..04cd2c5df10 100644 --- a/java/src/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/ServiceManagerI.java @@ -323,26 +323,61 @@ public class ServiceManagerI extends _ServiceManagerDisp Ice.Communicator communicator = info.communicator != null ? info.communicator : _server.communicator(); - info.service.start(service, communicator, serviceArgs); + try + { + info.service.start(service, communicator, serviceArgs); + } + catch(Exception ex) + { + if(info.communicator != null) + { + try + { + info.communicator.shutdown(); + info.communicator.waitForShutdown(); + } + catch(Ice.CommunicatorDestroyedException e) + { + // + // Ignore, the service might have already destroyed + // the communicator for its own reasons. + // + } + catch(java.lang.Exception e) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + e.printStackTrace(pw); + pw.flush(); + _logger.warning("ServiceManager: exception in shutting down communicator for service " + + service + "\n" + sw.toString()); + } + + try + { + info.communicator.destroy(); + } + catch(java.lang.Exception e) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + e.printStackTrace(pw); + pw.flush(); + _logger.warning("ServiceManager: exception in destroying communciator for service" + + service + "\n" + sw.toString()); + } + } + throw ex; + } _services.put(service, info); } catch(FailureException ex) { - if(info.communicator != null) - { - destroyCommunicator(service, info.communicator); - } - throw ex; } catch(java.lang.Exception ex) { - if(info.communicator != null) - { - destroyCommunicator(service, info.communicator); - } - FailureException e = new FailureException(); e.reason = "ServiceManager: exception while starting service " + service + ": " + ex; e.initCause(ex); @@ -378,7 +413,39 @@ public class ServiceManagerI extends _ServiceManagerDisp if(info.communicator != null) { - destroyCommunicator(name, info.communicator); + try + { + info.communicator.shutdown(); + info.communicator.waitForShutdown(); + } + catch(Ice.CommunicatorDestroyedException e) + { + // + // Ignore, the service might have already destroyed + // the communicator for its own reasons. + // + } + catch(java.lang.Exception e) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + e.printStackTrace(pw); + pw.flush(); + _logger.warning("ServiceManager: exception in stop for service " + name + "\n" + sw.toString()); + } + + try + { + info.communicator.destroy(); + } + catch(java.lang.Exception e) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + e.printStackTrace(pw); + pw.flush(); + _logger.warning("ServiceManager: exception in stop for service " + name + "\n" + sw.toString()); + } } } |