summaryrefslogtreecommitdiff
path: root/js/src/Ice/ObjectAdapterFactory.js
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2014-09-02 14:22:34 +0200
committerJose <jose@zeroc.com>2014-09-02 14:22:34 +0200
commitfef794cdd1f8eb698fa3ccfe6f4cacba88030e9d (patch)
tree8e0c3c353dbbaa57d60a1da49c13b4153e918763 /js/src/Ice/ObjectAdapterFactory.js
parentFix (ICE-3445) - consider not installing internal header files (diff)
downloadice-fef794cdd1f8eb698fa3ccfe6f4cacba88030e9d.tar.bz2
ice-fef794cdd1f8eb698fa3ccfe6f4cacba88030e9d.tar.xz
ice-fef794cdd1f8eb698fa3ccfe6f4cacba88030e9d.zip
Fixed (ICE-5654) - Update JS mapping to not use global types in NodeJS
Diffstat (limited to 'js/src/Ice/ObjectAdapterFactory.js')
-rw-r--r--js/src/Ice/ObjectAdapterFactory.js247
1 files changed, 123 insertions, 124 deletions
diff --git a/js/src/Ice/ObjectAdapterFactory.js b/js/src/Ice/ObjectAdapterFactory.js
index 8fe50d5d872..0090b8b64c6 100644
--- a/js/src/Ice/ObjectAdapterFactory.js
+++ b/js/src/Ice/ObjectAdapterFactory.js
@@ -7,144 +7,143 @@
//
// **********************************************************************
-(function(global){
- require("Ice/Class");
- require("Ice/AsyncResultBase");
- require("Ice/LocalException");
- require("Ice/ObjectAdapterI");
- require("Ice/Promise");
- require("Ice/UUID");
+var Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, "Ice",
+ [
+ "../Ice/Class",
+ "../Ice/AsyncResultBase",
+ "../Ice/LocalException",
+ "../Ice/ObjectAdapterI",
+ "../Ice/Promise",
+ "../Ice/UUID"
+ ]);
- var Ice = global.Ice || {};
+var AsyncResultBase = Ice.AsyncResultBase;
+var ObjectAdapterI = Ice.ObjectAdapterI;
+var Promise = Ice.Promise;
- var AsyncResultBase = Ice.AsyncResultBase;
- var ObjectAdapterI = Ice.ObjectAdapterI;
- var Promise = Ice.Promise;
- var UUID = Ice.UUID;
-
- //
- // Only for use by Instance.
- //
- var ObjectAdapterFactory = Ice.Class({
- __init__: function(instance, communicator)
- {
- this._instance = instance;
- this._communicator = communicator;
- this._adapters = [];
- this._adapterNamesInUse = [];
- this._shutdownPromise = new Promise();
- },
- shutdown: function()
+//
+// Only for use by Instance.
+//
+var ObjectAdapterFactory = Ice.Class({
+ __init__: function(instance, communicator)
+ {
+ this._instance = instance;
+ this._communicator = communicator;
+ this._adapters = [];
+ this._adapterNamesInUse = [];
+ this._shutdownPromise = new Promise();
+ },
+ shutdown: function()
+ {
+ //
+ // Ignore shutdown requests if the object adapter factory has
+ // already been shut down.
+ //
+ if(this._instance === null)
{
- //
- // Ignore shutdown requests if the object adapter factory has
- // already been shut down.
- //
- if(this._instance === null)
+ return this._shutdownPromise;
+ }
+
+ this._instance = null;
+ this._communicator = null;
+ var self = this;
+ Promise.all(
+ this._adapters.map(function(adapter)
+ {
+ return adapter.deactivate();
+ })
+ ).then(
+ function()
+ {
+ self._shutdownPromise.succeed();
+ },
+ function(ex)
{
- return this._shutdownPromise;
+ self._shutdownPromise.fail(ex);
}
-
- this._instance = null;
- this._communicator = null;
- var self = this;
- Promise.all(
- this._adapters.map(function(adapter)
- {
- return adapter.deactivate();
- })
- ).then(
- function()
- {
- self._shutdownPromise.succeed();
- },
- function(ex)
- {
- self._shutdownPromise.fail(ex);
- }
- );
- return this._shutdownPromise;
- },
- waitForShutdown: function()
- {
- var self = this;
- return this._shutdownPromise.then(
- function()
- {
- return Promise.all(self._adapters.map(function(adapter)
- {
- return adapter.waitForDeactivate();
- }));
- });
- },
- isShutdown: function()
- {
- return this._instance === null;
- },
- destroy: function()
+ );
+ return this._shutdownPromise;
+ },
+ waitForShutdown: function()
+ {
+ var self = this;
+ return this._shutdownPromise.then(
+ function()
+ {
+ return Promise.all(self._adapters.map(function(adapter)
+ {
+ return adapter.waitForDeactivate();
+ }));
+ });
+ },
+ isShutdown: function()
+ {
+ return this._instance === null;
+ },
+ destroy: function()
+ {
+ var self = this;
+ return this.waitForShutdown().then(
+ function()
+ {
+ return Promise.all(self._adapters.map(function(adapter)
+ {
+ return adapter.destroy();
+ }));
+ });
+ },
+ createObjectAdapter: function(name, router, promise)
+ {
+ if(this._instance === null)
{
- var self = this;
- return this.waitForShutdown().then(
- function()
- {
- return Promise.all(self._adapters.map(function(adapter)
- {
- return adapter.destroy();
- }));
- });
- },
- createObjectAdapter: function(name, router, promise)
+ throw new Ice.ObjectAdapterDeactivatedException();
+ }
+
+ var adapter = null;
+ try
{
- if(this._instance === null)
+ if(name.length === 0)
{
- throw new Ice.ObjectAdapterDeactivatedException();
+ var uuid = Ice.generateUUID();
+ adapter = new ObjectAdapterI(this._instance, this._communicator, this, uuid, null, true, promise);
}
-
- var adapter = null;
- try
+ else
{
- if(name.length === 0)
+ if(this._adapterNamesInUse.indexOf(name) !== -1)
{
- var uuid = UUID.generateUUID();
- adapter = new ObjectAdapterI(this._instance, this._communicator, this, uuid, null, true, promise);
+ throw new Ice.AlreadyRegisteredException("object adapter", name);
}
- else
- {
- if(this._adapterNamesInUse.indexOf(name) !== -1)
- {
- throw new Ice.AlreadyRegisteredException("object adapter", name);
- }
- adapter = new ObjectAdapterI(this._instance, this._communicator, this, name, router, false, promise);
- this._adapterNamesInUse.push(name);
- }
- this._adapters.push(adapter);
- }
- catch(ex)
- {
- promise.fail(ex, promise);
+ adapter = new ObjectAdapterI(this._instance, this._communicator, this, name, router, false, promise);
+ this._adapterNamesInUse.push(name);
}
- },
- removeObjectAdapter: function(adapter)
+ this._adapters.push(adapter);
+ }
+ catch(ex)
{
- if(this._instance === null)
- {
- return;
- }
+ promise.fail(ex, promise);
+ }
+ },
+ removeObjectAdapter: function(adapter)
+ {
+ if(this._instance === null)
+ {
+ return;
+ }
- var n = this._adapters.indexOf(adapter);
- if(n !== -1)
- {
- this._adapters.splice(n, 1);
- }
+ var n = this._adapters.indexOf(adapter);
+ if(n !== -1)
+ {
+ this._adapters.splice(n, 1);
+ }
- n = this._adapterNamesInUse.indexOf(adapter.getName());
- if(n !== -1)
- {
- this._adapterNamesInUse.splice(n, 1);
- }
+ n = this._adapterNamesInUse.indexOf(adapter.getName());
+ if(n !== -1)
+ {
+ this._adapterNamesInUse.splice(n, 1);
}
- });
-
- Ice.ObjectAdapterFactory = ObjectAdapterFactory;
- global.Ice = Ice;
-}(typeof (global) === "undefined" ? window : global));
+ }
+});
+
+Ice.ObjectAdapterFactory = ObjectAdapterFactory;
+module.exports.Ice = Ice;