diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-10-12 02:23:00 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-10-12 02:23:00 +0000 |
commit | 2a52a8fca98c1b3f5549f56a5d89356023699cb2 (patch) | |
tree | 6577c0dafdaf817d458adc092747f5c7a815aca5 | |
parent | http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=87 (diff) | |
download | ice-2a52a8fca98c1b3f5549f56a5d89356023699cb2.tar.bz2 ice-2a52a8fca98c1b3f5549f56a5d89356023699cb2.tar.xz ice-2a52a8fca98c1b3f5549f56a5d89356023699cb2.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=87
-rw-r--r-- | cpp/include/Ice/Application.h | 2 | ||||
-rw-r--r-- | cpp/include/Ice/Initialize.h | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Application.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.h | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Initialize.cpp | 18 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 43 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.h | 2 | ||||
-rwxr-xr-x | cs/src/Ice/Application.cs | 2 | ||||
-rwxr-xr-x | cs/src/Ice/CommunicatorI.cs | 4 | ||||
-rwxr-xr-x | cs/src/Ice/Instance.cs | 20 | ||||
-rwxr-xr-x | cs/src/Ice/Util.cs | 16 | ||||
-rw-r--r-- | java/src/Ice/Application.java | 2 | ||||
-rw-r--r-- | java/src/Ice/CommunicatorI.java | 4 | ||||
-rw-r--r-- | java/src/Ice/Util.java | 35 | ||||
-rw-r--r-- | java/src/IceInternal/Instance.java | 20 |
16 files changed, 128 insertions, 58 deletions
diff --git a/cpp/include/Ice/Application.h b/cpp/include/Ice/Application.h index 6254777eebd..10ab0d02f1c 100644 --- a/cpp/include/Ice/Application.h +++ b/cpp/include/Ice/Application.h @@ -30,7 +30,7 @@ public: // are printed if exceptions propagate to main(), and the // Communicator is always destroyed, regardless of exceptions. // - int main(int, char*[], const char* = 0); + int main(int, char*[], const char* = 0, const Ice::LoggerPtr& = 0); virtual int run(int, char*[]) = 0; // diff --git a/cpp/include/Ice/Initialize.h b/cpp/include/Ice/Initialize.h index 81b5372a627..a5bff74324b 100644 --- a/cpp/include/Ice/Initialize.h +++ b/cpp/include/Ice/Initialize.h @@ -13,8 +13,9 @@ #include <Ice/CommunicatorF.h> #include <Ice/PropertiesF.h> #include <Ice/InstanceF.h> -#include <Ice/BuiltinSequences.h> +#include <Ice/LoggerF.h> #include <Ice/StreamF.h> +#include <Ice/BuiltinSequences.h> namespace Ice { @@ -36,6 +37,9 @@ ICE_API PropertiesPtr createProperties(int&, char*[]); ICE_API CommunicatorPtr initialize(int&, char*[], Int = ICE_INT_VERSION); ICE_API CommunicatorPtr initializeWithProperties(int&, char*[], const PropertiesPtr&, Int = ICE_INT_VERSION); +ICE_API CommunicatorPtr initializeWithLogger(int&, char*[], const Ice::LoggerPtr&, Int = ICE_INT_VERSION); +ICE_API CommunicatorPtr initializeWithPropertiesAndLogger(int&, char*[], const PropertiesPtr&, + const Ice::LoggerPtr&, Int = ICE_INT_VERSION); ICE_API PropertiesPtr getDefaultProperties(); ICE_API PropertiesPtr getDefaultProperties(StringSeq&); diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp index 26e7c0d51d6..2e143fa81f2 100644 --- a/cpp/src/Ice/Application.cpp +++ b/cpp/src/Ice/Application.cpp @@ -249,7 +249,7 @@ Ice::Application::main(int argc, char* argv[], const char* configFile, const Log } else { - _communicator = initialize(argc, argv); + _communicator = initializeWithLogger(argc, argv, logger); } _destroyed = false; diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index 3fb9e387e67..8170ea1b1cf 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -239,12 +239,12 @@ Ice::CommunicatorI::flushBatchRequests() _instance->flushBatchRequests(); } -Ice::CommunicatorI::CommunicatorI(const PropertiesPtr& properties) +Ice::CommunicatorI::CommunicatorI(const PropertiesPtr& properties, const LoggerPtr& logger) { __setNoDelete(true); try { - const_cast<InstancePtr&>(_instance) = new Instance(this, properties); + const_cast<InstancePtr&>(_instance) = new Instance(this, properties, logger); // // Keep a reference to the dynamic library list to ensure diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index 2865f1b449e..46b2d1560db 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -61,7 +61,7 @@ public: private: - CommunicatorI(const PropertiesPtr&); + CommunicatorI(const PropertiesPtr&, const LoggerPtr&); virtual ~CommunicatorI(); // @@ -70,8 +70,8 @@ private: // void finishSetup(int&, char*[]); - friend ICE_API CommunicatorPtr initialize(int&, char*[], Int); - friend ICE_API CommunicatorPtr initializeWithProperties(int&, char*[], const PropertiesPtr&, Int); + friend ICE_API CommunicatorPtr initializeWithPropertiesAndLogger(int&, char*[], const PropertiesPtr&, + const LoggerPtr&, Int); friend ICE_API ::IceInternal::InstancePtr IceInternal::getInstance(const ::Ice::CommunicatorPtr&); const ::IceInternal::InstancePtr _instance; diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index b7d5a0246ed..733e3e278ac 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -151,12 +151,26 @@ CommunicatorPtr Ice::initialize(int& argc, char* argv[], Int version) { PropertiesPtr properties = getDefaultProperties(argc, argv); - return initializeWithProperties(argc, argv, properties, version); + return initializeWithPropertiesAndLogger(argc, argv, properties, 0, version); } CommunicatorPtr Ice::initializeWithProperties(int& argc, char* argv[], const PropertiesPtr& properties, Int version) { + return initializeWithPropertiesAndLogger(argc, argv, properties, 0, version); +} + +CommunicatorPtr +Ice::initializeWithLogger(int& argc, char* argv[], const LoggerPtr& logger, Int version) +{ + PropertiesPtr properties = getDefaultProperties(argc, argv); + return initializeWithPropertiesAndLogger(argc, argv, properties, logger, version); +} + +CommunicatorPtr +Ice::initializeWithPropertiesAndLogger(int& argc, char* argv[], const PropertiesPtr& properties, + const LoggerPtr& logger, Int version) +{ #ifndef ICE_IGNORE_VERSION // // Major and minor version numbers must match. @@ -179,7 +193,7 @@ Ice::initializeWithProperties(int& argc, char* argv[], const PropertiesPtr& prop args = properties->parseIceCommandLineOptions(args); stringSeqToArgs(args, argc, argv); - CommunicatorI* communicatorI = new CommunicatorI(properties); + CommunicatorI* communicatorI = new CommunicatorI(properties, logger); CommunicatorPtr result = communicatorI; // For exception safety. communicatorI->finishSetup(argc, argv); return result; diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 7e0c0cb8ea1..112fbd74cc8 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -414,9 +414,11 @@ IceInternal::Instance::getDefaultContext() const } -IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const PropertiesPtr& properties) : +IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const PropertiesPtr& properties, + const LoggerPtr& logger) : _state(StateActive), _properties(properties), + _logger(logger), _messageSizeMax(0), _clientACM(0), _serverACM(0), @@ -539,27 +541,30 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope sync.release(); -#ifdef _WIN32 - if(_properties->getPropertyAsInt("Ice.UseEventLog") > 0) - { - _logger = new EventLoggerI(_properties->getProperty("Ice.ProgramName")); - } - else + if(!_logger) { - _logger = new LoggerI(_properties->getProperty("Ice.ProgramName"), - _properties->getPropertyAsInt("Ice.Logger.Timestamp") > 0); - } +#ifdef _WIN32 + if(_properties->getPropertyAsInt("Ice.UseEventLog") > 0) + { + _logger = new EventLoggerI(_properties->getProperty("Ice.ProgramName")); + } + else + { + _logger = new LoggerI(_properties->getProperty("Ice.ProgramName"), + _properties->getPropertyAsInt("Ice.Logger.Timestamp") > 0); + } #else - if(_properties->getPropertyAsInt("Ice.UseSyslog") > 0) - { - _logger = new SysLoggerI; - } - else - { - _logger = new LoggerI(_properties->getProperty("Ice.ProgramName"), - _properties->getPropertyAsInt("Ice.Logger.Timestamp") > 0); - } + if(_properties->getPropertyAsInt("Ice.UseSyslog") > 0) + { + _logger = new SysLoggerI; + } + else + { + _logger = new LoggerI(_properties->getProperty("Ice.ProgramName"), + _properties->getPropertyAsInt("Ice.Logger.Timestamp") > 0); + } #endif + } _stats = 0; // There is no default statistics callback object. diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 44b50d98e95..4da34f46fc2 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -80,7 +80,7 @@ public: private: - Instance(const Ice::CommunicatorPtr&, const Ice::PropertiesPtr&); + Instance(const Ice::CommunicatorPtr&, const Ice::PropertiesPtr&, const Ice::LoggerPtr&); virtual ~Instance(); void finishSetup(int&, char*[]); bool destroy(); diff --git a/cs/src/Ice/Application.cs b/cs/src/Ice/Application.cs index cf9ab5d6191..c89ab1e68ad 100755 --- a/cs/src/Ice/Application.cs +++ b/cs/src/Ice/Application.cs @@ -65,7 +65,7 @@ namespace Ice } else { - _communicator = Util.initialize(ref args); + _communicator = Util.initializeWithLogger(ref args, logger); } Properties props = _communicator.getProperties(); diff --git a/cs/src/Ice/CommunicatorI.cs b/cs/src/Ice/CommunicatorI.cs index 4de986fc397..591e721a2ec 100755 --- a/cs/src/Ice/CommunicatorI.cs +++ b/cs/src/Ice/CommunicatorI.cs @@ -127,9 +127,9 @@ namespace Ice instance_.flushBatchRequests(); } - internal CommunicatorI(Properties properties) + internal CommunicatorI(Properties properties, Logger logger) { - instance_ = new IceInternal.Instance(this, properties); + instance_ = new IceInternal.Instance(this, properties, logger); } #if DEBUG diff --git a/cs/src/Ice/Instance.cs b/cs/src/Ice/Instance.cs index d7b040ea4df..32b662b744f 100755 --- a/cs/src/Ice/Instance.cs +++ b/cs/src/Ice/Instance.cs @@ -341,10 +341,11 @@ namespace IceInternal // // Only for use by Ice.CommunicatorI // - public Instance(Ice.Communicator communicator, Ice.Properties properties) + public Instance(Ice.Communicator communicator, Ice.Properties properties, Ice.Logger logger) { _state = StateActive; _properties = properties; + _logger = logger; try { @@ -402,14 +403,17 @@ namespace IceInternal } } - if(_properties.getPropertyAsInt("Ice.UseSyslog") > 0) + if(_logger == null) { - _logger = new Ice.SysLoggerI(_properties.getProperty("Ice.ProgramName")); - } - else - { - _logger = new Ice.LoggerI(_properties.getProperty("Ice.ProgramName"), - _properties.getPropertyAsInt("Ice.Logger.Timestamp") > 0); + if(_properties.getPropertyAsInt("Ice.UseSyslog") > 0) + { + _logger = new Ice.SysLoggerI(_properties.getProperty("Ice.ProgramName")); + } + else + { + _logger = new Ice.LoggerI(_properties.getProperty("Ice.ProgramName"), + _properties.getPropertyAsInt("Ice.Logger.Timestamp") > 0); + } } _stats = null; // There is no default statistics callback object. diff --git a/cs/src/Ice/Util.cs b/cs/src/Ice/Util.cs index 5f37c876d6c..daf18bf921d 100755 --- a/cs/src/Ice/Util.cs +++ b/cs/src/Ice/Util.cs @@ -55,14 +55,26 @@ namespace Ice public static Communicator initialize(ref string[] args) { Properties defaultProperties = getDefaultProperties(ref args); - return initializeWithProperties(ref args, defaultProperties); + return initializeWithPropertiesAndLogger(ref args, defaultProperties, null); + } + + public static Communicator initializeWithLogger(ref string[] args, Logger logger) + { + Properties defaultProperties = getDefaultProperties(ref args); + return initializeWithPropertiesAndLogger(ref args, defaultProperties, logger); } public static Communicator initializeWithProperties(ref string[] args, Properties properties) { + return initializeWithPropertiesAndLogger(ref args, properties, null); + } + + public static Communicator initializeWithPropertiesAndLogger(ref string[] args, Properties properties, + Ice.Logger logger) + { args = properties.parseIceCommandLineOptions(args); - CommunicatorI result = new CommunicatorI(properties); + CommunicatorI result = new CommunicatorI(properties, logger); result.finishSetup(ref args); return result; } diff --git a/java/src/Ice/Application.java b/java/src/Ice/Application.java index db3328804b4..ed55d84c2b9 100644 --- a/java/src/Ice/Application.java +++ b/java/src/Ice/Application.java @@ -60,7 +60,7 @@ public abstract class Application } else { - _communicator = Util.initialize(argHolder); + _communicator = Util.initializeWithLogger(argHolder, logger); } // diff --git a/java/src/Ice/CommunicatorI.java b/java/src/Ice/CommunicatorI.java index 292f28d82a5..1be4bc7ab93 100644 --- a/java/src/Ice/CommunicatorI.java +++ b/java/src/Ice/CommunicatorI.java @@ -149,9 +149,9 @@ public final class CommunicatorI extends LocalObjectImpl implements Communicator _instance.flushBatchRequests(); } - CommunicatorI(Properties properties) + CommunicatorI(Properties properties, Logger logger) { - _instance = new IceInternal.Instance(this, properties); + _instance = new IceInternal.Instance(this, properties, logger); } /** diff --git a/java/src/Ice/Util.java b/java/src/Ice/Util.java index 6e27ba8bde6..81e8c445c3f 100644 --- a/java/src/Ice/Util.java +++ b/java/src/Ice/Util.java @@ -67,7 +67,7 @@ public final class Util initialize(StringSeqHolder args) { Properties properties = getDefaultProperties(args); - return initializeWithProperties(args, properties); + return initializeWithPropertiesAndLogger(args, properties, null); } public static Communicator @@ -78,20 +78,47 @@ public final class Util } public static Communicator + initializeWithLogger(StringSeqHolder args, Logger logger) + { + Properties properties = getDefaultProperties(args); + return initializeWithPropertiesAndLogger(args, properties, logger); + } + + public static Communicator + initializeWithLogger(String[] args, Logger logger) + { + StringSeqHolder argsH = new StringSeqHolder(args); + return initializeWithLogger(argsH, logger); + } + + public static Communicator initializeWithProperties(StringSeqHolder args, Properties properties) { + return initializeWithPropertiesAndLogger(args, properties, null); + } + + public static Communicator + initializeWithProperties(String[] args, Properties properties) + { + StringSeqHolder argsH = new StringSeqHolder(args); + return initializeWithProperties(argsH, properties); + } + + public static Communicator + initializeWithPropertiesAndLogger(StringSeqHolder args, Properties properties, Logger logger) + { args.value = properties.parseIceCommandLineOptions(args.value); - CommunicatorI result = new CommunicatorI(properties); + CommunicatorI result = new CommunicatorI(properties, logger); result.finishSetup(args); return result; } public static Communicator - initializeWithProperties(String[] args, Properties properties) + initializeWithPropertiesAndLogger(String[] args, Properties properties, Logger logger) { StringSeqHolder argsH = new StringSeqHolder(args); - return initializeWithProperties(argsH, properties); + return initializeWithPropertiesAndLogger(argsH, properties, logger); } public static IceInternal.Instance diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index ccbd703ceae..a40eb31a534 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -310,10 +310,11 @@ public final class Instance // Only for use by Ice.CommunicatorI // public - Instance(Ice.Communicator communicator, Ice.Properties properties) + Instance(Ice.Communicator communicator, Ice.Properties properties, Ice.Logger logger) { _state = StateActive; _properties = properties; + _logger = logger; try { @@ -379,14 +380,17 @@ public final class Instance } } - if(_properties.getPropertyAsInt("Ice.UseSyslog") > 0) + if(_logger == null) { - _logger = new Ice.SysLoggerI(_properties.getProperty("Ice.ProgramName")); - } - else - { - _logger = new Ice.LoggerI(_properties.getProperty("Ice.ProgramName"), - _properties.getPropertyAsInt("Ice.Logger.Timestamp") > 0); + if(_properties.getPropertyAsInt("Ice.UseSyslog") > 0) + { + _logger = new Ice.SysLoggerI(_properties.getProperty("Ice.ProgramName")); + } + else + { + _logger = new Ice.LoggerI(_properties.getProperty("Ice.ProgramName"), + _properties.getPropertyAsInt("Ice.Logger.Timestamp") > 0); + } } _stats = null; // There is no default statistics callback object. |