diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-02-14 17:00:36 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-02-14 17:00:36 +0000 |
commit | b048961e8c3818d26f6aa52262e3296a8e03d048 (patch) | |
tree | f450bdc248212226e1afbf6b787bf712e079b77f /cpp/src/Ice/ReferenceFactory.cpp | |
parent | Removing fixVersion from files that do not need it. (diff) | |
download | ice-b048961e8c3818d26f6aa52262e3296a8e03d048.tar.bz2 ice-b048961e8c3818d26f6aa52262e3296a8e03d048.tar.xz ice-b048961e8c3818d26f6aa52262e3296a8e03d048.zip |
Added unknown property warning
Diffstat (limited to 'cpp/src/Ice/ReferenceFactory.cpp')
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 13348367d9a..06094811a70 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -22,6 +22,7 @@ #include <Ice/BasicStream.h> #include <Ice/Properties.h> #include <Ice/DefaultsAndOverrides.h> +#include <Ice/PropertyNames.h> #include <IceUtil/StringUtil.h> using namespace std; @@ -569,6 +570,14 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix return 0; } + // + // Warn about unknown properties. + // + if(properties->getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) + { + checkForUnknownProperties(propertyPrefix); + } + string property = propertyPrefix + ".Locator"; if(!properties->getProperty(property).empty()) { @@ -757,3 +766,62 @@ IceInternal::ReferenceFactory::destroy() _defaultRouter = 0; _defaultLocator = 0; } + +void +IceInternal::ReferenceFactory::checkForUnknownProperties(const string& prefix) +{ + static const string suffixes[] = + { + "EndpointSelection", + "ConnectionCached", + "PreferSecure", + "LocatorCacheTimeout", + "Locator", + "Router", + "CollocationOptimization", + "ThreadPerConnection" + }; + + // + // Do not warn about unknown properties list if Ice prefix, ie Ice, Glacier2, etc + // + for(const char** i = IceInternal::PropertyNames::clPropNames; *i != 0; ++i) + { + if(prefix.find(*i) == 0) + { + return; + } + } + + StringSeq unknownProps; + PropertyDict props = _instance->initializationData().properties->getPropertiesForPrefix(prefix + "."); + PropertyDict::const_iterator p; + for(p = props.begin(); p != props.end(); ++p) + { + bool valid = false; + for(unsigned int i = 0; i < sizeof(suffixes)/sizeof(*suffixes); ++i) + { + string prop = prefix + "." + suffixes[i]; + if(p->first == prop) + { + valid = true; + break; + } + } + + if(!valid) + { + unknownProps.push_back(p->first); + } + } + + if(unknownProps.size()) + { + Warning out(_instance->initializationData().logger); + out << "Found unknown properties for proxy '" << prefix << "':"; + for(unsigned int i = 0; i < unknownProps.size(); ++i) + { + out << "\n " << unknownProps[i]; + } + } +} |