diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2014-09-25 13:18:48 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2014-09-25 13:18:48 -0230 |
commit | 9a5bfaa13d31b346f1fbbf6de1be2ef1e657e92e (patch) | |
tree | 5932a0fca63b0cad86c9adcb45f8a03c4ed14c1c /java/src/Glacier2/SessionFactoryHelper.java | |
parent | Fixed again ICE-5687 - adapterDeactivation test warnings (diff) | |
download | ice-9a5bfaa13d31b346f1fbbf6de1be2ef1e657e92e.tar.bz2 ice-9a5bfaa13d31b346f1fbbf6de1be2ef1e657e92e.tar.xz ice-9a5bfaa13d31b346f1fbbf6de1be2ef1e657e92e.zip |
ICE-5611 on RouterFinder failure use default identity rather than failing
Diffstat (limited to 'java/src/Glacier2/SessionFactoryHelper.java')
-rw-r--r-- | java/src/Glacier2/SessionFactoryHelper.java | 117 |
1 files changed, 58 insertions, 59 deletions
diff --git a/java/src/Glacier2/SessionFactoryHelper.java b/java/src/Glacier2/SessionFactoryHelper.java index 474acf3dca7..dc7f7beec0e 100644 --- a/java/src/Glacier2/SessionFactoryHelper.java +++ b/java/src/Glacier2/SessionFactoryHelper.java @@ -237,7 +237,7 @@ public class SessionFactoryHelper synchronized public SessionHelper connect() { - SessionHelper session = new SessionHelper(_callback, createInitData()); + SessionHelper session = new SessionHelper(_callback, createInitData(), getRouterFinderStr()); session.connect(_context); return session; } @@ -255,7 +255,7 @@ public class SessionFactoryHelper synchronized public SessionHelper connect(final String username, final String password) { - SessionHelper session = new SessionHelper(_callback, createInitData()); + SessionHelper session = new SessionHelper(_callback, createInitData(), getRouterFinderStr()); session.connect(username, password, _context); return session; } @@ -269,75 +269,74 @@ public class SessionFactoryHelper Ice.InitializationData initData = (Ice.InitializationData)_initData.clone(); initData.properties = initData.properties._clone(); - if(initData.properties.getProperty("Ice.Default.Router").length() == 0) + if(initData.properties.getProperty("Ice.Default.Router").length() == 0 && _identity != null) { - boolean useFinder = _identity == null; + initData.properties.setProperty("Ice.Default.Router", getProxyStr(_identity)); + } - StringBuffer sb = new StringBuffer(); - sb.append("\""); - if(useFinder) - { - sb.append("Ice/RouterFinder"); - } - else - { - sb.append(Ice.Util.identityToString(_identity)); - } - sb.append("\""); - sb.append(":"); + // + // If using a secure connection setup the IceSSL plug-in, if IceSSL + // plug-in has already been setup we don't want to override the + // configuration so it can be loaded from a custom location. + // + if(_secure && initData.properties.getProperty("Ice.Plugin.IceSSL").length() == 0) + { + initData.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL.PluginFactory"); + } - if(_secure) - { - sb.append("ssl -p "); - } - else - { - sb.append("tcp -p "); - } + return initData; + } - if(_port != 0) - { - sb.append(_port); - } - else - { - if(_secure) - { - sb.append(GLACIER2_SSL_PORT); - } - else - { - sb.append(GLACIER2_TCP_PORT); - } - } + private String + getRouterFinderStr() + { + Ice.Identity ident = new Ice.Identity("RouterFinder", "Ice"); + return getProxyStr(ident); + } - sb.append(" -h "); - sb.append(_routerHost); - if(_timeout > 0) - { - sb.append(" -t "); - sb.append(_timeout); - } + private String + getProxyStr(Ice.Identity ident) + { + StringBuffer sb = new StringBuffer(); + sb.append("\""); + sb.append(Ice.Util.identityToString(ident)); + sb.append("\""); + sb.append(":"); + + if(_secure) + { + sb.append("ssl -p "); + } + else + { + sb.append("tcp -p "); + } - if(useFinder) + if(_port != 0) + { + sb.append(_port); + } + else + { + if(_secure) { - initData.properties.setProperty("SessionHelper.RouterFinder", sb.toString()); + sb.append(GLACIER2_SSL_PORT); } else { - initData.properties.setProperty("Ice.Default.Router", sb.toString()); - } - // - // If using a secure connection setup the IceSSL plug-in, if IceSSL - // plug-in has already been setup we don't want to override the - // configuration so it can be loaded from a custom location. - // - if(_secure && initData.properties.getProperty("Ice.Plugin.IceSSL").length() == 0) - { - initData.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL.PluginFactory"); + sb.append(GLACIER2_TCP_PORT); } } - return initData; + + sb.append(" -h "); + sb.append(_routerHost); + if(_timeout > 0) + { + sb.append(" -t "); + sb.append(_timeout); + } + + return sb.toString(); } private SessionCallback _callback; |