The client functionality associated with passing object references as method parameters requires no detailed discussion. OrbixWeb automatically creates a proxy for an object reference which enters a client's address space as an operation parameterso the operation invocation is the only functionality required to retrieve such an object reference.
_bind()
method provides a mechanism for creating proxies for objects which have been created in servers. A client which uses _bind()
to create a proxy does not need to specify the entire object reference for the target object. Although _bind()
can be invoked using either the Orbix communications protocol or CORBA IIOP, it can only succeed if the target object is implemented in an Orbix or OrbixWeb server_bind()
cannot be used with objects which are implemented using other ORBs.The creation of a proxy in a client's address space allows operations to be invoked on the target object; when an operation is invoked on the proxy, OrbixWeb automatically transmits the request to the target object. The
_bind()
method may be used to specify the exact object required or, by using default parameters, OrbixWeb may be allowed some freedom when choosing the object.In OrbixWeb, the
_bind()
method has been integrated with a locator which provides a basic service for finding objects when no host is specified. For details, see Chapter 24, "Locators".
8.1.1 The _bind() Method
The _bind()
method is a static method automatically generated by the IDL compiler for each IDL Java class. For interface A
, the full form of _bind()
is declared in Java class A
as follows:
// Java
public static final _ARef
_bind(String markerServer, String host)
throws IE.Iona.Orbix2.CORBA.SystemException {
...
}
As a result of overloading, _bind()
can take the following sets of parameters:
markerServer
, host
markerServer
_CORBA.Orbix._object_to_string()
.
_bind()
method supports polymorphic binds: that is, a call to A._bind()
can be made to an object of interface B
, if interface A
is a base interface of interface B
.The
markerServer
and host
parameters will be explained in turn in section 8.1.2 and section 8.1.3. Section 8.1.5 contains a tabular summary of the parameters to _bind()
, and section 8.1.6 describes how _bind()
can raise an exception and how its performance can be optimised. Finally, section 8.2 describes methods of creating proxy objects from object reference information, including binding to a stringified object reference.
8.1.2 The markerServer parameter to _bind()
The markerServer
parameter denotes a specific server name and object within that server. It can be a string of the form:
marker ':' server_nameThe marker identifies a specific object within the specified server.
The
server_name
is the name of a server, as registered in the OrbixWeb Implementation Repository at the server host. It is not necessarily the name of a class or an interface (although an OrbixWeb programmer is free to make a server name the same as that of a class or interface). The OrbixWeb Implementation Repository is described in detail in Chapter 11, "Registration and Activation of Servers".
If the server name is not given in the markerServer
parameter, the server name defaults to the name of the Java class for _bind()
.1 For example, in a parameterless call to Bank._bind()
, the server name will default to "Bank
";2 that is, the target server must then have been registered with the name "Bank
".
If the marker is not given, it defaults to any object, within the server, which implements the interface (or a derived interface) given by the Java class name specified. The chosen object may have been named explicitly by the programmer or assigned a default name by OrbixWeb.
:
' character then the string is understood to be just a marker with no explicit server name. Since colon (`:
') is used as a separator, it is illegal for a marker or a server name to include a `:
' character.markerServer
parameter which could be used in a call to Bank._bind()
are:
"College_Green:AIB"
The College_Green
object at the AIB
server.
"College_Green"
The College_Green
object at the Bank
server.
"College_Green:"
The College_Green
object at the Bank
server.
""
Any Bank
object at the Bank
server.
"College_Green:myBank"
The College_Green
object at the myBank
server.
":myBank"
Any Bank
object at the myBank
server.markerServer
parameter has at least two `:
' characters within it, it will not be treated as a marker:server-name pair, but it will be assumed to be the string form of a full object reference. See section 8.2 for further details.
8.1.3 The host parameter to _bind()
The host
parameter to _bind()
specifies the internet host name or the internet address of a node on which to find the object. An internet address is (assumed to be) a string of the form xxx.xxx.xxx.xxx
,
where x
is a decimal digit._bind()
, provided that the host parameter is not explicitly given. Note that the locator must be configured before it can be used.
OrbixWeb also allows developers to override the default locator with an alternative location mechanism. The programming steps required to achieve this are described in Chapter 24.
8.1.4 Example calls to _bind()
This section shows a selection of sample calls to _bind().
// Java import IE.Iona.Orbix2.CORBA.SystemException; ... _BankRef bRef; try { // Bind to any Bank object in any "Bank" server. // That object should implement the Bank IDL // interface. bRef = Bank._bind(); // Bind to any Bank object in the "Bank" server // at node alpha (in the current domain). // That object should implement the Bank IDL // interface. bRef = Bank._bind("", "alpha"); // Bind to the "College Green" object within the // "Bank" server at node alpha (in the current // domain). That object should implement the // Bank IDL interface. bRef = Bank._bind("College_Green", "alpha"); // Bind to the "College Green" object (in server // "Bank") somewhere within the network. // College_Green should implement the Bank IDL // interface. bRef = Bank._bind("College_Green"); // Bind to the "College_Green" object in // the "AIB" server somewhere in the network. // That object must implement the Bank // IDL interface. bRef = Bank._bind("College_Green:AIB"); // Bind to the "College_Green" object at // the "AIB" server at node beta, in the // internet domain "mc.ie". That object should // implement the Bank IDL interface. bRef = Bank._bind ("College_Green:AIB", "beta.mc.ie"); // Bind to the "College_Green" object at // the "AIB" server at Internet // Address 123.456.789.012. That object should // implement the Bank IDL interface. bRef = Bank._bind ("College_Green:AIB", "123.456.789.012"); } catch (SystemException se) { ... }
_bind()
:
// Java
_T1Ref tRef;
tRef = T2._bind("M:S", "H", C);
// Java _T2Ref tRef; tRef = T2._bind("aaa:sss","hhh");Since a server can support objects of any number of interfaces, the following can be used to bind to an object of interface
T3
and marker "bbb
" in the same server:
// Java _T3Ref tRef; tRef = T3._bind("bbb:sss","hhh");
_bind()
raises an exception if the desired object is unknown to OrbixWeb. Doing so requires OrbixWeb to ping that desired object in order to check its availability (the ping operation is defined by OrbixWeb and it has no effect on the target object). The pinging will cause the target OrbixWeb server process to be activated if necessary, and it will confirm that this server recognises the target object.If a programmer wishes to improve efficiency by reducing the number of remote invocations, pinging can be disabled by calling the method
pingDuringBind()
(on the _CORBA.Orbix
object) as follows:
// JavaThe previous setting is returned.import IE.Iona.Orbix2._CORBA;
..._CORBA.Orbix.pingDuringBind(false);
When pinging is disabled, binding to an unavailable object will not raise an exception at that time. Instead, an exception will be raised when the proxy object is first used.
A program should always check for exceptions when calling
_bind()
, whether or not pinging is enabled. Even when pinging is disabled, this method will raise an exception in some circumstances, including on some configuration errors.
string_to_object()
on the _CORBA.Orbix
object.For example, given an object reference string which identifies a
Bank
object:
// Java import IE.Iona.Orbix2._CORBA; import IE.Iona.Orbix2.CORBA.SystemException; ... String bStr = ... ; // Assign to object ref string. _BankRef bRef; try { bRef = _CORBA.Orbix.string_to_object (bStr); } catch (SystemException se) { ... }Similarly, the
markerServer
field of the _bind()
method can accept a stringified object reference:
// Java import IE.Iona.Orbix2.CORBA.SystemException; ... String bStr = ...; // Assign to object ref string. _BankRef bRef; try { bRef = Bank._bind (bStr); } catch (SystemException se) { ... }This has exactly the same functionality as calling
string_to_object()
.The method
string_to_object()
(of class ORB
) is overloaded to allow the individual fields of a stringified object reference to be specified. The definition of this form of string_to_object()
is as follows:
// Java // In package IE.Iona.Orbix2.CORBA, // in class ORB. public IE.Iona.Orbix2.CORBA._ObjectRef string_to_object( String host, String IR_host, String ServerName, String marker, String IR_server, String interfaceMarker) throws SystemException;The ability to create proxy objects from object reference strings has several useful applications. For example, this approach to proxy creation is often used in conjunction with the OrbixWeb Dynamic Invocation Interface (DII).
Full details of the functionality supported by the Naming Service are given in the OrbixNames Guide. The OrbixNames implementation of the Naming Service runs as an Orbix (or OrbixWeb) server. Clients can access the functionality of the Naming Service through the standard IDL definitions for this service.
objects.bank.national
to retrieve the object reference published by the server example in section 7.2.1.
// Java // An OrbixWeb client // (of an OrbixWeb server and of a Naming Server). // In file Client.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 Client { public static void main (String args[]) { _NamingContextRef initContext; Name name; _ObjectRef initRef, objRef; _BankRef bankRef; try { // Find initial naming context. initRef = _CORBA.Orbix.resolve_initial_references ("NameService"); initContext = NamingContext._narrow (initRef); // Set up name and contexts. name = new Name (3); name.buffer[0].id = new String ("objects"); name.buffer[0].kind = new String (""); name.buffer[1].id = new String ("banks"); name.buffer[1].kind = new String (""); name.buffer[2].id = new String ("national"); name.buffer[2].kind = new String (""); // Resolve the name. objRef = initContext.resolve (name); bankRef = Bank._narrow (objRef); } catch (SystemException se) { // Details omitted. } // Use bankRef as normal(not shown). ... } }
`:'; or a string which terminates with a `:'.