summaryrefslogtreecommitdiff
path: root/java/src/IceBox/ServiceManagerI.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/IceBox/ServiceManagerI.java')
-rw-r--r--java/src/IceBox/ServiceManagerI.java143
1 files changed, 72 insertions, 71 deletions
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java
index 611657a1773..297438f06f4 100644
--- a/java/src/IceBox/ServiceManagerI.java
+++ b/java/src/IceBox/ServiceManagerI.java
@@ -21,7 +21,8 @@ public class ServiceManagerI extends _ServiceManagerDisp
_server = server;
_logger = _server.communicator().getLogger();
_argv = args;
- _traceServiceObserver = _server.communicator().getProperties().getPropertyAsInt("IceBox.Trace.ServiceObserver");
+ _traceServiceObserver =
+ _server.communicator().getProperties().getPropertyAsInt("IceBox.Trace.ServiceObserver");
}
public java.util.Map
@@ -76,10 +77,10 @@ public class ServiceManagerI extends _ServiceManagerDisp
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
e.printStackTrace(pw);
pw.flush();
- _logger.warning("ServiceManager: exception in start for service " + info.name + "\n" +
+ _logger.warning("ServiceManager: exception in start for service " + info.name + "\n" +
sw.toString());
}
-
+
java.util.Set<ServiceObserverPrx> observers = null;
synchronized(this)
{
@@ -92,7 +93,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
if(started)
{
in.status = StatusStarted;
- observers = (java.util.Set<ServiceObserverPrx>)_observers.clone();
+ observers = new java.util.HashSet<ServiceObserverPrx>(_observers);
}
else
{
@@ -107,7 +108,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
if(observers != null)
{
- java.util.List<String> services = new java.util.Vector<String>();
+ java.util.List<String> services = new java.util.ArrayList<String>();
services.add(name);
servicesStarted(services, observers);
}
@@ -158,10 +159,10 @@ public class ServiceManagerI extends _ServiceManagerDisp
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" +
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
sw.toString());
}
-
+
java.util.Set<ServiceObserverPrx> observers = null;
synchronized(this)
{
@@ -174,7 +175,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
if(stopped)
{
in.status = StatusStopped;
- observers = (java.util.Set<ServiceObserverPrx>)_observers.clone();
+ observers = new java.util.HashSet<ServiceObserverPrx>(_observers);
}
else
{
@@ -189,7 +190,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
if(observers != null)
{
- java.util.List<String> services = new java.util.Vector<String>();
+ java.util.List<String> services = new java.util.ArrayList<String>();
services.add(name);
servicesStopped(services, observers);
}
@@ -212,9 +213,9 @@ public class ServiceManagerI extends _ServiceManagerDisp
{
_logger.trace("IceBox.ServiceObserver",
"Added service observer " + _server.communicator().proxyToString(observer));
- }
-
-
+ }
+
+
for(ServiceInfo info: _services)
{
if(info.status == StatusStarted)
@@ -222,10 +223,10 @@ public class ServiceManagerI extends _ServiceManagerDisp
activeServices.add(info.name);
}
}
-
+
}
}
-
+
if(activeServices.size() > 0)
{
AMI_ServiceObserver_servicesStarted cb = new AMI_ServiceObserver_servicesStarted()
@@ -234,7 +235,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
{
// ok, success
}
-
+
public void ice_exception(Ice.LocalException ex)
{
//
@@ -243,7 +244,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
removeObserver(observer, ex);
}
};
-
+
observer.servicesStarted_async(cb, activeServices.toArray(new String[0]));
}
}
@@ -299,7 +300,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
// then load any remaining services.
//
final String prefix = "IceBox.Service.";
- java.util.Map services = properties.getPropertiesForPrefix(prefix);
+ java.util.Map<String, String> services = properties.getPropertiesForPrefix(prefix);
if(loadOrder != null)
{
for(int i = 0; i < loadOrder.length; ++i)
@@ -307,7 +308,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
if(loadOrder[i].length() > 0)
{
String key = prefix + loadOrder[i];
- String value = (String)services.get(key);
+ String value = services.get(key);
if(value == null)
{
FailureException ex = new FailureException();
@@ -319,12 +320,12 @@ public class ServiceManagerI extends _ServiceManagerDisp
}
}
}
- java.util.Iterator p = services.entrySet().iterator();
+ java.util.Iterator<java.util.Map.Entry<String, String> > p = services.entrySet().iterator();
while(p.hasNext())
{
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- String name = ((String)entry.getKey()).substring(prefix.length());
- String value = (String)entry.getValue();
+ java.util.Map.Entry<String, String> entry = p.next();
+ String name = entry.getKey().substring(prefix.length());
+ String value = entry.getValue();
load(name, value);
}
@@ -354,7 +355,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
//
_server.shutdownOnInterrupt();
-
+
//
// Register "this" as a facet to the Admin object and
// create Admin object
@@ -365,7 +366,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
//
// Add a Properties facet for each service
- //
+ //
for(ServiceInfo info: _services)
{
Ice.Communicator communicator = info.communicator != null ? info.communicator : _sharedCommunicator;
@@ -382,7 +383,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
//
}
- //
+ //
// Start request dispatching after we've started the services.
//
if(adapter != null)
@@ -487,7 +488,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
// shared communicator, depending on the value of the
// IceBox.UseSharedCommunicator property.
//
- java.util.ArrayList l = new java.util.ArrayList();
+ java.util.List<String> l = new java.util.ArrayList<String>();
for(int j = 0; j < args.length; j++)
{
l.add(args[j]);
@@ -499,7 +500,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
l.add(_argv[j]);
}
}
-
+
Ice.StringSeqHolder serviceArgs = new Ice.StringSeqHolder();
serviceArgs.value = (String[])l.toArray(new String[0]);
@@ -573,25 +574,26 @@ public class ServiceManagerI extends _ServiceManagerDisp
//
// Erase properties in 'properties'
//
- java.util.Map allProps = properties.getPropertiesForPrefix("");
- java.util.Iterator p = allProps.keySet().iterator();
+ java.util.Map<String, String> allProps = properties.getPropertiesForPrefix("");
+ java.util.Iterator<String> p = allProps.keySet().iterator();
while(p.hasNext())
{
- String key = (String)p.next();
+ String key = p.next();
if(svcProperties.getProperty(key).length() == 0)
{
properties.setProperty(key, "");
}
}
-
+
//
// Add the service properties to the shared communicator properties.
//
- p = svcProperties.getPropertiesForPrefix("").entrySet().iterator();
- while(p.hasNext())
+ java.util.Iterator<java.util.Map.Entry<String, String> > q =
+ svcProperties.getPropertiesForPrefix("").entrySet().iterator();
+ while(q.hasNext())
{
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- properties.setProperty((String)entry.getKey(), (String)entry.getValue());
+ java.util.Map.Entry<String, String> entry = q.next();
+ properties.setProperty(entry.getKey(), entry.getValue());
}
//
@@ -605,7 +607,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
info.communicator = createCommunicator(service, serviceArgs);
communicator = info.communicator;
}
-
+
try
{
info.args = serviceArgs.value;
@@ -614,8 +616,8 @@ public class ServiceManagerI extends _ServiceManagerDisp
//
// There is no need to notify the observers since the 'start all'
- // (that indirectly calls this method) occurs before the creation of
- // the Server Admin object, and before the activation of the main
+ // (that indirectly calls this method) occurs before the creation of
+ // the Server Admin object, and before the activation of the main
// object adapter (so before any observer can be registered)
//
}
@@ -644,7 +646,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
_logger.warning("ServiceManager: exception in shutting down communicator for service "
+ service + "\n" + sw.toString());
}
-
+
try
{
info.communicator.destroy();
@@ -680,9 +682,9 @@ public class ServiceManagerI extends _ServiceManagerDisp
private void
stopAll()
{
- java.util.List<String> stoppedServices = new java.util.Vector<String>();
+ java.util.List<String> stoppedServices = new java.util.ArrayList<String>();
java.util.Set<ServiceObserverPrx> observers = null;
-
+
synchronized(this)
{
//
@@ -698,15 +700,15 @@ public class ServiceManagerI extends _ServiceManagerDisp
{
}
}
-
+
//
- // For each service, we call stop on the service and flush its database environment to
+ // 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 p = _services.listIterator(_services.size());
+ java.util.ListIterator<ServiceInfo> p = _services.listIterator(_services.size());
while(p.hasPrevious())
{
- ServiceInfo info = (ServiceInfo)p.previous();
+ ServiceInfo info = p.previous();
if(info.status == StatusStarted)
{
try
@@ -721,11 +723,11 @@ public class ServiceManagerI extends _ServiceManagerDisp
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" +
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
sw.toString());
}
}
-
+
try
{
_server.communicator().removeAdminFacet("IceBox.Service." + info.name + ".Properties");
@@ -734,7 +736,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
{
// Ignored
}
-
+
if(info.communicator != null)
{
try
@@ -755,10 +757,10 @@ public class ServiceManagerI extends _ServiceManagerDisp
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" +
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
sw.toString());
}
-
+
try
{
info.communicator.destroy();
@@ -769,7 +771,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
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" +
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
sw.toString());
}
}
@@ -787,20 +789,19 @@ public class ServiceManagerI extends _ServiceManagerDisp
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: unknown exception while destroying shared communicator:\n" +
sw.toString());
}
_sharedCommunicator = null;
}
_services.clear();
- observers = (java.util.Set<ServiceObserverPrx>)_observers.clone();
+ observers = new java.util.HashSet<ServiceObserverPrx>(_observers);
}
servicesStopped(stoppedServices, observers);
}
-
private void
servicesStarted(java.util.List<String> services, java.util.Set<ServiceObserverPrx> observers)
{
@@ -818,7 +819,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
{
// ok, success
}
-
+
public void ice_exception(Ice.LocalException ex)
{
//
@@ -850,7 +851,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
{
// ok, success
}
-
+
public void ice_exception(Ice.LocalException ex)
{
//
@@ -874,8 +875,8 @@ public class ServiceManagerI extends _ServiceManagerDisp
observerRemoved(observer, ex);
}
}
-
- private void
+
+ private void
observerRemoved(ServiceObserverPrx observer, RuntimeException ex)
{
if(_traceServiceObserver >= 1)
@@ -883,14 +884,14 @@ public class ServiceManagerI extends _ServiceManagerDisp
_logger.trace("IceBox.ServiceObserver",
"Removed service observer " + _server.communicator().proxyToString(observer)
+ "\nafter catching " + ex.toString());
- }
- }
+ }
+ }
public final static int StatusStopping = 0;
public final static int StatusStopped = 1;
public final static int StatusStarting = 2;
public final static int StatusStarted = 3;
-
+
static class ServiceInfo implements Cloneable
{
public Object clone()
@@ -919,19 +920,19 @@ public class ServiceManagerI extends _ServiceManagerDisp
{
_properties = properties;
}
-
+
public String
getProperty(String name, Ice.Current current)
{
return _properties.getProperty(name);
}
-
- public java.util.TreeMap
+
+ public java.util.TreeMap<String, String>
getPropertiesForPrefix(String name, Ice.Current current)
{
- return new java.util.TreeMap(_properties.getPropertiesForPrefix(name));
+ return new java.util.TreeMap<String, String>(_properties.getPropertiesForPrefix(name));
}
-
+
private final Ice.Properties _properties;
}
@@ -956,8 +957,8 @@ public class ServiceManagerI extends _ServiceManagerDisp
}
//
- // Set the default program name for the service properties. By default it's
- // the IceBox program name + "-" + the service name, or just the IceBox
+ // Set the default program name for the service properties. By default it's
+ // the IceBox program name + "-" + the service name, or just the IceBox
// program name if we're creating the shared communicator (service == "").
//
String programName = communicatorProperties.getProperty("Ice.ProgramName");
@@ -991,11 +992,11 @@ public class ServiceManagerI extends _ServiceManagerDisp
// read the service config file if it's specified with --Ice.Config.
//
properties = Ice.Util.createProperties(args, properties);
-
+
if(service.length() > 0)
{
//
- // Next, parse the service "<service>.*" command line options (the Ice command
+ // Next, parse the service "<service>.*" command line options (the Ice command
// line options were parsed by the createProperties above)
//
args.value = properties.parseCommandLineOptions(service, args.value);
@@ -1003,7 +1004,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
}
//
- // Remaining command line options are passed to the communicator. This is
+ // Remaining command line options are passed to the communicator. This is
// necessary for Ice plugin properties (e.g.: IceSSL).
//
Ice.InitializationData initData = new Ice.InitializationData();