
VA 4.5 IIOP and nil objects
Quote:
>Hello,
>I have an existing application which I want to IDL-ize it, so it can
>be used as a server. But the application sometimes return nil objects.
>On the client side I get a CORBA exception COMM_FAILURE, which can be
>everything. Is there a better solution to handle these nil objects?
>Thanks for your help in advance.
>Ho
As your other respondent mentioned, nil cannot be passed as a valid
IDL type. There is no default mapping between a Smalltalk nil object
and an IDL type. You could create an IDL type that represents nil but
then you have the problem that operations (methods) must return a
typed result. To get around this you could do one of two things:
specify the return type to be an 'any' which is a valid IDL type that
matches any type; or specify the return type to be a union of the type
it usually returns and your mapping for nil.
The drawback of 'any' types is that they must be self describing
therefore they take up more space in the request that is sent over the
network and they take longer to marshall and unmarshall.
Unions would also take more space but not as much as an 'any'.
The best solution, IMHO, is to get rid of the nil return values from
methods. I believe that they do not reflect good OO design anyway.
This design is in general not portable to typed OO languages. I'd be
curious as to why these methods are returning nil since I've been in
the position of making this recommendation to others in the past and
would like to have a better handle on what their reasons for doing
this are.
Good luck,
Larry