1 7 8 package com.sun.corba.se.impl.encoding; 9 10 import java.util.Hashtable ; 11 import com.sun.org.omg.CORBA.ValueDefPackage.FullValueDescription; 12 import com.sun.org.omg.SendingContext.CodeBase; 13 import com.sun.org.omg.SendingContext.CodeBaseHelper; 14 import com.sun.org.omg.SendingContext._CodeBaseImplBase; 15 import com.sun.org.omg.SendingContext._CodeBaseStub; 16 import com.sun.corba.se.spi.transport.CorbaConnection; 17 18 36 public class CachedCodeBase extends _CodeBaseImplBase 38 { 39 private Hashtable implementations, fvds, bases; 40 private CodeBase delegate; 41 private CorbaConnection conn; 42 43 private static Hashtable iorToCodeBaseObjMap = new Hashtable (); 44 45 public CachedCodeBase(CorbaConnection connection) { 46 conn = connection; 47 } 48 49 public com.sun.org.omg.CORBA.Repository get_ir () { 50 return null; 51 } 52 53 public String implementation (String repId) { 54 String urlResult = null; 55 56 if (implementations == null) 57 implementations = new Hashtable (); 58 else 59 urlResult = (String )implementations.get(repId); 60 61 if (urlResult == null && connectedCodeBase()) { 62 urlResult = delegate.implementation(repId); 63 64 if (urlResult != null) 65 implementations.put(repId, urlResult); 66 } 67 68 return urlResult; 69 } 70 71 public String [] implementations (String [] repIds) { 72 String [] urlResults = new String [repIds.length]; 73 74 for (int i = 0; i < urlResults.length; i++) 75 urlResults[i] = implementation(repIds[i]); 76 77 return urlResults; 78 } 79 80 public FullValueDescription meta (String repId) { 81 FullValueDescription result = null; 82 83 if (fvds == null) 84 fvds = new Hashtable (); 85 else 86 result = (FullValueDescription)fvds.get(repId); 87 88 if (result == null && connectedCodeBase()) { 89 result = delegate.meta(repId); 90 91 if (result != null) 92 fvds.put(repId, result); 93 } 94 95 return result; 96 } 97 98 public FullValueDescription[] metas (String [] repIds) { 99 FullValueDescription[] results 100 = new FullValueDescription[repIds.length]; 101 102 for (int i = 0; i < results.length; i++) 103 results[i] = meta(repIds[i]); 104 105 return results; 106 } 107 108 public String [] bases (String repId) { 109 110 String [] results = null; 111 112 if (bases == null) 113 bases = new Hashtable (); 114 else 115 results = (String [])bases.get(repId); 116 117 if (results == null && connectedCodeBase()) { 118 results = delegate.bases(repId); 119 120 if (results != null) 121 bases.put(repId, results); 122 } 123 124 return results; 125 } 126 127 private boolean connectedCodeBase() { 131 if (delegate != null) 132 return true; 133 134 if (conn.getCodeBaseIOR() == null) { 142 if (conn.getBroker().transportDebugFlag) 145 conn.dprint("CodeBase unavailable on connection: " + conn); 146 147 return false; 148 } 149 150 synchronized(this) { 151 152 if (delegate != null) 155 return true; 156 157 delegate = (CodeBase)CachedCodeBase.iorToCodeBaseObjMap.get(conn.getCodeBaseIOR()); 159 if (delegate != null) 160 return true; 161 162 delegate = CodeBaseHelper.narrow(getObjectFromIOR()); 164 165 CachedCodeBase.iorToCodeBaseObjMap.put(conn.getCodeBaseIOR(), 167 delegate); 168 } 169 170 return true; 172 } 173 174 private final org.omg.CORBA.Object getObjectFromIOR() { 175 return CDRInputStream_1_0.internalIORToObject( 176 conn.getCodeBaseIOR(), null , conn.getBroker()); 177 } 178 } 179 180 182 | Popular Tags |