summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2018-01-31 17:21:12 +0100
committerBenoit Foucher <benoit@zeroc.com>2018-01-31 17:21:12 +0100
commitc3f44e70ea6a8c9bd16281f4b7e2bcd8f7bae47f (patch)
treea02e199af243136b4dc4a83929e8c9a185c9dcd8
parentUpdated AutoStart description (diff)
downloadice-c3f44e70ea6a8c9bd16281f4b7e2bcd8f7bae47f.tar.bz2
ice-c3f44e70ea6a8c9bd16281f4b7e2bcd8f7bae47f.tar.xz
ice-c3f44e70ea6a8c9bd16281f4b7e2bcd8f7bae47f.zip
Added support for ice_fixed, ice_getTimeout, ice_getCompress methods (ICE-7996 & ICE-7976)
-rw-r--r--CHANGELOG-3.7.md9
-rw-r--r--cpp/include/Ice/Proxy.h114
-rw-r--r--cpp/src/Ice/Proxy.cpp45
-rw-r--r--cpp/src/Ice/Reference.cpp37
-rw-r--r--cpp/src/Ice/Reference.h10
-rw-r--r--cpp/test/Ice/proxy/AllTests.cpp91
-rw-r--r--csharp/src/Ice/Proxy.cs69
-rw-r--r--csharp/src/Ice/Reference.cs43
-rw-r--r--csharp/test/Ice/proxy/AllTests.cs50
-rw-r--r--java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java25
-rw-r--r--java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java56
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/FixedReference.java20
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/Reference.java8
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/RoutableReference.java21
-rw-r--r--java-compat/test/src/main/java/test/Ice/proxy/AllTests.java51
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java54
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java10
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/IceInternal/FixedReference.java27
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/IceInternal/Reference.java9
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/IceInternal/RoutableReference.java31
-rw-r--r--java/test/src/main/java/test/Ice/proxy/AllTests.java51
-rw-r--r--js/package-lock.json1
-rw-r--r--js/src/Ice/ObjectPrx.js26
-rw-r--r--js/src/Ice/Reference.js49
-rw-r--r--js/test/Ice/proxy/Client.js45
-rw-r--r--objective-c/include/objc/Ice/Proxy.h3
-rw-r--r--objective-c/src/Ice/Proxy.mm32
-rw-r--r--objective-c/test/Ice/proxy/AllTests.m50
-rw-r--r--php/src/php5/Connection.cpp6
-rw-r--r--php/src/php5/Connection.h5
-rw-r--r--php/src/php5/Proxy.cpp93
-rw-r--r--php/src/php7/Connection.cpp7
-rw-r--r--php/src/php7/Connection.h5
-rw-r--r--php/src/php7/Proxy.cpp93
-rw-r--r--php/test/Ice/proxy/Client.php41
-rw-r--r--python/modules/IcePy/Connection.cpp29
-rw-r--r--python/modules/IcePy/Connection.h3
-rw-r--r--python/modules/IcePy/Proxy.cpp99
-rw-r--r--python/test/Ice/proxy/AllTests.py39
-rw-r--r--ruby/src/IceRuby/Connection.cpp13
-rw-r--r--ruby/src/IceRuby/Connection.h3
-rw-r--r--ruby/src/IceRuby/Proxy.cpp69
-rw-r--r--ruby/test/Ice/proxy/AllTests.rb41
43 files changed, 1527 insertions, 56 deletions
diff --git a/CHANGELOG-3.7.md b/CHANGELOG-3.7.md
index 3ebaf38ef18..7660df9aede 100644
--- a/CHANGELOG-3.7.md
+++ b/CHANGELOG-3.7.md
@@ -27,6 +27,15 @@ These are the changes since Ice 3.7.0 included in this pre-release.
## General Changes
+- Added support for ice_fixed proxy method to create a fixed proxy bound
+ to a given connection.
+
+- Added support for ice_getTimeout and ice_getCompress proxy methods. These
+ methods return an optional value that contains the proxy timeout or
+ compression override setting. If the timeout or the compression setting
+ haven't been overridden with ice_timeout or ice_compress, the optional
+ value is unset.
+
- Fixed IceGrid node bug where a replica would not get up-to-date object
adapter information about a server if an update was pending for the
server. Thanks to Michael Gmelin for the bug report and fix.
diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h
index 58287e0aecc..cab5bb39956 100644
--- a/cpp/include/Ice/Proxy.h
+++ b/cpp/include/Ice/Proxy.h
@@ -946,20 +946,36 @@ public:
bool ice_isBatchDatagram() const;
/**
- * Obtains a proxy that is identical to this proxy, except for compression.
+ * Obtains a proxy that is identical to this proxy, except for its compression setting which
+ * overrides the compression setting from the proxy endpoints.
* @param b True enables compression for the new proxy, false disables compression.
- * @return A proxy with the specified compression setting.
+ * @return A proxy with the specified compression override setting.
*/
::std::shared_ptr<::Ice::ObjectPrx> ice_compress(bool b) const;
/**
- * Obtains a proxy that is identical to this proxy, except for its connection timeout setting.
- * @param timeout The connection timeout for the proxy (in milliseconds).
- * @return A proxy with the specified timeout.
+ * Obtains the compression override setting of this proxy.
+ * @return The compression override setting. If nullopt is returned, no override is set. Otherwise, true
+ * if compression is enabled, false otherwise.
+ */
+ ::Ice::optional<bool> ice_getCompress() const;
+
+ /**
+ * Obtains a proxy that is identical to this proxy, except for its connection timeout setting
+ * which overrides the timeot setting from the proxy endpoints.
+ * @param timeout The connection timeout override for the proxy (in milliseconds).
+ * @return A proxy with the specified timeout override.
*/
::std::shared_ptr<::Ice::ObjectPrx> ice_timeout(int timeout) const;
/**
+ * Obtains the timeout override of this proxy.
+ * @return The timeout override. If nullopt is returned, no override is set. Otherwise, returns
+ * the timeout override value.
+ */
+ ::Ice::optional<int> ice_getTimeout() const;
+
+ /**
* Obtains a proxy that is identical to this proxy, except for its connection ID.
* @param id The connection ID for the new proxy. An empty string removes the
* connection ID.
@@ -974,6 +990,14 @@ public:
::std::string ice_getConnectionId() const;
/**
+ * Obtains a proxy that is identical to this proxy, except it's a fixed proxy bound
+ * the given connection.
+ * @param connection The fixed proxy connection.
+ * @return A fixed proxy bound to the given connection.
+ */
+ ::std::shared_ptr<::Ice::ObjectPrx> ice_fixed(const ::std::shared_ptr<::Ice::Connection>& connection) const;
+
+ /**
* Obtains the Connection for this proxy. If the proxy does not yet have an established connection,
* it first attempts to create a connection.
* @return The connection for this proxy.
@@ -1326,9 +1350,10 @@ public:
}
/**
- * Obtains a proxy that is identical to this proxy, except for compression.
+ * Obtains a proxy that is identical to this proxy, except for its compression setting which
+ * overrides the compression setting from the proxy endpoints.
* @param b True enables compression for the new proxy, false disables compression.
- * @return A proxy with the specified compression setting.
+ * @return A proxy with the specified compression override setting.
*/
::std::shared_ptr<Prx> ice_compress(bool b) const
{
@@ -1336,9 +1361,10 @@ public:
}
/**
- * Obtains a proxy that is identical to this proxy, except for its connection timeout setting.
- * @param timeout The connection timeout for the proxy (in milliseconds).
- * @return A proxy with the specified timeout.
+ * Obtains a proxy that is identical to this proxy, except for its connection timeout setting
+ * which overrides the timeot setting from the proxy endpoints.
+ * @param timeout The connection timeout override for the proxy (in milliseconds).
+ * @return A proxy with the specified timeout override.
*/
::std::shared_ptr<Prx> ice_timeout(int timeout) const
{
@@ -1357,6 +1383,17 @@ public:
}
/**
+ * Obtains a proxy that is identical to this proxy, except it's a fixed proxy bound
+ * the given connection.
+ * @param connection The fixed proxy connection.
+ * @return A fixed proxy bound to the given connection.
+ */
+ ::std::shared_ptr<Prx> ice_fixed(const ::std::shared_ptr<::Ice::Connection>& connection) const
+ {
+ return ::std::dynamic_pointer_cast<Prx>(ObjectPrx::ice_fixed(connection));
+ }
+
+ /**
* Obtains a proxy that is identical to this proxy, except for the encoding used to marshal
* parameters.
* @param version The encoding version to use to marshal request parameters.
@@ -2561,20 +2598,36 @@ public:
bool ice_isBatchDatagram() const;
/**
- * Obtains a proxy that is identical to this proxy, except for compression.
+ * Obtains a proxy that is identical to this proxy, except for its compression setting which
+ * overrides the compression setting from the proxy endpoints.
* @param b True enables compression for the new proxy, false disables compression.
- * @return A proxy with the specified compression setting.
+ * @return A proxy with the specified compression override setting.
*/
::Ice::ObjectPrx ice_compress(bool b) const;
/**
- * Obtains a proxy that is identical to this proxy, except for its connection timeout setting.
- * @param timeout The connection timeout for the proxy (in milliseconds).
- * @return A proxy with the specified timeout.
+ * Obtains the compression override setting of this proxy.
+ * @return The compression override setting. If nullopt is returned, no override is set. Otherwise, true
+ * if compression is enabled, false otherwise.
+ */
+ ::IceUtil::Optional<bool> ice_getCompress() const;
+
+ /**
+ * Obtains a proxy that is identical to this proxy, except for its connection timeout setting
+ * which overrides the timeot setting from the proxy endpoints.
+ * @param timeout The connection timeout override for the proxy (in milliseconds).
+ * @return A proxy with the specified timeout override.
*/
::Ice::ObjectPrx ice_timeout(int timeout) const;
/**
+ * Obtains the timeout override of this proxy.
+ * @return The timeout override. If nullopt is returned, no override is set. Otherwise, returns
+ * the timeout override value.
+ */
+ ::IceUtil::Optional<int> ice_getTimeout() const;
+
+ /**
* Obtains a proxy that is identical to this proxy, except for its connection ID.
* @param id The connection ID for the new proxy. An empty string removes the
* connection ID.
@@ -2589,6 +2642,14 @@ public:
::std::string ice_getConnectionId() const;
/**
+ * Obtains a proxy that is identical to this proxy, except it's a fixed proxy bound
+ * the given connection.
+ * @param connection The fixed proxy connection.
+ * @return A fixed proxy bound to the given connection.
+ */
+ ::Ice::ObjectPrx ice_fixed(const ::Ice::ConnectionPtr& connection) const;
+
+ /**
* Obtains the Connection for this proxy. If the proxy does not yet have an established connection,
* it first attempts to create a connection.
* @return The connection for this proxy.
@@ -2964,9 +3025,10 @@ public:
}
/**
- * Obtains a proxy that is identical to this proxy, except for compression.
+ * Obtains a proxy that is identical to this proxy, except for its compression setting which
+ * overrides the compression setting from the proxy endpoints.
* @param b True enables compression for the new proxy, false disables compression.
- * @return A proxy with the specified compression setting.
+ * @return A proxy with the specified compression override setting.
*/
IceInternal::ProxyHandle<Prx> ice_compress(bool b) const
{
@@ -2974,9 +3036,10 @@ public:
}
/**
- * Obtains a proxy that is identical to this proxy, except for its connection timeout setting.
- * @param timeout The connection timeout for the proxy (in milliseconds).
- * @return A proxy with the specified timeout.
+ * Obtains a proxy that is identical to this proxy, except for its connection timeout setting
+ * which overrides the timeot setting from the proxy endpoints.
+ * @param timeout The connection timeout override for the proxy (in milliseconds).
+ * @return A proxy with the specified timeout override.
*/
IceInternal::ProxyHandle<Prx> ice_timeout(int timeout) const
{
@@ -2995,6 +3058,17 @@ public:
}
/**
+ * Obtains a proxy that is identical to this proxy, except it's a fixed proxy bound
+ * the given connection.
+ * @param connection The fixed proxy connection.
+ * @return A fixed proxy bound to the given connection.
+ */
+ IceInternal::ProxyHandle<Prx> ice_fixed(const ::Ice::ConnectionPtr& connection) const
+ {
+ return dynamic_cast<Prx*>(::IceProxy::Ice::Object::ice_fixed(connection).get());
+ }
+
+ /**
* Obtains a proxy that is identical to this proxy, except for the encoding used to marshal
* parameters.
* @param version The encoding version to use to marshal request parameters.
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index d24fcc1c4b2..2df594c44e5 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -1199,6 +1199,12 @@ ICE_OBJECT_PRX::ice_compress(bool b) const
}
}
+IceUtil::Optional<bool>
+ICE_OBJECT_PRX::ice_getCompress() const
+{
+ return _reference->getCompress();
+}
+
ObjectPrxPtr
ICE_OBJECT_PRX::ice_timeout(int t) const
{
@@ -1225,6 +1231,12 @@ ICE_OBJECT_PRX::ice_timeout(int t) const
}
}
+IceUtil::Optional<int>
+ICE_OBJECT_PRX::ice_getTimeout() const
+{
+ return _reference->getTimeout();
+}
+
ObjectPrxPtr
ICE_OBJECT_PRX::ice_connectionId(const string& id) const
{
@@ -1247,6 +1259,39 @@ ICE_OBJECT_PRX::ice_getConnectionId() const
return _reference->getConnectionId();
}
+ObjectPrxPtr
+ICE_OBJECT_PRX::ice_fixed(const ::Ice::ConnectionPtr& connection) const
+{
+ if(!connection)
+ {
+#ifdef ICE_CPP11_MAPPING
+ throw invalid_argument("invalid null connection passed to ice_fixed");
+#else
+ throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "invalid null connection passed to ice_fixed");
+#endif
+ }
+ ::Ice::ConnectionIPtr impl = ICE_DYNAMIC_CAST(::Ice::ConnectionI, connection);
+ if(!impl)
+ {
+#ifdef ICE_CPP11_MAPPING
+ throw invalid_argument("invalid connection passed to ice_fixed");
+#else
+ throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "invalid connection passed to ice_fixed");
+#endif
+ }
+ ReferencePtr ref = _reference->changeConnection(impl);
+ if(ref == _reference)
+ {
+ return CONST_POINTER_CAST_OBJECT_PRX;
+ }
+ else
+ {
+ ObjectPrxPtr proxy = _newInstance();
+ proxy->setup(ref);
+ return proxy;
+ }
+}
+
ConnectionPtr
ICE_OBJECT_PRX::ice_getCachedConnection() const
{
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index baf9f9eb719..2f331a1dace 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -658,6 +658,12 @@ IceInternal::FixedReference::getConnectionId() const
return string();
}
+IceUtil::Optional<int>
+IceInternal::FixedReference::getTimeout() const
+{
+ return IceUtil::Optional<int>();
+}
+
ReferencePtr
IceInternal::FixedReference::changeEndpoints(const vector<EndpointIPtr>& /*newEndpoints*/) const
{
@@ -735,6 +741,18 @@ IceInternal::FixedReference::changeConnectionId(const string&) const
return 0; // Keep the compiler happy.
}
+ReferencePtr
+IceInternal::FixedReference::changeConnection(const Ice::ConnectionIPtr& newConnection) const
+{
+ if(newConnection == _fixedConnection)
+ {
+ return FixedReferencePtr(const_cast<FixedReference*>(this));
+ }
+ FixedReferencePtr r = FixedReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
+ r->_fixedConnection = newConnection;
+ return r;
+}
+
bool
IceInternal::FixedReference::isIndirect() const
{
@@ -979,6 +997,12 @@ IceInternal::RoutableReference::getConnectionId() const
return _connectionId;
}
+IceUtil::Optional<int>
+IceInternal::RoutableReference::getTimeout() const
+{
+ return _overrideTimeout ? IceUtil::Optional<int>(_timeout) : IceUtil::None;
+}
+
ReferencePtr
IceInternal::RoutableReference::changeEncoding(const Ice::EncodingVersion& encoding) const
{
@@ -1167,6 +1191,19 @@ IceInternal::RoutableReference::changeConnectionId(const string& id) const
return r;
}
+ReferencePtr
+IceInternal::RoutableReference::changeConnection(const Ice::ConnectionIPtr& connection) const
+{
+ return new FixedReference(getInstance(),
+ getCommunicator(),
+ getIdentity(),
+ getFacet(),
+ getMode(),
+ getSecure(),
+ getEncoding(),
+ connection);
+}
+
bool
IceInternal::RoutableReference::isIndirect() const
{
diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h
index 3addd9a29f0..c06786e0339 100644
--- a/cpp/src/Ice/Reference.h
+++ b/cpp/src/Ice/Reference.h
@@ -72,6 +72,10 @@ public:
const InstancePtr& getInstance() const { return _instance; }
const SharedContextPtr& getContext() const { return _context; }
int getInvocationTimeout() const { return _invocationTimeout; }
+ IceUtil::Optional<bool> getCompress() const
+ {
+ return _overrideCompress ? IceUtil::Optional<bool>(_compress) : IceUtil::None;
+ }
Ice::CommunicatorPtr getCommunicator() const;
@@ -85,6 +89,7 @@ public:
virtual Ice::EndpointSelectionType getEndpointSelection() const = 0;
virtual int getLocatorCacheTimeout() const = 0;
virtual std::string getConnectionId() const = 0;
+ virtual IceUtil::Optional<int> getTimeout() const = 0;
//
// The change* methods (here and in derived classes) create
@@ -112,6 +117,7 @@ public:
virtual ReferencePtr changeTimeout(int) const = 0;
virtual ReferencePtr changeConnectionId(const std::string&) const = 0;
+ virtual ReferencePtr changeConnection(const Ice::ConnectionIPtr&) const = 0;
int hash() const; // Conceptually const.
@@ -195,6 +201,7 @@ public:
virtual Ice::EndpointSelectionType getEndpointSelection() const;
virtual int getLocatorCacheTimeout() const;
virtual std::string getConnectionId() const;
+ virtual IceUtil::Optional<int> getTimeout() const;
virtual ReferencePtr changeEndpoints(const std::vector<EndpointIPtr>&) const;
virtual ReferencePtr changeAdapterId(const std::string&) const;
@@ -208,6 +215,7 @@ public:
virtual ReferencePtr changeTimeout(int) const;
virtual ReferencePtr changeConnectionId(const std::string&) const;
+ virtual ReferencePtr changeConnection(const Ice::ConnectionIPtr&) const;
virtual bool isIndirect() const;
virtual bool isWellKnown() const;
@@ -249,6 +257,7 @@ public:
virtual Ice::EndpointSelectionType getEndpointSelection() const;
virtual int getLocatorCacheTimeout() const;
virtual std::string getConnectionId() const;
+ virtual IceUtil::Optional<int> getTimeout() const;
virtual ReferencePtr changeEncoding(const Ice::EncodingVersion&) const;
virtual ReferencePtr changeCompress(bool) const;
@@ -264,6 +273,7 @@ public:
virtual ReferencePtr changeTimeout(int) const;
virtual ReferencePtr changeConnectionId(const std::string&) const;
+ virtual ReferencePtr changeConnection(const Ice::ConnectionIPtr&) const;
virtual bool isIndirect() const;
virtual bool isWellKnown() const;
diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp
index 8c04095bc86..283238351fe 100644
--- a/cpp/test/Ice/proxy/AllTests.cpp
+++ b/cpp/test/Ice/proxy/AllTests.cpp
@@ -768,11 +768,19 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(Ice::targetLess(compObj->ice_compress(false), compObj->ice_compress(true)));
test(Ice::targetGreaterEqual(compObj->ice_compress(true), compObj->ice_compress(false)));
+ test(compObj->ice_getCompress() == Ice::nullopt);
+ test(compObj->ice_compress(true)->ice_getCompress() == Ice::optional<bool>(true));
+ test(compObj->ice_compress(false)->ice_getCompress() == Ice::optional<bool>(false));
+
test(Ice::targetEqualTo(compObj->ice_timeout(20), compObj->ice_timeout(20)));
test(Ice::targetNotEqualTo(compObj->ice_timeout(10), compObj->ice_timeout(20)));
test(Ice::targetLess(compObj->ice_timeout(10), compObj->ice_timeout(20)));
test(Ice::targetGreaterEqual(compObj->ice_timeout(20), compObj->ice_timeout(10)));
+ test(compObj->ice_getTimeout() == Ice::nullopt);
+ test(compObj->ice_timeout(10)->ice_getTimeout() == Ice::optional<int>(10));
+ test(compObj->ice_timeout(20)->ice_getTimeout() == Ice::optional<int>(20));
+
auto loc1 = Ice::uncheckedCast<Ice::LocatorPrx>(communicator->stringToProxy("loc1:default -p 10000"));
auto loc2 = Ice::uncheckedCast<Ice::LocatorPrx>(communicator->stringToProxy("loc2:default -p 10000"));
@@ -847,7 +855,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::EndpointSeq endpts1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000")->ice_getEndpoints();
Ice::EndpointSeq endpts2 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10001")->ice_getEndpoints();
- test(endpts1.size() != endpts2.size() || !equal(endpts1.begin(), endpts1.end(), endpts2.begin(), Ice::TargetCompare<shared_ptr<Ice::Endpoint>, std::equal_to>()));
+ test(endpts1.size() != endpts2.size() || !equal(endpts1.begin(), endpts1.end(), endpts2.begin(), Ice::TargetCompare<shared_ptr<Ice::Endpoint>, std::equal_to>()));
test(lexicographical_compare(endpts1.begin(), endpts1.end(), endpts2.begin(), endpts2.end(), Ice::TargetCompare<shared_ptr<Ice::Endpoint>, std::less>()));
test(!lexicographical_compare(endpts2.begin(), endpts2.end(), endpts1.begin(), endpts1.end(), Ice::TargetCompare<shared_ptr<Ice::Endpoint>, std::less>()));
@@ -859,9 +867,22 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(Ice::targetLess(compObj->ice_encodingVersion(Ice::Encoding_1_0), compObj->ice_encodingVersion(Ice::Encoding_1_1)));
test(Ice::targetGreaterEqual(compObj->ice_encodingVersion(Ice::Encoding_1_1), compObj->ice_encodingVersion(Ice::Encoding_1_0)));
- //
- // TODO: Ideally we should also test comparison of fixed proxies.
- //
+ Ice::ConnectionPtr baseConnection = base->ice_getConnection();
+ if(baseConnection)
+ {
+ Ice::ConnectionPtr baseConnection2 = base->ice_connectionId("base2")->ice_getConnection();
+ compObj1 = compObj1->ice_fixed(baseConnection);
+ compObj2 = compObj2->ice_fixed(baseConnection2);
+ test(Ice::targetNotEqualTo(compObj1, compObj2));
+ if(Ice::targetLess(compObj1, compObj2))
+ {
+ test(Ice::targetGreaterEqual(compObj2, compObj1));
+ }
+ else
+ {
+ test(Ice::targetGreaterEqual(compObj1, compObj2));
+ }
+ }
cout << "ok" << endl;
@@ -938,11 +959,19 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(compObj->ice_compress(false) < compObj->ice_compress(true));
test(!(compObj->ice_compress(true) < compObj->ice_compress(false)));
+ test(!compObj->ice_getCompress());
+ test(compObj->ice_compress(true)->ice_getCompress() == IceUtil::Optional<bool>(true));
+ test(compObj->ice_compress(false)->ice_getCompress() == IceUtil::Optional<bool>(false));
+
test(compObj->ice_timeout(20) == compObj->ice_timeout(20));
test(compObj->ice_timeout(10) != compObj->ice_timeout(20));
test(compObj->ice_timeout(10) < compObj->ice_timeout(20));
test(!(compObj->ice_timeout(20) < compObj->ice_timeout(10)));
+ test(!compObj->ice_getTimeout());
+ test(compObj->ice_timeout(10)->ice_getTimeout() == IceUtil::Optional<int>(10));
+ test(compObj->ice_timeout(20)->ice_getTimeout() == IceUtil::Optional<int>(20));
+
Ice::LocatorPrxPtr loc1 = ICE_UNCHECKED_CAST(Ice::LocatorPrx, communicator->stringToProxy("loc1:" + endp));
Ice::LocatorPrxPtr loc2 = ICE_UNCHECKED_CAST(Ice::LocatorPrx, communicator->stringToProxy("loc2:" + endp));
test(compObj->ice_locator(0) == compObj->ice_locator(0));
@@ -1024,9 +1053,22 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(compObj->ice_encodingVersion(Ice::Encoding_1_0) < compObj->ice_encodingVersion(Ice::Encoding_1_1));
test(!(compObj->ice_encodingVersion(Ice::Encoding_1_1) < compObj->ice_encodingVersion(Ice::Encoding_1_0)));
- //
- // TODO: Ideally we should also test comparison of fixed proxies.
- //
+ Ice::ConnectionPtr baseConnection = base->ice_getConnection();
+ if(baseConnection)
+ {
+ Ice::ConnectionPtr baseConnection2 = base->ice_connectionId("base2")->ice_getConnection();
+ compObj1 = compObj1->ice_fixed(baseConnection);
+ compObj2 = compObj2->ice_fixed(baseConnection2);
+ test(compObj1 != compObj2);
+ if(compObj1 < compObj2)
+ {
+ test(compObj2 >= compObj1);
+ }
+ else
+ {
+ test(compObj1 >= compObj2);
+ }
+ }
cout << "ok" << endl;
@@ -1104,6 +1146,41 @@ allTests(const Ice::CommunicatorPtr& communicator)
#endif
cout << "ok" << endl;
+ cout << "testing ice_fixed... " << flush;
+ {
+ Ice::ConnectionPtr connection = cl->ice_getConnection();
+ if(connection)
+ {
+ cl->ice_fixed(connection)->ice_ping();
+ test(cl->ice_secure(true)->ice_fixed(connection)->ice_isSecure());
+ test(cl->ice_facet("facet")->ice_fixed(connection)->ice_getFacet() == "facet");
+ test(cl->ice_oneway()->ice_fixed(connection)->ice_isOneway());
+ test(cl->ice_fixed(connection)->ice_getConnection() == connection);
+ test(cl->ice_fixed(connection)->ice_fixed(connection)->ice_getConnection() == connection);
+ test(!cl->ice_fixed(connection)->ice_getTimeout());
+ Ice::ConnectionPtr fixedConnection = cl->ice_connectionId("ice_fixed")->ice_getConnection();
+ test(cl->ice_fixed(connection)->ice_fixed(fixedConnection)->ice_getConnection() == fixedConnection);
+ }
+ else
+ {
+ try
+ {
+ cl->ice_fixed(connection);
+ test(false);
+ }
+#ifdef ICE_CPP11_MAPPING
+ catch(const invalid_argument&)
+#else
+ catch(const IceUtil::IllegalArgumentException&)
+#endif
+ {
+ // Expected with null connection.
+ }
+
+ }
+ }
+ cout << "ok" << endl;
+
cout << "testing encoding versioning... " << flush;
string ref20 = "test -e 2.0:" + endp;
Test::MyClassPrxPtr cl20 = ICE_UNCHECKED_CAST(Test::MyClassPrx, communicator->stringToProxy(ref20));
diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs
index 245f6b12b26..c692a6ca806 100644
--- a/csharp/src/Ice/Proxy.cs
+++ b/csharp/src/Ice/Proxy.cs
@@ -668,6 +668,13 @@ namespace Ice
ObjectPrx ice_compress(bool co);
/// <summary>
+ /// Obtains the compression override setting of this proxy.
+ /// </summary>
+ /// <returns>The compression override setting. If no optional value is present, no override is
+ /// set. Otherwise, true if compression is enabled, false otherwise.</returns>
+ Ice.Optional<bool> ice_getCompress();
+
+ /// <summary>
/// Creates a new proxy that is identical to this proxy, except for its timeout setting.
/// </summary>
/// <param name="t">The timeout for the new proxy in milliseconds.</param>
@@ -675,6 +682,13 @@ namespace Ice
ObjectPrx ice_timeout(int t);
/// <summary>
+ /// Obtains the timeout override of this proxy.
+ /// </summary>
+ /// <returns>The timeout override. If no optional value is present, no override is set. Otherwise,
+ /// returns the timeout override value.</returns>
+ Ice.Optional<int> ice_getTimeout();
+
+ /// <summary>
/// Creates a new proxy that is identical to this proxy, except for its connection ID.
/// </summary>
/// <param name="connectionId">The connection ID for the new proxy. An empty string removes the
@@ -689,6 +703,14 @@ namespace Ice
string ice_getConnectionId();
/// <summary>
+ /// Returns a proxy that is identical to this proxy, except it's a fixed proxy bound
+ /// the given connection.
+ /// </summary>
+ /// <param name="connection">The fixed proxy connection.</param>
+ /// <returns>A fixed proxy bound to the given connection.</returns>
+ ObjectPrx ice_fixed(Ice.Connection connection);
+
+ /// <summary>
/// Returns the Connection for this proxy. If the proxy does not yet have an established connection,
/// it first attempts to create a connection.
/// </summary>
@@ -2073,6 +2095,16 @@ namespace Ice
}
/// <summary>
+ /// Obtains the compression override setting of this proxy.
+ /// </summary>
+ /// <returns>The compression override setting. If no optional value is present, no override is
+ /// set. Otherwise, true if compression is enabled, false otherwise.</returns>
+ public Ice.Optional<bool> ice_getCompress()
+ {
+ return _reference.getCompress();
+ }
+
+ /// <summary>
/// Creates a new proxy that is identical to this proxy, except for its timeout setting.
/// </summary>
/// <param name="t">The timeout for the new proxy in milliseconds.</param>
@@ -2095,6 +2127,16 @@ namespace Ice
}
/// <summary>
+ /// Obtains the timeout override of this proxy.
+ /// </summary>
+ /// <returns>The timeout override. If no optional value is present, no override is set. Otherwise,
+ /// returns the timeout override value.</returns>
+ public Ice.Optional<int> ice_getTimeout()
+ {
+ return _reference.getTimeout();
+ }
+
+ /// <summary>
/// Creates a new proxy that is identical to this proxy, except for its connection ID.
/// </summary>
/// <param name="connectionId">The connection ID for the new proxy. An empty string removes the
@@ -2122,6 +2164,33 @@ namespace Ice
return _reference.getConnectionId();
}
+ /// <summary>
+ /// Returns a proxy that is identical to this proxy, except it's a fixed proxy bound
+ /// the given connection.
+ /// </summary>
+ /// <param name="connection">The fixed proxy connection.</param>
+ /// <returns>A fixed proxy bound to the given connection.</returns>
+ public ObjectPrx ice_fixed(Ice.Connection connection)
+ {
+ if(connection == null)
+ {
+ throw new ArgumentException("invalid null connection passed to ice_fixed");
+ }
+ if(!(connection is Ice.ConnectionI))
+ {
+ throw new ArgumentException("invalid connection passed to ice_fixed");
+ }
+ var @ref = _reference.changeConnection((Ice.ConnectionI)connection);
+ if(@ref.Equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ return newInstance(@ref);
+ }
+ }
+
private class ProxyGetConnectionAsyncCallback : ProxyAsyncResultCompletionCallback<Callback_Object_ice_getConnection>
{
public ProxyGetConnectionAsyncCallback(ObjectPrxHelperBase proxy, string operation, object cookie,
diff --git a/csharp/src/Ice/Reference.cs b/csharp/src/Ice/Reference.cs
index 09628f4b120..c4bd632734d 100644
--- a/csharp/src/Ice/Reference.cs
+++ b/csharp/src/Ice/Reference.cs
@@ -78,6 +78,12 @@ namespace IceInternal
return _invocationTimeout;
}
+ public Ice.Optional<bool>
+ getCompress()
+ {
+ return overrideCompress_ ? compress_ : new Ice.Optional<bool>();
+ }
+
public Ice.Communicator getCommunicator()
{
return _communicator;
@@ -93,6 +99,7 @@ namespace IceInternal
public abstract Ice.EndpointSelectionType getEndpointSelection();
public abstract int getLocatorCacheTimeout();
public abstract string getConnectionId();
+ public abstract Ice.Optional<int> getTimeout();
public abstract ThreadPool getThreadPool();
//
@@ -209,6 +216,7 @@ namespace IceInternal
public abstract Reference changeTimeout(int newTimeout);
public abstract Reference changeConnectionId(string connectionId);
+ public abstract Reference changeConnection(Ice.ConnectionI connection);
public override int GetHashCode()
{
@@ -607,6 +615,11 @@ namespace IceInternal
return "";
}
+ public override Ice.Optional<int> getTimeout()
+ {
+ return new Ice.Optional<int>();
+ }
+
public override ThreadPool getThreadPool()
{
return _fixedConnection.getThreadPool();
@@ -667,6 +680,17 @@ namespace IceInternal
throw new Ice.FixedProxyException();
}
+ public override Reference changeConnection(Ice.ConnectionI connection)
+ {
+ if(_fixedConnection == connection)
+ {
+ return this;
+ }
+ FixedReference r = (FixedReference)getInstance().referenceFactory().copy(this);
+ r._fixedConnection = connection;
+ return r;
+ }
+
public override bool isIndirect()
{
return false;
@@ -767,7 +791,7 @@ namespace IceInternal
{
return false;
}
- return _fixedConnection.Equals(_fixedConnection);
+ return _fixedConnection.Equals(rhs._fixedConnection);
}
//
@@ -834,6 +858,11 @@ namespace IceInternal
return _connectionId;
}
+ public override Ice.Optional<int> getTimeout()
+ {
+ return _overrideTimeout ? _timeout : new Ice.Optional<int>();
+ }
+
public override ThreadPool getThreadPool()
{
return getInstance().clientThreadPool();
@@ -1015,6 +1044,18 @@ namespace IceInternal
return r;
}
+ public override Reference changeConnection(Ice.ConnectionI connection)
+ {
+ return new FixedReference(getInstance(),
+ getCommunicator(),
+ getIdentity(),
+ getFacet(),
+ getMode(),
+ getSecure(),
+ getEncoding(),
+ connection);
+ }
+
public override bool isIndirect()
{
return _endpoints.Length == 0;
diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs
index 07b38a31b9c..b06ef372225 100644
--- a/csharp/test/Ice/proxy/AllTests.cs
+++ b/csharp/test/Ice/proxy/AllTests.cs
@@ -711,9 +711,17 @@ public class AllTests : TestCommon.AllTests
test(compObj.ice_compress(true).Equals(compObj.ice_compress(true)));
test(!compObj.ice_compress(false).Equals(compObj.ice_compress(true)));
+ test(!compObj.ice_getCompress().HasValue);
+ test(compObj.ice_compress(true).ice_getCompress().Value == true);
+ test(compObj.ice_compress(false).ice_getCompress().Value == false);
+
test(compObj.ice_timeout(20).Equals(compObj.ice_timeout(20)));
test(!compObj.ice_timeout(10).Equals(compObj.ice_timeout(20)));
+ test(!compObj.ice_getTimeout().HasValue);
+ test(compObj.ice_timeout(10).ice_getTimeout().Value == 10);
+ test(compObj.ice_timeout(20).ice_getTimeout().Value == 20);
+
Ice.LocatorPrx loc1 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000"));
Ice.LocatorPrx loc2 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc2:default -p 10000"));
test(compObj.ice_locator(null).Equals(compObj.ice_locator(null)));
@@ -766,9 +774,14 @@ public class AllTests : TestCommon.AllTests
test(!endpts1[0].Equals(endpts2[0]));
test(endpts1[0].Equals(communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints()[0]));
- //
- // TODO: Ideally we should also test comparison of fixed proxies.
- //
+ Ice.Connection baseConnection = baseProxy.ice_getConnection();
+ if(baseConnection != null)
+ {
+ Ice.Connection baseConnection2 = baseProxy.ice_connectionId("base2").ice_getConnection();
+ compObj1 = compObj1.ice_fixed(baseConnection);
+ compObj2 = compObj2.ice_fixed(baseConnection2);
+ test(!compObj1.Equals(compObj2));
+ }
WriteLine("ok");
Write("testing checked cast... ");
@@ -796,6 +809,37 @@ public class AllTests : TestCommon.AllTests
test(Ice.CollectionComparer.Equals(c, c2));
WriteLine("ok");
+ Write("testing ice_fixed... ");
+ Flush();
+ {
+ Ice.Connection connection = cl.ice_getConnection();
+ if(connection != null)
+ {
+ cl.ice_fixed(connection).ice_ping();
+ test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure());
+ test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet().Equals("facet"));
+ test(cl.ice_oneway().ice_fixed(connection).ice_isOneway());
+ test(cl.ice_fixed(connection).ice_getConnection() == connection);
+ test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection);
+ test(!cl.ice_fixed(connection).ice_getTimeout().HasValue);
+ Ice.Connection fixedConnection = cl.ice_connectionId("ice_fixed").ice_getConnection();
+ test(cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection);
+ }
+ else
+ {
+ try
+ {
+ cl.ice_fixed(connection);
+ test(false);
+ }
+ catch(ArgumentException)
+ {
+ // Expected with null connection.
+ }
+ }
+ }
+ WriteLine("ok");
+
Write("testing encoding versioning... ");
Flush();
string ref20 = "test -e 2.0:" + app.getTestEndpoint(0);
diff --git a/java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java b/java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java
index 933773ee817..e7a9db30540 100644
--- a/java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java
+++ b/java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java
@@ -1074,6 +1074,14 @@ public interface ObjectPrx
ObjectPrx ice_compress(boolean co);
/**
+ * Obtains the compression override setting of this proxy.
+ *
+ * @return The compression override setting. If no optional value is present, no override is
+ * set. Otherwise, true if compression is enabled, false otherwise.
+ */
+ Ice.BooleanOptional ice_getCompress();
+
+ /**
* Creates a new proxy that is identical to this proxy, except for its timeout setting.
*
* @param t The timeout for the new proxy in milliseconds.
@@ -1082,6 +1090,14 @@ public interface ObjectPrx
ObjectPrx ice_timeout(int t);
/**
+ * Obtains the timeout override of this proxy.
+ *
+ * @return The timeout override. If no optional value is present, no override is set. Otherwise,
+ * returns the timeout override value.
+ */
+ Ice.IntOptional ice_getTimeout();
+
+ /**
* Creates a new proxy that is identical to this proxy, except for its connection ID.
*
* @param connectionId The connection ID for the new proxy. An empty string removes the
@@ -1092,6 +1108,15 @@ public interface ObjectPrx
ObjectPrx ice_connectionId(String connectionId);
/**
+ * Returns a proxy that is identical to this proxy, except it's a fixed proxy bound
+ * the given connection.
+ *
+ * @param connection The fixed proxy connection.
+ * @return A fixed proxy bound to the given connection.
+ */
+ ObjectPrx ice_fixed(Ice.Connection connection);
+
+ /**
* Returns the {@link Connection} for this proxy. If the proxy does not yet have an established connection,
* it first attempts to create a connection.
*
diff --git a/java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java b/java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java
index decc37a32ab..a410f2caceb 100644
--- a/java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java
+++ b/java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java
@@ -2212,6 +2212,19 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
/**
+ * Obtains the compression override setting of this proxy.
+ *
+ * @return The compression override setting. If no optional value is present, no override is
+ * set. Otherwise, true if compression is enabled, false otherwise.
+ */
+ @Override
+ public final Ice.BooleanOptional
+ ice_getCompress()
+ {
+ return _reference.getCompress();
+ }
+
+ /**
* Creates a new proxy that is identical to this proxy, except for its timeout setting.
*
* @param t The timeout for the new proxy in milliseconds.
@@ -2237,6 +2250,19 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
/**
+ * Obtains the timeout override of this proxy.
+ *
+ * @return The timeout override. If no optional value is present, no override is set. Otherwise,
+ * returns the timeout override value.
+ */
+ @Override
+ public final Ice.IntOptional
+ ice_getTimeout()
+ {
+ return _reference.getTimeout();
+ }
+
+ /**
* Creates a new proxy that is identical to this proxy, except for its connection ID.
*
* @param id The connection ID for the new proxy. An empty string removes the
@@ -2260,6 +2286,36 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
/**
+ * Returns a proxy that is identical to this proxy, except it's a fixed proxy bound
+ * the given connection.
+ *
+ * @param connection The fixed proxy connection.
+ * @return A fixed proxy bound to the given connection.
+ */
+ @Override
+ public final ObjectPrx
+ ice_fixed(Ice.Connection connection)
+ {
+ if(connection == null)
+ {
+ throw new IllegalArgumentException("invalid null connection passed to ice_fixed");
+ }
+ if(!(connection instanceof Ice.ConnectionI))
+ {
+ throw new IllegalArgumentException("invalid connection passed to ice_fixed");
+ }
+ IceInternal.Reference ref = _reference.changeConnection((Ice.ConnectionI)connection);
+ if(ref.equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ return newInstance(ref);
+ }
+ }
+
+ /**
* Returns the {@link Connection} for this proxy. If the proxy does not yet have an established connection,
* it first attempts to create a connection.
*
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/FixedReference.java b/java-compat/src/Ice/src/main/java/IceInternal/FixedReference.java
index 8e7275d8294..9756fb5c01f 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/FixedReference.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/FixedReference.java
@@ -96,6 +96,13 @@ public class FixedReference extends Reference
}
@Override
+ public Ice.IntOptional
+ getTimeout()
+ {
+ return new Ice.IntOptional();
+ }
+
+ @Override
public Reference
changeEndpoints(EndpointI[] newEndpoints)
{
@@ -173,6 +180,19 @@ public class FixedReference extends Reference
}
@Override
+ public Reference
+ changeConnection(Ice.ConnectionI connection)
+ {
+ if(_fixedConnection == connection)
+ {
+ return this;
+ }
+ FixedReference r = (FixedReference)getInstance().referenceFactory().copy(this);
+ r._fixedConnection = connection;
+ return r;
+ }
+
+ @Override
public boolean
isIndirect()
{
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/Reference.java b/java-compat/src/Ice/src/main/java/IceInternal/Reference.java
index ee1a72b6246..f16a2282455 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/Reference.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/Reference.java
@@ -78,6 +78,12 @@ public abstract class Reference implements Cloneable
return _invocationTimeout;
}
+ public Ice.BooleanOptional
+ getCompress()
+ {
+ return _overrideCompress ? Ice.Optional.O(_compress) : new Ice.BooleanOptional();
+ }
+
public final Ice.Communicator
getCommunicator()
{
@@ -94,6 +100,7 @@ public abstract class Reference implements Cloneable
public abstract Ice.EndpointSelectionType getEndpointSelection();
public abstract int getLocatorCacheTimeout();
public abstract String getConnectionId();
+ public abstract Ice.IntOptional getTimeout();
//
// The change* methods (here and in derived classes) create
@@ -216,6 +223,7 @@ public abstract class Reference implements Cloneable
public abstract Reference changeTimeout(int newTimeout);
public abstract Reference changeConnectionId(String connectionId);
+ public abstract Reference changeConnection(Ice.ConnectionI connection);
@Override
public synchronized int
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/RoutableReference.java b/java-compat/src/Ice/src/main/java/IceInternal/RoutableReference.java
index 3008584b182..187c2ae4bd9 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/RoutableReference.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/RoutableReference.java
@@ -82,6 +82,13 @@ public class RoutableReference extends Reference
}
@Override
+ public Ice.IntOptional
+ getTimeout()
+ {
+ return _overrideTimeout ? Ice.Optional.O(_timeout) : new Ice.IntOptional();
+ }
+
+ @Override
public Reference
changeEncoding(Ice.EncodingVersion newEncoding)
{
@@ -283,6 +290,20 @@ public class RoutableReference extends Reference
}
@Override
+ public Reference
+ changeConnection(Ice.ConnectionI connection)
+ {
+ return new FixedReference(getInstance(),
+ getCommunicator(),
+ getIdentity(),
+ getFacet(),
+ getMode(),
+ getSecure(),
+ getEncoding(),
+ connection);
+ }
+
+ @Override
public boolean
isIndirect()
{
diff --git a/java-compat/test/src/main/java/test/Ice/proxy/AllTests.java b/java-compat/test/src/main/java/test/Ice/proxy/AllTests.java
index b518677b4df..af4d50466e8 100644
--- a/java-compat/test/src/main/java/test/Ice/proxy/AllTests.java
+++ b/java-compat/test/src/main/java/test/Ice/proxy/AllTests.java
@@ -724,9 +724,17 @@ public class AllTests
test(compObj.ice_compress(true).equals(compObj.ice_compress(true)));
test(!compObj.ice_compress(false).equals(compObj.ice_compress(true)));
+ test(!compObj.ice_getCompress().isSet());
+ test(compObj.ice_compress(true).ice_getCompress().get() == true);
+ test(compObj.ice_compress(false).ice_getCompress().get() == false);
+
test(compObj.ice_timeout(20).equals(compObj.ice_timeout(20)));
test(!compObj.ice_timeout(10).equals(compObj.ice_timeout(20)));
+ test(!compObj.ice_getTimeout().isSet());
+ test(compObj.ice_timeout(10).ice_getTimeout().get() == 10);
+ test(compObj.ice_timeout(20).ice_getTimeout().get() == 20);
+
Ice.LocatorPrx loc1 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc1:tcp -p 10000"));
Ice.LocatorPrx loc2 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc2:tcp -p 10000"));
test(compObj.ice_locator(null).equals(compObj.ice_locator(null)));
@@ -784,9 +792,15 @@ public class AllTests
test(!compObj1.ice_encodingVersion(Ice.Util.Encoding_1_0).equals(
compObj1.ice_encodingVersion(Ice.Util.Encoding_1_1)));
- //
- // TODO: Ideally we should also test comparison of fixed proxies.
- //
+ Ice.Connection baseConnection = base.ice_getConnection();
+ if(baseConnection != null)
+ {
+ Ice.Connection baseConnection2 = base.ice_connectionId("base2").ice_getConnection();
+ compObj1 = compObj1.ice_fixed(baseConnection);
+ compObj2 = compObj2.ice_fixed(baseConnection2);
+ test(!compObj1.equals(compObj2));
+ }
+
out.println("ok");
out.print("testing checked cast... ");
@@ -883,6 +897,37 @@ public class AllTests
out.println("ok");
+ out.print("testing ice_fixed... ");
+ out.flush();
+ {
+ Ice.Connection connection = cl.ice_getConnection();
+ if(connection != null)
+ {
+ cl.ice_fixed(connection).ice_ping();
+ test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure());
+ test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet().equals("facet"));
+ test(cl.ice_oneway().ice_fixed(connection).ice_isOneway());
+ test(cl.ice_fixed(connection).ice_getConnection() == connection);
+ test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection);
+ test(!cl.ice_fixed(connection).ice_getTimeout().isSet());
+ Ice.Connection fixedConnection = cl.ice_connectionId("ice_fixed").ice_getConnection();
+ test(cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection);
+ }
+ else
+ {
+ try
+ {
+ cl.ice_fixed(connection);
+ test(false);
+ }
+ catch(IllegalArgumentException e)
+ {
+ // Expected with null connection.
+ }
+ }
+ }
+ out.println("ok");
+
out.print("testing protocol versioning... ");
out.flush();
ref20 = "test -p 2.0:" + app.getTestEndpoint(0);
diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java
index 5996072233d..20a9c6a6902 100644
--- a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java
+++ b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java
@@ -323,6 +323,18 @@ public interface ObjectPrx
String ice_getConnectionId();
/**
+ * Returns a proxy that is identical to this proxy, except it's a fixed proxy bound
+ * the given connection.
+ *
+ * @param connection The fixed proxy connection.
+ * @return A fixed proxy bound to the given connection.
+ */
+ default ObjectPrx ice_fixed(com.zeroc.Ice.Connection connection)
+ {
+ return _ice_fixed(connection);
+ }
+
+ /**
* Returns a proxy that is identical to this proxy, except for the locator cache timeout.
*
* @param newTimeout The new locator cache timeout (in seconds).
@@ -583,7 +595,8 @@ public interface ObjectPrx
boolean ice_isBatchDatagram();
/**
- * Returns a proxy that is identical to this proxy, except for compression.
+ * Returns a proxy that is identical to this proxy, except for its compression setting which
+ * overrides the compression setting from the proxy endpoints.
*
* @param co <code>true</code> enables compression for the new proxy; <code>false</code> disables compression.
* @return A proxy with the specified compression setting.
@@ -594,7 +607,16 @@ public interface ObjectPrx
}
/**
- * Returns a proxy that is identical to this proxy, except for its connection timeout setting.
+ * Obtains the compression override setting of this proxy.
+ *
+ * @return The compression override setting. If no optional value is present, no override is
+ * set. Otherwise, true if compression is enabled, false otherwise.
+ */
+ java.util.Optional<Boolean> ice_getCompress();
+
+ /**
+ * Returns a proxy that is identical to this proxy, except for its connection timeout setting
+ * which overrides the timeot setting from the proxy endpoints.
*
* @param t The connection timeout for the proxy in milliseconds.
* @return A proxy with the specified timeout.
@@ -605,6 +627,14 @@ public interface ObjectPrx
}
/**
+ * Obtains the timeout override of this proxy.
+ *
+ * @return The timeout override. If no optional value is present, no override is set. Otherwise,
+ * returns the timeout override value.
+ */
+ java.util.OptionalInt ice_getTimeout();
+
+ /**
* Returns a proxy that is identical to this proxy, except for its connection ID.
*
* @param connectionId The connection ID for the new proxy. An empty string removes the
@@ -993,6 +1023,26 @@ public interface ObjectPrx
}
}
+ default ObjectPrx _ice_fixed(com.zeroc.Ice.Connection connection)
+ {
+ if(connection == null)
+ {
+ throw new IllegalArgumentException("invalid null connection passed to ice_fixed");
+ }
+ if(!(connection instanceof com.zeroc.Ice.ConnectionI))
+ {
+ throw new IllegalArgumentException("invalid connection passed to ice_fixed");
+ }
+ if(connection == _getReference().getConnection())
+ {
+ return this;
+ }
+ else
+ {
+ return _newInstance(_getReference().changeConnection((com.zeroc.Ice.ConnectionI)connection));
+ }
+ }
+
default ObjectPrx _ice_locatorCacheTimeout(int newTimeout)
{
if(newTimeout < -1)
diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java b/java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java
index 52b65a2a5ba..490a396a90d 100644
--- a/java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java
+++ b/java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java
@@ -310,6 +310,16 @@ public class _ObjectPrxI implements ObjectPrx, java.io.Serializable
return _reference.getMode() == com.zeroc.IceInternal.Reference.ModeBatchDatagram;
}
+ public java.util.Optional<Boolean> ice_getCompress()
+ {
+ return _reference.getCompress();
+ }
+
+ public java.util.OptionalInt ice_getTimeout()
+ {
+ return _reference.getTimeout();
+ }
+
public Connection ice_getConnection()
{
return _iceI_ice_getConnectionAsync().waitForResponse();
diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/FixedReference.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/FixedReference.java
index aa0b2dc60a8..b1e12566833 100644
--- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/FixedReference.java
+++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/FixedReference.java
@@ -97,6 +97,13 @@ public class FixedReference extends Reference
}
@Override
+ public java.util.OptionalInt
+ getTimeout()
+ {
+ return java.util.OptionalInt.empty();
+ }
+
+ @Override
public com.zeroc.IceInternal.ThreadPool
getThreadPool()
{
@@ -104,6 +111,13 @@ public class FixedReference extends Reference
}
@Override
+ public com.zeroc.Ice.ConnectionI
+ getConnection()
+ {
+ return _fixedConnection;
+ }
+
+ @Override
public Reference
changeEndpoints(EndpointI[] newEndpoints)
{
@@ -181,6 +195,19 @@ public class FixedReference extends Reference
}
@Override
+ public Reference
+ changeConnection(com.zeroc.Ice.ConnectionI connection)
+ {
+ if(_fixedConnection == connection)
+ {
+ return this;
+ }
+ FixedReference r = (FixedReference)getInstance().referenceFactory().copy(this);
+ r._fixedConnection = connection;
+ return r;
+ }
+
+ @Override
public boolean
isIndirect()
{
diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/Reference.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/Reference.java
index cbeb15fef7b..8c289cabd8e 100644
--- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/Reference.java
+++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/Reference.java
@@ -78,6 +78,12 @@ public abstract class Reference implements Cloneable
return _invocationTimeout;
}
+ public java.util.Optional<Boolean>
+ getCompress()
+ {
+ return _overrideCompress ? java.util.Optional.of(_compress) : java.util.Optional.empty();
+ }
+
public final com.zeroc.Ice.Communicator
getCommunicator()
{
@@ -94,7 +100,9 @@ public abstract class Reference implements Cloneable
public abstract com.zeroc.Ice.EndpointSelectionType getEndpointSelection();
public abstract int getLocatorCacheTimeout();
public abstract String getConnectionId();
+ public abstract java.util.OptionalInt getTimeout();
public abstract com.zeroc.IceInternal.ThreadPool getThreadPool();
+ public abstract com.zeroc.Ice.ConnectionI getConnection();
//
// The change* methods (here and in derived classes) create
@@ -217,6 +225,7 @@ public abstract class Reference implements Cloneable
public abstract Reference changeTimeout(int newTimeout);
public abstract Reference changeConnectionId(String connectionId);
+ public abstract Reference changeConnection(com.zeroc.Ice.ConnectionI connection);
@Override
public synchronized int
diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/RoutableReference.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/RoutableReference.java
index e51bc458172..b2ef5cf7987 100644
--- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/RoutableReference.java
+++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/RoutableReference.java
@@ -82,12 +82,27 @@ public class RoutableReference extends Reference
}
@Override
- public final com.zeroc.IceInternal.ThreadPool getThreadPool()
+ public java.util.OptionalInt
+ getTimeout()
+ {
+ return _overrideTimeout ? java.util.OptionalInt.of(_timeout) : java.util.OptionalInt.empty();
+ }
+
+ @Override
+ public final com.zeroc.IceInternal.ThreadPool
+ getThreadPool()
{
return getInstance().clientThreadPool();
}
@Override
+ public final com.zeroc.Ice.ConnectionI
+ getConnection()
+ {
+ return null;
+ }
+
+ @Override
public Reference
changeEncoding(com.zeroc.Ice.EncodingVersion newEncoding)
{
@@ -289,6 +304,20 @@ public class RoutableReference extends Reference
}
@Override
+ public Reference
+ changeConnection(com.zeroc.Ice.ConnectionI connection)
+ {
+ return new FixedReference(getInstance(),
+ getCommunicator(),
+ getIdentity(),
+ getFacet(),
+ getMode(),
+ getSecure(),
+ getEncoding(),
+ connection);
+ }
+
+ @Override
public boolean
isIndirect()
{
diff --git a/java/test/src/main/java/test/Ice/proxy/AllTests.java b/java/test/src/main/java/test/Ice/proxy/AllTests.java
index 9902fd34087..a3d5240101e 100644
--- a/java/test/src/main/java/test/Ice/proxy/AllTests.java
+++ b/java/test/src/main/java/test/Ice/proxy/AllTests.java
@@ -726,9 +726,17 @@ public class AllTests
test(compObj.ice_compress(true).equals(compObj.ice_compress(true)));
test(!compObj.ice_compress(false).equals(compObj.ice_compress(true)));
+ test(!compObj.ice_getCompress().isPresent());
+ test(compObj.ice_compress(true).ice_getCompress().get() == true);
+ test(compObj.ice_compress(false).ice_getCompress().get() == false);
+
test(compObj.ice_timeout(20).equals(compObj.ice_timeout(20)));
test(!compObj.ice_timeout(10).equals(compObj.ice_timeout(20)));
+ test(!compObj.ice_getTimeout().isPresent());
+ test(compObj.ice_timeout(10).ice_getTimeout().getAsInt() == 10);
+ test(compObj.ice_timeout(20).ice_getTimeout().getAsInt() == 20);
+
com.zeroc.Ice.LocatorPrx loc1 =
com.zeroc.Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc1:tcp -p 10000"));
com.zeroc.Ice.LocatorPrx loc2 =
@@ -790,9 +798,15 @@ public class AllTests
test(compObj1.ice_encodingVersion(Util.Encoding_1_0).equals(compObj1.ice_encodingVersion(Util.Encoding_1_0)));
test(!compObj1.ice_encodingVersion(Util.Encoding_1_0).equals(compObj1.ice_encodingVersion(Util.Encoding_1_1)));
- //
- // TODO: Ideally we should also test comparison of fixed proxies.
- //
+ com.zeroc.Ice.Connection baseConnection = base.ice_getConnection();
+ if(baseConnection != null)
+ {
+ com.zeroc.Ice.Connection baseConnection2 = base.ice_connectionId("base2").ice_getConnection();
+ compObj1 = compObj1.ice_fixed(baseConnection);
+ compObj2 = compObj2.ice_fixed(baseConnection2);
+ test(!compObj1.equals(compObj2));
+ }
+
out.println("ok");
out.print("testing checked cast... ");
@@ -820,6 +834,37 @@ public class AllTests
test(c.equals(c2));
out.println("ok");
+ out.print("testing ice_fixed... ");
+ out.flush();
+ {
+ com.zeroc.Ice.Connection connection = cl.ice_getConnection();
+ if(connection != null)
+ {
+ cl.ice_fixed(connection).ice_ping();
+ test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure());
+ test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet().equals("facet"));
+ test(cl.ice_oneway().ice_fixed(connection).ice_isOneway());
+ test(cl.ice_fixed(connection).ice_getConnection() == connection);
+ test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection);
+ test(!cl.ice_fixed(connection).ice_getTimeout().isPresent());
+ com.zeroc.Ice.Connection fixedConnection = cl.ice_connectionId("ice_fixed").ice_getConnection();
+ test(cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection);
+ }
+ else
+ {
+ try
+ {
+ cl.ice_fixed(connection);
+ test(false);
+ }
+ catch(IllegalArgumentException e)
+ {
+ // Expected with null connection.
+ }
+ }
+ }
+ out.println("ok");
+
out.print("testing encoding versioning... ");
out.flush();
String ref20 = "test -e 2.0:" + app.getTestEndpoint(0);
diff --git a/js/package-lock.json b/js/package-lock.json
index 53197945c30..b9bdf253c89 100644
--- a/js/package-lock.json
+++ b/js/package-lock.json
@@ -2,6 +2,7 @@
"name": "ice",
"version": "3.7.1",
"lockfileVersion": 1,
+ "requires": true,
"dependencies": {
"@gulp-sourcemaps/identity-map": {
"version": "1.0.1",
diff --git a/js/src/Ice/ObjectPrx.js b/js/src/Ice/ObjectPrx.js
index ae4d66ed156..9478274e608 100644
--- a/js/src/Ice/ObjectPrx.js
+++ b/js/src/Ice/ObjectPrx.js
@@ -428,6 +428,32 @@ class ObjectPrx
}
}
+ ice_getTimeout()
+ {
+ return this._reference.getTimeout();
+ }
+
+ ice_fixed(connection)
+ {
+ if(connection === null)
+ {
+ throw new Error("invalid null connection passed to ice_fixed");
+ }
+ if(!(connection instanceof Ice.ConnectionI))
+ {
+ throw new Error("invalid connection passed to ice_fixed");
+ }
+ const ref = this._reference.changeConnection(connection);
+ if(ref.equals(this._reference))
+ {
+ return this;
+ }
+ else
+ {
+ return this._newInstance(ref);
+ }
+ }
+
ice_getConnectionId()
{
return this._reference.getConnectionId();
diff --git a/js/src/Ice/Reference.js b/js/src/Ice/Reference.js
index 01e981d6421..84a302cc676 100644
--- a/js/src/Ice/Reference.js
+++ b/js/src/Ice/Reference.js
@@ -986,6 +986,13 @@ class Reference
return "";
}
+ getTimeout()
+ {
+ // Abstract
+ Debug.assert(false);
+ return "";
+ }
+
//
// The change* methods (here and in derived classes) create
// a new reference based on the existing one, with the
@@ -1145,6 +1152,13 @@ class Reference
return null;
}
+ changeConnection(connection)
+ {
+ // Abstract
+ Debug.assert(false);
+ return null;
+ }
+
hashCode()
{
if(this._hashInitialized)
@@ -1491,6 +1505,11 @@ class FixedReference extends Reference
return "";
}
+ getTimeout()
+ {
+ return undefined;
+ }
+
changeAdapterId(newAdapterId)
{
throw new Ice.FixedProxyException();
@@ -1541,6 +1560,17 @@ class FixedReference extends Reference
throw new Ice.FixedProxyException();
}
+ changeConnection(newConnection)
+ {
+ if(newConnection == this._fixedConnection)
+ {
+ return this;
+ }
+ const r = this.getInstance().referenceFactory().copy(this);
+ r._fixedConnection = newConnection;
+ return r;
+ }
+
isIndirect()
{
return false;
@@ -1630,7 +1660,7 @@ class FixedReference extends Reference
{
return false;
}
- return this._fixedConnection.equals(rhs._fixedConnection);
+ return this._fixedConnection == rhs._fixedConnection;
}
}
@@ -1711,6 +1741,11 @@ class RoutableReference extends Reference
return this._connectionId;
}
+ getTimeout()
+ {
+ return this._overrideTimeout ? this._timeout : undefined;
+ }
+
changeEncoding(newEncoding)
{
const r = super.changeEncoding(newEncoding);
@@ -1843,6 +1878,18 @@ class RoutableReference extends Reference
return r;
}
+ changeConnection(newConnection)
+ {
+ return new FixedReference(this.getInstance(),
+ this.getCommunicator(),
+ this.getIdentity(),
+ this.getFacet(),
+ this.getMode(),
+ this.getSecure(),
+ this.getEncoding(),
+ newConnection);
+ }
+
isIndirect()
{
return this._endpoints.length === 0;
diff --git a/js/test/Ice/proxy/Client.js b/js/test/Ice/proxy/Client.js
index 815d7e1b840..e5c811fde7f 100644
--- a/js/test/Ice/proxy/Client.js
+++ b/js/test/Ice/proxy/Client.js
@@ -678,6 +678,10 @@
test(compObj.ice_timeout(20).equals(compObj.ice_timeout(20)));
test(!compObj.ice_timeout(10).equals(compObj.ice_timeout(20)));
+ test(compObj.ice_getTimeout() === undefined);
+ test(compObj.ice_timeout(10).ice_getTimeout() == 10);
+ test(compObj.ice_timeout(20).ice_getTimeout() == 20);
+
let loc1 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000"));
let loc2 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc2:default -p 10000"));
test(compObj.ice_locator(null).equals(compObj.ice_locator(null)));
@@ -733,9 +737,14 @@
test(compObj1.ice_encodingVersion(Ice.Encoding_1_0).equals(compObj1.ice_encodingVersion(Ice.Encoding_1_0)));
test(!compObj1.ice_encodingVersion(Ice.Encoding_1_0).equals(compObj1.ice_encodingVersion(Ice.Encoding_1_1)));
- //
- // TODO: Ideally we should also test comparison of fixed proxies.
- //
+ let baseConnection = await base.ice_getConnection();
+ if(baseConnection !== null)
+ {
+ let baseConnection2 = await base.ice_connectionId("base2").ice_getConnection();
+ compObj1 = compObj1.ice_fixed(baseConnection);
+ compObj2 = compObj2.ice_fixed(baseConnection2);
+ test(!compObj1.equals(compObj2));
+ }
out.writeLine("ok");
out.write("testing checked cast... ");
@@ -759,6 +768,36 @@
test(Ice.MapUtil.equals(c, c2))
out.writeLine("ok");
+ out.write("testing ice_fixed... ");
+ {
+ const connection = await cl.ice_getConnection();
+ if(connection != null)
+ {
+ await cl.ice_fixed(connection).ice_ping();
+ test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure());
+ test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet");
+ test(cl.ice_oneway().ice_fixed(connection).ice_isOneway());
+ test(await cl.ice_fixed(connection).ice_getConnection() == connection);
+ test(await cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection);
+ test(cl.ice_fixed(connection).ice_getTimeout() === undefined);
+ const fixedConnection = await cl.ice_connectionId("ice_fixed").ice_getConnection();
+ test(await cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection);
+ }
+ else
+ {
+ try
+ {
+ cl.ice_fixed(connection);
+ test(false);
+ }
+ catch(ex)
+ {
+ // Expected with null connection.
+ }
+ }
+ }
+ out.writeLine("ok");
+
out.write("testing encoding versioning... ");
let ref20 = "test -e 2.0:default -p 12010";
diff --git a/objective-c/include/objc/Ice/Proxy.h b/objective-c/include/objc/Ice/Proxy.h
index 2dcc18ab105..602b0c4a8ba 100644
--- a/objective-c/include/objc/Ice/Proxy.h
+++ b/objective-c/include/objc/Ice/Proxy.h
@@ -146,7 +146,10 @@ ICE_API @protocol ICEObjectPrx <NSObject, NSCopying>
-(id) ice_batchDatagram;
-(BOOL) ice_isBatchDatagram;
-(id) ice_compress:(BOOL)compress;
+-(id) ice_getCompress;
-(id) ice_timeout:(int)timeout;
+-(id) ice_getTimeout;
+-(id) ice_fixed:(id<ICEConnection>)connection;
-(id) ice_connectionId:(NSString*)connectionId;
-(id<ICEConnection>) ice_getConnection;
-(id<ICEAsyncResult>) begin_ice_getConnection;
diff --git a/objective-c/src/Ice/Proxy.mm b/objective-c/src/Ice/Proxy.mm
index 94cc127ab02..bc4f75c6053 100644
--- a/objective-c/src/Ice/Proxy.mm
+++ b/objective-c/src/Ice/Proxy.mm
@@ -1589,6 +1589,11 @@ BOOL _returnsData;
{
return [[self class] iceObjectPrxWithObjectPrx:OBJECTPRX->ice_compress(compress)];
}
+-(id) ice_getCompress
+{
+ IceUtil::Optional<bool> compress = OBJECTPRX->ice_getCompress();
+ return compress ? @(*compress) : nil;
+}
-(id) ice_timeout:(int)timeout
{
NSException* nsex;
@@ -1602,6 +1607,33 @@ BOOL _returnsData;
}
@throw nsex;
}
+-(id) ice_getTimeout
+{
+ IceUtil::Optional<int> timeout = OBJECTPRX->ice_getTimeout();
+ return timeout ? @(*timeout) : nil;
+}
+-(id) ice_fixed:(id<ICEConnection>)connection
+{
+ Ice::ConnectionPtr con =
+ dynamic_cast<Ice::Connection*>(static_cast<IceUtil::Shared*>([(ICELocalObject*)connection cxxObject]));
+ if(!con)
+ {
+ @throw [NSException exceptionWithName:NSInvalidArgumentException
+ reason:@"invalid connection passed to ice_fixed"
+ userInfo:nil];
+ }
+ NSException* nsex = nil;
+ try
+ {
+ return [[self class] iceObjectPrxWithObjectPrx:OBJECTPRX->ice_fixed(con)];
+ }
+ catch(const std::exception& ex)
+ {
+ nsex = toObjCException(ex);
+ }
+ @throw nsex;
+ return nil; // Keep the compiler happy.
+}
-(id) ice_connectionId:(NSString*)connectionId
{
return [[self class] iceObjectPrxWithObjectPrx:OBJECTPRX->ice_connectionId(fromNSString(connectionId))];
diff --git a/objective-c/test/Ice/proxy/AllTests.m b/objective-c/test/Ice/proxy/AllTests.m
index 8bc18b11860..f51bc1be1ab 100644
--- a/objective-c/test/Ice/proxy/AllTests.m
+++ b/objective-c/test/Ice/proxy/AllTests.m
@@ -583,11 +583,19 @@ proxyAllTests(id<ICECommunicator> communicator)
// test([compObj ice_compress:NO] < [compObj ice_compress:YES]);
// test(!([compObj ice_compress:YES] < [compObj ice_compress:NO]));
+ test([compObj ice_getCompress] == nil);
+ test([[[compObj ice_compress:YES] ice_getCompress] boolValue] == YES);
+ test([[[compObj ice_compress:NO] ice_getCompress] boolValue] == NO);
+
test([[compObj ice_timeout:20] isEqual:[compObj ice_timeout:20]]);
test(![[compObj ice_timeout:10] isEqual:[compObj ice_timeout:20]]);
// test([compObj ice_timeout:10] < [compObj ice_timeout:20]);
// test(!([compObj ice_timeout:20] < [compObj ice_timeout:10]));
+ test([compObj ice_getTimeout] == nil);
+ test([[[compObj ice_timeout:10] ice_getTimeout] intValue] == 10);
+ test([[[compObj ice_timeout:20] ice_getTimeout] intValue] == 20);
+
id<ICELocatorPrx> loc1 = [ICELocatorPrx uncheckedCast:[communicator stringToProxy:@"loc1:default -p 10000"]];
id<ICELocatorPrx> loc2 = [ICELocatorPrx uncheckedCast:[communicator stringToProxy:@"loc2:default -p 10000"]];
test([[compObj ice_locator:0] isEqual:[compObj ice_locator:0]]);
@@ -657,9 +665,15 @@ proxyAllTests(id<ICECommunicator> communicator)
// test(compObj ice_encodingVersion:Ice::Encoding_1_0] < compObj->ice_encodingVersion(Ice::Encoding_1_1));
// test(!(compObj->ice_encodingVersion(Ice::Encoding_1_1) < compObj->ice_encodingVersion(Ice::Encoding_1_0)));
- //
- // TODO: Ideally we should also test comparison of fixed proxies.
- //
+
+ id<ICEConnection> baseConnection = [base ice_getConnection];
+ if(baseConnection != nil)
+ {
+ id<ICEConnection> baseConnection2 = [[base ice_connectionId:@"base2"] ice_getConnection];
+ compObj1 = [compObj1 ice_fixed:baseConnection];
+ compObj2 = [compObj2 ice_fixed:baseConnection2];
+ test(![compObj1 isEqual:compObj2]);
+ }
tprintf("ok\n");
@@ -700,6 +714,36 @@ proxyAllTests(id<ICECommunicator> communicator)
tprintf("ok\n");
+ tprintf("testing ice_fixed... ");
+ {
+ id<ICEConnection> connection = [cl ice_getConnection];
+ if(connection != nil)
+ {
+ [[cl ice_fixed:connection] ice_ping];
+ test([[[cl ice_secure:YES] ice_fixed:connection] ice_isSecure]);
+ test([[[[cl ice_facet:@"facet"] ice_fixed:connection] ice_getFacet] isEqualToString:@"facet"]);
+ test([[[cl ice_oneway] ice_fixed:connection] ice_isOneway]);
+ test([[cl ice_fixed:connection] ice_getConnection] == connection);
+ test([[[cl ice_fixed:connection] ice_fixed:connection] ice_getConnection] == connection);
+ test([[cl ice_fixed:connection] ice_getTimeout] === nil);
+ id<ICEConnection> fixedConnection = [[cl ice_connectionId:@"ice_fixed"] ice_getConnection];
+ test([[[cl ice_fixed:connection] ice_fixed:fixedConnection] ice_getConnection] == fixedConnection);
+ }
+ else
+ {
+ @try
+ {
+ [cl ice_fixed:connection];
+ test(false);
+ }
+ @catch(NSException*)
+ {
+ // Expected with null connection.
+ }
+ }
+ }
+ tprintf("ok\n");
+
tprintf("testing encoding versioning... ");
TestProxyMyClassPrx* cl20 = [TestProxyMyClassPrx uncheckedCast:
[communicator stringToProxy:@"test -e 2.0:default -p 12010"]];
diff --git a/php/src/php5/Connection.cpp b/php/src/php5/Connection.cpp
index bdec7d1264b..9718c576cb9 100644
--- a/php/src/php5/Connection.cpp
+++ b/php/src/php5/Connection.cpp
@@ -21,8 +21,12 @@ ZEND_EXTERN_MODULE_GLOBALS(ice)
//
// Class entries represent the PHP class implementations we have registered.
//
-static zend_class_entry* connectionClassEntry = 0;
+namespace IcePHP
+{
+
+zend_class_entry* connectionClassEntry = 0;
+}
static zend_class_entry* connectionInfoClassEntry = 0;
static zend_class_entry* ipConnectionInfoClassEntry = 0;
static zend_class_entry* tcpConnectionInfoClassEntry = 0;
diff --git a/php/src/php5/Connection.h b/php/src/php5/Connection.h
index 191e3b218c7..66d70614c9b 100644
--- a/php/src/php5/Connection.h
+++ b/php/src/php5/Connection.h
@@ -15,6 +15,11 @@
namespace IcePHP
{
+//
+// Class entry.
+//
+extern zend_class_entry* connectionClassEntry;
+
bool connectionInit(TSRMLS_D);
bool createConnection(zval*, const Ice::ConnectionPtr& TSRMLS_DC);
diff --git a/php/src/php5/Proxy.cpp b/php/src/php5/Proxy.cpp
index 5ba77e7e8e1..4758dd3db12 100644
--- a/php/src/php5/Proxy.cpp
+++ b/php/src/php5/Proxy.cpp
@@ -1167,6 +1167,35 @@ ZEND_METHOD(Ice_ObjectPrx, ice_compress)
}
}
+ZEND_METHOD(Ice_ObjectPrx, ice_getCompress)
+{
+ if(ZEND_NUM_ARGS() != 0)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ try
+ {
+ IceUtil::Optional<bool> compress = _this->proxy->ice_getCompress();
+ if(compress)
+ {
+ RETURN_BOOL(*compress ? 1 : 0);
+ }
+ else
+ {
+ assignUnset(return_value TSRMLS_CC);
+ }
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_ObjectPrx, ice_timeout)
{
ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
@@ -1192,6 +1221,35 @@ ZEND_METHOD(Ice_ObjectPrx, ice_timeout)
}
}
+ZEND_METHOD(Ice_ObjectPrx, ice_getTimeout)
+{
+ if(ZEND_NUM_ARGS() != 0)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ try
+ {
+ IceUtil::Optional<int> timeout = _this->proxy->ice_getTimeout();
+ if(timeout)
+ {
+ ZVAL_LONG(return_value, static_cast<long>(*timeout));
+ }
+ else
+ {
+ assignUnset(return_value TSRMLS_CC);
+ }
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_ObjectPrx, ice_invocationTimeout)
{
ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
@@ -1242,6 +1300,38 @@ ZEND_METHOD(Ice_ObjectPrx, ice_connectionId)
}
}
+ZEND_METHOD(Ice_ObjectPrx, ice_fixed)
+{
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ zval* zcon;
+ if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("O!"), &zcon, connectionClassEntry TSRMLS_CC) !=
+ SUCCESS)
+ {
+ RETURN_NULL();
+ }
+
+ Ice::ConnectionPtr connection;
+ if(zcon && !fetchConnection(zcon, connection TSRMLS_CC))
+ {
+ RETURN_NULL();
+ }
+
+ try
+ {
+ if(!_this->clone(return_value, _this->proxy->ice_fixed(connection) TSRMLS_CC))
+ {
+ RETURN_NULL();
+ }
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_ObjectPrx, ice_getConnection)
{
if(ZEND_NUM_ARGS() != 0)
@@ -1676,9 +1766,12 @@ static zend_function_entry _proxyMethods[] =
ZEND_ME(Ice_ObjectPrx, ice_batchDatagram, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_isBatchDatagram, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_compress, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getCompress, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_timeout, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getTimeout, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_invocationTimeout, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_connectionId, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_fixed, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_getConnection, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_getCachedConnection, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_flushBatchRequests, ICE_NULLPTR, ZEND_ACC_PUBLIC)
diff --git a/php/src/php7/Connection.cpp b/php/src/php7/Connection.cpp
index 4c67992750b..458c7c399fb 100644
--- a/php/src/php7/Connection.cpp
+++ b/php/src/php7/Connection.cpp
@@ -21,7 +21,12 @@ ZEND_EXTERN_MODULE_GLOBALS(ice)
//
// Class entries represent the PHP class implementations we have registered.
//
-static zend_class_entry* connectionClassEntry = 0;
+namespace IcePHP
+{
+
+zend_class_entry* connectionClassEntry = 0;
+
+}
static zend_class_entry* connectionInfoClassEntry = 0;
static zend_class_entry* ipConnectionInfoClassEntry = 0;
diff --git a/php/src/php7/Connection.h b/php/src/php7/Connection.h
index adb29df586b..474bc639655 100644
--- a/php/src/php7/Connection.h
+++ b/php/src/php7/Connection.h
@@ -15,6 +15,11 @@
namespace IcePHP
{
+//
+// Class entry.
+//
+extern zend_class_entry* connectionClassEntry;
+
bool connectionInit(void);
bool createConnection(zval*, const Ice::ConnectionPtr&);
diff --git a/php/src/php7/Proxy.cpp b/php/src/php7/Proxy.cpp
index 23b6e4d7806..54772d4afe3 100644
--- a/php/src/php7/Proxy.cpp
+++ b/php/src/php7/Proxy.cpp
@@ -1154,6 +1154,35 @@ ZEND_METHOD(Ice_ObjectPrx, ice_compress)
}
}
+ZEND_METHOD(Ice_ObjectPrx, ice_getCompress)
+{
+ if(ZEND_NUM_ARGS() != 0)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ try
+ {
+ IceUtil::Optional<bool> compress = _this->proxy->ice_getCompress();
+ if(compress)
+ {
+ RETURN_BOOL(*compress ? 1 : 0);
+ }
+ else
+ {
+ assignUnset(return_value TSRMLS_CC);
+ }
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_ObjectPrx, ice_timeout)
{
ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis());
@@ -1179,6 +1208,35 @@ ZEND_METHOD(Ice_ObjectPrx, ice_timeout)
}
}
+ZEND_METHOD(Ice_ObjectPrx, ice_getTimeout)
+{
+ if(ZEND_NUM_ARGS() != 0)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ try
+ {
+ IceUtil::Optional<int> timeout = _this->proxy->ice_getTimeout();
+ if(timeout)
+ {
+ ZVAL_LONG(return_value, static_cast<long>(*timeout));
+ }
+ else
+ {
+ assignUnset(return_value TSRMLS_CC);
+ }
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_ObjectPrx, ice_invocationTimeout )
{
ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis());
@@ -1229,6 +1287,38 @@ ZEND_METHOD(Ice_ObjectPrx, ice_connectionId)
}
}
+ZEND_METHOD(Ice_ObjectPrx, ice_fixed)
+{
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ zval* zcon;
+ if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("O!"), &zcon, connectionClassEntry TSRMLS_CC) !=
+ SUCCESS)
+ {
+ RETURN_NULL();
+ }
+
+ Ice::ConnectionPtr connection;
+ if(zcon && !fetchConnection(zcon, connection TSRMLS_CC))
+ {
+ RETURN_NULL();
+ }
+
+ try
+ {
+ if(!_this->clone(return_value, _this->proxy->ice_fixed(connection) TSRMLS_CC))
+ {
+ RETURN_NULL();
+ }
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_ObjectPrx, ice_getConnection)
{
if(ZEND_NUM_ARGS() != 0)
@@ -1629,9 +1719,12 @@ static zend_function_entry _proxyMethods[] =
ZEND_ME(Ice_ObjectPrx, ice_batchDatagram, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_isBatchDatagram, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_compress, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getCompress, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_timeout, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getTimeout, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_invocationTimeout, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_connectionId, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_fixed, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_getConnection, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_getCachedConnection, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_ObjectPrx, ice_flushBatchRequests, ICE_NULLPTR, ZEND_ACC_PUBLIC)
diff --git a/php/test/Ice/proxy/Client.php b/php/test/Ice/proxy/Client.php
index 824031306f9..e0aad1e35db 100644
--- a/php/test/Ice/proxy/Client.php
+++ b/php/test/Ice/proxy/Client.php
@@ -492,6 +492,16 @@ function allTests($communicator)
test($base->ice_encodingVersion($Ice_Encoding_1_1)->ice_getEncodingVersion() == $Ice_Encoding_1_1);
test($base->ice_encodingVersion($Ice_Encoding_1_0)->ice_getEncodingVersion() != $Ice_Encoding_1_1);
+ $none = $NS ? constant("Ice\\None") : constant("Ice_Unset");
+
+ test($base->ice_getCompress() == $none);
+ test($base->ice_compress(true)->ice_getCompress() == true);
+ test($base->ice_compress(false)->ice_getCompress() == false);
+
+ test($base->ice_getTimeout() == $none);
+ test($base->ice_timeout(10)->ice_getTimeout() == 10);
+ test($base->ice_timeout(20)->ice_getTimeout() == 20);
+
echo "ok\n";
echo "testing checked cast... ";
@@ -518,6 +528,35 @@ function allTests($communicator)
echo "ok\n";
+ echo "testing ice_fixed... ";
+ flush();
+ $connection = $cl->ice_getConnection();
+ if($connection != null)
+ {
+ $cl->ice_fixed($connection)->ice_ping();
+ test($cl->ice_secure(true)->ice_fixed($connection)->ice_isSecure());
+ test($cl->ice_facet("facet")->ice_fixed($connection)->ice_getFacet() == "facet");
+ test($cl->ice_oneway()->ice_fixed($connection)->ice_isOneway());
+ test($cl->ice_fixed($connection)->ice_getConnection() == $connection);
+ test($cl->ice_fixed($connection)->ice_fixed($connection)->ice_getConnection() == $connection);
+ test($cl->ice_fixed($connection)->ice_getTimeout() == $none);
+ $fixedConnection = $cl->ice_connectionId("ice_fixed")->ice_getConnection();
+ test($cl->ice_fixed($connection)->ice_fixed($fixedConnection)->ice_getConnection() == $fixedConnection);
+ }
+ else
+ {
+ try
+ {
+ $cl->ice_fixed($connection);
+ test(false);
+ }
+ catch(Exception $ex)
+ {
+ # Expected with null connection.
+ }
+ }
+ echo "ok\n";
+
echo "testing encoding versioning... ";
flush();
$ref20 = "test -e 2.0:default -p 12010";
@@ -759,7 +798,7 @@ function allTests($communicator)
//
// Try to invoke on the SSL endpoint to verify that we get a
// NoEndpointException (or ConnectionRefusedException when
- // running with SSL).
+ // running with SSL)->
//
try
{
diff --git a/python/modules/IcePy/Connection.cpp b/python/modules/IcePy/Connection.cpp
index 2a0c5338bb1..efb3f6222c7 100644
--- a/python/modules/IcePy/Connection.cpp
+++ b/python/modules/IcePy/Connection.cpp
@@ -1275,3 +1275,32 @@ IcePy::createConnection(const Ice::ConnectionPtr& connection, const Ice::Communi
}
return reinterpret_cast<PyObject*>(obj);
}
+
+bool
+IcePy::checkConnection(PyObject* p)
+{
+ PyTypeObject* type = &ConnectionType; // Necessary to prevent GCC's strict-alias warnings.
+ return PyObject_IsInstance(p, reinterpret_cast<PyObject*>(type)) == 1;
+}
+
+bool
+IcePy::getConnectionArg(PyObject* p, const string& func, const string& arg, Ice::ConnectionPtr& con)
+{
+ if(p == Py_None)
+ {
+ con = 0;
+ return true;
+ }
+ else if(!checkConnection(p))
+ {
+ PyErr_Format(PyExc_ValueError, STRCAST("%s expects an Ice.Connection object or None for argument '%s'"),
+ func.c_str(), arg.c_str());
+ return false;
+ }
+ else
+ {
+ ConnectionObject* obj = reinterpret_cast<ConnectionObject*>(p);
+ con = *obj->connection;
+ return true;
+ }
+}
diff --git a/python/modules/IcePy/Connection.h b/python/modules/IcePy/Connection.h
index 6abf13a6a0d..b8bc7bb3da2 100644
--- a/python/modules/IcePy/Connection.h
+++ b/python/modules/IcePy/Connection.h
@@ -21,6 +21,9 @@ bool initConnection(PyObject*);
PyObject* createConnection(const Ice::ConnectionPtr&, const Ice::CommunicatorPtr&);
+bool checkConnection(PyObject*);
+bool getConnectionArg(PyObject*, const std::string&, const std::string&, Ice::ConnectionPtr&);
+
}
#endif
diff --git a/python/modules/IcePy/Proxy.cpp b/python/modules/IcePy/Proxy.cpp
index 86a4a828eb1..2655d7eb975 100644
--- a/python/modules/IcePy/Proxy.cpp
+++ b/python/modules/IcePy/Proxy.cpp
@@ -19,6 +19,7 @@
#include <Operation.h>
#include <Thread.h>
#include <Util.h>
+#include <Types.h>
#include <Ice/Communicator.h>
#include <Ice/LocalException.h>
#include <Ice/Locator.h>
@@ -1653,6 +1654,36 @@ proxyIceCompress(ProxyObject* self, PyObject* args)
extern "C"
#endif
static PyObject*
+proxyIceGetCompress(ProxyObject* self)
+{
+ assert(self->proxy);
+
+ PyObject* b;
+ try
+ {
+ IceUtil::Optional<bool> compress = (*self->proxy)->ice_getCompress();
+ if(compress)
+ {
+ b = *compress ? getTrue() : getFalse();
+ }
+ else
+ {
+ b = Unset;
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+ Py_INCREF(b);
+ return b;
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
proxyIceTimeout(ProxyObject* self, PyObject* args)
{
int timeout;
@@ -1686,6 +1717,34 @@ proxyIceTimeout(ProxyObject* self, PyObject* args)
extern "C"
#endif
static PyObject*
+proxyIceGetTimeout(ProxyObject* self)
+{
+ assert(self->proxy);
+
+ try
+ {
+ IceUtil::Optional<int> timeout = (*self->proxy)->ice_getTimeout();
+ if(timeout)
+ {
+ return PyLong_FromLong(*timeout);
+ }
+ else
+ {
+ Py_INCREF(Unset);
+ return Unset;
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
proxyIceIsCollocationOptimized(ProxyObject* self)
{
assert(self->proxy);
@@ -1777,6 +1836,40 @@ proxyIceConnectionId(ProxyObject* self, PyObject* args)
extern "C"
#endif
static PyObject*
+proxyIceFixed(ProxyObject* self, PyObject* args)
+{
+ assert(self->proxy);
+
+ PyObject* p;
+ if(!PyArg_ParseTuple(args, STRCAST("O"), &p))
+ {
+ return 0;
+ }
+
+ Ice::ConnectionPtr connection;
+ if(!getConnectionArg(p, "ice_fixed", "connection", connection))
+ {
+ return 0;
+ }
+
+ Ice::ObjectPrx newProxy;
+ try
+ {
+ newProxy = (*self->proxy)->ice_fixed(connection);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self)));
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
proxyIceGetConnection(ProxyObject* self)
{
assert(self->proxy);
@@ -2664,10 +2757,16 @@ static PyMethodDef ProxyMethods[] =
PyDoc_STR(STRCAST("ice_isBatchDatagram() -> bool")) },
{ STRCAST("ice_compress"), reinterpret_cast<PyCFunction>(proxyIceCompress), METH_VARARGS,
PyDoc_STR(STRCAST("ice_compress(bool) -> Ice.ObjectPrx")) },
+ { STRCAST("ice_getCompress"), reinterpret_cast<PyCFunction>(proxyIceGetCompress), METH_VARARGS,
+ PyDoc_STR(STRCAST("ice_getCompress() -> bool")) },
{ STRCAST("ice_timeout"), reinterpret_cast<PyCFunction>(proxyIceTimeout), METH_VARARGS,
PyDoc_STR(STRCAST("ice_timeout(int) -> Ice.ObjectPrx")) },
+ { STRCAST("ice_getTimeout"), reinterpret_cast<PyCFunction>(proxyIceGetTimeout), METH_VARARGS,
+ PyDoc_STR(STRCAST("ice_getTimeout() -> int")) },
{ STRCAST("ice_connectionId"), reinterpret_cast<PyCFunction>(proxyIceConnectionId), METH_VARARGS,
PyDoc_STR(STRCAST("ice_connectionId(string) -> Ice.ObjectPrx")) },
+ { STRCAST("ice_fixed"), reinterpret_cast<PyCFunction>(proxyIceFixed), METH_VARARGS,
+ PyDoc_STR(STRCAST("ice_fixed(Ice.Connection) -> Ice.ObjectPrx")) },
{ STRCAST("ice_getConnection"), reinterpret_cast<PyCFunction>(proxyIceGetConnection), METH_NOARGS,
PyDoc_STR(STRCAST("ice_getConnection() -> Ice.Connection")) },
{ STRCAST("ice_getConnectionAsync"), reinterpret_cast<PyCFunction>(proxyIceGetConnectionAsync),
diff --git a/python/test/Ice/proxy/AllTests.py b/python/test/Ice/proxy/AllTests.py
index 75ba821c0fa..1777666cc96 100644
--- a/python/test/Ice/proxy/AllTests.py
+++ b/python/test/Ice/proxy/AllTests.py
@@ -512,11 +512,19 @@ def allTests(communicator, collocated):
test(compObj.ice_compress(False) < compObj.ice_compress(True))
test(not (compObj.ice_compress(True) < compObj.ice_compress(False)))
+ test(compObj.ice_getCompress() == Ice.Unset);
+ test(compObj.ice_compress(True).ice_getCompress() == True);
+ test(compObj.ice_compress(False).ice_getCompress() == False);
+
test(compObj.ice_timeout(20) == compObj.ice_timeout(20))
test(compObj.ice_timeout(10) != compObj.ice_timeout(20))
test(compObj.ice_timeout(10) < compObj.ice_timeout(20))
test(not (compObj.ice_timeout(20) < compObj.ice_timeout(10)))
+ test(compObj.ice_getTimeout() == Ice.Unset);
+ test(compObj.ice_timeout(10).ice_getTimeout() == 10);
+ test(compObj.ice_timeout(20).ice_getTimeout() == 20);
+
loc1 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000"))
loc2 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc2:default -p 10000"))
test(compObj.ice_locator(None) == compObj.ice_locator(None))
@@ -598,9 +606,12 @@ def allTests(communicator, collocated):
test(compObj.ice_encodingVersion(Ice.Encoding_1_0) < compObj.ice_encodingVersion(Ice.Encoding_1_1))
test(not (compObj.ice_encodingVersion(Ice.Encoding_1_1) < compObj.ice_encodingVersion(Ice.Encoding_1_0)))
- #
- # TODO: Ideally we should also test comparison of fixed proxies.
- #
+ baseConnection = base.ice_getConnection();
+ if baseConnection:
+ baseConnection2 = base.ice_connectionId("base2").ice_getConnection();
+ compObj1 = compObj1.ice_fixed(baseConnection);
+ compObj2 = compObj2.ice_fixed(baseConnection2);
+ test(compObj1 != compObj2);
print("ok")
@@ -644,6 +655,28 @@ def allTests(communicator, collocated):
test(c == c2)
print("ok")
+ sys.stdout.write("testing ice_fixed... ")
+ sys.stdout.flush()
+ connection = cl.ice_getConnection()
+ if connection != None:
+ cl.ice_fixed(connection).ice_ping()
+ test(cl.ice_secure(True).ice_fixed(connection).ice_isSecure())
+ test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet")
+ test(cl.ice_oneway().ice_fixed(connection).ice_isOneway())
+ test(cl.ice_fixed(connection).ice_getConnection() == connection)
+ test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection)
+ test(cl.ice_fixed(connection).ice_getTimeout() == Ice.Unset)
+ fixedConnection = cl.ice_connectionId("ice_fixed").ice_getConnection()
+ test(cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection)
+ else:
+ try:
+ cl.ice_fixed(connection)
+ test(False)
+ except:
+ # Expected with null connection.
+ pass
+ print("ok")
+
sys.stdout.write("testing encoding versioning... ")
sys.stdout.flush()
ref20 = "test -e 2.0:default -p 12010";
diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp
index a4f0f8bcbff..b2df21c6419 100644
--- a/ruby/src/IceRuby/Connection.cpp
+++ b/ruby/src/IceRuby/Connection.cpp
@@ -512,3 +512,16 @@ IceRuby::initConnection(VALUE iceModule)
rb_define_attr(_sslConnectionInfoClass, "certs", 1, 0);
rb_define_attr(_sslConnectionInfoClass, "verified", 1, 0);
}
+
+Ice::ConnectionPtr
+IceRuby::getConnection(VALUE v)
+{
+ Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(v));
+ return *p;
+}
+
+bool
+IceRuby::checkConnection(VALUE v)
+{
+ return callRuby(rb_obj_is_kind_of, v, _connectionClass) == Qtrue;
+}
diff --git a/ruby/src/IceRuby/Connection.h b/ruby/src/IceRuby/Connection.h
index 3c7a1a31038..9debcae3d27 100644
--- a/ruby/src/IceRuby/Connection.h
+++ b/ruby/src/IceRuby/Connection.h
@@ -21,6 +21,9 @@ void initConnection(VALUE);
VALUE createConnection(const Ice::ConnectionPtr&);
VALUE createConnectionInfo(const Ice::ConnectionInfoPtr&);
+Ice::ConnectionPtr getConnection(VALUE);
+bool checkConnection(VALUE);
+
}
#endif
diff --git a/ruby/src/IceRuby/Proxy.cpp b/ruby/src/IceRuby/Proxy.cpp
index 51a02f5e108..c93f27cea36 100644
--- a/ruby/src/IceRuby/Proxy.cpp
+++ b/ruby/src/IceRuby/Proxy.cpp
@@ -13,6 +13,7 @@
#include <Connection.h>
#include <Endpoint.h>
#include <Util.h>
+#include <Types.h>
#include <Ice/LocalException.h>
#include <Ice/Locator.h>
#include <Ice/Proxy.h>
@@ -827,6 +828,27 @@ IceRuby_ObjectPrx_ice_compress(VALUE self, VALUE b)
extern "C"
VALUE
+IceRuby_ObjectPrx_ice_getCompress(VALUE self)
+{
+ ICE_RUBY_TRY
+ {
+ Ice::ObjectPrx p = getProxy(self);
+ IceUtil::Optional<bool> c = p->ice_getCompress();
+ if(c)
+ {
+ return *c ? Qtrue : Qfalse;
+ }
+ else
+ {
+ return Unset;
+ }
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_ObjectPrx_ice_timeout(VALUE self, VALUE t)
{
ICE_RUBY_TRY
@@ -848,6 +870,27 @@ IceRuby_ObjectPrx_ice_timeout(VALUE self, VALUE t)
extern "C"
VALUE
+IceRuby_ObjectPrx_ice_getTimeout(VALUE self)
+{
+ ICE_RUBY_TRY
+ {
+ Ice::ObjectPrx p = getProxy(self);
+ IceUtil::Optional<int> t = p->ice_getTimeout();
+ if(t)
+ {
+ return INT2FIX(*t);
+ }
+ else
+ {
+ return Unset;
+ }
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_ObjectPrx_ice_connectionId(VALUE self, VALUE id)
{
ICE_RUBY_TRY
@@ -862,6 +905,29 @@ IceRuby_ObjectPrx_ice_connectionId(VALUE self, VALUE id)
extern "C"
VALUE
+IceRuby_ObjectPrx_ice_fixed(VALUE self, VALUE con)
+{
+ ICE_RUBY_TRY
+ {
+ Ice::ObjectPrx p = getProxy(self);
+
+ Ice::ConnectionPtr connection;
+ if(!NIL_P(con))
+ {
+ if(!checkConnection(con))
+ {
+ throw RubyException(rb_eTypeError, "argument must be an Ice.Connection");
+ }
+ connection = getConnection(con);
+ }
+ return createProxy(p->ice_fixed(connection), rb_class_of(self));
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_ObjectPrx_ice_getConnection(VALUE self)
{
ICE_RUBY_TRY
@@ -1265,8 +1331,11 @@ IceRuby::initProxy(VALUE iceModule)
rb_define_method(_proxyClass, "ice_batchDatagram", CAST_METHOD(IceRuby_ObjectPrx_ice_batchDatagram), 0);
rb_define_method(_proxyClass, "ice_isBatchDatagram", CAST_METHOD(IceRuby_ObjectPrx_ice_isBatchDatagram), 0);
rb_define_method(_proxyClass, "ice_compress", CAST_METHOD(IceRuby_ObjectPrx_ice_compress), 1);
+ rb_define_method(_proxyClass, "ice_getCompress", CAST_METHOD(IceRuby_ObjectPrx_ice_getCompress), 0);
rb_define_method(_proxyClass, "ice_timeout", CAST_METHOD(IceRuby_ObjectPrx_ice_timeout), 1);
+ rb_define_method(_proxyClass, "ice_getTimeout", CAST_METHOD(IceRuby_ObjectPrx_ice_getTimeout), 0);
rb_define_method(_proxyClass, "ice_connectionId", CAST_METHOD(IceRuby_ObjectPrx_ice_connectionId), 1);
+ rb_define_method(_proxyClass, "ice_fixed", CAST_METHOD(IceRuby_ObjectPrx_ice_fixed), 1);
rb_define_method(_proxyClass, "ice_getConnection", CAST_METHOD(IceRuby_ObjectPrx_ice_getConnection), 0);
rb_define_method(_proxyClass, "ice_getCachedConnection", CAST_METHOD(IceRuby_ObjectPrx_ice_getCachedConnection), 0);
rb_define_method(_proxyClass, "ice_flushBatchRequests", CAST_METHOD(IceRuby_ObjectPrx_ice_flushBatchRequests), 0);
diff --git a/ruby/test/Ice/proxy/AllTests.rb b/ruby/test/Ice/proxy/AllTests.rb
index 42b4410ba97..a83885fe27f 100644
--- a/ruby/test/Ice/proxy/AllTests.rb
+++ b/ruby/test/Ice/proxy/AllTests.rb
@@ -508,11 +508,19 @@ def allTests(communicator)
#test(compObj.ice_compress(false) < compObj.ice_compress(true))
#test(!(compObj.ice_compress(true) < compObj.ice_compress(false)))
+ test(compObj.ice_getCompress() == Ice::Unset);
+ test(compObj.ice_compress(true).ice_getCompress() == true);
+ test(compObj.ice_compress(false).ice_getCompress() == false);
+
test(compObj.ice_timeout(20) == compObj.ice_timeout(20))
test(compObj.ice_timeout(10) != compObj.ice_timeout(20))
#test(compObj.ice_timeout(10) < compObj.ice_timeout(20))
#test(!(compObj.ice_timeout(20) < compObj.ice_timeout(10)))
+ test(compObj.ice_getTimeout() == Ice::Unset);
+ test(compObj.ice_timeout(10).ice_getTimeout() == 10);
+ test(compObj.ice_timeout(20).ice_getTimeout() == 20);
+
loc1 = Ice::LocatorPrx::uncheckedCast(communicator.stringToProxy("loc1:default -p 10000"))
loc2 = Ice::LocatorPrx::uncheckedCast(communicator.stringToProxy("loc2:default -p 10000"))
test(compObj.ice_locator(nil) == compObj.ice_locator(nil))
@@ -594,9 +602,13 @@ def allTests(communicator)
#test(compObj.ice_encodingVersion(Ice::Encoding_1_0) < compObj.ice_encodingVersion(Ice::Encoding_1_1))
#test(! (compObj.ice_encodingVersion(Ice::Encoding_1_1) < compObj.ice_encodingVersion(Ice::Encoding_1_0)))
- #
- # TODO: Ideally we should also test comparison of fixed proxies.
- #
+ baseConnection = base.ice_getConnection();
+ if(baseConnection != nil)
+ baseConnection2 = base.ice_connectionId("base2").ice_getConnection();
+ compObj1 = compObj1.ice_fixed(baseConnection);
+ compObj2 = compObj2.ice_fixed(baseConnection2);
+ test(compObj1 != compObj2);
+ end
puts "ok"
@@ -640,6 +652,29 @@ def allTests(communicator)
test(c == c2)
puts "ok"
+ print "testing ice_fixed... "
+ STDOUT.flush
+ connection = cl.ice_getConnection()
+ if connection != nil
+ cl.ice_fixed(connection).ice_ping()
+ test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure())
+ test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet")
+ test(cl.ice_oneway().ice_fixed(connection).ice_isOneway())
+ test(cl.ice_fixed(connection).ice_getConnection() == connection)
+ test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection)
+ test(cl.ice_fixed(connection).ice_getTimeout() == Ice::Unset)
+ fixedConnection = cl.ice_connectionId("ice_fixed").ice_getConnection()
+ test(cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection)
+ else
+ begin
+ cl.ice_fixed(connection)
+ test(false)
+ rescue
+ # Expected with null connection.
+ end
+ end
+ puts "ok"
+
print "testing encoding versioning... "
STDOUT.flush
ref20 = "test -e 2.0:default -p 12010";