diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-10-02 11:48:54 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-10-02 11:48:54 -0400 |
commit | 2cb718a85b417fb6a58be04fe1f102f733b8d39c (patch) | |
tree | 26549f37c7307037f0bf8bf0d42b6c1da7eaeb4b | |
parent | Fixed bug 2503 (diff) | |
download | ice-2cb718a85b417fb6a58be04fe1f102f733b8d39c.tar.bz2 ice-2cb718a85b417fb6a58be04fe1f102f733b8d39c.tar.xz ice-2cb718a85b417fb6a58be04fe1f102f733b8d39c.zip |
Squashed commit of the following:
commit 0ba15449d9dd44933d82cb643efded9dee12c5af
Author: Bernard Normier <bernard@zeroc.com>
Date: Tue Oct 2 11:48:07 2007 -0400
Documented updates
commit cf49ee5a73bc62d1b6814dec5d9f288f0f45901d
Author: Bernard Normier <bernard@zeroc.com>
Date: Tue Oct 2 11:38:25 2007 -0400
Optimized implementation of various Prx ice_xxx functions/methods
commit 706209d6d1a4e894fecf19dd1c0c3b6f12ef5842
Author: Bernard Normier <bernard@zeroc.com>
Date: Fri Sep 28 14:34:02 2007 -0400
Updated code-generation to "overwrite" various Ice::ObjectPrx ice_ operations.
-rw-r--r-- | cpp/CHANGES | 8 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/Client.cpp | 24 | ||||
-rw-r--r-- | cpp/include/Ice/Proxy.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 52 | ||||
-rw-r--r-- | cpp/src/IceGrid/Client.cpp | 8 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 120 | ||||
-rw-r--r-- | java/CHANGES | 8 | ||||
-rw-r--r-- | java/demo/Ice/hello/Client.java | 24 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrxHelperBase.java | 111 |
9 files changed, 245 insertions, 112 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index c4496d8bdd2..fae73343ef3 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,6 +1,14 @@ Changes since version 3.2.X (binary incompatible) ------------------------------------------------- +- A number of proxy functions (ice_timeout(), ice_oneway() etc.) now + return a proxy of the same type as the target. This way, you don't + need to uncheckedCast the returned proxy. For example, you can now + write: + hello = hello.ice_oneway(); + instead of: + hello = HelloPrx::uncheckedCast(hello->ice_oneway()); + - Added a fix to prevent the IceGrid node from printing an annoying thread pool size warning on startup. diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp index 1620c93f7c0..d45ff0ca8d6 100644 --- a/cpp/demo/Ice/hello/Client.cpp +++ b/cpp/demo/Ice/hello/Client.cpp @@ -54,10 +54,10 @@ HelloClient::run(int argc, char* argv[]) cerr << argv[0] << ": invalid proxy" << endl; return EXIT_FAILURE; } - HelloPrx oneway = HelloPrx::uncheckedCast(twoway->ice_oneway()); - HelloPrx batchOneway = HelloPrx::uncheckedCast(twoway->ice_batchOneway()); - HelloPrx datagram = HelloPrx::uncheckedCast(twoway->ice_datagram()); - HelloPrx batchDatagram = HelloPrx::uncheckedCast(twoway->ice_batchDatagram()); + HelloPrx oneway = twoway->ice_oneway(); + HelloPrx batchOneway = twoway->ice_batchOneway(); + HelloPrx datagram = twoway->ice_datagram(); + HelloPrx batchDatagram = twoway->ice_batchDatagram(); bool secure = false; int timeout = -1; @@ -121,9 +121,9 @@ HelloClient::run(int argc, char* argv[]) timeout = -1; } - twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout)); - oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout)); - batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); + twoway = twoway->ice_timeout(timeout); + oneway = oneway->ice_timeout(timeout); + batchOneway = batchOneway->ice_timeout(timeout); if(timeout == -1) { @@ -158,11 +158,11 @@ HelloClient::run(int argc, char* argv[]) { secure = !secure; - twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure)); - oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure)); - batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure)); - datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); - batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); + twoway = twoway->ice_secure(secure); + oneway = oneway->ice_secure(secure); + batchOneway = batchOneway->ice_secure(secure); + datagram = datagram->ice_secure(secure); + batchDatagram = batchDatagram->ice_secure(secure); if(secure) { diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index 35d5b904f0b..2e2696b0c86 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -253,6 +253,8 @@ protected: virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM(); virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD(); + virtual Object* __newInstance() const; + private: bool ice_isA(const ::std::string&, const ::Ice::Context*); diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index fde808f5acd..b902dedaad1 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -323,7 +323,7 @@ IceProxy::Ice::Object::ice_identity(const Identity& newIdentity) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = new Object; proxy->setup(_reference->changeIdentity(newIdentity)); return proxy; } @@ -344,7 +344,7 @@ IceProxy::Ice::Object::ice_getContext() const ObjectPrx IceProxy::Ice::Object::ice_context(const Context& newContext) const { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeContext(newContext)); return proxy; } @@ -358,7 +358,7 @@ IceProxy::Ice::Object::ice_newContext(const Context& newContext) const ObjectPrx IceProxy::Ice::Object::ice_defaultContext() const { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->defaultContext()); return proxy; } @@ -378,7 +378,7 @@ IceProxy::Ice::Object::ice_facet(const string& newFacet) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = new Object; proxy->setup(_reference->changeFacet(newFacet)); return proxy; } @@ -405,7 +405,7 @@ IceProxy::Ice::Object::ice_adapterId(const string& newAdapterId) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeAdapterId(newAdapterId)); return proxy; } @@ -444,7 +444,7 @@ IceProxy::Ice::Object::ice_endpoints(const EndpointSeq& newEndpoints) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeEndpoints(endpoints)); return proxy; } @@ -471,7 +471,7 @@ IceProxy::Ice::Object::ice_locatorCacheTimeout(Int newTimeout) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeLocatorCacheTimeout(newTimeout)); return proxy; } @@ -492,7 +492,7 @@ IceProxy::Ice::Object::ice_connectionCached(bool newCache) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeCacheConnection(newCache)); return proxy; } @@ -513,7 +513,7 @@ IceProxy::Ice::Object::ice_endpointSelection(EndpointSelectionType newType) cons } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeEndpointSelection(newType)); return proxy; } @@ -534,7 +534,7 @@ IceProxy::Ice::Object::ice_secure(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeSecure(b)); return proxy; } @@ -555,7 +555,7 @@ IceProxy::Ice::Object::ice_preferSecure(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changePreferSecure(b)); return proxy; } @@ -578,7 +578,7 @@ IceProxy::Ice::Object::ice_router(const RouterPrx& router) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -601,7 +601,7 @@ IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -628,7 +628,7 @@ IceProxy::Ice::Object::ice_collocationOptimized(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeCollocationOptimization(b)); return proxy; } @@ -643,7 +643,7 @@ IceProxy::Ice::Object::ice_twoway() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeTwoway)); return proxy; } @@ -664,7 +664,7 @@ IceProxy::Ice::Object::ice_oneway() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeOneway)); return proxy; } @@ -685,7 +685,7 @@ IceProxy::Ice::Object::ice_batchOneway() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeBatchOneway)); return proxy; } @@ -706,7 +706,7 @@ IceProxy::Ice::Object::ice_datagram() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeDatagram)); return proxy; } @@ -727,7 +727,7 @@ IceProxy::Ice::Object::ice_batchDatagram() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeBatchDatagram)); return proxy; } @@ -749,7 +749,7 @@ IceProxy::Ice::Object::ice_compress(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -765,7 +765,7 @@ IceProxy::Ice::Object::ice_timeout(int t) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -781,7 +781,7 @@ IceProxy::Ice::Object::ice_connectionId(const string& id) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -803,7 +803,7 @@ IceProxy::Ice::Object::ice_threadPerConnection(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -1088,6 +1088,12 @@ IceProxy::Ice::Object::__createDelegateD() return Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD::Ice::Object); } +IceProxy::Ice::Object* +IceProxy::Ice::Object::__newInstance() const +{ + return new Object; +} + void IceProxy::Ice::Object::setup(const ReferencePtr& ref) { diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp index 3e67844adc0..c814f9cb0cb 100644 --- a/cpp/src/IceGrid/Client.cpp +++ b/cpp/src/IceGrid/Client.cpp @@ -364,7 +364,9 @@ Client::run(int argc, char* argv[]) // Use SSL if available. try { - router = Glacier2::RouterPrx::checkedCast(router->ice_secure(true)); + Glacier2::RouterPrx secureRouter = router->ice_secure(true); + secureRouter->ice_ping(); + router = secureRouter; } catch(const Ice::NoEndpointException&) { @@ -484,7 +486,9 @@ Client::run(int argc, char* argv[]) // Use SSL if available. try { - registry = RegistryPrx::checkedCast(registry->ice_secure(true)); + RegistryPrx secureRegistry = registry->ice_secure(true); + secureRegistry->ice_ping(); + registry = secureRegistry; } catch(const Ice::NoEndpointException&) { diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 0d70727d44f..ebafdf80e5b 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1778,9 +1778,123 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) void Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) { + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); string scope = fixKwd(p->scope()); + + // + // "Overwrite" various non-virtual functions in ::IceProxy::Ice::Object that return an ObjectPrx and + // are more usable when they return a <name>Prx + // + + // + // No identity! + // + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_context(const ::Ice::Context& __context) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_context(__context).get());"; + H << eb; + + // + // No facet! + // + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_adapterId(const std::string& __id) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_adapterId(__id).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_endpoints(const ::Ice::EndpointSeq& __endpoints) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_endpoints(__endpoints).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_locatorCacheTimeout(int __timeout) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_locatorCacheTimeout(__timeout).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_connectionCached(bool __cached) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_connectionCached(__cached).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_endpointSelection(::Ice::EndpointSelectionType __est) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_endpointSelection(__est).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_secure(bool __secure) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_secure(__secure).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_preferSecure(bool __preferSecure) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_preferSecure(__preferSecure).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_router(const ::Ice::RouterPrx& __router) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_router(__router).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_locator(const ::Ice::LocatorPrx& __locator) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_locator(__locator).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_collocationOptimized(bool __co) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_collocationOptimized(__co).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_twoway() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_twoway().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_oneway() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_oneway().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_batchOneway() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_batchOneway().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_datagram() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_datagram().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_batchDatagram() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_batchDatagram().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_compress(bool __compress) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_compress(__compress).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_timeout(int __timeout) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_timeout(__timeout).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_connectionId(const std::string& __id) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_connectionId(__id).get());"; + H << eb; + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_threadPerConnection(bool __tpc) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_threadPerConnection(__tpc).get());"; + H << eb; + H << nl << nl << _dllExport << "static const ::std::string& ice_staticId();"; H.dec(); @@ -1788,6 +1902,7 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) H.inc(); H << sp << nl << _dllExport << "virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();"; H << nl << _dllExport << "virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD();"; + H << nl << _dllExport << "virtual ::IceProxy::Ice::Object* __newInstance() const;"; H << eb << ';'; C << sp; @@ -1806,6 +1921,11 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) C << sb; C << nl << "return ::IceInternal::Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD" << scoped << ");"; C << eb; + C << sp << nl << "::IceProxy::Ice::Object*"; + C << nl << "IceProxy" << scoped << "::__newInstance() const"; + C << sb; + C << nl << "return new " << name << ";"; + C << eb; _useWstring = resetUseWstring(_useWstringHist); } diff --git a/java/CHANGES b/java/CHANGES index 8dc2ae5b724..7fcb083a8f3 100644 --- a/java/CHANGES +++ b/java/CHANGES @@ -1,6 +1,14 @@ Changes since version 3.2.X (binary incompatible) ------------------------------------------------- +- A number of proxy methods (ice_timeout(), ice_oneway() etc.) now + return a proxy of the same type as the target. This allows you to + cast the return proxy instead using uncheckedCast on the Helper. + For example, you can now write: + hello = (HelloPrx)hello.ice_oneway(); + instead of: + hello = HelloPrxHelper.uncheckedCast(hello.ice_oneway()); + - Added support for a password callback in IceSSL. Also added new properties for specifying the name of a password callback class or certificate verifier class. See manual for more details. diff --git a/java/demo/Ice/hello/Client.java b/java/demo/Ice/hello/Client.java index cb8f29a5e68..47ab65ea2a6 100644 --- a/java/demo/Ice/hello/Client.java +++ b/java/demo/Ice/hello/Client.java @@ -69,10 +69,10 @@ public class Client extends Ice.Application System.err.println("invalid proxy"); return 1; } - HelloPrx oneway = HelloPrxHelper.uncheckedCast(twoway.ice_oneway()); - HelloPrx batchOneway = HelloPrxHelper.uncheckedCast(twoway.ice_batchOneway()); - HelloPrx datagram = HelloPrxHelper.uncheckedCast(twoway.ice_datagram()); - HelloPrx batchDatagram = HelloPrxHelper.uncheckedCast(twoway.ice_batchDatagram()); + HelloPrx oneway = (HelloPrx)twoway.ice_oneway(); + HelloPrx batchOneway = (HelloPrx)twoway.ice_batchOneway(); + HelloPrx datagram = (HelloPrx)twoway.ice_datagram(); + HelloPrx batchDatagram = (HelloPrx)twoway.ice_batchDatagram(); boolean secure = false; int timeout = -1; @@ -143,9 +143,9 @@ public class Client extends Ice.Application timeout = -1; } - twoway = HelloPrxHelper.uncheckedCast(twoway.ice_timeout(timeout)); - oneway = HelloPrxHelper.uncheckedCast(oneway.ice_timeout(timeout)); - batchOneway = HelloPrxHelper.uncheckedCast(batchOneway.ice_timeout(timeout)); + twoway = (HelloPrx)twoway.ice_timeout(timeout); + oneway = (HelloPrx)oneway.ice_timeout(timeout); + batchOneway = (HelloPrx)batchOneway.ice_timeout(timeout); if(timeout == -1) { @@ -180,11 +180,11 @@ public class Client extends Ice.Application { secure = !secure; - twoway = HelloPrxHelper.uncheckedCast(twoway.ice_secure(secure)); - oneway = HelloPrxHelper.uncheckedCast(oneway.ice_secure(secure)); - batchOneway = HelloPrxHelper.uncheckedCast(batchOneway.ice_secure(secure)); - datagram = HelloPrxHelper.uncheckedCast(datagram.ice_secure(secure)); - batchDatagram = HelloPrxHelper.uncheckedCast(batchDatagram.ice_secure(secure)); + twoway = (HelloPrx)twoway.ice_secure(secure); + oneway = (HelloPrx)oneway.ice_secure(secure); + batchOneway = (HelloPrx)batchOneway.ice_secure(secure); + datagram = (HelloPrx)datagram.ice_secure(secure); + batchDatagram = (HelloPrx)batchDatagram.ice_secure(secure); if(secure) { diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index 3bcc8527cb3..72df0844773 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -330,9 +330,7 @@ public class ObjectPrxHelperBase implements ObjectPrx public final ObjectPrx ice_context(java.util.Map newContext) { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeContext(newContext)); - return proxy; + return newInstance(_reference.changeContext(newContext)); } /** @@ -350,9 +348,7 @@ public class ObjectPrxHelperBase implements ObjectPrx public final ObjectPrx ice_defaultContext() { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.defaultContext()); - return proxy; + return newInstance(_reference.defaultContext()); } public final String @@ -410,9 +406,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeAdapterId(newAdapterId)); - return proxy; + return newInstance(_reference.changeAdapterId(newAdapterId)); } } @@ -442,9 +436,7 @@ public class ObjectPrxHelperBase implements ObjectPrx { IceInternal.EndpointI[] edpts = new IceInternal.EndpointI[newEndpoints.length]; edpts = (IceInternal.EndpointI[])java.util.Arrays.asList(newEndpoints).toArray(edpts); - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeEndpoints(edpts)); - return proxy; + return newInstance(_reference.changeEndpoints(edpts)); } } @@ -472,9 +464,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeLocatorCacheTimeout(newTimeout)); - return proxy; + return newInstance(_reference.changeLocatorCacheTimeout(newTimeout)); } } @@ -493,9 +483,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeCacheConnection(newCache)); - return proxy; + return newInstance(_reference.changeCacheConnection(newCache)); } } @@ -514,9 +502,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeEndpointSelection(newType)); - return proxy; + return newInstance(_reference.changeEndpointSelection(newType)); } } @@ -535,9 +521,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeSecure(b)); - return proxy; + return newInstance(_reference.changeSecure(b)); } } @@ -556,9 +540,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changePreferSecure(b)); - return proxy; + return newInstance(_reference.changePreferSecure(b)); } } @@ -579,9 +561,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); - return proxy; + return newInstance(ref); } } @@ -602,9 +582,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); - return proxy; + return newInstance(ref); } } @@ -632,9 +610,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeCollocationOptimization(b)); - return proxy; + return newInstance(_reference.changeCollocationOptimization(b)); } } @@ -647,9 +623,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeMode(IceInternal.Reference.ModeTwoway)); - return proxy; + return newInstance(_reference.changeMode(IceInternal.Reference.ModeTwoway)); } } @@ -668,9 +642,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeMode(IceInternal.Reference.ModeOneway)); - return proxy; + return newInstance(_reference.changeMode(IceInternal.Reference.ModeOneway)); } } @@ -689,9 +661,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeMode(IceInternal.Reference.ModeBatchOneway)); - return proxy; + return newInstance(_reference.changeMode(IceInternal.Reference.ModeBatchOneway)); } } @@ -710,9 +680,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeMode(IceInternal.Reference.ModeDatagram)); - return proxy; + return newInstance(_reference.changeMode(IceInternal.Reference.ModeDatagram)); } } @@ -731,9 +699,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(_reference.changeMode(IceInternal.Reference.ModeBatchDatagram)); - return proxy; + return newInstance(_reference.changeMode(IceInternal.Reference.ModeBatchDatagram)); } } @@ -753,9 +719,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); - return proxy; + return newInstance(ref); } } @@ -769,9 +733,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); - return proxy; + return newInstance(ref); } } @@ -785,9 +747,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); - return proxy; + return newInstance(ref); } } @@ -807,9 +767,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } else { - ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); - return proxy; + return newInstance(ref); } } @@ -1109,6 +1067,33 @@ public class ObjectPrxHelperBase implements ObjectPrx _reference = ref; } + private final ObjectPrxHelperBase + newInstance(IceInternal.Reference ref) + { + try + { + ObjectPrxHelperBase proxy = (ObjectPrxHelperBase)getClass().newInstance(); + proxy.setup(ref); + return proxy; + } + catch(InstantiationException e) + { + // + // Impossible + // + assert false; + return null; + } + catch(IllegalAccessException e) + { + // + // Impossible + // + assert false; + return null; + } + } + protected static final java.util.Map _emptyContext = new java.util.HashMap(); private IceInternal.Reference _reference; |