KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ve > luz > ica > jackass > ref > IORRipper


1 /*
2  * Copyright (c) 2003 by The Jackass Team
3  * Licensed under the Open Software License version 2.0
4  */

5 package ve.luz.ica.jackass.ref;
6
7 import java.io.BufferedReader JavaDoc;
8 import java.io.FileNotFoundException JavaDoc;
9 import java.io.FileReader JavaDoc;
10 import java.io.IOException JavaDoc;
11
12 import org.omg.CORBA.ORB JavaDoc;
13 import org.omg.IIOP.ProfileBody_1_1;
14 import org.omg.IOP.IOR JavaDoc;
15 import org.omg.IOP.TAG_INTERNET_IOP JavaDoc;
16 import org.omg.IOP.TaggedComponent JavaDoc;
17 import org.omg.IOP.TaggedProfile JavaDoc;
18
19
20 /**
21  * Prints information about a CORBA reference
22  * @author guidox, davidf
23  */

24 public final class IORRipper
25 {
26     /**
27      * Main
28      * @param args arguments.
29      */

30     public static void main(String JavaDoc[] args)
31     {
32         FileReader JavaDoc fr = null;
33         String JavaDoc serverRef = null;
34
35         if (args.length < 1)
36         {
37             System.err.println("Usage: java " + IORRipper.class.getName() + " filename");
38             System.err.println("where filename is the name of a file with an IOR");
39             System.exit(1);
40         }
41         //Obtención de la referencia del archivo.
42
try
43         {
44             fr = new FileReader JavaDoc(args[0]);
45             serverRef = (new BufferedReader JavaDoc(fr)).readLine();
46         }
47         catch (FileNotFoundException JavaDoc ex_FF)
48         {
49             ex_FF.printStackTrace();
50         }
51         catch (IOException JavaDoc ex_IO)
52         {
53             ex_IO.printStackTrace();
54         }
55
56         //Inicialización del Orb.
57
try
58         {
59             ORB JavaDoc orb = ORB.init(args, null);
60             RefUtil refUtil = new RefUtil(orb);
61             //CodecFactory codecFactory = CodecFactoryHelper.narrow(orb.resolve_initial_references("CodecFactory"));
62
//Codec codec = codecFactory.create_codec(RefUtil.DEF_ENCODING);
63

64
65             // Obtener la referencia del objeto servidor.
66
org.omg.CORBA.Object JavaDoc obj = orb.string_to_object(serverRef);
67             // Narrow del Servidor a un objeto de tipo GoodDay
68

69             IORData iorData = refUtil.rip(obj);
70             IOR JavaDoc ior = iorData.ior;
71             System.out.println("IOR = " + ior);
72             System.out.println("Type ID:" + ior.type_id);
73             System.out.println("Profiles: ");
74             for (int i = 0; i < ior.profiles.length; i++)
75             {
76                 TaggedProfile JavaDoc profile = ior.profiles[i];
77                 System.out.println("Profile " + i + ": " + profile);
78                 System.out.println("\tTag: " + profile.tag);
79                 System.out.println("\tData:" + profile.profile_data);
80
81                 if (profile.tag == TAG_INTERNET_IOP.value && iorData.isIIOP_1_1())
82                 {
83                     ProfileBody_1_1 profBody = iorData.profileBody;
84                     System.out.println("\tProfileBody: " + profBody);
85                     TaggedComponent JavaDoc[] components = profBody.components;
86                     System.out.println("\t\tProfileBody Components: " + components);
87                     for (int j = 0; j < components.length; j++)
88                     {
89                         TaggedComponent JavaDoc component = components[j];
90                         System.out.println("\t\t\tComponent[" + j + "]=" + component.tag +
91                                 ", " + component.component_data + ", " + new String JavaDoc(component.component_data));
92                     }
93                 }
94
95             }
96         }
97         catch (Exception JavaDoc ex)
98         {
99             ex.printStackTrace();
100         }
101     }
102 }
103
Popular Tags