Public Methods | |
void | addStubListener (StubListener l) |
void | removeStubListener (StubListener l) |
String | addStub (String intfId, String name, Object stub) |
Enumeration | listInterfaces () |
Enumeration | listStubs (String interfaceId) |
Object | getStub (String interfaceId, String name) |
String | getStubName (String interfaceId, Object stub) |
void | removeStub (String interfaceId, String name) |
boolean | existsStub (String intfId, String name, Object stub) |
StubInfo | getStubInfo (String interfaceId, String name) |
Static Public Methods | |
StubRepository | instance () |
StubInfo | getStubInfo (org.omg.CORBA.Object stub) |
|
00020 { 00021 if(_instance == null) _instance = new StubRepository(); 00022 return _instance; 00023 } |
|
00026 { 00027 _listeners.addElement(l); 00028 00029 for(Enumeration iEnum = listInterfaces(); iEnum.hasMoreElements();) { 00030 String intf = (String)iEnum.nextElement(); 00031 for(Enumeration sEnum = listStubs(intf); sEnum.hasMoreElements();) { 00032 String name = (String)sEnum.nextElement(); 00033 l.stubAdded(intf, name, getStub(intf, name)); 00034 } 00035 } 00036 } |
|
00039 { 00040 _listeners.removeElement(l); 00041 } |
|
00048 { 00049 if(stub == null) return null; 00050 00051 if(name.endsWith("*")) { 00052 String prefix = name.substring(0, name.length() - 1); 00053 if(existsStub(intfId, prefix, stub)) 00054 return prefix; 00055 } 00056 00057 Hashtable t = (Hashtable)_table.get(intfId); 00058 if(t == null) { 00059 t = new Hashtable(); 00060 _table.put(intfId, t); 00061 } 00062 00063 if(name.endsWith("*")) 00064 name = getUnusedName(t, name); 00065 if(name.endsWith("+")) 00066 name = getNextName(t, name); 00067 00068 t.put(name, stub); 00069 00070 int len = _listeners.size(); 00071 for (int i = 0; i < len; i++) 00072 ((StubListener)_listeners.elementAt(i)).stubAdded(intfId, name, stub); 00073 00074 return name; 00075 } |
|
00078 { 00079 return _table.keys(); 00080 } |
|
00083 { 00084 Hashtable t = (Hashtable)_table.get(interfaceId); 00085 if(t == null) t = new Hashtable(); 00086 00087 return t.keys(); 00088 } |
|
00091 { 00092 Hashtable t = (Hashtable)_table.get(interfaceId); 00093 if(t == null) return null; 00094 00095 return t.get(name); 00096 } |
|
00099 { 00100 for(Enumeration sEnum = listStubs(interfaceId); sEnum.hasMoreElements();) { 00101 String name = (String)sEnum.nextElement(); 00102 if (existsStub(interfaceId, name, stub)) 00103 return name; 00104 } 00105 return null; 00106 } |
|
00109 { 00110 Hashtable t = (Hashtable)_table.get(interfaceId); 00111 if(t == null) return; 00112 t.remove(name); 00113 00114 int len = _listeners.size(); 00115 for (int i = 0; i < len; i++) 00116 ((StubListener)_listeners.elementAt(i)).stubRemoved(interfaceId, name); 00117 } |
|
00120 { 00121 Object oldStub = getStub(intfId,name); 00122 00123 if((stub == null) || (oldStub == null)) return false; 00124 00125 if(!(stub instanceof org.omg.CORBA.Object)) return false; 00126 00127 return ((org.omg.CORBA.Object)stub)._is_equivalent((org.omg.CORBA.Object)oldStub); 00128 } |
|
00131 { 00132 Object obj = getStub(interfaceId, name); 00133 if(obj instanceof org.omg.CORBA.Object) 00134 return getStubInfo((org.omg.CORBA.Object)obj); 00135 else 00136 return null; 00137 } |
|
00140 { 00141 if(stub == null) return null; 00142 00143 StubInfo info = new StubInfo(); 00144 00145 info.ior = CorbaMediator.instance().object_to_string(stub); 00146 00147 IORStream stream = new IORStream(info.ior); 00148 boolean endian = stream.readBoolean(); 00149 stream.setEndian(endian); 00150 00151 String typeId = stream.readString(); 00152 int nProfiles = stream.readLong(); 00153 00154 info.items = new StubInfoItem[1]; 00155 info.items[0] = new StubInfoItem("Protocol"); 00156 for(int i=0; (i<nProfiles) && !info.items[0].value.equals("IIOP"); i++) { 00157 int id = stream.readLong(); 00158 info.items[0].pos = stream.lastStart(); 00159 info.items[0].length = stream.lastLength(); 00160 int dataLength = stream.readLong(); 00161 IORStream profileStream = stream.subStream(dataLength); 00162 if(id != 0) 00163 info.items[0].value = ""+id; 00164 else { 00165 info.items[0].value = "IIOP"; 00166 StubInfoItem[] iiopItems = new StubInfoItem[4]; 00167 iiopItems[0] = info.items[0]; 00168 iiopItems[1] = new StubInfoItem("Version"); 00169 iiopItems[2] = new StubInfoItem("Host"); 00170 iiopItems[3] = new StubInfoItem("Port"); 00171 00172 endian = profileStream.readBoolean(); 00173 profileStream.setEndian(endian); 00174 00175 byte major = profileStream.readOctet(); 00176 iiopItems[1].pos = profileStream.lastStart(); 00177 byte minor = profileStream.readOctet(); 00178 iiopItems[1].length = 4; 00179 iiopItems[1].value = major+"."+minor; 00180 00181 String host = profileStream.readString(); 00182 iiopItems[2].pos = profileStream.lastStart(); 00183 iiopItems[2].length = profileStream.lastLength(); 00184 iiopItems[2].value = host; 00185 00186 short port = profileStream.readShort(); 00187 iiopItems[3].pos = profileStream.lastStart(); 00188 iiopItems[3].length = profileStream.lastLength(); 00189 iiopItems[3].value = ""+portToInt(port); 00190 00191 info.items = iiopItems; 00192 } 00193 } 00194 00195 return info; 00196 } |