summaryrefslogtreecommitdiff
path: root/java/src/Ice/PluginManagerI.java
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
committerBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
commitabada90e3f84dc703b8ddc9efcbed8a946fadead (patch)
tree2c6f9dccd510ea97cb927a7bd635422efaae547a /java/src/Ice/PluginManagerI.java
parentremoving trace message (diff)
downloadice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip
Expanded tabs into spaces
Diffstat (limited to 'java/src/Ice/PluginManagerI.java')
-rw-r--r--java/src/Ice/PluginManagerI.java350
1 files changed, 175 insertions, 175 deletions
diff --git a/java/src/Ice/PluginManagerI.java b/java/src/Ice/PluginManagerI.java
index 5a29965c3a9..e88bb3cc129 100644
--- a/java/src/Ice/PluginManagerI.java
+++ b/java/src/Ice/PluginManagerI.java
@@ -16,84 +16,84 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
public synchronized void
initializePlugins()
{
- if(_initialized)
- {
- InitializationException ex = new InitializationException();
- ex.reason = "plugins already initialized";
- throw ex;
- }
+ if(_initialized)
+ {
+ InitializationException ex = new InitializationException();
+ ex.reason = "plugins already initialized";
+ throw ex;
+ }
- //
- // Invoke initialize() on the plugins, in the order they were loaded.
- //
- java.util.ArrayList initializedPlugins = new java.util.ArrayList();
- try
- {
- java.util.Iterator i = _initOrder.iterator();
- while(i.hasNext())
- {
- Plugin p = (Plugin)i.next();
- p.initialize();
- initializedPlugins.add(p);
- }
- }
- catch(RuntimeException ex)
- {
- //
- // Destroy the plugins that have been successfully initialized, in the
- // reverse order.
- //
- java.util.ListIterator i = initializedPlugins.listIterator(initializedPlugins.size());
- while(i.hasPrevious())
- {
- Plugin p = (Plugin)i.previous();
- try
- {
- p.destroy();
- }
- catch(RuntimeException e)
- {
- // Ignore.
- }
- }
- throw ex;
- }
+ //
+ // Invoke initialize() on the plugins, in the order they were loaded.
+ //
+ java.util.ArrayList initializedPlugins = new java.util.ArrayList();
+ try
+ {
+ java.util.Iterator i = _initOrder.iterator();
+ while(i.hasNext())
+ {
+ Plugin p = (Plugin)i.next();
+ p.initialize();
+ initializedPlugins.add(p);
+ }
+ }
+ catch(RuntimeException ex)
+ {
+ //
+ // Destroy the plugins that have been successfully initialized, in the
+ // reverse order.
+ //
+ java.util.ListIterator i = initializedPlugins.listIterator(initializedPlugins.size());
+ while(i.hasPrevious())
+ {
+ Plugin p = (Plugin)i.previous();
+ try
+ {
+ p.destroy();
+ }
+ catch(RuntimeException e)
+ {
+ // Ignore.
+ }
+ }
+ throw ex;
+ }
- _initialized = true;
+ _initialized = true;
}
public synchronized Plugin
getPlugin(String name)
{
- if(_communicator == null)
- {
- throw new CommunicatorDestroyedException();
- }
+ if(_communicator == null)
+ {
+ throw new CommunicatorDestroyedException();
+ }
Plugin p = (Plugin)_plugins.get(name);
if(p != null)
{
return p;
}
- NotRegisteredException ex = new NotRegisteredException();
- ex.id = name;
- ex.kindOfObject = _kindOfObject;
+ NotRegisteredException ex = new NotRegisteredException();
+ ex.id = name;
+ ex.kindOfObject = _kindOfObject;
throw ex;
}
public synchronized void
addPlugin(String name, Plugin plugin)
{
- if(_communicator == null)
- {
- throw new CommunicatorDestroyedException();
- }
+ if(_communicator == null)
+ {
+ throw new CommunicatorDestroyedException();
+ }
if(_plugins.containsKey(name))
{
- AlreadyRegisteredException ex = new AlreadyRegisteredException();
- ex.id = name;
- ex.kindOfObject = _kindOfObject;
+ AlreadyRegisteredException ex = new AlreadyRegisteredException();
+ ex.id = name;
+ ex.kindOfObject = _kindOfObject;
throw ex;
}
_plugins.put(name, plugin);
@@ -102,31 +102,31 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
public synchronized void
destroy()
{
- if(_communicator != null)
- {
- java.util.Iterator i = _plugins.values().iterator();
- while(i.hasNext())
- {
- Plugin p = (Plugin)i.next();
- p.destroy();
- }
+ if(_communicator != null)
+ {
+ java.util.Iterator i = _plugins.values().iterator();
+ while(i.hasNext())
+ {
+ Plugin p = (Plugin)i.next();
+ p.destroy();
+ }
- _logger = null;
- _communicator = null;
- }
+ _logger = null;
+ _communicator = null;
+ }
}
public
PluginManagerI(Communicator communicator)
{
_communicator = communicator;
- _initialized = false;
+ _initialized = false;
}
public void
loadPlugins(StringSeqHolder cmdArgs)
{
- assert(_communicator != null);
+ assert(_communicator != null);
//
// Load and initialize the plug-ins defined in the property set
@@ -135,113 +135,113 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
//
// Ice.Plugin.name=entry_point [args]
//
- // If the Ice.PluginLoadOrder property is defined, load the
- // specified plugins in the specified order, then load any
- // remaining plugins.
- //
+ // If the Ice.PluginLoadOrder property is defined, load the
+ // specified plugins in the specified order, then load any
+ // remaining plugins.
+ //
final String prefix = "Ice.Plugin.";
- Properties properties = _communicator.getProperties();
+ Properties properties = _communicator.getProperties();
java.util.Map plugins = properties.getPropertiesForPrefix(prefix);
- final String loadOrder = properties.getProperty("Ice.PluginLoadOrder");
- if(loadOrder.length() > 0)
- {
- String[] names = loadOrder.split("[, \t\n]+");
- for(int i = 0; i < names.length; ++i)
- {
- if(_plugins.containsKey(names[i]))
- {
- PluginInitializationException ex = new PluginInitializationException();
- ex.reason = "plugin `" + names[i] + "' already loaded";
- throw ex;
- }
+ final String loadOrder = properties.getProperty("Ice.PluginLoadOrder");
+ if(loadOrder.length() > 0)
+ {
+ String[] names = loadOrder.split("[, \t\n]+");
+ for(int i = 0; i < names.length; ++i)
+ {
+ if(_plugins.containsKey(names[i]))
+ {
+ PluginInitializationException ex = new PluginInitializationException();
+ ex.reason = "plugin `" + names[i] + "' already loaded";
+ throw ex;
+ }
- final String key = "Ice.Plugin." + names[i];
- if(plugins.containsKey(key))
- {
- final String value = (String)plugins.get(key);
- loadPlugin(names[i], value, cmdArgs, false);
- plugins.remove(key);
- }
- else
- {
- PluginInitializationException ex = new PluginInitializationException();
- ex.reason = "plugin `" + names[i] + "' not defined";
- throw ex;
- }
- }
- }
+ final String key = "Ice.Plugin." + names[i];
+ if(plugins.containsKey(key))
+ {
+ final String value = (String)plugins.get(key);
+ loadPlugin(names[i], value, cmdArgs, false);
+ plugins.remove(key);
+ }
+ else
+ {
+ PluginInitializationException ex = new PluginInitializationException();
+ ex.reason = "plugin `" + names[i] + "' not defined";
+ throw ex;
+ }
+ }
+ }
- //
- // Load any remaining plugins that weren't specified in PluginLoadOrder.
- //
+ //
+ // Load any remaining plugins that weren't specified in PluginLoadOrder.
+ //
java.util.Iterator p = plugins.entrySet().iterator();
while(p.hasNext())
{
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
String name = ((String)entry.getKey()).substring(prefix.length());
String value = (String)entry.getValue();
loadPlugin(name, value, cmdArgs, false);
}
- //
- // Check for a Logger Plugin
- //
- String loggerStr = properties.getProperty("Ice.LoggerPlugin");
- if(loggerStr.length() != 0)
- {
- loadPlugin("Logger", loggerStr, cmdArgs, true);
- }
+ //
+ // Check for a Logger Plugin
+ //
+ String loggerStr = properties.getProperty("Ice.LoggerPlugin");
+ if(loggerStr.length() != 0)
+ {
+ loadPlugin("Logger", loggerStr, cmdArgs, true);
+ }
- //
- // An application can set Ice.InitPlugins=0 if it wants to postpone
- // initialization until after it has interacted directly with the
- // plugins.
- //
- if(properties.getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0)
- {
- initializePlugins();
- }
+ //
+ // An application can set Ice.InitPlugins=0 if it wants to postpone
+ // initialization until after it has interacted directly with the
+ // plugins.
+ //
+ if(properties.getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0)
+ {
+ initializePlugins();
+ }
}
private void
loadPlugin(String name, String pluginSpec, StringSeqHolder cmdArgs, boolean isLogger)
{
- assert(_communicator != null);
+ assert(_communicator != null);
- //
- // Separate the entry point from the arguments.
- //
- String className;
- String[] args;
- int pos = pluginSpec.indexOf(' ');
- if(pos == -1)
- {
- pos = pluginSpec.indexOf('\t');
- }
- if(pos == -1)
- {
- pos = pluginSpec.indexOf('\n');
- }
- if(pos == -1)
- {
- className = pluginSpec;
- args = new String[0];
- }
- else
- {
- className = pluginSpec.substring(0, pos);
- args = pluginSpec.substring(pos).trim().split("[ \t\n]+", pos);
- }
+ //
+ // Separate the entry point from the arguments.
+ //
+ String className;
+ String[] args;
+ int pos = pluginSpec.indexOf(' ');
+ if(pos == -1)
+ {
+ pos = pluginSpec.indexOf('\t');
+ }
+ if(pos == -1)
+ {
+ pos = pluginSpec.indexOf('\n');
+ }
+ if(pos == -1)
+ {
+ className = pluginSpec;
+ args = new String[0];
+ }
+ else
+ {
+ className = pluginSpec.substring(0, pos);
+ args = pluginSpec.substring(pos).trim().split("[ \t\n]+", pos);
+ }
- //
- // Convert command-line options into properties. First we
- // convert the options from the plug-in configuration, then
- // we convert the options from the application command-line.
- //
- Properties properties = _communicator.getProperties();
- args = properties.parseCommandLineOptions(name, args);
- cmdArgs.value = properties.parseCommandLineOptions(name, cmdArgs.value);
+ //
+ // Convert command-line options into properties. First we
+ // convert the options from the plug-in configuration, then
+ // we convert the options from the application command-line.
+ //
+ Properties properties = _communicator.getProperties();
+ args = properties.parseCommandLineOptions(name, args);
+ cmdArgs.value = properties.parseCommandLineOptions(name, cmdArgs.value);
//
// Instantiate the class.
@@ -254,20 +254,20 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
java.lang.Object obj = c.newInstance();
try
{
- if(isLogger)
- {
+ if(isLogger)
+ {
loggerFactory = (LoggerFactory)obj;
- }
- else
- {
+ }
+ else
+ {
pluginFactory = (PluginFactory)obj;
- }
+ }
}
catch(ClassCastException ex)
{
PluginInitializationException e = new PluginInitializationException();
e.reason = "class " + className + " does not implement " +
- (isLogger ? "Ice.LoggerFactory" : "Ice.PluginFactory");
+ (isLogger ? "Ice.LoggerFactory" : "Ice.PluginFactory");
e.initCause(ex);
throw e;
}
@@ -297,8 +297,8 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
//
// Invoke the factory.
//
- if(isLogger)
- {
+ if(isLogger)
+ {
try
{
_logger = loggerFactory.create(_communicator, args);
@@ -311,15 +311,15 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
throw e;
}
- if(_logger == null)
- {
+ if(_logger == null)
+ {
PluginInitializationException e = new PluginInitializationException();
e.reason = "failure in factory " + className;
throw e;
- }
- }
- else
- {
+ }
+ }
+ else
+ {
Plugin plugin = null;
try
{
@@ -337,16 +337,16 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
throw e;
}
- if(plugin == null)
- {
+ if(plugin == null)
+ {
PluginInitializationException e = new PluginInitializationException();
e.reason = "failure in factory " + className;
throw e;
- }
+ }
_plugins.put(name, plugin);
- _initOrder.add(plugin);
- }
+ _initOrder.add(plugin);
+ }
}
public Logger