1 7 8 package com.sun.corba.se.impl.protocol.giopmsgheaders; 9 10 import org.omg.CORBA.INTERNAL ; 11 import org.omg.CORBA.SystemException ; 12 import org.omg.CORBA.CompletionStatus ; 13 14 import com.sun.corba.se.spi.ior.IOR; 15 import com.sun.corba.se.spi.ior.IORFactories ; 16 17 import com.sun.corba.se.spi.orb.ORB; 18 19 import com.sun.corba.se.spi.servicecontext.ServiceContexts; 20 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 21 22 import com.sun.corba.se.impl.encoding.CDRInputStream; 23 import com.sun.corba.se.impl.encoding.CDROutputStream; 24 import com.sun.corba.se.impl.encoding.CDRInputStream_1_2; 25 import com.sun.corba.se.impl.encoding.CDROutputStream_1_2; 26 27 import com.sun.corba.se.impl.orbutil.ORBUtility; 28 import com.sun.corba.se.impl.orbutil.ORBConstants; 29 30 import com.sun.corba.se.spi.logging.CORBALogDomains ; 31 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 32 33 39 40 public final class ReplyMessage_1_2 extends Message_1_2 41 implements ReplyMessage { 42 43 45 private ORB orb = null; 46 private ORBUtilSystemException wrapper = null ; 47 private int reply_status = (int) 0; 48 private ServiceContexts service_contexts = null; 49 private IOR ior = null; 50 private String exClassName = null; 51 private int minorCode = (int) 0; 52 private CompletionStatus completionStatus = null; 53 private short addrDisposition = KeyAddr.value; 55 57 ReplyMessage_1_2(ORB orb) { 58 this.orb = orb; 59 this.wrapper = ORBUtilSystemException.get( orb, 60 CORBALogDomains.RPC_PROTOCOL ) ; 61 } 62 63 ReplyMessage_1_2(ORB orb, int _request_id, int _reply_status, 64 ServiceContexts _service_contexts, IOR _ior) { 65 super(Message.GIOPBigMagic, GIOPVersion.V1_2, FLAG_NO_FRAG_BIG_ENDIAN, 66 Message.GIOPReply, 0); 67 this.orb = orb; 68 this.wrapper = ORBUtilSystemException.get( orb, 69 CORBALogDomains.RPC_PROTOCOL ) ; 70 request_id = _request_id; 71 reply_status = _reply_status; 72 service_contexts = _service_contexts; 73 ior = _ior; 74 } 75 76 78 public int getRequestId() { 79 return this.request_id; 80 } 81 82 public int getReplyStatus() { 83 return this.reply_status; 84 } 85 86 public short getAddrDisposition() { 87 return this.addrDisposition; 88 } 89 90 public ServiceContexts getServiceContexts() { 91 return this.service_contexts; 92 } 93 94 public void setServiceContexts( ServiceContexts sc ) { 95 this.service_contexts = sc; 96 } 97 98 public SystemException getSystemException(String message) { 99 return MessageBase.getSystemException( 100 exClassName, minorCode, completionStatus, message, wrapper); 101 } 102 103 public IOR getIOR() { 104 return this.ior; 105 } 106 107 public void setIOR( IOR ior ) { 108 this.ior = ior; 109 } 110 111 113 public void read(org.omg.CORBA.portable.InputStream istream) { 114 super.read(istream); 115 this.request_id = istream.read_ulong(); 116 this.reply_status = istream.read_long(); 117 isValidReplyStatus(this.reply_status); this.service_contexts 119 = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream ) istream); 120 121 ((CDRInputStream)istream).setHeaderPadding(true); 127 128 if (this.reply_status == SYSTEM_EXCEPTION) { 132 133 String reposId = istream.read_string(); 134 this.exClassName = ORBUtility.classNameOf(reposId); 135 this.minorCode = istream.read_long(); 136 int status = istream.read_long(); 137 138 switch (status) { 139 case CompletionStatus._COMPLETED_YES: 140 this.completionStatus = CompletionStatus.COMPLETED_YES; 141 break; 142 case CompletionStatus._COMPLETED_NO: 143 this.completionStatus = CompletionStatus.COMPLETED_NO; 144 break; 145 case CompletionStatus._COMPLETED_MAYBE: 146 this.completionStatus = CompletionStatus.COMPLETED_MAYBE; 147 break; 148 default: 149 throw wrapper.badCompletionStatusInReply( 150 CompletionStatus.COMPLETED_MAYBE, new Integer (status) ); 151 } 152 153 } else if (this.reply_status == USER_EXCEPTION) { 154 } else if ( (this.reply_status == LOCATION_FORWARD) || 156 (this.reply_status == LOCATION_FORWARD_PERM) ){ 157 CDRInputStream cdr = (CDRInputStream) istream; 158 this.ior = IORFactories.makeIOR( cdr ) ; 159 } else if (this.reply_status == NEEDS_ADDRESSING_MODE) { 160 this.addrDisposition = AddressingDispositionHelper.read(istream); 164 } 165 } 166 167 public void write(org.omg.CORBA.portable.OutputStream ostream) { 171 super.write(ostream); 172 ostream.write_ulong(this.request_id); 173 ostream.write_long(this.reply_status); 174 if (this.service_contexts != null) { 175 service_contexts.write( 176 (org.omg.CORBA_2_3.portable.OutputStream ) ostream, 177 GIOPVersion.V1_2); 178 } else { 179 ServiceContexts.writeNullServiceContext( 180 (org.omg.CORBA_2_3.portable.OutputStream ) ostream); 181 } 182 183 ((CDROutputStream)ostream).setHeaderPadding(true); 189 190 } 191 192 194 public static void isValidReplyStatus(int replyStatus) { 195 switch (replyStatus) { 196 case NO_EXCEPTION : 197 case USER_EXCEPTION : 198 case SYSTEM_EXCEPTION : 199 case LOCATION_FORWARD : 200 case LOCATION_FORWARD_PERM : 201 case NEEDS_ADDRESSING_MODE : 202 break; 203 default : 204 ORBUtilSystemException localWrapper = ORBUtilSystemException.get( 205 CORBALogDomains.RPC_PROTOCOL ) ; 206 throw localWrapper.illegalReplyStatus( CompletionStatus.COMPLETED_MAYBE); 207 } 208 } 209 210 public void callback(MessageHandler handler) 211 throws java.io.IOException 212 { 213 handler.handleInput(this); 214 } 215 } | Popular Tags |