Oracle8i CORBA Developer's Guide and Reference Release 3 (8.1.7) Part Number A83722-01 |
|
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
.
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:
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:
|
If an IDL interface definition currently exists within the IFR, replace it with this version. If not specified, the |
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
.
publish -republish -user SCOTT -password TIGER -schema SCOTT \
-service sess_iiop://dlsun164:2481:orcl \ /test/myBank bankServer.AccountManagerImpl \ Bank.AccountManagerHelper -idl Bank.idl -replaceIDL
To remove the IDL interface from the IFR, use the -idl
option for the sess_sh remove
command.
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
:
AccountManager manager = (AccountManager)ic.lookup (serviceURL + objectName); Bank.Account account = manager.open(name); org.omg.CORBA.InterfaceDef intf = (org.omg.CORBA.InterfaceDef) account._get_interface_def();
Once retrieved, you can execute any of the InterfaceDef
methods for retrieving information about the interface.
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.
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.
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.
public void print( ) throws org.omg.CORBA.UserException { //retrieve the repository as a container... as the top level container org.omg.CORBA.Container container =
(Container)ic.lookup(serviceURL + "/etc/ifr"); //All objects in the IFR are Contained, except for the Repository. //Retrieve the contents of the Repository, which would be all objects that //it contains. org.omg.CORBA.Contained[] contained = container.contents(org.omg.CORBA.DefinitionKind.dk_all, true); //The length is equal to the number of objects contained within the IFR for(int i = 0; i < contained.length; i++) { { //Each Contained object has a description. org.omg.CORBA.ContainedPackage.Description description =
contained[i].describe(); //Each object is of a certain type, which is retrieved by the value method. switch(contained[i].def_kind().value()) { case org.omg.CORBA.DefinitionKind._dk_Attribute: printAttribute(org.omg.CORBA.AttributeDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Constant: printConstant(org.omg.CORBA.ConstantDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Exception: printException(org.omg.CORBA.ExceptionDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Interface: printInterface(org.omg.CORBA.InterfaceDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Module: printModule(org.omg.CORBA.ModuleDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Operation: printOperation(org.omg.CORBA.OperationDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Alias: printAlias(org.omg.CORBA.AliasDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Struct: printStruct(org.omg.CORBA.StructDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Union: printUnion(org.omg.CORBA.UnionDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_Enum: printEnum(org.omg.CORBA.EnumDefHelper.narrow(contained[i])); break; case org.omg.CORBA.DefinitionKind._dk_none: case org.omg.CORBA.DefinitionKind._dk_all: case org.omg.CORBA.DefinitionKind._dk_Typedef: case org.omg.CORBA.DefinitionKind._dk_Primitive: case org.omg.CORBA.DefinitionKind._dk_String: case org.omg.CORBA.DefinitionKind._dk_Sequence: case org.omg.CORBA.DefinitionKind._dk_Array: default: break; } } }
|
Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|