summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2015-12-08 11:33:42 -0500
committerJoe George <joe@zeroc.com>2015-12-08 16:09:24 -0500
commit6a43686ce26de5d2d5edf4a485ecff3a242c26b6 (patch)
treed31e4f16dc9ed6e28056a7224e045a4638955f5e /js
parentC++11 mapping IceDiscovery plug-in (diff)
downloadice-6a43686ce26de5d2d5edf4a485ecff3a242c26b6.tar.bz2
ice-6a43686ce26de5d2d5edf4a485ecff3a242c26b6.tar.xz
ice-6a43686ce26de5d2d5edf4a485ecff3a242c26b6.zip
ICE-6908 - Add ValueFactory
ValueFactory is a replacement for ObjectFactory (which is still available if needed). It is an interface with only one operation and can has the "delegate" metadata.
Diffstat (limited to 'js')
-rw-r--r--js/src/Ice/BasicStream.js18
-rw-r--r--js/src/Ice/Communicator.js10
-rw-r--r--js/src/Ice/Ice.js1
-rw-r--r--js/src/Ice/Instance.js6
-rw-r--r--js/src/Ice/ValueFactory.js17
-rw-r--r--js/src/Ice/ValueFactoryManager.js (renamed from js/src/Ice/ObjectFactoryManager.js)36
-rw-r--r--js/src/Ice/sources.json3
-rw-r--r--js/test/Ice/exceptions/Client.js16
-rw-r--r--js/test/Ice/objects/Client.js56
-rw-r--r--js/test/Ice/slicing/objects/Client.js11
10 files changed, 112 insertions, 62 deletions
diff --git a/js/src/Ice/BasicStream.js b/js/src/Ice/BasicStream.js
index 548956fc158..43dbc355fd7 100644
--- a/js/src/Ice/BasicStream.js
+++ b/js/src/Ice/BasicStream.js
@@ -490,7 +490,7 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
//
if(this._typeId == IceObject.ice_staticId())
{
- throw new Ice.NoObjectFactoryException("", mostDerivedId);
+ throw new Ice.NoValueFactoryException("", mostDerivedId);
}
v = this.newInstance(this._typeId);
@@ -508,7 +508,7 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
//
if(!this._sliceObjects)
{
- throw new Ice.NoObjectFactoryException("no object factory found and object slicing is disabled",
+ throw new Ice.NoValueFactoryException("no value factory found and object slicing is disabled",
this._typeId);
}
@@ -793,7 +793,7 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
{
if(this._current.sliceType === SliceType.ObjectSlice)
{
- throw new Ice.NoObjectFactoryException("no object factory found and compact format prevents slicing " +
+ throw new Ice.NoValueFactoryException("no value factory found and compact format prevents slicing " +
"(the sender should use the sliced format instead)",
this._current.typeId);
}
@@ -936,7 +936,7 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
//
if(!this._sliceObjects)
{
- throw new Ice.NoObjectFactoryException("no object factory found and object slicing is disabled",
+ throw new Ice.NoValueFactoryException("no value factory found and object slicing is disabled",
this._current.typeId);
}
@@ -2761,7 +2761,7 @@ var BasicStream = Class({
}
catch(ex)
{
- throw new Ice.NoObjectFactoryException("no object factory", id, ex);
+ throw new Ice.NoValueFactoryException("no value factory", id, ex);
}
return obj;
@@ -2898,7 +2898,7 @@ var defineBuiltinHelper = function(write, read, sz, format, min, max)
writeOpt: function(os, tag, v) { os.writeOptValue(tag, format, write, v); },
readOpt: function(is, tag) { return is.readOptValue(tag, format, read); },
};
-
+
if(min !== undefined && max !== undefined)
{
helper.validate = function(v) {
@@ -2932,13 +2932,13 @@ var MAX_INT32_VALUE = 0x7FFFFFFF;
var MIN_FLOAT32_VALUE = -3.4028234664e+38;
var MAX_FLOAT32_VALUE = 3.4028234664e+38;
-Ice.ByteHelper = defineBuiltinHelper(stream.writeByte, stream.readByte, 1, Ice.OptionalFormat.F1,
+Ice.ByteHelper = defineBuiltinHelper(stream.writeByte, stream.readByte, 1, Ice.OptionalFormat.F1,
MIN_UINT8_VALUE, MAX_UINT8_VALUE);
Ice.ShortHelper = defineBuiltinHelper(stream.writeShort, stream.readShort, 2, Ice.OptionalFormat.F2,
MIN_INT16_VALUE, MAX_INT16_VALUE);
-Ice.IntHelper = defineBuiltinHelper(stream.writeInt, stream.readInt, 4, Ice.OptionalFormat.F4,
+Ice.IntHelper = defineBuiltinHelper(stream.writeInt, stream.readInt, 4, Ice.OptionalFormat.F4,
MIN_INT32_VALUE, MAX_INT32_VALUE);
Ice.FloatHelper = defineBuiltinHelper(stream.writeFloat, stream.readFloat, 4, Ice.OptionalFormat.F4,
@@ -2964,7 +2964,7 @@ Ice.LongHelper.validate = function(v)
//
// For a long to be valid both words must be within the range of UINT32
//
- return v.low >= MIN_UINT32_VALUE && v.low <= MAX_UINT32_VALUE &&
+ return v.low >= MIN_UINT32_VALUE && v.low <= MAX_UINT32_VALUE &&
v.high >= MIN_UINT32_VALUE && v.high <= MAX_UINT32_VALUE;
};
diff --git a/js/src/Ice/Communicator.js b/js/src/Ice/Communicator.js
index 7e2d1eee99c..b522a4c9f09 100644
--- a/js/src/Ice/Communicator.js
+++ b/js/src/Ice/Communicator.js
@@ -117,10 +117,18 @@ var Communicator = Ice.Class({
},
addObjectFactory: function(factory, id)
{
- this._instance.servantFactoryManager().add(factory, id);
+ this._instance.servantFactoryManager().addObjectFactory(factory, id);
},
findObjectFactory: function(id)
{
+ return this._instance.servantFactoryManager().findObjectFactory(id);
+ },
+ addValueFactory: function(factory, id)
+ {
+ this._instance.servantFactoryManager().add(factory, id);
+ },
+ findValueFactory: function(id)
+ {
return this._instance.servantFactoryManager().find(id);
},
getImplicitContext: function()
diff --git a/js/src/Ice/Ice.js b/js/src/Ice/Ice.js
index 31248e043eb..1ef8c2bd5cc 100644
--- a/js/src/Ice/Ice.js
+++ b/js/src/Ice/Ice.js
@@ -35,6 +35,7 @@ module.exports.Ice = __M.require(module,
"../Ice/Router",
"../Ice/Version",
"../Ice/ObjectFactory",
+ "../Ice/ValueFactory",
"../Ice/Buffer",
"../Ice/ArrayUtil",
"../Ice/UnknownSlicedObject",
diff --git a/js/src/Ice/Instance.js b/js/src/Ice/Instance.js
index 7a87146a74e..c8cd21abc2d 100644
--- a/js/src/Ice/Instance.js
+++ b/js/src/Ice/Instance.js
@@ -21,7 +21,7 @@ Ice.__M.require(module,
"../Ice/LocatorManager",
"../Ice/Logger",
"../Ice/ObjectAdapterFactory",
- "../Ice/ObjectFactoryManager",
+ "../Ice/ValueFactoryManager",
"../Ice/OutgoingConnectionFactory",
"../Ice/Promise",
"../Ice/Properties",
@@ -52,7 +52,7 @@ var ImplicitContextI = Ice.ImplicitContextI;
var LocatorManager = Ice.LocatorManager;
var Logger = Ice.Logger;
var ObjectAdapterFactory = Ice.ObjectAdapterFactory;
-var ObjectFactoryManager = Ice.ObjectFactoryManager;
+var ValueFactoryManager = Ice.ValueFactoryManager;
var OutgoingConnectionFactory = Ice.OutgoingConnectionFactory;
var Promise = Ice.Promise;
var Properties = Ice.Properties;
@@ -381,7 +381,7 @@ var Instance = Ice.Class({
this._endpointFactoryManager.add(wssEndpointFactory);
this._outgoingConnectionFactory = new OutgoingConnectionFactory(communicator, this);
- this._servantFactoryManager = new ObjectFactoryManager();
+ this._servantFactoryManager = new ValueFactoryManager();
this._objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
diff --git a/js/src/Ice/ValueFactory.js b/js/src/Ice/ValueFactory.js
new file mode 100644
index 00000000000..ebea4cbfd40
--- /dev/null
+++ b/js/src/Ice/ValueFactory.js
@@ -0,0 +1,17 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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/Class").Ice;
+Ice.ValueFactory = Ice.Class({
+ create: function(type)
+ {
+ throw new Error("not implemented");
+ }
+});
+module.exports.Ice = Ice;
diff --git a/js/src/Ice/ObjectFactoryManager.js b/js/src/Ice/ValueFactoryManager.js
index 0036e6b09ec..55efddf9fea 100644
--- a/js/src/Ice/ObjectFactoryManager.js
+++ b/js/src/Ice/ValueFactoryManager.js
@@ -9,7 +9,7 @@
var Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module, ["../Ice/Class", "../Ice/HashMap", "../Ice/LocalException"]);
-
+
var HashMap = Ice.HashMap;
var AlreadyRegisteredException = Ice.AlreadyRegisteredException;
var NotRegisteredException = Ice.NotRegisteredException;
@@ -17,10 +17,11 @@ var NotRegisteredException = Ice.NotRegisteredException;
//
// Only for use by Instance
//
-var ObjectFactoryManager = Ice.Class({
+var ValueFactoryManager = Ice.Class({
__init__: function()
{
- this._factoryMap = new HashMap(); // Map<String, ObjectFactory>
+ this._factoryMap = new HashMap(); // Map<String, ValueFactory>
+ this._objectFactoryMap = new HashMap(); // Map<String, ObjectFactory>
},
add: function(factory, id)
{
@@ -30,34 +31,39 @@ var ObjectFactoryManager = Ice.Class({
{
ex = new AlreadyRegisteredException();
ex.id = id;
- ex.kindOfObject = "object factory";
+ ex.kindOfObject = "value factory";
throw ex;
}
this._factoryMap.set(id, factory);
},
- remove: function(id)
+ addObjectFactory: function(factory, id)
{
- var factory, ex;
- factory = this._factoryMap.get(id);
- if(factory === undefined)
+ var o, ex;
+ o = this._factoryMap.get(id);
+ if(o !== undefined)
{
- ex = new NotRegisteredException();
+ ex = new AlreadyRegisteredException();
ex.id = id;
- ex.kindOfObject = "object factory";
+ ex.kindOfObject = "value factory";
throw ex;
}
- this._factoryMap.delete(id);
- factory.destroy();
+ this._factoryMap.set(id, factory);
+ this._objectFactoryMap.set(id, factory);
},
find: function(id)
{
return this._factoryMap.get(id);
},
+ findObjectFactory: function(id)
+ {
+ return this._objectFactoryMap.get(id);
+ },
destroy: function()
{
- var oldMap = this._factoryMap,
+ var oldMap = this._objectFactoryMap,
e = oldMap.entries;
- this._factoryMap = new HashMap(); // Map<String, ObjectFactory>
+ this._factoryMap = new HashMap(); // Map<String, ValueFactory>
+ this._objectFactoryMap = new HashMap(); // Map<String, ObjectFactory>
while(e !== null)
{
@@ -67,5 +73,5 @@ var ObjectFactoryManager = Ice.Class({
}
});
-Ice.ObjectFactoryManager = ObjectFactoryManager;
+Ice.ValueFactoryManager = ValueFactoryManager;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/sources.json b/js/src/Ice/sources.json
index 99cf32a9021..cb3387ea16d 100644
--- a/js/src/Ice/sources.json
+++ b/js/src/Ice/sources.json
@@ -65,7 +65,6 @@
"ObjectAdapterFactory.js",
"ObjectAdapterI.js",
"ObjectFactory.js",
- "ObjectFactoryManager.js",
"ObjectPrx.js",
"OpaqueEndpointI.js",
"Operation.js",
@@ -99,6 +98,8 @@
"TraceUtil.js",
"UnknownSlicedObject.js",
"UUID.js",
+ "ValueFactory.js",
+ "ValueFactoryManager.js",
"WSEndpoint.js",
"WSEndpointFactory.js"],
diff --git a/js/test/Ice/exceptions/Client.js b/js/test/Ice/exceptions/Client.js
index eeded84d58b..53cad9d2f27 100644
--- a/js/test/Ice/exceptions/Client.js
+++ b/js/test/Ice/exceptions/Client.js
@@ -40,19 +40,15 @@
{
};
- var ObjectFactoryI = function()
+ var ValueFactoryI = function()
{
};
- ObjectFactoryI.prototype.create = function(type)
+ ValueFactoryI.prototype.create = function(type)
{
return null;
};
- ObjectFactoryI.prototype.destroy = function()
- {
- };
-
var p = new Ice.Promise();
var test = function(b)
{
@@ -235,12 +231,12 @@
).then(
function()
{
- out.write("testing object factory registration exception... ");
- var of = new ObjectFactoryI();
- communicator.addObjectFactory(of, "::x");
+ out.write("testing value factory registration exception... ");
+ var vf = new ValueFactoryI();
+ communicator.addValueFactory(vf, "::x");
try
{
- communicator.addObjectFactory(of, "::x");
+ communicator.addValueFactory(vf, "::x");
test(false);
}
catch(ex)
diff --git a/js/test/Ice/objects/Client.js b/js/test/Ice/objects/Client.js
index c67ed7bb28a..db27ce73e71 100644
--- a/js/test/Ice/objects/Client.js
+++ b/js/test/Ice/objects/Client.js
@@ -136,16 +136,16 @@
JI.prototype = new Test.J();
JI.prototype.constructor = JI;
- var MyObjectFactory = function()
+ var MyValueFactory = function()
{
- Ice.ObjectFactory.call(this);
+ Ice.ValueFactory.call(this);
};
- MyObjectFactory.prototype = new Ice.ObjectFactory();
+ MyValueFactory.prototype = new Ice.ValueFactory();
- MyObjectFactory.prototype.constructor = MyObjectFactory;
+ MyValueFactory.prototype.constructor = MyValueFactory;
- MyObjectFactory.prototype.create = function(type)
+ MyValueFactory.prototype.create = function(type)
{
switch(type)
{
@@ -175,6 +175,20 @@
return null;
};
+ var MyObjectFactory = function()
+ {
+ Ice.ObjectFactory.call(this);
+ };
+
+ MyObjectFactory.prototype = new Ice.ObjectFactory();
+
+ MyObjectFactory.prototype.constructor = MyObjectFactory;
+
+ MyObjectFactory.prototype.create = function(type)
+ {
+ return null;
+ };
+
MyObjectFactory.prototype.destroy = function()
{
};
@@ -203,17 +217,19 @@
Promise.try(
function()
{
- var factory = new MyObjectFactory();
- communicator.addObjectFactory(factory, "::Test::B");
- communicator.addObjectFactory(factory, "::Test::C");
- communicator.addObjectFactory(factory, "::Test::D");
- communicator.addObjectFactory(factory, "::Test::E");
- communicator.addObjectFactory(factory, "::Test::F");
- communicator.addObjectFactory(factory, "::Test::I");
- communicator.addObjectFactory(factory, "::Test::J");
- communicator.addObjectFactory(factory, "::Test::H");
- communicator.addObjectFactory(factory, "::Test::Inner::A");
- communicator.addObjectFactory(factory, "::Test::Inner::Sub::A");
+ var factory = new MyValueFactory();
+ communicator.addValueFactory(factory, "::Test::B");
+ communicator.addValueFactory(factory, "::Test::C");
+ communicator.addValueFactory(factory, "::Test::D");
+ communicator.addValueFactory(factory, "::Test::E");
+ communicator.addValueFactory(factory, "::Test::F");
+ communicator.addValueFactory(factory, "::Test::I");
+ communicator.addValueFactory(factory, "::Test::J");
+ communicator.addValueFactory(factory, "::Test::H");
+ communicator.addValueFactory(factory, "::Test::Inner::A");
+ communicator.addValueFactory(factory, "::Test::Inner::Sub::A");
+
+ communicator.addObjectFactory(new MyObjectFactory(), "TestOF");
out.write("testing stringToProxy... ");
ref = "initial:default -p 12010";
@@ -508,6 +524,14 @@
{
test(ex.reason == "Inner::Sub::Ex");
out.writeLine("ok");
+
+ out.write("testing getting ObjectFactory... ");
+ test(communicator.findObjectFactory("TestOF") !== null);
+ out.writeLine("ok");
+ out.write("testing getting ObjectFactory as ValueFactory... ");
+ test(communicator.findValueFactory("TestOF") !== null);
+ out.writeLine("ok");
+
return initial.shutdown();
}
).then(
diff --git a/js/test/Ice/slicing/objects/Client.js b/js/test/Ice/slicing/objects/Client.js
index df5a684561e..7c9dae3b081 100644
--- a/js/test/Ice/slicing/objects/Client.js
+++ b/js/test/Ice/slicing/objects/Client.js
@@ -24,7 +24,7 @@
}
});
- var PreservedFactoryI = Ice.Class(Ice.ObjectFactory,
+ var PreservedFactoryI = Ice.Class(Ice.ValueFactory,
{
create: function(id)
{
@@ -33,9 +33,6 @@
return new PreservedI();
}
return null;
- },
- destroy: function()
- {
}
});
@@ -140,7 +137,7 @@
function(ex)
{
test(ex instanceof Ice.OperationNotExistException ||
- ex instanceof Ice.NoObjectFactoryException);
+ ex instanceof Ice.NoValueFactoryException);
});
}
}
@@ -161,7 +158,7 @@
},
function(ex)
{
- test(ex instanceof Ice.NoObjectFactoryException);
+ test(ex instanceof Ice.NoValueFactoryException);
test(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0));
}
).then(
@@ -682,7 +679,7 @@
// the Ice run time will install its own internal factory for Preserved upon receiving the
// first instance.
//
- communicator.addObjectFactory(new PreservedFactoryI(), Test.Preserved.ice_staticId());
+ communicator.addValueFactory(new PreservedFactoryI(), Test.Preserved.ice_staticId());
//
// Server knows the most-derived class PDerived.