diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-04-29 14:12:15 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-04-29 14:12:15 -0230 |
commit | 2532cae1fa4d5893e90e938da376671c6e530b93 (patch) | |
tree | 079fcc63d3094ae272105bb9c94126b6d1ac30d8 | |
parent | Bug 2433 - new logger plugin mechanism (diff) | |
download | ice-2532cae1fa4d5893e90e938da376671c6e530b93.tar.bz2 ice-2532cae1fa4d5893e90e938da376671c6e530b93.tar.xz ice-2532cae1fa4d5893e90e938da376671c6e530b93.zip |
Bug 2433 - changed logger plugin mechanism
-rw-r--r-- | cpp/include/Ice/LoggerUtil.h | 8 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/LoggerUtil.cpp | 16 | ||||
-rw-r--r-- | cpp/src/Ice/PluginManagerI.cpp | 68 | ||||
-rw-r--r-- | cpp/src/Ice/PluginManagerI.h | 6 | ||||
-rw-r--r-- | cs/src/Ice/.depend | 2 | ||||
-rw-r--r-- | cs/src/Ice/Instance.cs | 14 | ||||
-rw-r--r-- | cs/src/Ice/LoggerPlugin.cs | 45 | ||||
-rw-r--r-- | cs/src/Ice/Makefile | 1 | ||||
-rw-r--r-- | cs/src/Ice/Makefile.mak | 1 | ||||
-rw-r--r-- | cs/src/Ice/PluginManagerI.cs | 147 | ||||
-rw-r--r-- | java/src/Ice/LoggerFactory.java | 18 | ||||
-rw-r--r-- | java/src/Ice/LoggerPlugin.java | 45 | ||||
-rw-r--r-- | java/src/Ice/PluginManagerI.java | 119 | ||||
-rw-r--r-- | java/src/IceInternal/Instance.java | 14 | ||||
-rw-r--r-- | slice/Ice/Plugin.ice | 12 |
16 files changed, 194 insertions, 328 deletions
diff --git a/cpp/include/Ice/LoggerUtil.h b/cpp/include/Ice/LoggerUtil.h index 8028e10aece..3c64cbf9eb7 100644 --- a/cpp/include/Ice/LoggerUtil.h +++ b/cpp/include/Ice/LoggerUtil.h @@ -150,15 +150,15 @@ template<class Y> ICE_API Trace& operator<<(Trace&, std::ios_base& (*)(std::ios_base&)); // -// A special plugin that sets logger during construction (when the provided logger is not -// null). Both initialize and destroy are no-op. See Ice::InitializationData. +// A special plugin that sets logger during construction. Both initialize and +// destroy are no-op. See Ice::InitializationData. // -class ICE_API IceLoggerPlugin : public Ice::Plugin +class ICE_API LoggerPlugin : public Ice::Plugin { public: - IceLoggerPlugin(const CommunicatorPtr& communicator, const LoggerPtr&); + LoggerPlugin(const CommunicatorPtr& communicator, const LoggerPtr&); virtual void initialize(); diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 6a56fdfa3bd..8a1e5f45405 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -1079,12 +1079,6 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) assert(pluginManagerImpl); pluginManagerImpl->loadPlugins(argc, argv); - LoggerPtr logger = pluginManagerImpl->getLogger(); - if(logger) - { - _initData.logger = logger; - } - // // Get default router and locator proxies. Don't move this // initialization before the plug-in initialization!!! The proxies diff --git a/cpp/src/Ice/LoggerUtil.cpp b/cpp/src/Ice/LoggerUtil.cpp index e015980c6d0..d6a534401e5 100644 --- a/cpp/src/Ice/LoggerUtil.cpp +++ b/cpp/src/Ice/LoggerUtil.cpp @@ -154,28 +154,28 @@ Ice::operator<<(Trace& out, ios_base& (*val)(ios_base&)) return out; } -Ice::IceLoggerPlugin::IceLoggerPlugin(const CommunicatorPtr& communicator, - const LoggerPtr& logger) +Ice::LoggerPlugin::LoggerPlugin(const CommunicatorPtr& communicator, const LoggerPtr& logger) { if(communicator == 0) { throw PluginInitializationException(__FILE__, __LINE__, "Communicator cannot be null"); } - IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); - - if(logger != 0) + if(logger == 0) { - instance->setLogger(logger); + throw PluginInitializationException(__FILE__, __LINE__, "Logger cannot be null"); } + + IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); + instance->setLogger(logger); } void -Ice::IceLoggerPlugin::initialize() +Ice::LoggerPlugin::initialize() { } void -Ice::IceLoggerPlugin::destroy() +Ice::LoggerPlugin::destroy() { } diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp index 5c685b6c3bd..36812c69ac5 100644 --- a/cpp/src/Ice/PluginManagerI.cpp +++ b/cpp/src/Ice/PluginManagerI.cpp @@ -22,7 +22,6 @@ using namespace IceInternal; const char * const Ice::PluginManagerI::_kindOfObject = "plugin"; typedef Ice::Plugin* (*PLUGIN_FACTORY)(const CommunicatorPtr&, const string&, const StringSeq&); -typedef Ice::Logger* (*LOGGER_FACTORY)(const CommunicatorPtr&, const StringSeq&); // DEPRECATED void Ice::PluginManagerI::initializePlugins() @@ -126,7 +125,6 @@ Ice::PluginManagerI::destroy() r->second = 0; } - _logger = 0; _communicator = 0; } @@ -252,13 +250,6 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) } } - // DEPRECATED - string loggerStr = properties->getProperty("Ice.LoggerPlugin"); - if(loggerStr.length() != 0) - { - loadPlugin("Logger", loggerStr, cmdArgs, true); - } - stringSeqToArgs(cmdArgs, argc, argv); // @@ -273,7 +264,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) } void -Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, StringSeq& cmdArgs, bool isLogger) +Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, StringSeq& cmdArgs) { assert(_communicator); @@ -341,57 +332,20 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St // Invoke the factory function. No exceptions can be raised // by the factory function because it's declared extern "C". // - if(isLogger) + PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym; + plugin = factory(_communicator, name, args); + if(!plugin) { - // DEPRECATED - LOGGER_FACTORY factory = (LOGGER_FACTORY)sym; - _logger = factory(_communicator, args); - if(!_logger) - { - PluginInitializationException e(__FILE__, __LINE__); - ostringstream out; - out << "failure in entry point `" << entryPoint << "'"; - e.reason = out.str(); - throw e; - } + PluginInitializationException e(__FILE__, __LINE__); + ostringstream out; + out << "failure in entry point `" << entryPoint << "'"; + e.reason = out.str(); + throw e; } - else - { - PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym; - plugin = factory(_communicator, name, args); - if(!plugin) - { - PluginInitializationException e(__FILE__, __LINE__); - ostringstream out; - out << "failure in entry point `" << entryPoint << "'"; - e.reason = out.str(); - throw e; - } - if(name == "Logger") - { - LoggerPluginPtr loggerPlugin = dynamic_cast<LoggerPlugin*>(plugin.get()); - if(!loggerPlugin) - { - PluginInitializationException e(__FILE__, __LINE__); - ostringstream out; - out << "Ice.Plugin.Logger does not implement an Ice::LoggerPlugin"; - e.reason = out.str(); - throw e; - } - _logger = loggerPlugin->getLogger(); - } - - _plugins[name] = plugin; - _initOrder.push_back(plugin); - } + _plugins[name] = plugin; + _initOrder.push_back(plugin); _libraries->add(library); } -Ice::LoggerPtr -Ice::PluginManagerI::getLogger() const -{ - return _logger; -} - diff --git a/cpp/src/Ice/PluginManagerI.h b/cpp/src/Ice/PluginManagerI.h index fb4f6a528e5..ec715e6770d 100644 --- a/cpp/src/Ice/PluginManagerI.h +++ b/cpp/src/Ice/PluginManagerI.h @@ -13,7 +13,6 @@ #include <Ice/Plugin.h> #include <Ice/InstanceF.h> #include <Ice/CommunicatorF.h> -#include <Ice/LoggerF.h> #include <Ice/DynamicLibraryF.h> #include <Ice/BuiltinSequences.h> #include <IceUtil/Mutex.h> @@ -37,8 +36,7 @@ private: friend class IceInternal::Instance; void loadPlugins(int&, char*[]); - void loadPlugin(const std::string&, const std::string&, StringSeq&, bool = false); - LoggerPtr getLogger() const; + void loadPlugin(const std::string&, const std::string&, StringSeq&); CommunicatorPtr _communicator; IceInternal::DynamicLibraryListPtr _libraries; @@ -47,8 +45,6 @@ private: std::vector<PluginPtr> _initOrder; bool _initialized; static const char * const _kindOfObject; - - LoggerPtr _logger; }; } diff --git a/cs/src/Ice/.depend b/cs/src/Ice/.depend index 63451bb9892..40b0faa832b 100644 --- a/cs/src/Ice/.depend +++ b/cs/src/Ice/.depend @@ -9,7 +9,7 @@ ImplicitContext.cs: $(slicedir)/Ice/ImplicitContext.ice $(slicedir)/Ice/LocalExc LocalException.cs: $(slicedir)/Ice/LocalException.ice $(slicedir)/Ice/Identity.ice $(slicedir)/Ice/BuiltinSequences.ice Locator.cs: $(slicedir)/Ice/Locator.ice $(slicedir)/Ice/Identity.ice $(slicedir)/Ice/ProcessF.ice Logger.cs: $(slicedir)/Ice/Logger.ice -ObjectAdapter.cs: $(slicedir)/Ice/ObjectAdapter.ice $(slicedir)/Ice/CommunicatorF.ice $(slicedir)/Ice/ServantLocatorF.ice $(slicedir)/Ice/RouterF.ice $(slicedir)/Ice/LocatorF.ice $(slicedir)/Ice/Identity.ice $(slicedir)/Ice/FacetMap.ice +ObjectAdapter.cs: $(slicedir)/Ice/ObjectAdapter.ice $(slicedir)/Ice/CommunicatorF.ice $(slicedir)/Ice/ServantLocatorF.ice $(slicedir)/Ice/LocatorF.ice $(slicedir)/Ice/Identity.ice $(slicedir)/Ice/FacetMap.ice ObjectFactory.cs: $(slicedir)/Ice/ObjectFactory.ice Plugin.cs: $(slicedir)/Ice/Plugin.ice $(slicedir)/Ice/LoggerF.ice Process.cs: $(slicedir)/Ice/Process.ice diff --git a/cs/src/Ice/Instance.cs b/cs/src/Ice/Instance.cs index 45da4ea25ed..2c9012ea81c 100644 --- a/cs/src/Ice/Instance.cs +++ b/cs/src/Ice/Instance.cs @@ -580,6 +580,15 @@ namespace IceInternal } } + public void + setLogger(Ice.Logger logger) + { + // + // No locking, as it can only be called during plugin loading + // + _initData.logger = logger; + } + // // Only for use by Ice.CommunicatorI // @@ -759,11 +768,6 @@ namespace IceInternal // Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager; pluginManagerImpl.loadPlugins(ref args); - Ice.Logger logger = pluginManagerImpl.getLogger(); - if(logger != null) - { - _initData.logger = logger; - } // // Get default router and locator proxies. Don't move this diff --git a/cs/src/Ice/LoggerPlugin.cs b/cs/src/Ice/LoggerPlugin.cs new file mode 100644 index 00000000000..d79ce89706d --- /dev/null +++ b/cs/src/Ice/LoggerPlugin.cs @@ -0,0 +1,45 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +namespace Ice +{ + public sealed class LoggerPlugin : Ice.Plugin + { + public + LoggerPlugin(Communicator communicator, Logger logger) + { + if(communicator == null) + { + PluginInitializationException ex = new PluginInitializationException(); + ex.reason = "Communicator cannot be null"; + throw ex; + } + + if(logger == null) + { + PluginInitializationException ex = new PluginInitializationException(); + ex.reason = "Logger cannot be null"; + throw ex; + } + + IceInternal.Instance instance = Util.getInstance(communicator); + instance.setLogger(logger); + } + + public void + initialize() + { + } + + public void + destroy() + { + } + } +} diff --git a/cs/src/Ice/Makefile b/cs/src/Ice/Makefile index 9f51921018b..bd65ee7fa9a 100644 --- a/cs/src/Ice/Makefile +++ b/cs/src/Ice/Makefile @@ -50,6 +50,7 @@ SRCS = Acceptor.cs \ LocalObject.cs \ LocatorInfo.cs \ LoggerI.cs \ + LoggerPlugin.cs \ Network.cs \ ObjectAdapterFactory.cs \ ObjectAdapterI.cs \ diff --git a/cs/src/Ice/Makefile.mak b/cs/src/Ice/Makefile.mak index 96719dc4c32..eb3c5761577 100644 --- a/cs/src/Ice/Makefile.mak +++ b/cs/src/Ice/Makefile.mak @@ -50,6 +50,7 @@ SRCS = Acceptor.cs \ LocalObject.cs \
LocatorInfo.cs \
LoggerI.cs \
+ LoggerPlugin.cs \
Network.cs \
ObjectAdapterFactory.cs \
ObjectAdapterI.cs \
diff --git a/cs/src/Ice/PluginManagerI.cs b/cs/src/Ice/PluginManagerI.cs index f44e70ed37e..f762081a32a 100644 --- a/cs/src/Ice/PluginManagerI.cs +++ b/cs/src/Ice/PluginManagerI.cs @@ -19,12 +19,6 @@ namespace Ice Plugin create(Communicator communicator, string name, string[] args); } - [Obsolete("This interface is deprecated, use Ice.LoggerPlugin instead.")] - public interface LoggerFactory - { - Logger create(Communicator communicator, string[] args); - } - public sealed class PluginManagerI : PluginManager { private static string _kindOfObject = "plugin"; @@ -126,7 +120,6 @@ namespace Ice plugin.destroy(); } - _logger = null; _communicator = null; } } @@ -194,7 +187,7 @@ namespace Ice if(hasKey) { string value = plugins[key]; - loadPlugin(loadOrder[i], value, ref cmdArgs, false); + loadPlugin(loadOrder[i], value, ref cmdArgs); plugins.Remove(key); } else @@ -230,7 +223,7 @@ namespace Ice else if(suffix.Equals("clr")) { name = name.Substring(0, dotPos); - loadPlugin(name, val, ref cmdArgs, false); + loadPlugin(name, val, ref cmdArgs); plugins.Remove(key); plugins.Remove("Ice.Plugin." + name); @@ -257,19 +250,10 @@ namespace Ice val = plugins[clrKey]; plugins.Remove(clrKey); } - loadPlugin(name, val, ref cmdArgs, false); + loadPlugin(name, val, ref cmdArgs); } } - // - // The Ice.LoggerPlugin property is deprecated but still supported. - // - string loggerStr = properties.getProperty("Ice.LoggerPlugin"); - if(loggerStr.Length != 0) - { - loadPlugin("Logger", loggerStr, ref cmdArgs, true); - } - // // An application can set Ice.InitPlugins=0 if it wants to postpone // initialization until after it has interacted directly with the @@ -281,7 +265,7 @@ namespace Ice } } - private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs, bool isLogger) + private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs) { Debug.Assert(_communicator != null); @@ -390,7 +374,6 @@ namespace Ice // Instantiate the class. // PluginFactory pluginFactory = null; - LoggerFactory loggerFactory = null; string className = entryPoint.Substring(sepPos + 1); System.Type c = pluginAssembly.GetType(className); if(c == null) @@ -402,31 +385,18 @@ namespace Ice try { - if(isLogger) + pluginFactory = (PluginFactory)IceInternal.AssemblyUtil.createInstance(c); + if(pluginFactory == null) { - loggerFactory = (LoggerFactory)IceInternal.AssemblyUtil.createInstance(c); - if(loggerFactory == null) - { - PluginInitializationException e = new PluginInitializationException(); - e.reason = err + "Can't find constructor for '" + className + "'"; - throw e; - } - } - else - { - pluginFactory = (PluginFactory)IceInternal.AssemblyUtil.createInstance(c); - if(pluginFactory == null) - { - PluginInitializationException e = new PluginInitializationException(); - e.reason = err + "Can't find constructor for '" + className + "'"; - throw e; - } + PluginInitializationException e = new PluginInitializationException(); + e.reason = err + "Can't find constructor for '" + className + "'"; + throw e; } } catch(System.InvalidCastException ex) { PluginInitializationException e = new PluginInitializationException(ex); - e.reason = err + "InvalidCastException to " + (isLogger ? "Ice.LoggerFactory" : "Ice.PluginFactory"); + e.reason = err + "InvalidCastException to Ice.PluginFactory"; throw e; } catch(System.UnauthorizedAccessException ex) @@ -442,90 +412,37 @@ namespace Ice throw e; } - // - // Invoke the factory. - // - if(isLogger) + Plugin plugin = null; + try { - try - { - _logger = loggerFactory.create(_communicator, args); - } - catch(PluginInitializationException ex) - { - ex.reason = err + ex.reason; - throw ex; - } - catch(System.Exception ex) - { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = err + "System.Exception in factory.create: " + ex.ToString(); - throw e; - } - - if(_logger == null) - { - PluginInitializationException ex = new PluginInitializationException(); - ex.reason = err + "factory.create returned null logger"; - throw ex; - } + plugin = pluginFactory.create(_communicator, name, args); } - else + catch(PluginInitializationException ex) { - Plugin plugin = null; - try - { - plugin = pluginFactory.create(_communicator, name, args); - } - catch(PluginInitializationException ex) - { - ex.reason = err + ex.reason; - throw ex; - } - catch(System.Exception ex) - { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = err + "System.Exception in factory.create: " + ex.ToString(); - throw e; - } - - if(plugin == null) - { - PluginInitializationException ex = new PluginInitializationException(); - ex.reason = err + "factory.create returned null plug-in"; - throw ex; - } - - if(name.Equals("Logger")) - { - try - { - LoggerPlugin loggerPlugin = (LoggerPlugin)plugin; - _logger = loggerPlugin.getLogger(); - } - catch(System.InvalidCastException ex) - { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = "Ice.Plugin.Logger does not implement an Ice.LoggerPlugin"; - throw e; - } - } - - _plugins[name] = plugin; - _initOrder.Add(plugin); + ex.reason = err + ex.reason; + throw ex; + } + catch(System.Exception ex) + { + PluginInitializationException e = new PluginInitializationException(ex); + e.reason = err + "System.Exception in factory.create: " + ex.ToString(); + throw e; + } + + if(plugin == null) + { + PluginInitializationException ex = new PluginInitializationException(); + ex.reason = err + "factory.create returned null plug-in"; + throw ex; } - } - public Logger - getLogger() - { - return _logger; + _plugins[name] = plugin; + _initOrder.Add(plugin); } - + private Communicator _communicator; private Hashtable _plugins; private ArrayList _initOrder; - private Logger _logger = null; private bool _initialized; private static bool _sslWarnOnce = false; } diff --git a/java/src/Ice/LoggerFactory.java b/java/src/Ice/LoggerFactory.java deleted file mode 100644 index 2ad0c0e41ae..00000000000 --- a/java/src/Ice/LoggerFactory.java +++ /dev/null @@ -1,18 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package Ice; - -/** - * @deprecated LoggerFactory is deprecated, use Ice.LoggerPlugin instead. - **/ -public interface LoggerFactory -{ - Logger create(Communicator communicator, String[] args); -} diff --git a/java/src/Ice/LoggerPlugin.java b/java/src/Ice/LoggerPlugin.java new file mode 100644 index 00000000000..43d96aba8bd --- /dev/null +++ b/java/src/Ice/LoggerPlugin.java @@ -0,0 +1,45 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +public final class LoggerPlugin implements Ice.Plugin +{ + public + LoggerPlugin(Communicator communicator, Logger logger) + { + if(communicator == null) + { + PluginInitializationException ex = new PluginInitializationException(); + ex.reason = "Communicator cannot be null"; + throw ex; + } + + if(logger == null) + { + PluginInitializationException ex = new PluginInitializationException(); + ex.reason = "Logger cannot be null"; + throw ex; + } + + IceInternal.Instance instance = Util.getInstance(communicator); + instance.setLogger(logger); + } + + public void + initialize() + { + } + + public void + destroy() + { + } +} + diff --git a/java/src/Ice/PluginManagerI.java b/java/src/Ice/PluginManagerI.java index e97444bc412..912c1203997 100644 --- a/java/src/Ice/PluginManagerI.java +++ b/java/src/Ice/PluginManagerI.java @@ -111,7 +111,6 @@ public final class PluginManagerI implements PluginManager p.destroy(); } - _logger = null; _communicator = null; } } @@ -168,7 +167,7 @@ public final class PluginManagerI implements PluginManager if(hasKey) { final String value = (String)plugins.get(key); - loadPlugin(loadOrder[i], value, cmdArgs, false); + loadPlugin(loadOrder[i], value, cmdArgs); plugins.remove(key); } else @@ -203,7 +202,7 @@ public final class PluginManagerI implements PluginManager else if(suffix.equals("java")) { name = name.substring(0, dotPos); - loadPlugin(name, entry.getValue(), cmdArgs, false); + loadPlugin(name, entry.getValue(), cmdArgs); p.remove(); // @@ -234,17 +233,10 @@ public final class PluginManagerI implements PluginManager value = javaValue; } - loadPlugin(name, value, cmdArgs, false); + loadPlugin(name, value, cmdArgs); } } - // DEPRECATED - 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 @@ -257,7 +249,7 @@ public final class PluginManagerI implements PluginManager } private void - loadPlugin(String name, String pluginSpec, StringSeqHolder cmdArgs, boolean isLogger) + loadPlugin(String name, String pluginSpec, StringSeqHolder cmdArgs) { assert(_communicator != null); @@ -299,27 +291,18 @@ public final class PluginManagerI implements PluginManager // Instantiate the class. // PluginFactory pluginFactory = null; - LoggerFactory loggerFactory = null; try { Class c = Class.forName(className); java.lang.Object obj = c.newInstance(); try { - if(isLogger) - { - loggerFactory = (LoggerFactory)obj; - } - else - { - pluginFactory = (PluginFactory)obj; - } + pluginFactory = (PluginFactory)obj; } catch(ClassCastException ex) { PluginInitializationException e = new PluginInitializationException(); - e.reason = "class " + className + " does not implement " + - (isLogger ? "Ice.LoggerFactory" : "Ice.PluginFactory"); + e.reason = "class " + className + " does not implement Ice.PluginFactory"; e.initCause(ex); throw e; } @@ -349,84 +332,36 @@ public final class PluginManagerI implements PluginManager // // Invoke the factory. // - if(isLogger) + Plugin plugin = null; + try { - // DEPRECATED - try - { - _logger = loggerFactory.create(_communicator, args); - } - catch(Throwable ex) - { - PluginInitializationException e = new PluginInitializationException(); - e.reason = "exception in factory " + className; - e.initCause(ex); - throw e; - } - - if(_logger == null) - { - PluginInitializationException e = new PluginInitializationException(); - e.reason = "failure in factory " + className; - throw e; - } + plugin = pluginFactory.create(_communicator, name, args); } - else + catch(PluginInitializationException ex) { - Plugin plugin = null; - try - { - plugin = pluginFactory.create(_communicator, name, args); - } - catch(PluginInitializationException ex) - { - throw ex; - } - catch(Throwable ex) - { - PluginInitializationException e = new PluginInitializationException(); - e.reason = "exception in factory " + className; - e.initCause(ex); - throw e; - } - - if(plugin == null) - { - PluginInitializationException e = new PluginInitializationException(); - e.reason = "failure in factory " + className; - throw e; - } - - if(name.equals("Logger")) - { - try - { - LoggerPlugin loggerPlugin = (LoggerPlugin)plugin; - _logger = loggerPlugin.getLogger(); - } - catch(ClassCastException ex) - { - PluginInitializationException e = new PluginInitializationException(); - e.reason = "Ice.Plugin.Logger does not implement an Ice.LoggerPlugin"; - e.initCause(ex); - throw e; - } - } - - _plugins.put(name, plugin); - _initOrder.add(plugin); + throw ex; + } + catch(Throwable ex) + { + PluginInitializationException e = new PluginInitializationException(); + e.reason = "exception in factory " + className; + e.initCause(ex); + throw e; + } + + if(plugin == null) + { + PluginInitializationException e = new PluginInitializationException(); + e.reason = "failure in factory " + className; + throw e; } - } - public Logger - getLogger() - { - return _logger; + _plugins.put(name, plugin); + _initOrder.add(plugin); } private Communicator _communicator; private java.util.Map<String, Plugin> _plugins = new java.util.HashMap<String, Plugin>(); private java.util.List<Plugin> _initOrder = new java.util.ArrayList<Plugin>(); - private Logger _logger = null; private boolean _initialized; } diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index 2a47cba9112..9cc5cee4f03 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -541,6 +541,15 @@ public final class Instance _referenceFactory = _referenceFactory.setDefaultRouter(router); } + public void + setLogger(Ice.Logger logger) + { + // + // No locking, as it can only be called during plugin loading + // + _initData.logger = logger; + } + // // Only for use by Ice.CommunicatorI // @@ -756,11 +765,6 @@ public final class Instance // Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager; pluginManagerImpl.loadPlugins(args); - Ice.Logger logger = pluginManagerImpl.getLogger(); - if(logger != null) - { - _initData.logger = logger; - } // // Get default router and locator proxies. Don't move this diff --git a/slice/Ice/Plugin.ice b/slice/Ice/Plugin.ice index 6836f93ed1c..90c7feaaf02 100644 --- a/slice/Ice/Plugin.ice +++ b/slice/Ice/Plugin.ice @@ -44,18 +44,6 @@ local interface Plugin /** * - * Special communicator plugin used to set the logger. - * Can only be used in conjunction with Ice.Plugin.Logger - * property. - * - **/ -local interface LoggerPlugin extends Plugin -{ - Logger getLogger(); -}; - -/** - * * Each communicator has a plugin manager to administer the set of * plugins. * |