3.5.4 Creating and Registering a Factory

If your CORBA server application manages a factory that you want CORBA client applications to be able to locate easily, you require to write the code that registers that factory with the FactoryFinder object.

To write the code that registers a factory managed by your CORBA server application, you do the following:

  1. Create an object reference to the factory.

    You include an invocation to thecreate_object_reference() method, specifying the Interface Repository ID of the factory’s OMG IDL interface or the object ID (OID) in string format. In addition, you can specify routing criteria.

  2. Register the factory with the Oracle Tuxedo domain.

    Use the register_factory() method to register the factory with the FactoryFinder object in the Oracle Tuxedo domain. The register_factory() method requires the object reference for the factory and a string identifier.

The following code snippet illustrates the code snippet from the Simpapp sample application that creates and registers a factory.

...
CORBA::Object_var v_reg_oref =
       TP:create_object_reference(
       _tc.SimpleFactory->id(),       //Factory Interface ID
       “simplefactory”,               //Object ID
        CORBA::NVList::_nil()        //Routing Criteria
      );
      TP::register_factory(
       CORBA::Object_var v_reg_oref.in(),
       _tc_SimpleFactory->id(),
      );
...

In the above code snippet, notice the following:

  • tc.SimpleFactory->id() specifies the SimpleFactory object's Interface Repository ID by extracting it from its typecode.
  • CORBA::NVList::_nil() specifies that no routing criteria are used, with the result that an object reference created for the Simple object is routed to the same group as the SimpleFactory object that created the object reference.