1 7 8 package com.sun.corba.se.impl.encoding; 9 10 import java.nio.ByteBuffer ; 11 12 import com.sun.org.omg.SendingContext.CodeBase; 13 14 import com.sun.corba.se.pept.encoding.InputObject; 15 16 import com.sun.corba.se.spi.logging.CORBALogDomains; 17 18 import com.sun.corba.se.spi.orb.ORB; 19 20 import com.sun.corba.se.spi.transport.CorbaConnection; 21 22 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 23 24 import com.sun.corba.se.impl.encoding.BufferManagerFactory; 25 import com.sun.corba.se.impl.encoding.CodeSetComponentInfo; 26 import com.sun.corba.se.impl.encoding.CodeSetConversion; 27 import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry; 28 import com.sun.corba.se.impl.encoding.CDRInputStream; 29 30 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; 31 32 import com.sun.corba.se.impl.logging.ORBUtilSystemException; 33 import com.sun.corba.se.impl.logging.OMGSystemException; 34 35 import com.sun.corba.se.impl.orbutil.ORBUtility; 36 37 40 public class CDRInputObject extends CDRInputStream 41 implements 42 InputObject 43 { 44 private CorbaConnection corbaConnection; 45 private Message header; 46 private boolean unmarshaledHeader; 47 private ORB orb ; 48 private ORBUtilSystemException wrapper ; 49 private OMGSystemException omgWrapper ; 50 51 public CDRInputObject(ORB orb, 52 CorbaConnection corbaConnection, 53 ByteBuffer byteBuffer, 54 Message header) 55 { 56 super(orb, byteBuffer, header.getSize(), header.isLittleEndian(), 57 header.getGIOPVersion(), header.getEncodingVersion(), 58 BufferManagerFactory.newBufferManagerRead( 59 header.getGIOPVersion(), 60 header.getEncodingVersion(), 61 orb)); 62 63 this.corbaConnection = corbaConnection; 64 this.orb = orb ; 65 this.wrapper = ORBUtilSystemException.get( orb, 66 CORBALogDomains.RPC_ENCODING ) ; 67 this.omgWrapper = OMGSystemException.get( orb, 68 CORBALogDomains.RPC_ENCODING ) ; 69 70 if (orb.transportDebugFlag) { 71 dprint(".CDRInputObject constructor:"); 72 } 73 74 getBufferManager().init(header); 75 76 this.header = header; 77 78 unmarshaledHeader = false; 79 80 setIndex(Message.GIOPMessageHeaderLength); 81 82 setBufferLength(header.getSize()); 83 } 84 85 public final CorbaConnection getConnection() 90 { 91 return corbaConnection; 92 } 93 94 public Message getMessageHeader() 99 { 100 return header; 101 } 102 103 109 public void unmarshalHeader() 110 { 111 113 if (!unmarshaledHeader) { 114 try { 115 if (((ORB)orb()).transportDebugFlag) { 116 dprint(".unmarshalHeader->: " + getMessageHeader()); 117 } 118 getMessageHeader().read(this); 119 unmarshaledHeader= true; 120 } catch (RuntimeException e) { 121 if (((ORB)orb()).transportDebugFlag) { 122 dprint(".unmarshalHeader: !!ERROR!!: " 123 + getMessageHeader() 124 + ": " + e); 125 } 126 throw e; 127 } finally { 128 if (((ORB)orb()).transportDebugFlag) { 129 dprint(".unmarshalHeader<-: " + getMessageHeader()); 130 } 131 } 132 } 133 } 134 135 public final boolean unmarshaledHeader() 136 { 137 return unmarshaledHeader; 138 } 139 140 149 protected CodeSetConversion.BTCConverter createCharBTCConverter() { 150 CodeSetComponentInfo.CodeSetContext codesets = getCodeSets(); 151 152 if (codesets == null) 156 return super.createCharBTCConverter(); 157 158 OSFCodeSetRegistry.Entry charSet 159 = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet()); 160 161 if (charSet == null) 162 throw wrapper.unknownCodeset( charSet ) ; 163 164 return CodeSetConversion.impl().getBTCConverter(charSet, isLittleEndian()); 165 } 166 167 protected CodeSetConversion.BTCConverter createWCharBTCConverter() { 168 169 CodeSetComponentInfo.CodeSetContext codesets = getCodeSets(); 170 171 if (codesets == null) { 175 if (getConnection().isServer()) 176 throw omgWrapper.noClientWcharCodesetCtx() ; 177 else 178 throw omgWrapper.noServerWcharCodesetCmp() ; 179 } 180 181 OSFCodeSetRegistry.Entry wcharSet 182 = OSFCodeSetRegistry.lookupEntry(codesets.getWCharCodeSet()); 183 184 if (wcharSet == null) 185 throw wrapper.unknownCodeset( wcharSet ) ; 186 187 if (wcharSet == OSFCodeSetRegistry.UTF_16) { 196 if (getGIOPVersion().equals(GIOPVersion.V1_2)) 197 return CodeSetConversion.impl().getBTCConverter(wcharSet, false); 198 } 199 200 return CodeSetConversion.impl().getBTCConverter(wcharSet, isLittleEndian()); 201 } 202 203 private CodeSetComponentInfo.CodeSetContext getCodeSets() { 209 if (getConnection() == null) 210 return CodeSetComponentInfo.LOCAL_CODE_SETS; 211 else 212 return getConnection().getCodeSetContext(); 213 } 214 215 public final CodeBase getCodeBase() { 216 if (getConnection() == null) 217 return null; 218 else 219 return getConnection().getCodeBase(); 220 } 221 222 228 232 237 public CDRInputStream dup() { 238 return null; 240 } 242 243 protected void dprint(String msg) 244 { 245 ORBUtility.dprint("CDRInputObject", msg); 246 } 247 } 248 249 | Popular Tags |