1 package SOFA.SOFAnode.Made.TIR.Access.Browser; 2 import java.rmi.Naming ; 3 import java.rmi.RemoteException ; 4 5 import SOFA.SOFAnode.Made.TIR.ArchitectureDef; 6 import SOFA.SOFAnode.Made.TIR.Contained; 7 import SOFA.SOFAnode.Made.TIR.Container; 8 import SOFA.SOFAnode.Made.TIR.DefinitionKind; 9 import SOFA.SOFAnode.Made.TIR.FrameDef; 10 import SOFA.SOFAnode.Made.TIR.Identification; 11 import SOFA.SOFAnode.Made.TIR.InterfaceDef; 12 import SOFA.SOFAnode.Made.TIR.Repository; 13 import SOFA.SOFAnode.Made.TIR.TIRExceptLock; 14 15 16 public class Main { 17 public static void printKind(DefinitionKind dk) throws RemoteException { 18 switch (dk.value()) { 19 case DefinitionKind.dk_Attribute : System.out.print("Attribute"); break; 20 case DefinitionKind.dk_Constant : System.out.print("Constant"); break; 21 case DefinitionKind.dk_Exception : System.out.print("Exception"); break; 22 case DefinitionKind.dk_Interface : System.out.print("Interface"); break; 23 case DefinitionKind.dk_Module : System.out.print("Module"); break; 24 case DefinitionKind.dk_Operation : System.out.print("Operation"); break; 25 case DefinitionKind.dk_Typedef : System.out.print("Typedef"); break; 26 case DefinitionKind.dk_Struct : System.out.print("Struct"); break; 27 case DefinitionKind.dk_Union : System.out.print("Union"); break; 28 case DefinitionKind.dk_Enum : System.out.print("Enum"); break; 29 case DefinitionKind.dk_Primitive : System.out.print("Primitive"); break; 30 case DefinitionKind.dk_String : System.out.print("String"); break; 31 case DefinitionKind.dk_Sequence : System.out.print("Sequence"); break; 32 case DefinitionKind.dk_Array : System.out.print("Array"); break; 33 case DefinitionKind.dk_Repository : System.out.print("Repository"); break; 34 case DefinitionKind.dk_Frame : System.out.print("Frame"); break; 36 case DefinitionKind.dk_Architecture : System.out.print("Architecture"); break; 37 case DefinitionKind.dk_Provides : System.out.print("Provides"); break; 38 case DefinitionKind.dk_Requires : System.out.print("Requires"); break; 39 case DefinitionKind.dk_Property : System.out.print("Property"); break; 40 case DefinitionKind.dk_Implements : System.out.print("Implements"); break; 42 case DefinitionKind.dk_Inst : System.out.print("Inst"); break; 43 case DefinitionKind.dk_Bind : System.out.print("Bind"); break; 44 case DefinitionKind.dk_Protocol : System.out.print("Protocol"); break; 45 case DefinitionKind.dk_StructMember : System.out.print("StructMember"); break; 46 case DefinitionKind.dk_EnumMember : System.out.print("EnumMember"); break; 47 case DefinitionKind.dk_UnionMember : System.out.print("UnionMember"); break; 48 case DefinitionKind.dk_Expression : System.out.print("Expression"); break; 49 case DefinitionKind.dk_ProtocolOper : System.out.print("ProtocolOper"); break; 50 case DefinitionKind.dk_ValueGen : System.out.print("ValueGen"); break; 51 case DefinitionKind.dk_ValueGenElem : System.out.print("ValueGenOper"); break; 52 case DefinitionKind.dk_BindOper : System.out.print("BindOper"); break; 53 case DefinitionKind.dk_Provider : System.out.print("Provider"); break; 54 case DefinitionKind.dk_AModule : System.out.print("AModule"); break; 55 case DefinitionKind.dk_Wstring : System.out.print("Wstring"); break; 56 case DefinitionKind.dk_Fixed : System.out.print("Fixed"); break; 57 } 58 } 59 60 public static boolean isContainer(DefinitionKind dk) throws RemoteException { 61 int v = dk.value(); 62 if (v == DefinitionKind.dk_Module) return true; 63 if (v == DefinitionKind.dk_AModule) return true; 64 if (v == DefinitionKind.dk_Provider) return true; 65 if (v == DefinitionKind.dk_Interface) return true; 66 if (v == DefinitionKind.dk_Struct) return true; 67 if (v == DefinitionKind.dk_Union) return true; 68 if (v == DefinitionKind.dk_Architecture) return true; 69 if (v == DefinitionKind.dk_Exception) return true; 70 if (v == DefinitionKind.dk_Frame) return true; 71 if (v == DefinitionKind.dk_CDLRepository) return true; 72 return false; 73 } 74 75 public static void intend(int in) { 76 for(int i=0;i<in;i++) 77 System.out.print("| "); 78 } 79 80 public static void scanModule(Container what, int ind) throws RemoteException , TIRExceptLock { 81 Contained con[] = what.contents(null); 82 DefinitionKind dk; 83 Identification id; 84 for (int i=0;i<con.length;i++) { 85 intend(ind); 86 System.out.print("+--"); 87 printKind(dk = con[i].get_def_kind()); 88 id = con[i].get_identification(); 89 System.out.println(" \""+id.name()+"\" "+id.version()); 90 91 if (con[i] instanceof FrameDef) { 92 if (((FrameDef)con[i]).is_system()) { 93 intend(ind); 94 System.out.println("***System frame"); 95 } 96 } 97 98 if (con[i] instanceof ArchitectureDef) { 99 if (((ArchitectureDef)con[i]).is_system()) { 100 intend(ind); 101 System.out.println("***System architecure"); 102 } 103 } 104 105 106 if (con[i] instanceof InterfaceDef) { 107 if (((InterfaceDef)con[i]).protocol() != null) { 108 intend(ind); 109 System.out.println(((InterfaceDef)con[i]).protocol().to_text()); 110 } 111 InterfaceDef base[] = ((InterfaceDef)con[i]).base_interfaces(); 112 intend(ind); 113 System.out.println(base.length); 114 } 115 if (con[i] instanceof FrameDef) { 116 if (((FrameDef)con[i]).protocol() != null) { 117 intend(ind); 118 System.out.println(((FrameDef)con[i]).protocol().to_text()); 119 } 120 } 121 122 123 if (isContainer(dk)) 124 scanModule((Container)con[i], ind+1); 125 } 126 } 127 128 public static void main(String [] argv) { 129 try { 130 System.setSecurityManager(new java.rmi.RMISecurityManager ()); 131 132 String rmiport = System.getProperty("sofa.rmiport","1099"); 133 String rmihost = System.getProperty("sofa.rmihost","localhost"); 134 Repository obj = (Repository) Naming.lookup("//"+rmihost+":"+rmiport+"/Repository"); 135 System.out.println("Listing of repository: (kind \"name\" version)"); 136 scanModule(obj,0); 137 } catch (Exception e) { 138 System.out.println("Exception: " + e.getMessage()); 139 e.printStackTrace(); 140 } 141 } 142 } 143 | Popular Tags |