[omniORB] Finding methods in objects / part 2

Duncan Grisby dgrisby@uk.research.att.com
Wed, 01 Dec 1999 11:22:05 +0000


On Monday 29 November, Casillas_Juan_M/madrid_tecnologia@sinvest.es wrote:

>    well, our sample scenario is one program (say A) asking for =20
>    all the interfaces that have a method called hello(). All the >
>    interfaces running must answer its IOR and type (to allow A
>    comunicate with them) to A.

[... finding objects which respond to events ...]

>       How A can instantiate new objects from the implementations,
>       A knows the IOR, but ... program A can't cast dinamically new
>       objects from a string ... or It can ?

I don't think you mean "instantiate new objects...". I think you mean
you want A to use an _object reference_ to an object which has a type
that A does not know. In this case, there is no problem with creating
the reference, and invoking operations on it with DII. You obviously
can't use static invocation since you don't have compile-time
knowledge of it.

That said, I think you need to carefully re-think what it is you are
trying to do. As someone pointed out earlier, knowing that a server
supports an interface with an operation named hello() doesn't do you
any good at all, since the name of an operation doesn't tell you
anything about what it does. Not only that, but there is no guarantee
that the arguments to different hello() operations are the
same. Consider two interfaces:

interface I {
  void hello();
};

interface J {
  struct myStruct {
    // Some complex struct
  };
  double hello(in myStruct);
};

If a client of your proposed system asks for objects supporting
hello(), and gets back references to instances of I and J, how can it
possibly do anything useful?  Especially since it doesn't have
compile-time knowledge of J::myStruct.

Maybe what you really want to do is something like:

interface HelloSupporter {
  void hello(); // Fixed semantics for hello()
};

interface I : HelloSupporter {
  // Some other stuff
};

interface J : HelloSupporter {
  // Some different stuff
};

Now you can usefully find objects which derive from HelloSupporter,
and call their hello() operations, using the static invocation
interface (since you have compile-time knowledge of the HelloSupporter
interface), and have some idea as to what hello() will do.

HTH,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --