summaryrefslogtreecommitdiff
path: root/java/src/IceBox/ServiceManagerI.java
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2008-03-06 20:22:24 +0100
committerBenoit Foucher <benoit@zeroc.com>2008-03-06 20:22:24 +0100
commitd9f98281c0f45dac197280c9b2fed7bcb4d443a9 (patch)
tree747baa2face3b6f264a3959569d5bb8004b997b8 /java/src/IceBox/ServiceManagerI.java
parentmore PHP docu fixes (diff)
downloadice-d9f98281c0f45dac197280c9b2fed7bcb4d443a9.tar.bz2
ice-d9f98281c0f45dac197280c9b2fed7bcb4d443a9.tar.xz
ice-d9f98281c0f45dac197280c9b2fed7bcb4d443a9.zip
Fixed bug 2740 (again), IceBox observers fixes
Diffstat (limited to 'java/src/IceBox/ServiceManagerI.java')
-rw-r--r--java/src/IceBox/ServiceManagerI.java192
1 files changed, 86 insertions, 106 deletions
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java
index 6545cd39473..6be461c616b 100644
--- a/java/src/IceBox/ServiceManagerI.java
+++ b/java/src/IceBox/ServiceManagerI.java
@@ -93,7 +93,10 @@ public class ServiceManagerI extends _ServiceManagerDisp
if(started)
{
in.status = StatusStarted;
- observers = new java.util.HashSet<ServiceObserverPrx>(_observers);
+
+ java.util.List<String> services = new java.util.ArrayList<String>();
+ services.add(name);
+ servicesStarted(services, _observers);
}
else
{
@@ -105,13 +108,6 @@ public class ServiceManagerI extends _ServiceManagerDisp
_pendingStatusChanges = false;
notifyAll();
}
-
- if(observers != null)
- {
- java.util.List<String> services = new java.util.ArrayList<String>();
- services.add(name);
- servicesStarted(services, observers);
- }
}
public void
@@ -163,7 +159,6 @@ public class ServiceManagerI extends _ServiceManagerDisp
sw.toString());
}
- java.util.Set<ServiceObserverPrx> observers = null;
synchronized(this)
{
java.util.Iterator<ServiceInfo> p = _services.iterator();
@@ -175,7 +170,10 @@ public class ServiceManagerI extends _ServiceManagerDisp
if(stopped)
{
in.status = StatusStopped;
- observers = new java.util.HashSet<ServiceObserverPrx>(_observers);
+
+ java.util.List<String> services = new java.util.ArrayList<String>();
+ services.add(name);
+ servicesStopped(services, _observers);
}
else
{
@@ -187,13 +185,6 @@ public class ServiceManagerI extends _ServiceManagerDisp
_pendingStatusChanges = false;
notifyAll();
}
-
- if(observers != null)
- {
- java.util.List<String> services = new java.util.ArrayList<String>();
- services.add(name);
- servicesStopped(services, observers);
- }
}
public void
@@ -667,134 +658,125 @@ public class ServiceManagerI extends _ServiceManagerDisp
}
}
- private void
+ private synchronized void
stopAll()
{
- java.util.List<String> stoppedServices = new java.util.ArrayList<String>();
- java.util.Set<ServiceObserverPrx> observers = null;
+ //
+ // First wait for any active startService/stopService calls to complete.
+ //
+ while(_pendingStatusChanges)
+ {
+ try
+ {
+ wait();
+ }
+ catch(java.lang.InterruptedException ex)
+ {
+ }
+ }
- synchronized(this)
+ //
+ // For each service, we call stop on the service and flush its database environment to
+ // the disk. Services are stopped in the reverse order of the order they were started.
+ //
+ java.util.List<String> stoppedServices = new java.util.ArrayList<String>();
+ java.util.ListIterator<ServiceInfo> p = _services.listIterator(_services.size());
+ while(p.hasPrevious())
{
- //
- // First wait for any active startService/stopService calls to complete.
- //
- while(_pendingStatusChanges)
+ ServiceInfo info = p.previous();
+ if(info.status == StatusStarted)
{
try
{
- wait();
+ info.service.stop();
+ info.status = StatusStopped;
+ stoppedServices.add(info.name);
}
- catch(java.lang.InterruptedException ex)
+ 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 " + info.name + "\n" +
+ sw.toString());
}
}
- //
- // For each service, we call stop on the service and flush its database environment to
- // the disk. Services are stopped in the reverse order of the order they were started.
- //
- java.util.ListIterator<ServiceInfo> p = _services.listIterator(_services.size());
- while(p.hasPrevious())
+ try
{
- ServiceInfo info = p.previous();
- if(info.status == StatusStarted)
- {
- try
- {
- info.service.stop();
- info.status = StatusStopped;
- stoppedServices.add(info.name);
- }
- 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 " + info.name + "\n" +
- sw.toString());
- }
- }
+ _server.communicator().removeAdminFacet("IceBox.Service." + info.name + ".Properties");
+ }
+ catch(Ice.LocalException e)
+ {
+ // Ignored
+ }
+ if(info.communicator != null)
+ {
try
{
- _server.communicator().removeAdminFacet("IceBox.Service." + info.name + ".Properties");
+ info.communicator.shutdown();
+ info.communicator.waitForShutdown();
}
- catch(Ice.LocalException e)
+ catch(Ice.CommunicatorDestroyedException e)
{
- // Ignored
+ //
+ // Ignore, the service might have already destroyed
+ // the communicator for its own reasons.
+ //
}
-
- if(info.communicator != null)
+ catch(java.lang.Exception e)
{
- 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 " + info.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 " + info.name + "\n" +
- sw.toString());
- }
+ 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 " + info.name + "\n" +
+ sw.toString());
}
- }
- if(_sharedCommunicator != null)
- {
try
{
- _sharedCommunicator.destroy();
+ info.communicator.destroy();
}
- catch(Exception e)
+ 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: unknown exception while destroying shared communicator:\n" +
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
sw.toString());
}
- _sharedCommunicator = null;
}
+ }
- _services.clear();
- observers = new java.util.HashSet<ServiceObserverPrx>(_observers);
+ if(_sharedCommunicator != null)
+ {
+ try
+ {
+ _sharedCommunicator.destroy();
+ }
+ catch(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: unknown exception while destroying shared communicator:\n" +
+ sw.toString());
+ }
+ _sharedCommunicator = null;
}
- servicesStopped(stoppedServices, observers);
+ _services.clear();
+ servicesStopped(stoppedServices, _observers);
}
private void
servicesStarted(java.util.List<String> services, java.util.Set<ServiceObserverPrx> observers)
{
- assert !Thread.holdsLock(this);
-
if(services.size() > 0)
{
String[] servicesArray = services.toArray(new String[0]);
@@ -825,8 +807,6 @@ public class ServiceManagerI extends _ServiceManagerDisp
private void
servicesStopped(java.util.List<String> services, java.util.Set<ServiceObserverPrx> observers)
{
- assert !Thread.holdsLock(this);
-
if(services.size() > 0)
{
String[] servicesArray = services.toArray(new String[0]);