Archived

This forum has been archived. Please start a new discussion on GitHub.

About ObjectFactory

Hi!

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.

Luigi

Comments

  • matthew
    matthew NL, Canada
    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.