For example, given an object reference of type
_ObjectRef
or any derived interface,1 an OrbixWeb program can determine the interface type of the object to which it points, and it can then use the Interface Repository to determine all of the information about that interface. In particular, it can determine:
-R
switch is specified to the IDL compiler when the definitions are compiled.When the
-R
switch is used, the IDL file is copied to a file with the same name in the Interface Repository's storage system (as specified by IT_INT_REP_PATH
in Orbix.cfg
). If the -d<dir>
switch is specified to the IDL compiler, then the file is copied relative to the dir
sub-directory of IT_INT_REP_PATH
.Clients may retrieve the IDL information at runtime only if an Interface Repository server has been correctly registered on the host at which the definitions are stored, and this server will access the same
IT_INT_REP_PATH
directory as used in the compilation stage.The overall requirements for storing IDL definitions in the Interface Repository by using the OrbixWeb IDL compiler are:
IT_INT_REP_PATH
in the OrbixWeb configuration file, or the IT_INT_REP_PATH
environment variable must be set; and the corresponding directory must exist.
IT_INT_REP_PATH
value accessed by the Interface Repository server must match the value used in the IDL compilation.
-R
switch must be specified to the IDL compiler (for any IDL definitions that need to be dynamically visible.
Note that IDL definitions stored in the Interface Repository, but compiled with the Orbix IDL compiler will also be available to OrbixWeb clients (if the Interface Repository requirements, as described in the Orbix Programming Guide, have been satisfied).
IR", and it takes the following switches:
The Interface Repository's executable file can be explicitly run as a background process. This has the advantage that the Interface Repository can initialise itself before any other processes need to use it, especially if the
-L
switch is specified.IR
":
putit IR <absolute path name and switches>Remember, however, that if the
-L
switch is specified then there may be significant latency while the files are being loaded.The Interface Repository process can be terminated using the
killit
utility.
-R
switch is specified to the IDL compiler when the definitions are compiled. The Interface Repository copies the IDL file to its own storage space (specified by IT_INT_REP_PATH
). (If the -d<dir>
switch is specified to the IDL compiler, then the file is copied relative to the dir
subdirectory of IT_INT_REP_PATH
).4
If the IDL file includes other IDL files (using the
#include
directive) then, by default, these included files are not copied into the Interface Repository's storage space. This default behaviour can be overridden by specifying the -N
switch to the IDL compiler. The -N
switch
specifies that the IDL compiler is to compile and produce code for included files. In conjunction with the -R
switch, -N
copies the included files into the Interface Repository's storage space.-N
switch, the compilation must be invoked from the same directory as the root IDL file (that is, the file containing the #include
directive(s)), in order to retain compatibility with the Interface Repository server.-d<dir>
switch is also specified to the IDL compiler, care should be taken to ensure that included IDL files (specified relative to the root file's directory) fit into the Interface Repository directory and do not overwrite existing IDL (and shadow) files. The subdirectory specified to the -d
switch should be sufficiently deep within the Interface Repository to ensure this. 20.2.3 Retrieving Information from the Interface Repository
The Interface Repository is best viewed as a set of objects, one object per definition stored in the Interface Repository. These objects can be interrogated to determine their definitions, and they are nested in a natural manner according to the IDL interface. For example, each Interface Repository object representing an interface is said to contain objects representing the interface's constant, type, exceptions, attribute and operation definitions. The outermost object is know as a Repository. Repository
Repository
can contain:
ConstantDef
TypeDef
ExceptionDef
InterfaceDef
ModuleDef
A ModuleDef
can contain:
ConstantDef TypeDef ExceptionDef ModuleDef InterfaceDef
An InterfaceDef
can contain:
ConstantDef TypeDef ExceptionDef AttributeDef OperationDefThis constant, type, exception, interface and module definitions can appear outside of any module. These are said to be defined directly within a repository. A module can contain constant, type, exception, interface and module definitions. An interface can contain constant, type and exception definitions.
Repository
, ModuleDef
, InterfaceDef
, ConstantDef
, TypeDef
, ExceptionDef
, AttributeDef
, and OperationDef
are types defined by the Interface Repository. Given an object of any of these types, full information on that definition can be determined. For example, an InterfaceDef
, can be acquired by navigating through a Repository
using the interface's name, or simply by browsing through a Repository
.There are two ways to retrieve information from the Interface Repository:
objRef
for interface _ObjectRef
, or any derived (IDL generated) Java interface, an InterfaceDef
reference can be acquired by calling:
// Java IE.Iona.Orbix2._InterfaceDefRef ifRef = objRef._get_interface();The method
_get_interface()
returns an interface object reference within the Interface Repository. Information can then be retrieved about that interface; and object references can be obtained for the Interface Repository objects containing, or contained in, that interface object as explained in section 20.3.
Note that for
_get_interface()
to work correctly, the -R
switch must be specified to the IDL compiler when an interface is being compiled. Otherwise _get_interface()
will raise an exception. Binding to a Repository
Bind to a Repository as follows:
// Java IE.Iona.Orbix2.RepositoryRef repRef = Repository._bind(":IR","");and use the methods defined on the Interface Repository's interface to browse the repository (see section 20.3).
20.3 The Interface to the Interface Repository
This section outlines the set of IDL interfaces provided in the Interface Repository to describe IDL types and to navigate the Interface Repository so that full details of a particular type can be found. The (abstract) interfaces Container
and Contained
define a common set of operations that are inherited by the derived interfaces which are used to describe IDL types and the Repository itself.
Repository
can be a container for other items.
AttributeDef
, OperationDef
, ParameterDef
, TypeDef
, ConstantDef
and ExceptionDef
can be contained in other items.
ModuleDef
and InterfaceDef
can be a container for other items, and can themselves be contained in other items.
// IDL typedef string Identifier; typedef string RepositoryId; typedef Identifier InterfaceName;
Identifier
is used for the simple names of modules, interfaces, constants, typedefs, exceptions, attributes and operations. For example, in the following definition:
// IDL interface Example { long op(); };the
Identifier
s are "Example
" and "op
". A name is not necessarily unique within an Interface Repository. Names need be unique only within a scope.A
RepositoryId
is an identifier used to uniquely identify a module, interface, constant, typedef, exception, attribute or operation. An
InterfaceName
is a string containing one of the following:
"AttributeDef" "ConstantDef" "ExceptionDef" "InterfaceDef" "ModuleDef" "ParameterDef" "OperationDef" "TypeDef" "all"It is used as a parameter to the repository search operations, so that a program can selectively search a repository for a given type of definition. The string "
all
" is used where selectivity is not required.
Contained
is an conceptually abstract interface from which all Interface Repository interfaces that describe types that can be contained in other types inherit. The types that inherit from Contained
are: AttributeDef
, OperationDef
, ParameterDef
, TypeDef
, ConstantDef
, ModuleDef
, InterfaceDef
and ExceptionDef
. Note that interface ModuleDef
inherits from Contained
because it can be contained in a Repository.
// IDL interface Contained { attribute Identifier name; attribute RepositoryId id; attribute RepositoryId defined_in; sequence <Container> within(); struct Description { Identifier name; // Type of value. any value; }; Description describe(); };Interface
Contained
defines the attributes name
and id
which are common to all of these types. Each Interface Repository object is identified by a name
(which is unique within its scope) and an id
(which is unique within a repository).The
defined_in
attribute of a Contained
object gives the unique identifier of the Interface Repository object in which the object was defined. The defined_in
attribute is nil for a definition given at the file level of an IDL file.The operation
within()
returns the list of objects that contain the object. An Interface Repository object is contained in another if:
The operation
describe()
returns a Contained::Description
structure, which contains a name
and a value
. The type of the latter is different for each Interface Repository object type: it can be one of the following types:
ModuleDescription InterfaceDescription AttributeDescription OperationDescription ParameterDescription TypeDescription ConstantDescription ExceptionDescriptionThe
name
of a Description
is a string corresponding to each of these. For example, if describe()
is called on an operation, then Description::name
will be "OperationDescription" and Description::value
will be an any
which contains an OperationDescription
.
Container
is a conceptually abstract interface which defines attributes and operations common to all Interface Repository types that can contain objects. These interfaces are: Repository
, ModuleDef
and InterfaceDef
.
// IDL interface Container { sequence<Contained> contents ( in InterfaceName restrict_type, in boolean exclude_inherited ); sequence<Contained> lookup_name ( in Identifier search_name, in long levels_to_search, in InterfaceName restrict_type, in boolean exclude_inherited ); struct Description { Contained contained_object; Identifier name; any value; }; sequence<Description> describe_contents ( in InterfaceName restrict_type, in boolean exclude_inherited, in long max_returned_objs ); };The operation
contents()
returns the list of Interface Repository objects contained by the object, and can be used to navigate through the hierarchy of definitionsstarting for example at a Repository
. The operation
lookup_name()
is used to return all of the objects within a given Interface Repository object which have the name specified by search_name
. The operation
describe_contents()
is a combination of the operation contents()
and the operation describe()
from interface Contained
. It returns a sequence of structures each of which gives the object reference of a contained object, and its name
and value
(the last two are the same as in Contained::Description
). Each of the Interface Repository types inherits from Contained
or Container
, or both. Each will be described now in detail.Each of the search operations
contents()
, lookup_name()
and describe_contents()
takes a parameter restrict_type
. If this parameter is set to a particular InterfaceName
, for example OperationDef
, then only contained operations are returned by the search operation. If set to "all
", then all contained objects are returned. The parameter exclude_inherited
indicates whether inherited objects should be returned by a search operationit is meaningful only for interfaces.
Contained
and Container
provide an abstraction of the functionality of all Interface Repository types. The Interface Repository itself is a container for IDL type definitions. Its interface is described by the IDL Interface Repository which inherits from Container
(note, therefore, that it does not have a name
or id
attribute):
// IDL interface Repository : Container { Contained lookup_id (in RepositoryId search_id); // The following operations request the IR to // load files immediately, rather than // waiting for them to be used: exception invalidLoad {}; void loadIDLAll(); // Similar to the -L switch. void loadIDLFile(in string fileName) raises (invalidLoad); };An Interface Repository server,
IR
, contains one Repository
object. From this Repository
object, the descriptions of all IDL type definitions contained in the server, IR
, can be found. The server, IR
, maintains these descriptions persistently in the Interface Repository storage system (as specified by IT_INT_REP_PATH
).A reference to a
Repository
object can be obtained by binding to it as follows:
// Java IE.Iona.Orbix2.RepositoryRef repRef = Repository._bind(":IR","");The operation
lookup_id()
returns a Contained
object given its RepositoryId
.On a
Repository
object, the inherited describe_contents()
operation returns a sequence of Container::Description
structures; one such structure for each top level item in the repository.
// IDL struct Description { Contained contained_object; Identifier name; any value; };Each structure has a member
contained_object
on which the describe()
operation can be called to get further information on a top level object in the Repository. The name member contains the string "RepositoryDescription". The value is an any whose TypeCode
is _tc_RepositoryDescription
and whose value is a structure of type:
// IDL struct RepositoryDescription { Identifier name; RepositoryId id; RepositoryId defined_in; };Note that the
describe_contents()
operation behaves differently on a Repository
object than it does on other objects (it is also valid on objects of type Module
and Interface
).Regarding the operations
loadIDLAll()
and loadIDLFile()
, note that the Interface Repository will load a file only once; attempts to re-load a file will be ignored.
InterfaceDef
describes an IDL interface. An interface is a container since it contains other IDL definitions, for example, operations, and exceptions. It is also contained in a Repository (and possibly in an IDL module). Therefore, InterfaceDef
inherits from both Container
and Contained
.
// IDL interface InterfaceDef: Container, Contained { attribute sequence<RepositoryId> base_interfaces; struct FullInterfaceDescription { Identifier name; RepositoryId id; RepositoryId defined_in; sequence<OperationDescription> operation; sequence<AttributeDescription> attributes;5 }; FullInterfaceDescription describe_interface(); };The attribute
base_interfaces
represents the set of interfaces from which this interface inherits.The operation
describe_interface()
provides detailed information about an interface, including information about its operations and attributes. Alternatively, the inherited operation Container::describe_contents()
can be used to iterate through the items declared directly in the interface. The operation describe_interface()
is the most straightforward way to obtain a description of an interface's operations and attributes. These can be obtained by calling the function Container::describe_contents()
(or a combination of Container::contents()
and Contained::describe()
).The interface reference, of type
InterfaceDef
, of an object can be obtained by calling the function _get_interface()
on a pointer to the object. Subsequently, the functions InterfaceDef::describe_interface()
and/or Container::describe_contents()
can be used to get detailed information about the interface.The inherited operation
Container::contents()
returns a list of the constants, typedefs, exceptions, operations and attributes defined in the interface; these will include those inherited if exclude_inherited
is false. Container::describe_contents()
is a combination of the functions Container::contents()
and Contained::describe()
.The inherited operation
Contained::describe()
returns a structure of type Contained::Description
. The value
member, of type any
, will have a TypeCode
_tc_InterfaceDescription
and a value which is a structure of type InterfaceDescription
:
// IDL struct InterfaceDescription { Identifier name; RepositoryId id; RepositoryId defined_in; };
ModuleDef
, AttributeDef
, ParameterDef
, TypeDef
, ConstantDef
and ExceptionDef
are given in the OrbixWeb Reference Guide. In this section, we show some example code that uses the types that have been described in this chapter.
The following code prints the list of operation names and attribute names defined on the interface of a given object:
// Java // List the names of the operations valid on // the object referenced by objRef. IE.Iona.Orbix2._InterfaceDefRef interfaceRef; try { // Get interface definition: interfaceRef = objRef._get_interface(); } catch ... // Handle any exceptions. IE.Iona.Orbix2.InterfaceDef. FullInterfaceDescription full; try { full = interfaceRef.describe_interface(); } catch ... // Handle any exceptions. // Now print out the operation names: System.out.println ("The operation names are:"); long i; for (i=0; i < full.operation.length; i++) { System.out.println ("\t" + full.operation.buffer[i].name); // Now print out the attribute names: System.out.println ("The attribute names are:"); for (i=0; i < full.attributes.length; i++) { System.out.println ("\t" + full.attributes.buffer[i].name);Now we assume that the interface has an operation
doit()
whose name we can find using the operation lookup_name()
defined on interface Container
.
// Look up the operation doit() on the // interface: try { IE.Iona.Orbix2.ContainedSeq operations; System.out.println ( "Looking up operation doit()"); operations = interfaceRef.lookup_name( "doit", 1, "OperationDef", 0); if (operations.length != 1) System.out.println ( "Incorrect result lookup_name()"); } else { // Narrow the result to be an OperationDef: IE.Iona.Orbix2._OperationDefRef doitOpRef; doitOpRef = OperationDef. _narrow(operations.buffer[0]); } ... } catch ... // Handle any exceptions.
Interfaces
which contains interfaces shipped with OrbixWeb. Currently, only the interfaces pertaining to the Interface Repository itself are stored in the Interface Repository in the repository subdirectory IR
. Later versions of OrbixWeb may store a more complete set of interfaces.
_ObjectRef
; which is defined in the IE.Iona.Orbix2.CORBA
package.
putit
or the Server Manager on Windows as appropriate. The server should be registered with the name "IR
".
-R
switch will result in one or more "shadow" files, with the same base name but with different extensions:
extension
.sa
This is used if the
-N
switch is not specified. A file with the same base name but with extension .sa
will be created in the Interface Repository's storage space to indicate that the -N
switch was not specified.
extensions
.rt
and .inc
These are used if the
-N
switch is specified. For the root file being compiled, a file with the same base name but with extension .rt
will be created in the Interface Repository's storage space to indicate that the -N
switch was specified (this is in addition to copying the .idl
file). In addition, each included file will be copied into the Interface Repository's storage space (using the normal .idl
extension) and a .inc
file will be created for each to indicate that its .idl
file was copied because of inclusion in another file.
attribute
, context
and exception
are keywords in IDL, Orbix and OrbixWeb have renamed these to their plural form in the Interface Repository interfaces.