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_0 extends Message_1_0 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_0(ORB orb) { 54 this.orb = orb; 55 this.wrapper = ORBUtilSystemException.get( orb, 56 CORBALogDomains.RPC_PROTOCOL ) ; 57 } 58 59 ReplyMessage_1_0(ORB orb, ServiceContexts _service_contexts, 60 int _request_id, int _reply_status, IOR _ior) { 61 super(Message.GIOPBigMagic, false, Message.GIOPReply, 0); 62 this.orb = orb; 63 this.wrapper = ORBUtilSystemException.get( orb, 64 CORBALogDomains.RPC_PROTOCOL ) ; 65 service_contexts = _service_contexts; 66 request_id = _request_id; 67 reply_status = _reply_status; 68 ior = _ior; 69 } 70 71 73 public int getRequestId() { 74 return this.request_id; 75 } 76 77 public int getReplyStatus() { 78 return this.reply_status; 79 } 80 81 public short getAddrDisposition() { 82 return KeyAddr.value; 83 } 84 85 public ServiceContexts getServiceContexts() { 86 return this.service_contexts; 87 } 88 89 public void setServiceContexts( ServiceContexts sc ) { 90 this.service_contexts = sc; 91 } 92 93 public SystemException getSystemException(String message) { 94 return MessageBase.getSystemException( 95 exClassName, minorCode, completionStatus, message, wrapper); 96 } 97 98 public IOR getIOR() { 99 return this.ior; 100 } 101 102 public void setIOR( IOR ior ) { 103 this.ior = ior; 104 } 105 106 108 public void read(org.omg.CORBA.portable.InputStream istream) { 109 super.read(istream); 110 this.service_contexts 111 = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream ) istream); 112 this.request_id = istream.read_ulong(); 113 this.reply_status = istream.read_long(); 114 isValidReplyStatus(this.reply_status); 116 if (this.reply_status == SYSTEM_EXCEPTION) { 119 120 String reposId = istream.read_string(); 121 this.exClassName = ORBUtility.classNameOf(reposId); 122 this.minorCode = istream.read_long(); 123 int status = istream.read_long(); 124 125 switch (status) { 126 case CompletionStatus._COMPLETED_YES: 127 this.completionStatus = CompletionStatus.COMPLETED_YES; 128 break; 129 case CompletionStatus._COMPLETED_NO: 130 this.completionStatus = CompletionStatus.COMPLETED_NO; 131 break; 132 case CompletionStatus._COMPLETED_MAYBE: 133 this.completionStatus = CompletionStatus.COMPLETED_MAYBE; 134 break; 135 default: 136 throw wrapper.badCompletionStatusInReply( 137 CompletionStatus.COMPLETED_MAYBE, new Integer (status) ); 138 } 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_0); 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 |