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 /java/src | |
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 'java/src')
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 67 | ||||
-rw-r--r-- | java/src/IceInternal/PropertyNames.java | 3 | ||||
-rw-r--r-- | java/src/IceInternal/ReferenceFactory.java | 70 |
3 files changed, 128 insertions, 12 deletions
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index fa0a9801cfa..f70e36eb097 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -747,12 +747,29 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt return; } + final Properties properties = _instance.initializationData().properties; + java.util.ArrayList props = new java.util.ArrayList(); + java.util.ArrayList unknownProps = new java.util.ArrayList(); + filterProperties(props, unknownProps); + + // + // Warn about unknown object adapter properties. + // + if(unknownProps.size() != 0 && properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) + { + String message = "Found unknown properties for object adapter '" + _name + "':"; + java.util.Iterator p = unknownProps.iterator(); + while(p.hasNext()) + { + message += "\n " + (String)p.next(); + } + _instance.initializationData().logger.warning(message); + } + // // Make sure named adapter has some configuration. // - final Properties properties = _instance.initializationData().properties; - String[] props = filterProperties(_name + "."); - if(endpointInfo.length() == 0 && router == null && props.length == 0) + if(endpointInfo.length() == 0 && router == null && props.size() == 0) { // // These need to be set to prevent finalizer from complaining. @@ -1223,26 +1240,54 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt "RegisterProcess", "ReplicaGroupId", "Router", + "ThreadPerConnection", + "ThreadPerConnection.StackSize", "ThreadPool.Size", "ThreadPool.SizeMax", "ThreadPool.SizeWarn", "ThreadPool.StackSize" }; - String[] - filterProperties(String prefix) + void + filterProperties(java.util.List oaProps, java.util.List unknownProps) { - java.util.ArrayList propertySet = new java.util.ArrayList(); - java.util.Map props = _instance.initializationData().properties.getPropertiesForPrefix(prefix); - for(int i = 0; i < _suffixes.length; ++i) + // + // Do not create unknown properties list if Ice prefix, ie Ice, Glacier2, etc + // + boolean addUnknown = true; + String prefix = _name + "."; + for(int i = 0; IceInternal.PropertyNames.clPropNames[i] != null; ++i) { - if(props.containsKey(prefix + _suffixes[i])) + if(prefix.startsWith(IceInternal.PropertyNames.clPropNames[i] + ".")) { - propertySet.add(prefix + _suffixes[i]); + addUnknown = false; + break; } } - return (String[])propertySet.toArray(new String[0]); + java.util.Map props = _instance.initializationData().properties.getPropertiesForPrefix(prefix); + java.util.Iterator p = props.entrySet().iterator(); + while(p.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + String prop = (String)entry.getKey(); + + boolean valid = false; + for(int i = 0; i < _suffixes.length; ++i) + { + if(prop.equals(prefix + _suffixes[i])) + { + oaProps.add(prop); + valid = true; + break; + } + } + + if(!valid && addUnknown) + { + unknownProps.add(prop); + } + } } private static class ProcessI extends _ProcessDisp diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index d7c514c7ba1..8b8ac9f0ea8 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -7,7 +7,7 @@ // // ********************************************************************** -// Generated by makeprops.py from file `../config/PropertyNames.def', Wed Feb 14 09:38:50 2007 +// Generated by makeprops.py from file `./config/PropertyNames.def', Wed Feb 14 11:54:25 2007 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -97,6 +97,7 @@ public final class PropertyNames "^Ice\\.Warn\\.Datagrams$", "^Ice\\.Warn\\.Dispatch$", "^Ice\\.Warn\\.Endpoints$", + "^Ice\\.Warn\\.UnknownProperties$", "^Ice\\.CacheMessageBuffers$", null }; diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java index a2f1433cce3..f224dea1a76 100644 --- a/java/src/IceInternal/ReferenceFactory.java +++ b/java/src/IceInternal/ReferenceFactory.java @@ -522,6 +522,14 @@ public final class ReferenceFactory return null; } + // + // Warn about unknown properties. + // + if(properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) + { + checkForUnknownProperties(propertyPrefix); + } + String property = propertyPrefix + ".Locator"; if(properties.getProperty(property).length() != 0) { @@ -740,6 +748,68 @@ public final class ReferenceFactory return ref; } + static private String[] _suffixes = + { + "EndpointSelection", + "ConnectionCached", + "PreferSecure", + "LocatorCacheTimeout", + "Locator", + "Router", + "CollocationOptimization", + "ThreadPerConnection" + }; + + private void + checkForUnknownProperties(String prefix) + { + // + // Do not create unknown properties list if Ice prefix, ie Ice, Glacier2, etc + // + for(int i = 0; IceInternal.PropertyNames.clPropNames[i] != null; ++i) + { + if(prefix.startsWith(IceInternal.PropertyNames.clPropNames[i] + ".")) + { + return; + } + } + + java.util.ArrayList unknownProps = new java.util.ArrayList(); + java.util.Map props = _instance.initializationData().properties.getPropertiesForPrefix(prefix + "."); + java.util.Iterator p = props.entrySet().iterator(); + while(p.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + String prop = (String)entry.getKey(); + + boolean valid = false; + for(int i = 0; i < _suffixes.length; ++i) + { + if(prop.equals(prefix + "." + _suffixes[i])) + { + valid = true; + break; + } + } + + if(!valid) + { + unknownProps.add(prop); + } + } + + if(unknownProps.size() != 0) + { + String message = "Found unknown properties for proxy '" + prefix + "':"; + p = unknownProps.iterator(); + while(p.hasNext()) + { + message += "\n " + (String)p.next(); + } + _instance.initializationData().logger.warning(message); + } + } + private Instance _instance; private Ice.Communicator _communicator; private Ice.RouterPrx _defaultRouter; |