Hi Michael,<br><br>This is a great tip. Thanks a lot. <br><br>/David<br><br><div class="gmail_quote">On Thu, Apr 17, 2008 at 4:35 PM, Michael <<a href="mailto:omniorb@bindone.de">omniorb@bindone.de</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi David,<br>
<br>
seems like you're using the default poa. What you could do is the following:<br>
<br>
Assuming you a method that accepts a ref reference:<br>
<br>
void MyObject::MyMethod(RemoteProxy_ptr p)<br>
{<br>
try<br>
{<br>
PortableServer::Servant servant = poa_->reference_to_servant(p)<br>
if (RemoteProxy_i* rp = dynamic_cast<RemoteProxy_i*>(servant))<br>
{<br>
WrappedObject* o = rp->getWrapedObject();<br>
}<br>
}<br>
catch(...)<br>
{<br>
// there are different (meaningful) exceptions emitted, check the standard<br>
}<br>
}<br>
(this assumes, you stored the poa used somewhere - if it's the default poa you could also<br>
get it through resolve_initial_reference)<br>
<br>
This is also nice, because you can verify that the servant is really out of this oa (and<br>
not a remote object).<br>
<br>
cheers<br>
michael<br>
<div><div></div><div class="Wj3C7c"><br>
David wrote:<br>
> Hi,<br>
><br>
> I'm having a problem with my IDL interface. I have a RemoteProxy class that<br>
> wraps an object on the server. On the server side, the factory creating the<br>
> RemoteProxy object needs to inject the wrapped object somehow. The interface<br>
> of RemoteProxy is however specified in IDL, and I can't specify my wrapped<br>
> object in IDL, and hence can't pass it as an argument to an IDL-specified<br>
> method.<br>
><br>
> So far, I have been able to add a RemoteProxy_i.setWrappedObject(<br>
> WrappedObject *o ) method to the RemoteProxy_i class, which is my object<br>
> implementation class (inheriting from POA_RemoteProxy). So when I create it,<br>
> I can do:<br>
><br>
> RemoteProxy_i *rp = new RemoteProxy_i();<br>
> rp->setWrappedObject( o );<br>
> poa->activate_object( rp );<br>
> RemoteProxy_ptr ref = rp->_this();<br>
><br>
> Once I've created the reference object "ref", "rp" is not saved. Now, my<br>
> problem is that I can't get the wrapped object "o" back from "ref", because<br>
> "ref" only implements the IDL interface. How should I solve this? Do I need<br>
> an external data structure, mapping references to "wrapped objects" (except<br>
> they wouldn't be mapped in an object-oriented sense). Any help is<br>
> appreciated.<br>
><br>
> /David<br>
><br>
><br>
><br>
</div></div>> ------------------------------------------------------------------------<br>
><br>
> _______________________________________________<br>
> omniORB-list mailing list<br>
> <a href="mailto:omniORB-list@omniorb-support.com">omniORB-list@omniorb-support.com</a><br>
> <a href="http://www.omniorb-support.com/mailman/listinfo/omniorb-list" target="_blank">http://www.omniorb-support.com/mailman/listinfo/omniorb-list</a><br>
<br>
</blockquote></div><br>