1 26 27 package org.objectweb.openccm.explorer.CosNaming; 28 29 import java.util.Iterator ; 30 import java.util.List ; 31 import java.util.Vector ; 32 33 import org.objectweb.openccm.explorer.CORBA.ConsoleFactory; 34 import org.objectweb.openccm.explorer.util.ior.IorPrinter; 35 import org.objectweb.util.explorer.api.Table; 36 import org.objectweb.util.explorer.api.TreeView; 37 import org.objectweb.util.explorer.core.naming.lib.DefaultEntry; 38 import org.omg.CosNaming.NamingContextExt ; 39 40 47 public class CosNamingPanel 48 implements Table { 49 50 56 62 68 74 77 public String [] getHeaders(TreeView treeView) { 78 return new String []{"ID","Kind","Value"}; 79 } 80 81 84 public Object [][] getRows(TreeView treeView) { 85 NamingContextExt naming = (NamingContextExt )treeView.getSelectedObject(); 86 org.omg.CORBA.ORB orb = org.objectweb.openccm.corba.TheORB.getORB(); 87 IorPrinter iorPrinter = null; 88 List l = new Vector (); 89 try{ 90 org.omg.CosNaming.BindingListHolder bindingList = new org.omg.CosNaming.BindingListHolder (); 91 org.omg.CosNaming.BindingIteratorHolder bindingIterator = new org.omg.CosNaming.BindingIteratorHolder (); 92 93 naming.list(100, bindingList, bindingIterator); 94 while(true){ 95 for(int i = 0; i< bindingList.value.length ; i++){ 96 try{ 97 org.omg.CosNaming.NameComponent [] nameComponent = bindingList.value[i].binding_name; 98 org.omg.CORBA.Object object = naming.resolve(nameComponent); 99 iorPrinter = new IorPrinter(orb.object_to_string(object)); 100 101 String id="",kind=""; 102 id = nameComponent[nameComponent.length-1].id; 103 kind = nameComponent[nameComponent.length-1].kind; 104 105 l.add(new Object []{id,kind,new DefaultEntry(iorPrinter.getTypeId(), object)}); 106 } catch (org.omg.CosNaming.NamingContextPackage.NotFound e) { 107 System.out.println(getClass().getName() + " : Object Not Found Exception !"); 108 } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed e) { 109 System.out.println(getClass().getName() + " : CannotProceed Exception"); 110 } catch (org.omg.CosNaming.NamingContextPackage.InvalidName e) { 111 System.out.println(getClass().getName() + " : InvalidName Exception"); 112 } 113 } 114 if(!bindingIterator.value.next_n(100, bindingList)) break; 115 } 116 } catch(Exception e) { 117 ConsoleFactory.getDebugConsole().add(e.getMessage()+ "\n"); 118 } 119 120 Object [][] contenu = new Object [l.size()][2]; 121 Iterator it = l.iterator(); 122 int cpt = 0; 123 while(it.hasNext()){ 124 contenu[cpt] = (Object [])it.next(); 125 cpt++; 126 } 127 128 return contenu; 129 } 130 } 131 | Popular Tags |