Home Help Center

About ObjectFactory

AnhurAnhur Member Luigi PaioroOrganization: INAF - IASF MilanProject: MIMA prototype

I've read the documentation about class factories (ObjectFactory). What I understand is that if I want to cast an object (A) which is returned by a proxy object (B) method call, I must implement an ObjectFactory which provides, to the client side, directly the local instace of A. It is logical, but I guess this means that, within a multilanguage environment, I must create an ObjectFactory (and A) implementation for each language... I'm right? How could I do to have something like a ProxyObjectFactory (in order to have a more generic factory)? Is this possible?

Thank you in advance.



  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    ObjectFactory has nothing to do with casting. If you return an abstract object to a caller from a remote method invocation you must provide an object factory which is capable of instantiating this object. For example:
    // This class is abstract because it has a method.
    class A
      void someMethod();
    // This class is non-abstract.
    class B
     int a;
    interface C
       A getA();
       B getB();

    If you call getA the caller must have an object factory capable of creating an instance of class A. You do not need to provide such a factory for getB since B is not abstract.

    You need to provide such an implementation for all languages that call C::getA.
Sign In or Register to comment.