diff options
author | Mark Spruiell <mes@zeroc.com> | 2009-04-07 14:47:49 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2009-04-07 14:47:49 -0700 |
commit | b6434cdb0b59adf520c4d782d991cbd5fac818cd (patch) | |
tree | a54daae0d762bb8eab8aaa596d43e926bfddcb10 /java/src/IceSSL/Instance.java | |
parent | Changes update (diff) | |
download | ice-b6434cdb0b59adf520c4d782d991cbd5fac818cd.tar.bz2 ice-b6434cdb0b59adf520c4d782d991cbd5fac818cd.tar.xz ice-b6434cdb0b59adf520c4d782d991cbd5fac818cd.zip |
bug 849 - load properties from JAR file
Ice now attempts to load a configuration file as a class path
resource, and if that fails it opens the file in the local file
system.
bug 3613 - System properties
Ice for Java no longer uses Java system properties as default
values for Ice properties.
Diffstat (limited to 'java/src/IceSSL/Instance.java')
-rw-r--r-- | java/src/IceSSL/Instance.java | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/java/src/IceSSL/Instance.java b/java/src/IceSSL/Instance.java index e0af23f18f4..7314a839fe1 100644 --- a/java/src/IceSSL/Instance.java +++ b/java/src/IceSSL/Instance.java @@ -1087,53 +1087,20 @@ class Instance throws java.io.IOException { // - // We resolve the path as follows: - // - // 1. Try to open it as a class path resource - // 2. Try to open it in the file system - // 3. Prepend the value of IceSSL.DefaultDir (if defined) and try to open - // it in the file system + // This method wraps a call to IceInternal.Util.openResource. If the first call fails and + // IceSSL.DefaultDir is defined, prepend the default directory and try again. // + java.io.InputStream stream = IceInternal.Util.openResource(getClass().getClassLoader(), path); + if(stream == null && _defaultDir.length() > 0) + { + stream = IceInternal.Util.openResource(getClass().getClassLoader(), + _defaultDir + java.io.File.separator + path); + } - // - // Calling getResourceAsStream on the class loader means all paths are absolute, - // whereas calling it on the class requires you to prepend "/" to the path in - // order to make it absolute, otherwise the path is interpreted relative to the - // class. - // - // getResourceAsStream returns null if the resource can't be found. - // - java.io.InputStream stream = getClass().getClassLoader().getResourceAsStream(path); if(stream != null) { stream = new java.io.BufferedInputStream(stream); } - else - { - try - { - java.io.File f = new java.io.File(path); - if(f.exists()) - { - stream = new java.io.BufferedInputStream(new java.io.FileInputStream(f)); - } - else - { - if(_defaultDir.length() > 0) - { - f = new java.io.File(_defaultDir + java.io.File.separator + path); - if(f.exists()) - { - stream = new java.io.BufferedInputStream(new java.io.FileInputStream(f)); - } - } - } - } - catch(java.lang.SecurityException ex) - { - // Ignore - a security manager may forbid access to the local file system. - } - } return stream; } |