[22] OBJECT REFERENCES UPDATED!
(Part of the CORBA FAQ, Copyright © 1996-99)


[22.1] WHAT IS AN OBJECT REFERENCE?

A transient, opaque handle that identifies an object instance in your ORB. An object reference is the identifier needed to invoke methods on objects.

Object references are not global identifiers that are valid across all machines in a distributed network. Their scope is limited to your local ORB.

TopBottomPrevious sectionNext section ]


[22.2] WHY A HANDLE RATHER THAN A “HARD” ADDRESS?

CORBA is a dynamic environment and objects move around in an unpredictable manner. You need a soft locator rather than something static and brittle.

TopBottomPrevious sectionNext section ]


[22.3] FOR HOW LONG IS AN OBJECT REFERENCE VALID?

Only during the session while your client is connected to the ORB. If a target object moves during a session, the ORB will provide the equivalent of a transparent forwarding mechanism.

TopBottomPrevious sectionNext section ]


[22.4] WHAT IF I WANT A PERSISTENT REFERENCE?

Stringify the object reference and save it in a persistent medium. But, we have to warn you, you’re about to get into deep water. Maybe you should just skip to the section on Naming Service, unless you want to be an “expert”.

TopBottomPrevious sectionNext section ]


[22.5] I WANT TO BE AN EXPERT. HOW DO I STRINGIFY AN OBJECT REFERENCE?

Use object_to_string(), and reverse the process using string_to_object(). There is some magic in string_to_object(); it not only does the necessary string-to-pointer conversion, it ensures that you get a currently valid object reference that is equivalent to the original reference that was stringified (i.e., both refer to the same object instance).

TopBottomPrevious sectionNext section ]


[22.6] WHAT IS THE FORMAT OF AN OBJECT REFERENCE?

We can’t tell you because there is no standard for this. OMG wanted to give ORB implementers as much freedom as possible to develop efficient, possibly platform-dependent schemes. Thus, the references are opaque and should be thought of as an interface without regard for their implementation.

TopBottomPrevious sectionNext section ]


[22.7] WHO CREATES OBJECT REFERENCES?

Some ORB calls such as resolve_initial_references() and string_to_object() generate an object reference. The object it refers to might or might not exist (the act of using the object reference can result in the creation of the actual object).

Also, a factory might create an object reference by creating an object implementation within the same process. The factory could generate the object reference and cause an object to be created (as above), or the factory could obtain the object reference from some other source (NameService, TraderService).

TopBottomPrevious sectionNext section ]


[22.8] HOW DO I COMPARE REFERENCES?

Use is_equivalent(), but don’t take it too seriously. This method never lies to you, if it says two references are equivalent, then they are. But they might be equivalent but not identical and is_equivalent() can potentially return false. See the October 1996 column by Steve Vinoski and Doug Schmidt in C++ Report.

TopBottomPrevious sectionNext section ]


[22.9] GREAT. WHAT OTHER SURPRISES ARE THERE WITH IS_EQUIVALENT()?

Remember that is_equivalent() is invoked on one of the two objects, and there are cases where this can cause deadlock. The following example illustrates how this can happen on one particular single-threaded ORB that won’t allow a server to invoke a method on the client (contributed by Jeff Stewart, jstewart+@andrew.cmu.edu; used with permission):

Suppose a server receives updates from cached clients and then has to update all clients except for the one that reported (updating the reporting client would cause a deadlock on this ORB). So, as the server iterates through its client list it must ensure that it does not invoke the reporting client. But it can’t use is_equivalent() because this will eventually cause an invocation on the reporting client just to do the is_equivalent() check, inadvertently creating a deadlock.

TopBottomPrevious sectionNext section ]


[22.10] IS THAT ALL OF THE BAD NEWS ABOUT IS_EQUIVALENT()?

Not really. You also have to remember that it typically requires network traffic. It’s easy to fall into the wishful thinking that the ORB can handle is_equivalent() for you, but, in general, it doesn’t.

TopBottomPrevious sectionNext section ]


[22.11] SO WHY DON’T WE JUST COMPARE STRINGIFIED REFERENCES?

First, the object may have moved in between the times that its references were stringified, so the strings may not be identical. Also, there are potential problems if you have multiple vendors because stringified object references can be quite ORB-specific.

TopBottomPrevious sectionNext section ]


[22.12] THIS SOUNDS TOO COMPLICATED. SHOULD I JUST LEARN DCOM INSTEAD?

No, not at all. We’ve taken you into the depths of a topic that has deep philosophical roots, which has been the focus of arguments for many years. Most people never need this kind of knowledge. We warned you earlier, didn’t we? And you just had to know, didn’t you?

TopBottomPrevious sectionNext section ]


[22.13] WHY DO YOU SAY, “MOST PEOPLE NEVER NEED THIS KIND OF KNOWLEDGE?

From a practical standpoint, these considerations don’t come up all that often, even for people who have to work at this level. Fortunately, most users can merely use the Naming Service and work with (essentially) character strings for names, and avoid all the complexity above.

TopBottomPrevious sectionNext section ]


[22.14] THEN WHY DID YOU JUST DRAG US THROUGH THE MUD?

You’re the one who wanted to be an expert. We just wanted to raise your awareness so that you’ll think twice when comparing object references. Besides, this is a good way to illustrate how CORBA requires a little learning on your part.

TopBottomPrevious sectionNext section ]


[22.15] HOW ARE OBJECT REFERENCES DECLARED IN C?

The IDL compiler will generate code that typedefs your interface to a CORBA_Object.

TopBottomPrevious sectionNext section ]


[22.16] HOW ARE OBJECT REFERENCES HANDLED IN C++?

Two ways, _var and _ptr. The idea behind _var is to force automatic memory management, where allocation is off of the stack and memory is returned when the object reference goes out of scope. On the other hand, _ptr object references require specific management, including freeing memory at the appropriate time.

TopBottomPrevious sectionNext section ]


[22.17] WHEN DO I USE _VAR INSTEAD OF _PTR?

Use _var when you can, because they are simpler. Use _ptr when you have to, usually for performance reasons. Sometimes there are critical windows you can’t afford to let the system take over memory management. As a very rough guide, think about _ptr when you have many fine-grained objects and known timing or performance problems.

TopBottomPrevious sectionNext section ]


[22.18] WHAT IF I WANT TO INVOKE METHODS ON AN OBJECT IN ANOTHER ORB?

Then you need to know about interoperable object references (IOR).

TopBottomPrevious sectionNext section ]


[22.19] DOES AN IOR HAVE A DEFINED FORMAT AND, IF SO, WHY?

Yes, because this is something that inherently requires cooperation between different vendors and ORBs. Ordinary object references exist within an ORB so there was no compelling reason to standardize formats.

TopBottomPrevious sectionNext section ]


[22.20] WHAT IS THE FORMAT OF AN IOR?

The specific details can be found at the OMG web site, and probably shouldn’t matter to you. But it doesn’t hurt to know that an IOR consists of a type ID and one or more tagged profiles.

TopBottomPrevious sectionNext section ]


[22.21] WHAT IS A TAG?

A tag indicates the protocol ID from the most recent protocol change as the IOR flowed from its home ORB to your local ORB (we’ll discuss what this is all about when we get into more detail on bridges and interoperability), and is something that is registered with OMG; for instance, IIOP has an ID of zero.

TopBottomPrevious sectionNext section ]


[22.22] WHAT IS A PROFILE?

A high-performance way for an ORB to tell another ORB what it needs to know to use the IOR properly. There are two types, single- and multiple-component. Both typically contain information about the presence of ORB services such as Transaction Service.

TopBottomPrevious sectionNext section ]


[22.23] WHAT IS THE DIFFERENCE BETWEEN THE TWO TYPES OF PROFILES?

It depends. Profiles are defined by the people who developed the protocol and registered its tag with OMG. IIOP uses a single-component profile, while DCE CIOP uses a multiple-component profile.

TopBottomPrevious sectionNext section ]


[22.24] WHY DID YOU SAY THAT THE SPECIFIC DETAILS PROBABLY SHOULDN’T MATTER?

You’ll probably never need them because you’ll probably never see an example of an IOR. These only exist in the nether world between ORBs.

TopBottomPrevious sectionNext section ]


[22.25] BUT HOW DOES MY PROGRAM USE AN IOR?

It doesn’t. Your local ORB creates a local proxy for the remote object represented by the IOR. All your program ever sees directly is the object reference for the proxy. The ORB takes care of everything else.

TopBottomPrevious sectionNext section ]


[22.26] THIS EXPERT STUFF ISN’T SO TOUGH. WHAT ABOUT STRINGIFYING AN IOR?

You never learn, do you? Let’s discuss this at another time. When you are in a position where you need this knowledge, you won’t be getting your information from this document. In the meantime, learn all about Naming Service.

TopBottomPrevious sectionNext section ]


[22.27] WHEN I OBTAIN AN OBJECT REFERENCE, WHAT DETERMINES IF IT IS AN IOR OR JUST AN OR? NEW!

[Recently created (12/1998). Click here to go to the next FAQ in the “chain” of recent changes]

  1. If you create the object reference from a string via a CORBA 2.0 compliant library then the object reference is an IOR.
  2. If you create the object reference via resolve_initial_references() the ORB libraries might create an OR or an IOR. Some ORBs from companies such as Expersoft and Visigenic ORBs support only native IIOP and thus all references are IORs. On the other hand, some commericial vendors who shipped ORBS that supported IDL before IIOP existed pass around references that are not IORs and thus these referencesmight not always be IORs. Many cases an ORB vendor might support a proprietary protocol in addition to IIOP. Note: even if resolve_initial_references() returns and IOR, the IOR almost always refers to an object implemented with the same ORB environment as the application calling resolve_initial_references().
  3. If the object reference is obtained from a server, a NameContext, or from a factory, the process and ORB libraries that originially created the object reference, determine if the reference is an OR or an IOR.

TopBottomPrevious sectionNext section ]


E-Mail E-mail us
CORBA FAQTable of ContentsExhaustiveAlphabeticalSubject indexAbout the authors©TMDownload your own copy ]
Revised Oct 27, 1999