1 7 15 16 package com.sun.corba.se.impl.io; 17 18 import org.omg.CORBA.ORB ; 19 import java.util.Properties ; 20 import javax.rmi.CORBA.Util ; 21 import javax.rmi.CORBA.ValueHandler ; 22 import java.util.Hashtable ; 23 import java.util.Stack ; 24 25 import com.sun.org.omg.CORBA.ValueDefPackage.FullValueDescription; 26 import com.sun.org.omg.SendingContext._CodeBaseImplBase; 27 import com.sun.org.omg.SendingContext.CodeBase; 28 import com.sun.org.omg.SendingContext.CodeBaseHelper; 29 import org.omg.CORBA.CompletionStatus ; 30 import org.omg.CORBA.ORB ; 31 32 import com.sun.corba.se.impl.logging.OMGSystemException; 33 import com.sun.corba.se.spi.logging.CORBALogDomains; 34 35 39 public class FVDCodeBaseImpl extends _CodeBaseImplBase 40 { 41 private static Hashtable fvds = new Hashtable (); 43 44 private transient ORB orb = null; 47 48 private transient OMGSystemException wrapper = OMGSystemException.get( 49 CORBALogDomains.RPC_ENCODING ) ; 50 51 private transient ValueHandlerImpl vhandler = null; 56 57 void setValueHandler(ValueHandler vh) 58 { 59 vhandler = (com.sun.corba.se.impl.io.ValueHandlerImpl) vh; 60 } 61 62 public com.sun.org.omg.CORBA.Repository get_ir (){ 64 return null; 65 } 66 67 public String implementation (String x){ 69 try{ 70 if (vhandler == null) { 73 vhandler = new ValueHandlerImpl(false); 74 } 75 76 String result = Util.getCodebase(vhandler.getClassFromType(x)); 79 if (result == null) 80 return ""; 81 else 82 return result; 83 } catch(ClassNotFoundException cnfe){ 84 throw wrapper.missingLocalValueImpl( CompletionStatus.COMPLETED_MAYBE, 85 cnfe ) ; 86 } 87 } 88 89 public String [] implementations (String [] x){ 90 String result[] = new String [x.length]; 91 92 for (int i = 0; i < x.length; i++) 93 result[i] = implementation(x[i]); 94 95 return result; 96 } 97 98 public FullValueDescription meta (String x){ 100 try{ 101 FullValueDescription result = (FullValueDescription)fvds.get(x); 102 103 if (result == null) { 104 if (vhandler == null) { 107 vhandler = new ValueHandlerImpl(false); 108 } 109 110 try{ 111 result = ValueUtility.translate(_orb(), 112 ObjectStreamClass.lookup(vhandler.getAnyClassFromType(x)), vhandler); 113 } catch(Throwable t){ 114 if (orb == null) 115 orb = ORB.init(); result = ValueUtility.translate(orb, 117 ObjectStreamClass.lookup(vhandler.getAnyClassFromType(x)), vhandler); 118 } 119 120 if (result != null){ 121 fvds.put(x, result); 122 } else { 123 throw wrapper.missingLocalValueImpl( CompletionStatus.COMPLETED_MAYBE); 124 } 125 } 126 127 return result; 128 } catch(Throwable t){ 129 throw wrapper.incompatibleValueImpl(CompletionStatus.COMPLETED_MAYBE,t); 130 } 131 } 132 133 public FullValueDescription[] metas (String [] x){ 134 FullValueDescription descriptions[] = new FullValueDescription[x.length]; 135 136 for (int i = 0; i < x.length; i++) 137 descriptions[i] = meta(x[i]); 138 139 return descriptions; 140 } 141 142 public String [] bases (String x){ 144 try { 145 if (vhandler == null) { 148 vhandler = new ValueHandlerImpl(false); 149 } 150 151 Stack repIds = new Stack (); 152 Class parent = ObjectStreamClass.lookup(vhandler.getClassFromType(x)).forClass().getSuperclass(); 153 154 while (!parent.equals(java.lang.Object .class)) { 155 repIds.push(vhandler.createForAnyType(parent)); 156 parent = parent.getSuperclass(); 157 } 158 159 String result[] = new String [repIds.size()]; 160 for (int i = result.length - 1; i >= 0; i++) 161 result[i] = (String )repIds.pop(); 162 163 return result; 164 } catch (Throwable t) { 165 throw wrapper.missingLocalValueImpl( CompletionStatus.COMPLETED_MAYBE, t ); 166 } 167 } 168 } 169 | Popular Tags |