summaryrefslogtreecommitdiff
path: root/js/src/Ice/RequestHandlerFactory.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/Ice/RequestHandlerFactory.js')
-rw-r--r--js/src/Ice/RequestHandlerFactory.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/js/src/Ice/RequestHandlerFactory.js b/js/src/Ice/RequestHandlerFactory.js
new file mode 100644
index 00000000000..58c63aa339b
--- /dev/null
+++ b/js/src/Ice/RequestHandlerFactory.js
@@ -0,0 +1,60 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+var Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module,
+ [
+ "../Ice/Class",
+ "../Ice/Debug",
+ "../Ice/HashMap",
+ "../Ice/Reference",
+ "../Ice/ConnectRequestHandler"
+ ]);
+
+var Debug = Ice.Debug;
+var HashMap = Ice.HashMap;
+var ConnectRequestHandler = Ice.ConnectRequestHandler;
+
+var RequestHandlerFactory = Ice.Class({
+ __init__: function(instance)
+ {
+ this._instance = instance;
+ this._handlers = new HashMap();
+ this._handlers.keyComparator = HashMap.compareEquals;
+ },
+ getRequestHandler: function(ref, proxy)
+ {
+ if(ref.getCacheConnection())
+ {
+ var handler = this._handlers.get(ref);
+ if(handler)
+ {
+ return handler;
+ }
+ handler = new ConnectRequestHandler(ref, proxy);
+ this._handlers.set(ref, handler);
+ return handler;
+ }
+ else
+ {
+ return new ConnectRequestHandler(ref, proxy);
+ }
+ },
+ removeRequestHandler: function(ref, handler)
+ {
+ if(ref.getCacheConnection())
+ {
+ var h = this._handlers.delete(ref);
+ Debug.assert(h === handler);
+ }
+ }
+});
+
+Ice.RequestHandlerFactory = RequestHandlerFactory;
+module.exports.Ice = Ice;