Archived
This forum has been archived. Please start a new discussion on GitHub.
Ptr to Proxy w/o identity?
Suppose I have the following interface definition:
module Foo {
};
and the following implementation:
class ConnectionI : public Foo::Connection {
};
and I create an object, a corresponding proxy and add it to the
adapter and save off the ptr somewhere:
{
assuming the object/prx are still in the adapter, given a
ConnectionIPtr how would I convert from the Ptr to a Prx w/o adding
another proxy e.g. this won't work as ice_getIdentity() is not part of
Object:
{
Should I be stashing off my identity in ConnectionI as created by
addWithUUID() while I have the Prx and then later use that to call
ObjectAdapter::find(Identity &)?
Or should I rethink what I'm doing? :-)
Regards,
Brendan
module Foo {
interface Connection {
};
};
and the following implementation:
class ConnectionI : public Foo::Connection {
public:
ConnectionI();
static Ice::ObjectAdapterPtr _adapter;
};
and I create an object, a corresponding proxy and add it to the
adapter and save off the ptr somewhere:
{
ConnectionIPtr conn_ptr = new ConnectionI();
conn = ConnectionPrx::uncheckedCast(_adapter->addWithUUID(conn_ptr));
<save conn_ptr to somewhere>;
}assuming the object/prx are still in the adapter, given a
ConnectionIPtr how would I convert from the Ptr to a Prx w/o adding
another proxy e.g. this won't work as ice_getIdentity() is not part of
Object:
{
ConnectionIPtr ptr = <get conn_ptr from somewhere>;
ConnectionPrx conn = ConnectionI::_adapter->find(ptr->ice_getIdentity());
}Should I be stashing off my identity in ConnectionI as created by
addWithUUID() while I have the Prx and then later use that to call
ObjectAdapter::find(Identity &)?
Or should I rethink what I'm doing? :-)
Regards,
Brendan
0
Comments
-
Urgh, got my Ptr and Prx mixed up
Um, I have my Prx and Ptr reversed (i.e. realized after I created the
thread that ObjectAdapter::find(Identity&) returns a Ptr, not a Prx.
So should I be using createReverseProxy():ConnectionPrx conn = ConnectionPrx::uncheckedCast(ConnectionI::_adapter->createReverseProxy(conn_ptr->_identity));
The doc states that "This operation is intended to be used by special
services, such as Router implementations. Regular user code should
not attempt to use this operation." so would this unadvisable?
Thanks,
Brendan0 -
Please see this post regarding our support policy on these forums:
http://www.zeroc.com/vbulletin/showthread.php?t=16970 -
marc wrote:Please see this post regarding our support policy on these forums:
http://www.zeroc.com/vbulletin/showthread.php?t=1697
Ok, sorry about that - signature created.
Regards,
Brendan0 -
Don't use createReverseProxy(), it is only used for special services, such as Glacier.
In general, given only a pointer to an instance of a servant (a "Ptr" in C++), you cannot get a proxy. That's because there doesn't necessarily have to be a one-to-one relationship between servants and Ice objects and their proxies. A servant might implement multiple Ice objects, or no Ice objects at all. Similarly, there might be Ice objects and proxies for which no servant exists at the time of proxy creation (for example, because the servant is created by servant locator).
This means that you must store your proxy or at least the identity. If you have the identity, you can call ObjectAdapter::createProxy().
For more information, please refer to the Ice manual.0 -
marc wrote:Don't use createReverseProxy(), it is only used for special services, such as Glacier.
...
This means that you must store your proxy or at least the identity. If you have the identity, you can call ObjectAdapter::createProxy().
Marc, thanks for the explanation and suggestions, I greatly appreciate being 'pointed in the right direction'.
Regards,
Brendan0