Instantiating pseudocomponents from C++

C++ standalone programs or EAServer components can instantiate pseudocomponents implemented in C++. Pseudocomponents implemented in Java can be instantiated only by C++ components that are executing in EAServer.

In order to instantiate a C++ pseudocomponent in a standalone program, the environment must include all the settings required by the EAServer C++ client runtime, and the location of the library must be specified in the system’s library search path.

You can instantiate a pseudocomponent any time after initializing and instantiating an ORB instance. Call the ORB.string_to_object method, passing a URL formatted as described in “Pseudocomponent object URLs”. Narrow the returned object to an interface supported by the component. See Chapter 15, “Creating CORBA C++ Clients” for more information on the ORB interface and narrowing objects to an interface.

Example: instantiating a C++ pseudocomponent

The following fragment instantiates a pseudocomponent proxy for a C++ component in the DLL CppPseudo.dll that is installed in the package Demo and has component name PseudoCpp. The returned object is narrowed to PseudocomponentDemo::Arithmetic interface. On UNIX platforms, this syntax also works for a shared library with base name "CppPseudo", as in CppPseudo.so.

String url = "pseudo://cpp/CppPseudo/Demo/PseudoCPP";
CORBA::Object_var obj = orb->string_to_object(url);
PseudocomponentDemo::Arithmetic_var arith = 
  PseudocomponentDemo::Arithmetic::_narrow(obj);

Example: instantiating a Java pseudocomponent

The following fragment instantiates a pseudocomponent proxy for a Java component. The implementation class and skeleton class are in the Java package Sample.PseudoComponents. The component is installed in the EAServer package Demo and has component name PseudoJava. The returned object is narrowed to PseudocomponentDemo::Arithmetic interface.

String url =   "pseudo://java/Sample.PseudoComponents/Demo/PseudoJava";
CORBA::Object_var obj = orb->string_to_object(url);
PseudocomponentDemo::Arithmetic_var arith = 
  PseudocomponentDemo::Arithmetic::_narrow(obj);