1 7 8 package com.sun.corba.se.impl.protocol.giopmsgheaders; 9 10 import org.omg.CORBA.INTERNAL ; 11 import org.omg.CORBA.CompletionStatus ; 12 import org.omg.CORBA.SystemException ; 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 import com.sun.corba.se.impl.orbutil.ORBUtility; 22 import com.sun.corba.se.impl.orbutil.ORBClassLoader; 23 import com.sun.corba.se.spi.ior.IOR; 24 import com.sun.corba.se.impl.encoding.CDRInputStream; 25 26 import com.sun.corba.se.spi.logging.CORBALogDomains ; 27 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 28 29 35 36 public final class ReplyMessage_1_1 extends Message_1_1 37 implements ReplyMessage { 38 39 41 private ORB orb = null; 42 private ORBUtilSystemException wrapper = null ; 43 private ServiceContexts service_contexts = null; 44 private int request_id = (int) 0; 45 private int reply_status = (int) 0; 46 private IOR ior = null; 47 private String exClassName = null; 48 private int minorCode = (int) 0; 49 private CompletionStatus completionStatus = null; 50 51 53 ReplyMessage_1_1(ORB orb) { 54 this.orb = orb; 55 this.wrapper = ORBUtilSystemException.get( orb, 56 CORBALogDomains.RPC_PROTOCOL ) ; 57 } 58 59 ReplyMessage_1_1(ORB orb, ServiceContexts _service_contexts, 60 int _request_id, int _reply_status, IOR _ior) { 61 super(Message.GIOPBigMagic, GIOPVersion.V1_1, FLAG_NO_FRAG_BIG_ENDIAN, 62 Message.GIOPReply, 0); 63 this.orb = orb; 64 this.wrapper = ORBUtilSystemException.get( orb, 65 CORBALogDomains.RPC_PROTOCOL ) ; 66 service_contexts = _service_contexts; 67 request_id = _request_id; 68 reply_status = _reply_status; 69 ior = _ior; 70 } 71 72 74 public int getRequestId() { 75 return this.request_id; 76 } 77 78 public int getReplyStatus() { 79 return this.reply_status; 80 } 81 82 public short getAddrDisposition() { 83 return KeyAddr.value; 84 } 85 86 public ServiceContexts getServiceContexts() { 87 return this.service_contexts; 88 } 89 90 public void setServiceContexts( ServiceContexts sc ) { 91 this.service_contexts = sc; 92 } 93 94 public SystemException getSystemException(String message) { 95 return MessageBase.getSystemException( 96 exClassName, minorCode, completionStatus, message, wrapper); 97 } 98 99 public IOR getIOR() { 100 return this.ior; 101 } 102 103 public void setIOR( IOR ior ) { 104 this.ior = ior; 105 } 106 107 109 public void read(org.omg.CORBA.portable.InputStream istream) { 110 super.read(istream); 111 this.service_contexts 112 = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream ) istream); 113 this.request_id = istream.read_ulong(); 114 this.reply_status = istream.read_long(); 115 isValidReplyStatus(this.reply_status); 117 if (this.reply_status == SYSTEM_EXCEPTION) { 120 121 String reposId = istream.read_string(); 122 this.exClassName = ORBUtility.classNameOf(reposId); 123 this.minorCode = istream.read_long(); 124 int status = istream.read_long(); 125 126 switch (status) { 127 case CompletionStatus._COMPLETED_YES: 128 this.completionStatus = CompletionStatus.COMPLETED_YES; 129 break; 130 case CompletionStatus._COMPLETED_NO: 131 this.completionStatus = CompletionStatus.COMPLETED_NO; 132 break; 133 case CompletionStatus._COMPLETED_MAYBE: 134 this.completionStatus = CompletionStatus.COMPLETED_MAYBE; 135 break; 136 default: 137 throw wrapper.badCompletionStatusInReply( 138 CompletionStatus.COMPLETED_MAYBE, new Integer (status) ); 139 } 140 } else if (this.reply_status == USER_EXCEPTION) { 141 } else if (this.reply_status == LOCATION_FORWARD) { 143 CDRInputStream cdr = (CDRInputStream) istream; 144 this.ior = IORFactories.makeIOR(cdr) ; 145 } 146 } 147 148 public void write(org.omg.CORBA.portable.OutputStream ostream) { 151 super.write(ostream); 152 if (this.service_contexts != null) { 153 service_contexts.write( 154 (org.omg.CORBA_2_3.portable.OutputStream ) ostream, 155 GIOPVersion.V1_1); 156 } else { 157 ServiceContexts.writeNullServiceContext( 158 (org.omg.CORBA_2_3.portable.OutputStream ) ostream); 159 } 160 ostream.write_ulong(this.request_id); 161 ostream.write_long(this.reply_status); 162 } 163 164 166 public static void isValidReplyStatus(int replyStatus) { 167 switch (replyStatus) { 168 case NO_EXCEPTION : 169 case USER_EXCEPTION : 170 case SYSTEM_EXCEPTION : 171 case LOCATION_FORWARD : 172 break; 173 default : 174 ORBUtilSystemException localWrapper = ORBUtilSystemException.get( 175 CORBALogDomains.RPC_PROTOCOL ) ; 176 throw localWrapper.illegalReplyStatus( CompletionStatus.COMPLETED_MAYBE); 177 } 178 } 179 180 public void callback(MessageHandler handler) 181 throws java.io.IOException 182 { 183 handler.handleInput(this); 184 } 185 } | Popular Tags |