[omniORB] WG: How to return an object reference?

OKeeffe, Michael K MOKEEFFE at amfam.com
Fri Jul 8 15:03:38 BST 2005


Andreas,
 
Where do you register the DefaultAPI object with a POA?  There should be some similar code to how you create ObjectFactory.  Then use the POA's 'id_to_reference' method to get an object reference, and narrow to DefaultApi.  
 
See Duncan's example code (Python, but same idea).
 
http://www.grisby.org/presentations/py10tut.pdf
 
-Mike
 
-----Ursprüngliche Nachricht-----
Von: Andreas Groch [mailto:groch at promessmontage.de] 
Gesendet: Donnerstag, 7. Juli 2005 13:57
An: 'omniorb-list at omniorb-support.com'
Betreff: How to return an object reference?
 
Hi all,
 
I am trying to use an ObjectFactory in order to get an object reference on the client side of an existing object in the server.
It should be possible that any number of clients can connect to the DefaultApi at any time.
This is the idl:
 
interface DefaultApi {
            void hello();
};
 
interface ObjectFactory {
            DefaultApi getDefaultApi();
            void hello();
};
 
I create the object and the object reference like this:
 
DefaultApi_var defaultApi_ref;
 
DefaultApi_impl* defaultApi_servant = new DefaultApi_impl();
defaultApi_ref = defaultApi_servant->_this();
 
The getDefaultApi function looks like this:
 
DefaultApi_ptr ObjectFactory_impl::getDefaultApi() {
            return defaultApi_ref;
}
 
When I call the getDefaultApi() function on the client I get an object reference and I can invoke the hello function on it. But the console output of the server says: 
"omniORB: ObjRef(IDL:DefaultApi:1.0) - deleted."
 
When I call the function again or when I start the client again and invoke the getDefaultApi function I get a segmentation fault on the server.
I am wondering if this is the right way of passing an object reference from the server to the client.
How can I avoid that the ObjRef(IDL:DefaultApi:1.0) gets deleted when I return it in the getDefaultApi function?
 
Any help would be greatly appreciated.
 
Best regards/Mit freundlichen Grüßen
 
Andreas Groch
......................... 
Promess Gesellschaft für Montage- und Prüfsysteme mbH 
Nunsdorfer Ring. 29 
D-12277 Berlin 
  
Tel.:          0049 - (0)30 - 62 88 72 - 0
Fax:           0049 - (0)30 - 62 88 72 - 59 
Mobil:         0049 - (0) 
E-Mail:        groch at promessmontage.de 
Web:           www.promessmontage.de <file:///\\www.promessmontage.de\>  
........................ 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20050708/f195c467/attachment.htm


More information about the omniORB-list mailing list