7.1 Object Identification
An OrbixWeb object is uniquely identified by its object reference; an object reference is an internal identification structure which contains a fixed set of fields.
If an application wishes to bind to an object, then it must have a mechanism for obtaining the information stored in the object reference. There are several ways for a server to make this information available, and these will be discussed in section 7.2.
7.1.1 OrbixWeb Object References
Each OrbixWeb object reference includes the following information:
In more detail, an OrbixWeb object reference is fully specified by the following fields:
_ObjectRef
. This interface supplies several methods common to all object references, including _object_to_string()
which (with a single parameter value IE.Iona.Orbix2._CORBA.IT_ORBIX_OR_KIND
) produces a stringified form of the object reference in the following format:
:\server_host:server_name:marker:IR_host:IR_server:IDL_interface
_ObjectRef
also provides access to the individual fields of an object reference string via the following set of accessor methods:
// Java
// in package IE.Iona.Orbix2.CORBA,
// in interface _ObjectRef.
public String _host();
public String _implementation();
public String _marker();
public String _interfaceHost();
public String _interfaceImplementation();
public String _interfaceMarker();
In general, the IR host name (interfaceHost
) and IR server (interfaceImplementation
) fields are set to default values; in the stringified form these are `IR' and the blank string, respectively. OrbixWeb automatically assigns the server host, server name and IDL interface fields on object creation and it is not generally necessary to update these values. OrbixWeb also assigns a marker value to each object, but programmers may choose alternative marker values in order to explicitly name OrbixWeb objects. The assignment of marker names to objects is discussed in section 7.1.3.
7.1.2 Interoperable Object References
An object which is accessible via IIOP is identified by an interoperable object reference (IOR). Since an ORB's object reference format is not prescribed by the OMG, the format of an IOR includes an ORB's internal object reference as well as an internet host address and a port number. _object_to_string()
on the required object, passing the value IE.Iona.Orbix2._CORBA.IT_INTEROPERABLE_OR_KIND
as a parameter.7.1.3 Assigning Markers to OrbixWeb Objects
An OrbixWeb marker value allows a name (in string format) to be associated with an object, as part of its object reference. A marker name may be specified at the time an object is created as we will see in "Assigning a Marker on Creation". If a marker is not specified for a newly created object, a name is automatically chosen by OrbixWeb.
An object which has a user-specified name or a name assigned by OrbixWeb may be renamed using the modifier method
_marker(String)
which is defined on the interface _ObjectRef
, in package IE.Iona.Orbix2.CORBA
and is available on every OrbixWeb object._marker()
. The following code demonstrates the use of this method:
// Java import IE.Iona.Orbix2.CORBA.SystemException; ... _AccountRef aRef; try { aRef = new _tie_Account (new AccountImplementation ()); System.out.println ("The marker name chosen " + "by OrbixWeb is " + aRef._marker ()); } catch (SystemException se) { ... }
String
) of a TIE-class constructor. For example:
// Java import IE.Iona.Orbix2.CORBA.SystemException; ... _BankRef bRef; try { bRef = new _tie_Bank (new BankImplementation (), "College_Green"); } catch (SystemException se) { ... }
String
) of a BOAImpl-class constructor. For example:
// Java // Constructor definition in implementation class: import IE.Iona.Orbix2.CORBA.SystemException; ... public class BankImplementation extends _boaimpl_Bank { BankImplementation (String marker) throws SystemException { super (marker); } } // Usage in server class: import IE.Iona.Orbix2.CORBA.SystemException; ... BankImplementation bankImpl; try { bankImpl = new BankImplementation ("College Green"); } catch (SystemException se) { ... }
Marker names cannot contain the character `
:
' and cannot contain the null character.An object's interface name together with its marker name must be unique within a server. If a chosen marker is already in use when an object is named, OrbixWeb will (silently) assign a different marker to the object (and the object with the original marker will be unaffected). There are two ways to test for this, depending on how a marker is assigned to an object:
_marker(String)
is used, the programmer can test for a false return value (a false return value indicates a name clash).
-
class or a BOAImpl-
class constructor, then the server programmer can test for a name clash by calling the accessor method _marker()
(with takes no parameters) on the new object and comparing the marker with the one the programmer tried to assign.
impl_is_ready()
. Either approach allows clients to obtain references to server objects using the OrbixWeb _bind()
method, which does not require all the object reference field values to be specified.
string_to_object()
(called on the _CORBA.Orbix
object).
Passing an object reference as a parameter is very useful and is frequently implemented in CORBA applications. However, it is important to note that this system implies that the client is already connected to a server object. Therefore, it must be used in conjunction with one of the other approaches.
The CORBA Naming Service approach is suitable for a wide range of applications. The Naming Service is defined as part of the CORBAservices specification and allows ORB applications to assign abstract names to objects in a distributed system. These names can be assigned, and the objects associated with the names can be retrieved, through a standard IDL interface.
For example, if an OrbixWeb application assigns a name to an IOR for one of its objects, then this object can be located using the Naming Service interface by an application implemented using any ORB. In section 7.2.1, we will illustrate how to use the Naming Service in this context.
7.2.1 Publishing Object References using the Naming Service
The role of the CORBA Naming Service is to allow a name to be bound to (associated with) an object and to allow that object to be found subsequently by resolving that name.NamingContext
, in which the second name in the compound name is looked up. This process continues until the last component of the compound name has been reached.objects
and objects.banks
, and then to bind the name objects.banks.national
to the object reference for a Bank
implementation object.
// Java // An OrbixWeb server // (and client of a Naming Server). // In file BankServer.java. package idl_demo; import CosNaming._NamingContextRef; import CosNaming.Name; import IE.Iona.Orbix2._CORBA; import IE.Iona.Orbix2.CORBA.SystemException; import IE.Iona.Orbix2.CORBA._ObjectRef; public class BankServer { public static void main (String args[]) { // Declare object types. BankImplementation bankImpl = new BankImplementation (); _BankRef bankRef; // Declare Naming service types. _ObjectRef initRef; _NamingContextRef initContext; _NamingContextRef objectsContext; _NamingContextRef banksContext; Name name; try { bankRef = new _tie_Bank (bankImpl); } catch (SystemException se) { // Details omitted. } try { // Find initial naming context. initRef = _CORBA.Orbix.resolve_initial_references ("NameService"); initContext = NamingContext._narrow (initRef); // A CosNaming.Name is simply a sequence // of structs. name = new Name (1); name.buffer[0].id = new String ("objects"); name.buffer[0].kind = new String (""); // (In one step) create a new context, // and bind it relative to the // initial context: objectsContext = initContext.bind_new_context (name); name.buffer[0].id = new String ("banks"); name.buffer[0].kind = new String (""); // (In one step) create a new context, // and bind it relative to the // objects context: banksContext = objectsContext.bind_new_context (name); name.buffer[0].id = new String ("national"); name.buffer[0].kind = new String (""); // Bind name to object bankRef in context // objects.banks: banksContext.bind (name, bankRef); } catch (SystemException se) { // Details omitted. } try { // Wait for incoming requests. _CORBA.Orbix.impl_is_ready ("BankSrv"); } catch (SystemException se) { // Details omitted. } } };In Chapter 8, we will describe how clients can resolve object references using the Naming Service.