[omniORB] IDL interface insufficient

Michael omniorb at bindone.de
Thu Apr 17 17:35:24 BST 2008


Hi David,

seems like you're using the default poa. What you could do is the following:

Assuming you a method that accepts a ref reference:

void MyObject::MyMethod(RemoteProxy_ptr p)
{
  try
  {
    PortableServer::Servant servant = poa_->reference_to_servant(p)
    if (RemoteProxy_i* rp = dynamic_cast<RemoteProxy_i*>(servant))
    {
      WrappedObject* o = rp->getWrapedObject();
    }
  }
  catch(...)
  {
    // there are different (meaningful) exceptions emitted, check the standard
  }
}
(this assumes, you stored the poa used somewhere - if it's the default poa you could also
get it through resolve_initial_reference)

This is also nice, because you can verify that the servant is really out of this oa (and
not a remote object).

cheers
michael

David wrote:
> Hi,
> 
> I'm having a problem with my IDL interface. I have a RemoteProxy class that
> wraps an object on the server. On the server side, the factory creating the
> RemoteProxy object needs to inject the wrapped object somehow. The interface
> of RemoteProxy is however specified in IDL, and I can't specify my wrapped
> object in IDL, and hence can't pass it as an argument to an IDL-specified
> method.
> 
> So far, I have been able to add a RemoteProxy_i.setWrappedObject(
> WrappedObject *o ) method to the RemoteProxy_i class, which is my object
> implementation class (inheriting from POA_RemoteProxy). So when I create it,
> I can do:
> 
> RemoteProxy_i *rp = new RemoteProxy_i();
> rp->setWrappedObject( o );
> poa->activate_object( rp );
> RemoteProxy_ptr ref = rp->_this();
> 
> Once I've created the reference object "ref", "rp" is not saved. Now, my
> problem is that I can't get the wrapped object "o" back from "ref", because
> "ref" only implements the IDL interface. How should I solve this? Do I need
> an external data structure, mapping references to "wrapped objects" (except
> they wouldn't be mapped in an object-oriented sense). Any help is
> appreciated.
> 
> /David
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> omniORB-list mailing list
> omniORB-list at omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list




More information about the omniORB-list mailing list