summaryrefslogtreecommitdiff
path: root/js/src/Ice/LocatorTable.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/Ice/LocatorTable.js')
-rw-r--r--js/src/Ice/LocatorTable.js94
1 files changed, 55 insertions, 39 deletions
diff --git a/js/src/Ice/LocatorTable.js b/js/src/Ice/LocatorTable.js
index 5130a13b3ca..be29ec34528 100644
--- a/js/src/Ice/LocatorTable.js
+++ b/js/src/Ice/LocatorTable.js
@@ -7,24 +7,45 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/HashMap", "../Ice/Debug"]);
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, ["../Ice/HashMap", "../Ice/Debug", "../Ice/IdentityUtil"]);
-var HashMap = Ice.HashMap;
-var Debug = Ice.Debug;
+const HashMap = Ice.HashMap;
+const Debug = Ice.Debug;
-var LocatorTable = Ice.Class({
- __init__: function()
+class EndpointTableEntry
+{
+ constructor(time, endpoints)
+ {
+ this.time = time;
+ this.endpoints = endpoints;
+ }
+}
+
+class ReferenceTableEntry
+{
+ constructor(time, reference)
+ {
+ this.time = time;
+ this.reference = reference;
+ }
+}
+
+class LocatorTable
+{
+ constructor()
{
- this._adapterEndpointsTable = new HashMap(); // Map<String, EndpointTableEntry>
+ this._adapterEndpointsTable = new Map(); // Map<String, EndpointTableEntry>
this._objectTable = new HashMap(HashMap.compareEquals); // Map<Ice.Identity, ReferenceTableEntry>
- },
- clear: function()
+ }
+
+ clear()
{
this._adapterEndpointsTable.clear();
this._objectTable.clear();
- },
- getAdapterEndpoints: function(adapter, ttl, cached)
+ }
+
+ getAdapterEndpoints(adapter, ttl, cached)
{
if(ttl === 0) // Locator cache disabled.
{
@@ -32,7 +53,7 @@ var LocatorTable = Ice.Class({
return null;
}
- var entry = this._adapterEndpointsTable.get(adapter);
+ const entry = this._adapterEndpointsTable.get(adapter);
if(entry !== undefined)
{
cached.value = this.checkTTL(entry.time, ttl);
@@ -40,18 +61,21 @@ var LocatorTable = Ice.Class({
}
cached.value = false;
return null;
- },
- addAdapterEndpoints: function(adapter, endpoints)
+ }
+
+ addAdapterEndpoints(adapter, endpoints)
{
this._adapterEndpointsTable.set(adapter, new EndpointTableEntry(Date.now(), endpoints));
- },
- removeAdapterEndpoints: function(adapter)
+ }
+
+ removeAdapterEndpoints(adapter)
{
- var entry = this._adapterEndpointsTable.get(adapter);
+ const entry = this._adapterEndpointsTable.get(adapter);
this._adapterEndpointsTable.delete(adapter);
return entry !== undefined ? entry.endpoints : null;
- },
- getObjectReference: function(id, ttl, cached)
+ }
+
+ getObjectReference(id, ttl, cached)
{
if(ttl === 0) // Locator cache disabled.
{
@@ -59,7 +83,7 @@ var LocatorTable = Ice.Class({
return null;
}
- var entry = this._objectTable.get(id);
+ const entry = this._objectTable.get(id);
if(entry !== undefined)
{
cached.value = this.checkTTL(entry.time, ttl);
@@ -67,18 +91,21 @@ var LocatorTable = Ice.Class({
}
cached.value = false;
return null;
- },
- addObjectReference: function(id, ref)
+ }
+
+ addObjectReference(id, ref)
{
this._objectTable.set(id, new ReferenceTableEntry(Date.now(), ref));
- },
- removeObjectReference: function(id)
+ }
+
+ removeObjectReference(id)
{
- var entry = this._objectTable.get(id);
+ const entry = this._objectTable.get(id);
this._objectTable.delete(id);
return entry !== undefined ? entry.reference : null;
- },
- checkTTL: function(time, ttl)
+ }
+
+ checkTTL(time, ttl)
{
Debug.assert(ttl !== 0);
if(ttl < 0) // TTL = infinite
@@ -90,19 +117,8 @@ var LocatorTable = Ice.Class({
return Date.now() - time <= (ttl * 1000);
}
}
-});
+}
Ice.LocatorTable = LocatorTable;
module.exports.Ice = Ice;
-var EndpointTableEntry = function(time, endpoints)
-{
- this.time = time;
- this.endpoints = endpoints;
-};
-
-var ReferenceTableEntry = function(time, reference)
-{
- this.time = time;
- this.reference = reference;
-};