Re: Creating CORBA objects in a child process



nickg glencros demon co uk wrote:

Hello,

I'd appreciate guidance on the following scenario. What I ideally want to do is:

Create a CORBA server with a factory in it, and allow clients to request object creation, but for the objects to actually be created in a child process. Another way of describing this, is that the factory is capable of creating child CORBA processes.
Here is some C++ code to do what I think you want. I use essentially this code in a project of my own. A cbol::Environment object is created within a child process (model_server program). The IOR of the object is printed to stdout before calling orb->run(). I've used popen to setup the communication and to do the fork and exec. The Assert calls throw work like assert's except they throw an exception when the condition is false.

       ::cbol::Environment_ptr new_environment()
throw (CORBA::SystemException, ::cbol::BadAlloc, ::cbol::SolverError)
       {
               FILE* fp = popen("model_server", "r");
               Assert(fp != 0, ::cbol::BadAlloc("Bad file pointer"));
               char ior[4096];
Assert(fscanf(fp, "%s", ior) == 1, ::cbol::BadAlloc("Bad IOR read"))
               CORBA::Object_var obj = orb_->string_to_object(ior);
::cbol::Environment_var env = ::cbol::Environment::_narrow(obj);
               return ::cbol::Environment::_duplicate(env);
       }



--
Bowie Owens

CSIRO Mathematical & Information Sciences
phone  : +61 3 9545 8055
fax    : +61 3 9545 8080
mobile : 0425 729 875
email  : Bowie Owens csiro au




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]