Retrieving Interfaces With The IFR

The Interface Repository (IFR) specified by OMG defines how to store and retrieve interface definitions. The information contained within the interface can be used internally by the ORB to retrieve information about an object reference, for type-checking the request signatures, or used externally by DII/DSI applications for instantiating objects dynamically through DII/DSI.

You store the IDL interface definition within the IFR through the Oracle8i JServer publish command. The publish command stores the interface within a flat file, AuroraIFR.idl.

Note:

Normally, this file is automatically written to $ORACLE_HOME/javavm/admin. However, if this directory is not write-enabled, you can specify another fully-qualified filename within the "aurora.ifr.file" system property through the modifyprops tool, as follows:

Once stored, you can retrieve the interface definition either implicitly through the _get_interface_def method or explicitly looking up the IFR Repository object and invoking the standard methods to traverse through the repository.

The following sections detail how to publish and retrieve IDL interface information:

Publishing the IDL Interface

You store the IDL interface definition within the IFR through the Oracle8i JServer publish command. This command contains the following two options for storing the IDL interface definition within the IFR:

-replaceIDL

If an IDL interface definition currently exists within the IFR, replace it with this version. If not specified, the publish command will not replace the existing interface within the IFR.

Note:

The -replaceIDL flag will replace any interface with the same name in the IFR, even if it was originally stored by another user. Thus, different users can overwrite another user's interface unknowingly.

The following publish command loads the Bank.idl interfaces into the IFR. This is executed under the SCOTT schema security permissions. If it already exists, the -replaceIDL option specifies that the interfaces should be replaced with this version of Bank.idl.

To remove the IDL interface from the IFR, use the -idl option for the sess_sh remove command.

Retrieving Interfaces Implicitly

You can retrieve the interface definition implicitly through the org.omg.CORBA.Object._get_interface_def method. The object returned should be cast to InterfaceDef. The following code retrieves the InterfaceDef object for the Bank.Account:

Once retrieved, you can execute any of the InterfaceDef methods for retrieving information about the interface.

Retrieving Interfaces Explicitly

All defined interfaces stored in the IFR are stored in a hierarchy. The top level of the hierarchy is a Repository object, which is also a Container object. All objects under the Repository object are Contained objects. You can parse down through the Container objects, reviewing the Contained objects, until you find the particular interface definition you want.

Note:

The user can only see the objects to which the user has read privileges.

The Repository object is pre-published under the name "/etc/ifr". You can retrieve the Repository object by executing the following:

You retrieve a prepublished IFR Repository object by looking up the "/etc/ifr" object as shown below:

Repository rep = (Repository)ic.lookup(serviceURL + "/etc/ifr");

Once the Repository object is retrieved, you can traverse through the hierarchy until you reach the object you are interested in. The methods for each object type, InterfaceDef and others, are documented fully in the OMG CORBA specification.

As shown in Figure 5-1, the Account interface is contained within AccountManager, which is container within the Repository object.

Figure 5-1 IFR Hierarchy for Account Interface

Example 5-1 Traversing IFR Repository Within the print Method

Once you retrieve the IFR object, you can traverse through all stored definitions within the IFR. The print method in Example 5-1 prints out all stored definitions located within the IFR.