Summary
Locating Objects with corbaloc
Using corbaloc object references
Environment
Orbix 6.3.x
All supported platforms
Question/Problem Description
This article describes how to write an Orbix 6.3, C client and server using a corbaloc URL to locate a direct-persistent object.
Clarifying Information
Corbaloc URLs specify the location of a CORBA service in a human-readable format.
For more information on corbaloc object references, please see the section entitled "Locating Objects with corbaloc" in the Orbix 6 CORBA Programmer's Guides.
Resolution
For direct-persistent servers, human-readable keys are substituted in a corbaloc URL is performed by the plain_text_key plug-in, which holds a transient list of plain text keys.
Firstly, the server obtains a reference to the PlainTextKeyForwarder:
CORBA::Object_var objref = global_orb->resolve_initial_references("IT_PlainTextKeyForwarder");
IT_PlainTextKey::Forwarder_var forwarder = IT_PlainTextKey::Forwarder::_narrow(objref);
The server then registers a service's plain text key (For example "corbaloc_demo_server") and its corresponding object reference with the plain_text_key plug-in:
forwarder->add_plain_text_key(
"corbaloc_demo_server",
persistent_poa->create_reference_with_id(
oid,
Simple::_tc_SimpleObject->id()
)
);
On the client-side, the client converts the corbaloc string (containing the host and port for the service) to an object reference and opens a connection directly to the server:
CORBA::Object_var objref = orb->string_to_object(objref_text);
Simple::SimpleObject_var simple = Simple::SimpleObject::_narrow(objref);
On the server-side, the plain_text_key plug-in finds the object reference corresponding to the key in the corbaloc. The object reference is then sent back to the client in a reply message. The client can now send the GIOP Request message to the server.
Support Incidents
- 2795040
Notes
Further information on direct persistence can be found in the section entitled "Setting Object Lifespan" in the Orbix 6.3 CORBA Programmer's Guides.
Attachment
Please find a sample application here, demonstraiting how to write an Orbix 6.3, C client and server using a corbaloc URL to locate a direct-persistent object.
#Orbix6
#KnowledgeDocs
#Orbix