diff options
Diffstat (limited to 'js/src/Ice/ProxyFactory.js')
-rw-r--r-- | js/src/Ice/ProxyFactory.js | 138 |
1 files changed, 56 insertions, 82 deletions
diff --git a/js/src/Ice/ProxyFactory.js b/js/src/Ice/ProxyFactory.js index 1aa3cc05209..2a72f40acd9 100644 --- a/js/src/Ice/ProxyFactory.js +++ b/js/src/Ice/ProxyFactory.js @@ -7,12 +7,10 @@ // // ********************************************************************** -var Ice = require("../Ice/ModuleRegistry").Ice; -Ice.__M.require(module, +const Ice = require("../Ice/ModuleRegistry").Ice; +Ice._ModuleRegistry.require(module, [ - "../Ice/Class", "../Ice/Debug", - "../Ice/HashMap", "../Ice/ObjectPrx", "../Ice/StringUtil", "../Ice/Identity", @@ -20,29 +18,29 @@ Ice.__M.require(module, "../Ice/LocalException" ]); -var Debug = Ice.Debug; -var HashMap = Ice.HashMap; -var ObjectPrx = Ice.ObjectPrx; -var StringUtil = Ice.StringUtil; -var Identity = Ice.Identity; +const Debug = Ice.Debug; +const ObjectPrx = Ice.ObjectPrx; +const StringUtil = Ice.StringUtil; +const Identity = Ice.Identity; // // Only for use by Instance. // -var ProxyFactory = Ice.Class({ - __init__: function(instance) +class ProxyFactory +{ + constructor(instance) { this._instance = instance; - var arr = this._instance.initializationData().properties.getPropertyAsList("Ice.RetryIntervals"); + const arr = this._instance.initializationData().properties.getPropertyAsList("Ice.RetryIntervals"); if(arr.length > 0) { this._retryIntervals = []; - for(var i = 0; i < arr.length; i++) + for(let i = 0; i < arr.length; i++) { - var v; + let v; try { @@ -68,79 +66,55 @@ var ProxyFactory = Ice.Class({ { this._retryIntervals = [ 0 ]; } - }, - stringToProxy: function(str) + } + + stringToProxy(str) { - var ref = this._instance.referenceFactory().createFromString(str, null); - return this.referenceToProxy(ref); - }, - proxyToString: function(proxy) + return this.referenceToProxy(this._instance.referenceFactory().createFromString(str, null)); + } + + proxyToString(proxy) { - if(proxy !== null) - { - return proxy.__reference().toString(); - } - else - { - return ""; - } - }, - propertyToProxy: function(prefix) + return proxy === null ? "" : proxy._getReference().toString(); + } + + propertyToProxy(prefix) { - var proxy = this._instance.initializationData().properties.getProperty(prefix); - var ref = this._instance.referenceFactory().createFromString(proxy, prefix); + const proxy = this._instance.initializationData().properties.getProperty(prefix); + const ref = this._instance.referenceFactory().createFromString(proxy, prefix); return this.referenceToProxy(ref); - }, - proxyToProperty: function(proxy, prefix) + } + + proxyToProperty(proxy, prefix) { - if(proxy !== null) - { - return proxy.__reference().toProperty(prefix); - } - else - { - return new HashMap(); - } - }, - streamToProxy: function(s, type) + return proxy === null ? new Map() : proxy._getReference().toProperty(prefix); + } + + streamToProxy(s, type) { - var ident = new Identity(); - ident.__read(s); + const ident = new Identity(); + ident._read(s); + return this.referenceToProxy(this._instance.referenceFactory().createFromStream(ident, s), type); + } - var ref = this._instance.referenceFactory().createFromStream(ident, s); - return this.referenceToProxy(ref, type); - }, - referenceToProxy: function(ref, type) + referenceToProxy(ref, type) { if(ref !== null) { - var proxy = type ? new type() : new ObjectPrx(); - proxy.__setup(ref); + const proxy = type ? new type() : new ObjectPrx(); + proxy._setup(ref); return proxy; } else { return null; } - }, - proxyToStream: function(proxy, s) - { - if(proxy !== null) - { - var ref = proxy.__reference(); - ref.getIdentity().__write(s); - ref.streamWrite(s); - } - else - { - var ident = new Identity("", ""); - ident.__write(s); - } - }, - checkRetryAfterException: function(ex, ref, sleepInterval, cnt) + } + + checkRetryAfterException(ex, ref, sleepInterval, cnt) { - var traceLevels = this._instance.traceLevels(); - var logger = this._instance.initializationData().logger; + const traceLevels = this._instance.traceLevels(); + const logger = this._instance.initializationData().logger; // // We don't retry batch requests because the exception might have caused @@ -154,9 +128,7 @@ var ProxyFactory = Ice.Class({ if(ex instanceof Ice.ObjectNotExistException) { - var one = ex; - - if(ref.getRouterInfo() !== null && one.operation === "ice_add_proxy") + if(ref.getRouterInfo() !== null && ex.operation === "ice_add_proxy") { // // If we have a router, an ObjectNotExistException with an @@ -172,7 +144,7 @@ var ProxyFactory = Ice.Class({ if(traceLevels.retry >= 1) { logger.trace(traceLevels.retryCat, "retrying operation call to add proxy to router\n" + - ex.toString()); + ex.toString()); } if(sleepInterval !== null) @@ -190,7 +162,7 @@ var ProxyFactory = Ice.Class({ if(ref.isWellKnown()) { - var li = ref.getLocatorInfo(); + const li = ref.getLocatorInfo(); if(li !== null) { li.clearCache(ref); @@ -241,10 +213,12 @@ var ProxyFactory = Ice.Class({ } // - // Don't retry if the communicator is destroyed or object adapter - // deactivated. + // Don't retry if the communicator is destroyed, object adapter is deactivated, + // or connection is manually closed. // - if(ex instanceof Ice.CommunicatorDestroyedException || ex instanceof Ice.ObjectAdapterDeactivatedException) + if(ex instanceof Ice.CommunicatorDestroyedException || + ex instanceof Ice.ObjectAdapterDeactivatedException || + ex instanceof Ice.ConnectionManuallyClosedException) { throw ex; } @@ -260,7 +234,7 @@ var ProxyFactory = Ice.Class({ ++cnt; Debug.assert(cnt > 0); - var interval; + let interval; if(cnt === (this._retryIntervals.length + 1) && ex instanceof Ice.CloseConnectionException) { // @@ -274,7 +248,7 @@ var ProxyFactory = Ice.Class({ if(traceLevels.retry >= 1) { logger.trace(traceLevels.retryCat, - "cannot retry operation call because retry limit has been exceeded\n" + ex.toString()); + "cannot retry operation call because retry limit has been exceeded\n" + ex.toString()); } throw ex; } @@ -285,7 +259,7 @@ var ProxyFactory = Ice.Class({ if(traceLevels.retry >= 1) { - var msg = "retrying operation call"; + let msg = "retrying operation call"; if(interval > 0) { msg += " in " + interval + "ms"; @@ -299,7 +273,7 @@ var ProxyFactory = Ice.Class({ return cnt; } -}); +} Ice.ProxyFactory = ProxyFactory; module.exports.Ice = Ice; |