home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / TRIAL / JBUILDER / JVISBRKR.Z / PrintIDL.java < prev    next >
Encoding:
Java Source  |  1998-05-08  |  2.9 KB  |  78 lines

  1. /*
  2.  * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
  3.  * 
  4.  * This SOURCE CODE FILE, which has been provided by Borland as part
  5.  * of a Borland product for use ONLY by licensed users of the product,
  6.  * includes CONFIDENTIAL and PROPRIETARY information of Borland.  
  7.  *
  8.  * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS 
  9.  * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
  10.  * THE PRODUCT.
  11.  *
  12.  * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
  13.  * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
  14.  * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
  15.  * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
  16.  * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
  17.  * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
  18.  * CODE FILE.
  19.  */
  20. package visibroker.samples.ir;
  21.  
  22. /** 
  23. This is a simple client program that does the following:
  24.  
  25. 0. Before this program can be tested, the following conditions should
  26.    exist.
  27.    a) The OSAgent should be up and running
  28.    b) An interface Repository should be started using
  29.       irep "irep-name" 
  30.    c) The Interface Repository should be loaded with an IDL file 
  31.       either by using the graphical interface that comes up, or,
  32.       by using
  33.       idl2ir -ir "irep-name" IDLfile_name  
  34.  
  35. 1. It binds to the interface Repository started by the user and known to 
  36.    the OSAgent. 
  37. 2. The client then takes as a command line argument, the IDL name for 
  38.    an interface, such as module::interface
  39. 3. The method lookup(idlname) is invoked on the Repository which is then
  40.    narrowed down to an interface description. Following this, 
  41.    describe_interface() is called on this interface description. 
  42. 4. The methods and attributes are retrieved from the interface description
  43.    and printed to the user.
  44.  
  45. */
  46.  
  47.  
  48. public class PrintIDL {
  49.  
  50.   public static void main(String[] args) {
  51.     
  52.     if ( args.length == 0 ) {
  53.       System.out.println("Usage: vbj PrintIDL idlName");
  54.       System.exit(1);
  55.     }
  56.     String idlName = args[0]; 
  57.  
  58.     org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
  59.     org.omg.CORBA.Repository rep = org.omg.CORBA.RepositoryHelper.bind(orb);
  60.     org.omg.CORBA.InterfaceDef idef = 
  61.       org.omg.CORBA.InterfaceDefHelper.narrow(rep.lookup(idlName));
  62.     if (idef == null) 
  63.       throw new org.omg.CORBA.INTF_REPOS("The idlName is not an interface: " 
  64. + idlName);
  65.     org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription intDesc = 
  66.       idef.describe_interface();
  67.  
  68.     System.out.println("Operations:");
  69.     for(int i = 0; i < intDesc.operations.length; i++) 
  70.       System.out.println("  " + intDesc.operations[i].name);
  71.  
  72.     System.out.println("Attributes:");
  73.     for(int i = 0; i < intDesc.attributes.length; i++) 
  74.       System.out.println("  " + intDesc.attributes[i].name);
  75.   }
  76.  
  77. }
  78.