1 package org.jacorb.orb.giop; 2 3 22 23 import java.io.IOException ; 24 import org.apache.avalon.framework.logger.Logger; 25 26 import org.omg.CORBA.MARSHAL ; 27 import org.omg.GIOP.*; 28 import org.jacorb.orb.*; 29 30 35 public class ReplyOutputStream 36 extends ServiceContextTransportingOutputStream 37 { 38 private boolean is_locate_reply = false; 39 private Logger logger; 40 41 public ReplyOutputStream ( int request_id, 42 ReplyStatusType_1_2 reply_status, 43 int giop_minor, 44 boolean is_locate_reply, 45 Logger logger) 46 { 47 super(); 48 49 this.is_locate_reply = is_locate_reply; 50 51 setGIOPMinor( giop_minor ); 52 53 writeGIOPMsgHeader( MsgType_1_1._Reply, 54 giop_minor ); 55 56 switch( giop_minor ) 57 { 58 case 0 : 59 { 60 } 62 case 1 : 63 { 64 69 76 78 org.omg.IOP.ServiceContextListHelper.write(this , Messages.service_context ); 79 write_ulong( request_id ); 80 org.omg.GIOP.ReplyStatusType_1_0Helper.write( this, 81 ReplyStatusType_1_0.from_int( reply_status.value() )); 82 83 break; 84 } 85 case 2 : 86 { 87 93 95 97 write_ulong( request_id ); 98 org.omg.GIOP.ReplyStatusType_1_2Helper.write(this, 99 reply_status); 100 101 102 org.omg.IOP.ServiceContextListHelper.write( this, Messages.service_context ); 103 104 markHeaderEnd(); 106 break; 107 } 108 default : 109 { 110 throw new MARSHAL ( "Unknown GIOP minor: " + giop_minor ); 111 } 112 } 113 } 114 115 public void write_to( GIOPConnection conn ) 116 throws IOException 117 { 118 if( is_locate_reply ) 119 { 120 ReplyInputStream r_in = 121 new ReplyInputStream( null, getBufferCopy() ); 122 123 LocateReplyOutputStream lr_out = null; 124 125 if( r_in.getGIOPMinor() < 2 ) 126 { 127 switch( r_in.rep_hdr.reply_status.value() ) 129 { 130 case ReplyStatusType_1_2._NO_EXCEPTION : 131 { 132 int status; 133 134 if (r_in.read_boolean()) 136 { 137 status = LocateStatusType_1_2._UNKNOWN_OBJECT; 139 } 140 else 141 { 142 status = LocateStatusType_1_2._OBJECT_HERE; 144 } 145 146 lr_out = new LocateReplyOutputStream( r_in.rep_hdr.request_id, 147 status, 148 r_in.getGIOPMinor() ); 149 150 break; 151 } 152 case ReplyStatusType_1_2._USER_EXCEPTION : 153 { 154 } 156 case ReplyStatusType_1_2._SYSTEM_EXCEPTION : 157 { 158 if (logger.isErrorEnabled()) 160 logger.error("Received an exception when processing a LocateRequest" ); 161 162 lr_out = 166 new LocateReplyOutputStream( r_in.rep_hdr.request_id, 167 LocateStatusType_1_2._UNKNOWN_OBJECT, 168 r_in.getGIOPMinor() ); 169 break; 170 } 171 case ReplyStatusType_1_2._LOCATION_FORWARD : 172 { 173 174 lr_out = 175 new LocateReplyOutputStream( r_in.rep_hdr.request_id, 176 LocateStatusType_1_2._OBJECT_FORWARD, 177 r_in.getGIOPMinor() ); 178 179 180 lr_out.write_IOR( org.omg.IOP.IORHelper.read( r_in )); 184 185 break; 186 } 187 } 188 } 189 else 190 { 191 switch( r_in.rep_hdr.reply_status.value() ) 193 { 194 case ReplyStatusType_1_2._NO_EXCEPTION : 195 { 196 int status; 197 198 if( r_in.read_boolean() ) 200 { 201 status = LocateStatusType_1_2._UNKNOWN_OBJECT; 203 } 204 else 205 { 206 status = LocateStatusType_1_2._OBJECT_HERE; 208 } 209 210 lr_out = new LocateReplyOutputStream( r_in.rep_hdr.request_id, 211 status, 212 r_in.getGIOPMinor() ); 213 214 break; 215 } 216 case ReplyStatusType_1_2._USER_EXCEPTION : 217 { 218 if (logger.isErrorEnabled()) 220 logger.error("Received an exception when processing a LocateRequest - mapping to UNKNOWN system exception" ); 221 222 lr_out = 223 new LocateReplyOutputStream( r_in.rep_hdr.request_id, 224 LocateStatusType_1_2._LOC_SYSTEM_EXCEPTION, 225 r_in.getGIOPMinor() ); 226 227 SystemExceptionHelper.write( lr_out, 228 new org.omg.CORBA.UNKNOWN () ); 229 230 } 231 case ReplyStatusType_1_2._SYSTEM_EXCEPTION : 232 { 233 234 235 lr_out = 236 new LocateReplyOutputStream( r_in.rep_hdr.request_id, 237 LocateStatusType_1_2._LOC_SYSTEM_EXCEPTION, 238 r_in.getGIOPMinor() ); 239 240 SystemExceptionHelper.write( lr_out, 242 SystemExceptionHelper.read( r_in )); 243 244 break; 245 } 246 case ReplyStatusType_1_2._LOCATION_FORWARD : 247 { 248 249 lr_out = 250 new LocateReplyOutputStream( r_in.rep_hdr.request_id, 251 LocateStatusType_1_2._OBJECT_FORWARD, 252 r_in.getGIOPMinor() ); 253 254 255 lr_out.write_IOR( org.omg.IOP.IORHelper.read( r_in )); 259 260 break; 261 } 262 } 263 } 264 265 lr_out.write_to( conn ); 266 } 267 else 268 { 269 super.write_to( conn ); 270 } 271 } 272 } 273 | Popular Tags |