1 package org.jacorb.orb.giop; 2 3 22 23 import org.jacorb.orb.*; 24 import org.omg.CORBA.MARSHAL ; 25 import org.omg.GIOP.*; 26 import org.omg.IOP.ServiceContext ; 27 28 34 35 public class RequestInputStream 36 extends ServiceContextTransportingInputStream 37 { 38 private static byte[] reserved = new byte[3]; 39 40 private boolean is_locate_request = false; 41 42 public RequestHeader_1_2 req_hdr = null; 43 44 public RequestInputStream( org.omg.CORBA.ORB orb, byte[] buf ) 45 { 46 super( orb, buf ); 47 48 if( Messages.getMsgType( buffer ) == MsgType_1_1._Request ) 49 { 50 switch( giop_minor ) 51 { 52 case 0 : 53 { 54 RequestHeader_1_0 hdr = 56 RequestHeader_1_0Helper.read( this ); 57 58 TargetAddress addr = new TargetAddress(); 59 addr.object_key( hdr.object_key ); 60 61 req_hdr = 62 new RequestHeader_1_2( hdr.request_id, 63 Messages.responseFlags( hdr.response_expected ), 64 reserved, 65 addr, hdr.operation, 67 hdr.service_context ); 68 break; 69 } 70 case 1 : 71 { 72 RequestHeader_1_1 hdr = 74 RequestHeader_1_1Helper.read( this ); 75 76 TargetAddress addr = new TargetAddress(); 77 addr.object_key( hdr.object_key ); 78 79 req_hdr = 80 new RequestHeader_1_2( hdr.request_id, 81 Messages.responseFlags( hdr.response_expected ), 82 reserved, 83 addr, hdr.operation, 85 hdr.service_context ); 86 break; 87 } 88 case 2 : 89 { 90 req_hdr = RequestHeader_1_2Helper.read( this ); 92 93 skipHeaderPadding(); 94 95 break; 96 } 97 default : { 98 throw new MARSHAL ( "Unknown GIOP minor version: " + giop_minor ); 99 } 100 } 101 } 102 else if( Messages.getMsgType( buffer ) == MsgType_1_1._LocateRequest ) 103 { 104 switch( giop_minor ) 105 { 106 case 0 : 107 { 108 } 110 case 1 : 111 { 112 LocateRequestHeader_1_0 locate_req_hdr = 114 LocateRequestHeader_1_0Helper.read( this ); 115 116 TargetAddress addr = new TargetAddress(); 117 addr.object_key( locate_req_hdr.object_key ); 118 119 req_hdr = 120 new RequestHeader_1_2( locate_req_hdr.request_id, 121 (byte) 0x03, reserved, 123 addr, 124 "_non_existent", 125 Messages.service_context ); 126 break; 127 } 128 case 2 : 129 { 130 LocateRequestHeader_1_2 locate_req_hdr = 132 LocateRequestHeader_1_2Helper.read( this ); 133 134 req_hdr = 135 new RequestHeader_1_2( locate_req_hdr.request_id, 136 (byte) 0x03, reserved, 138 locate_req_hdr.target, 139 "_non_existent", 140 Messages.service_context ); 141 break; 142 } 143 default : 144 { 145 throw new MARSHAL ( "Unknown GIOP minor version: " + giop_minor ); 146 } 147 } 148 149 is_locate_request = true; 150 } 151 else 152 { 153 throw new MARSHAL ( "Error: not a request!" ); 154 } 155 } 156 157 public ServiceContext getServiceContext( int id ) 158 { 159 for( int i = 0; i < req_hdr.service_context.length; i++ ) 160 { 161 if( req_hdr.service_context[i].context_id == id ) 162 { 163 return req_hdr.service_context[i]; 164 } 165 } 166 167 return null; 168 } 169 170 public boolean isLocateRequest() 171 { 172 return is_locate_request; 173 } 174 175 protected void finalize() throws Throwable 176 { 177 try 178 { 179 close(); 180 } 181 catch( java.io.IOException iox ) 182 { 183 } 185 finally 186 { 187 super.finalize(); 188 } 189 } 190 } 191 | Popular Tags |