An Interface Repository (IR) is like a database of CORBA object interface information that enables clients to learn about or update interface descriptions at runtime. In contrast to the VisiBroker Location Service, described in “Using the Location Service” which holds data describing object
instances, an IR's data describes
interfaces (types). There may or may not be available instances that satisfy the interfaces stored in an IR. The information in an IR is equivalent to the information in an IDL file (or files), but it is represented in a way that is easier for clients to use at runtime.
Clients that use Interface Repositories may also use the Dynamic Invocation Interface (DII) described in “Using the Dynamic Invocation Interface”. Such clients use an Interface Repository to learn about an unknown object's interface, and they use the DII to invoke methods on the object. However, there is no necessary connection between an IR and the DII. For example, someone could use the IR to write an “IDL browser” tool for developers; in such a tool, dragging a method description from the browser to an editor would insert a template method invocation into the developer's source code. In this example, the IR is used without the DII.
You create an Interface Repository with the VisiBroker irep program, which is the IR server (implementation). You can update or populate an Interface Repository with the VisiBroker
idl2ir program, or you can write your own IR client that inspects an Interface Repository, updates it, or does both.
As an example of the kinds of objects an IR can contain, consider that IDL files can contain IDL module definitions, and modules can contain interface definitions, and interfaces can contain operation (method) definitions. Correspondingly, an Interface Repository can contain ModuleDef objects which can contain
InterfaceDef objects, which can contain
OperationDef objects. Thus, from an IR
ModuleDef, you can learn what
InterfaceDefs it contains. The reverse is also true; given an
InterfaceDef you can learn what
ModuleDef it is contained in. All other IDL constructs, including exceptions, attributes, and valuetypes, can be represented in an Interface Repository.
An Interface Repository also contains typecodes. Typecodes are not explicitly listed in IDL files, but are automatically derived from the types (long,
string,
struct, and so on) that are defined or mentioned in IDL files. Typecodes are used to encode and decode instances of the CORBA
any type: a generic type that stands for any type and is used with the dynamic invocation interface.
If you want to use the _get_interface_def method defined for all objects, you must have at least one Interface Repository server running so the VisiBroker ORB can look up the interface in the IR. If no Interface Repository is available, or if the IR that the VisiBroker ORB binds to has not been loaded with an interface definition for the object,
_get_interface_def raises a
NO_IMPLEMENT exception.
The VisiBroker Interface Repository server is called irep, and is located in the
<install_dir>/bin directory. The
irep program runs as a daemon. You can register
irep with the Object Activation Daemon (OAD) as you would any object implementation. The
oadutil tool requires the object ID, for example,
IDL:org.omg/CORBA/Repository:2.3 (as opposed to an interface name such as
CORBA::Repository).
Use the irep program to create an Interface Repository and view its contents. The usage syntax for the
irep program is as follows:
The irep arguments are defined in the following table. You may also use the driver options defined in
“General options”.
You can view the contents of the Interface Repository with either the VisiBroker ir2idl utility, or the VisiBroker Console application. The syntax for the
ir2idl utility is:
You can update an Interface Repository with the VisiBroker idl2ir utility, which is an IR client. The syntax for the
idl2ir utility is:
The following example shows how the TestIR Interface Repository would be updated with definitions from the
Bank.idl file.
The OperationDef object contains references to additional data structures (not interfaces) that hold the parameters and return type.
The following table summarizes the objects that can be contained in an Interface Repository. Most of these objects correspond to IDL syntax elements. A StructDef, for example, contains the same information as an IDL struct declaration, an
InterfaceDef contains the same information as an IDL interface declaration, all the way down to a
PrimitiveDef which contains the same information as an IDL primitive (
boolean,
long, and so forth.) declaration.
|
|
|
|
|
Represents an IDL module declaration that can contain ModuleDefs, InterfaceDefs, ConstantDefs, AliasDefs, ExceptionDefs, and the IR equivalents of other IDL constructs that can be defined in IDL modules.
|
|
Represents an IDL interface declaration and contain OperationDefs, ExceptionDefs, AliasDefs, ConstantDefs, and AttributeDefs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Represents an IDL typedef declaration. Note that the IR TypedefDef interface is a base interface that defines common operations for StructDefs, UnionDefs, and others.
|
|
|
|
|
|
|
|
Represents an IDL primitive declaration: null, void, long, ushort, ulong, float, double, boolean, char, octet, any, TypeCode, Principal, string, objref, longlong, ulonglong, longdouble, wchar, wstring.
|
package org.omg.CORBA;
public interface Repository extends
Container {
...
org.omg.CORBA.Contained
lookup_id(string id);
org.omg.CORBA.PrimitiveDef
get_primitive(org.omg.CORBA.PrimitiveKind kind);
org.omg.CORBA.StringDef
create_string(long bound);
org.omg.CORBA.SequenceDef
create_sequence(long bound,
org.omg.CORBA.IDLType element_type);
org.omg.CORBA.ArrayDef
create_array(long length,
org.omg.CORBA.IDLType element_type);
...
}
This section describes a simple Interface Repository example which contains an AccountManager interface to create an account and (re)open an account. This example code can be found in the following directory:
At the initialization time the AccountManager implementation bootstraps the Interface Repository definition for the managed Account interface. This exposes the additional operation that has been already implemented by this particular
Account implementation to the clients. The clients now can access all known operations (which are described in IDL) and, additionally, they can verify with the Interface Repository support for other operations and invoke them. The example illustrates how we can manage Interface Repository definition objects and how to introspect remote objects using the Interface Repository.