[Previous] [Contents] [Next] [IONA Technologies]


Chapter 20
Interface Repository


Contents

20.1 Runtime Information on IDL Definitions
20.2 Using the Interface Repository
20.2.1 Installing the Interface Repository
20.2.2 Inserting Definitions into the Interface Repository
20.2.3 Retrieving Information from the Interface Repository
20.3 The Interface to the Interface Repository
20.3.1 Interface Contained
20.3.2 Interface Container
20.3.3 Repository
20.3.4 InterfaceDef
20.3.5 Using the Interface Repository
20.4 Standard Interfaces in the Interface Repository



This chapter describes the Interface Repository, the component of OrbixWeb which provides persistent storage of module, interface and type definitions. Given an object reference, the object's type and all information about that type can be determined at runtime by calling operations defined by the Interface Repository. Such facilities are very important for some tools, such as browsers, as well as for components of applications which need to perform dynamic type checking.

20.1 Runtime Information on IDL Definitions

The Interface Repository maintains full information about the IDL definitions that have been processed by the IDL compiler. A program can use the Interface Repository to browse through the set of modules and interfaces known to OrbixWeb, determining the name of each module, the name of each interface and the full definition of that interface. Further, given a name of a module, interface, attribute, operation, parameter, typedef, constant or exception, a program can find its full definition.

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:

20.2 Using the Interface Repository

Runtime information is available on the definitions in an IDL file only if the -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:

If these criteria are fulfilled, then subsequent OrbixWeb clients will be able to query the IDL definitions successfully.

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).

20.2.1 Installing the Interface Repository

The Interface Repository is itself an OrbixWeb server2. The interfaces to its objects are defined in IDL and it must be registered with the Implementation Repository.3 The Interface Repository can then be activated by the OrbixWeb daemon, or manually launched. The Interface Repository's executable file is "IR", and it takes the following switches:

     -L
    
Immediately load the files from the IR data directory. The default is not to do this, but instead to load each file on demand at runtime as it is required.

     -l <file>
    
Log any errors to the given file.

     -s
    
Silent mode: output no error messages.

     -v
    
Print version information about the Interface Repository.

     -h
    
Print summary of 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.

Note that the registration record in the Implementation Repository should be named "IR":

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.

20.2.2 Inserting Definitions into the Interface Repository

Runtime information is available on the definitions in an IDL file only if the -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.

Note that when using the -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.

Note also that if the -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.

The overall nesting is as follows:

Repository

A Repository can contain:

A ModuleDef can contain:

An InterfaceDef can contain:

This 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:

    1. Given an object reference, find its interface name and from this find further information.
    2. Obtain an object reference for the Interface Repository and navigate the Repository from this.
These will now be explained in more detail.

Using _ObjectRef._get_interface()

Given an object reference objRef for interface _ObjectRef, or any derived (IDL generated) Java interface, an InterfaceDef reference can be acquired by calling:

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:

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.

Notice that:

The Interface Repository types are specified here using IDL, each definition defining the operations needed to get full details for its type. These IDL definitions use the following simple definitions:

Identifier is used for the simple names of modules, interfaces, constants, typedefs, exceptions, attributes and operations. For example, in the following definition:

the Identifiers 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:

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.

20.3.1 Interface Contained

Interface 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.

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:

If an object is an interface or module, it can be contained only by the object that defines it. Other objects can be contained by the objects that define them and by the objects that inherit them.

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:

The 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.

20.3.2 Interface Container

Interface 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.

The operation contents() returns the list of Interface Repository objects contained by the object, and can be used to navigate through the hierarchy of definitions–starting 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 operation–it is meaningful only for interfaces.

20.3.3 Repository

We have seen that 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):

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:

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.

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:

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.

20.3.4 InterfaceDef

The interface 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.

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:

20.3.5 Using the Interface Repository

Full details of the all of the Interface Repository types including 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:

Now we assume that the interface has an operation doit() whose name we can find using the operation lookup_name() defined on interface Container.

20.4 Standard Interfaces in the Interface Repository

The Interface Repository provides a directory 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.



1 All Java interfaces generated from IDL interface definitions implicitly inherit from _ObjectRef; which is defined in the IE.Iona.Orbix2.CORBA package.



2 Note that the Interface Repository server is not currently implemented as a Java application and is consequently platform-dependent.



3 Using putit or the Server Manager on Windows as appropriate. The server should be registered with the name "IR".



4 Each IDL file is copied into a file with the same name and extension in the Interface Repository's storage space. In addition, the -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.



5 Because attribute, context and exception are keywords in IDL, Orbix and OrbixWeb have renamed these to their plural form in the Interface Repository interfaces.



[Roadmap] [Introduction] [GS: Applications] [GS: Applets]
[IDL] [Mapping] [Programming OrbixWeb] [Publishing Objects] [Retrieving Objects] [IIOP]
[Running Clients] [Running Servers] [Exceptions] [Inheritance] [Callbacks] [Contexts]
[API Configuration] [TypeCode] [Any] [DII] [IR] [Filters] [Smart Proxies] [Loaders] [Locators]
[Index]