1 21 package org.jacorb.orb.portableInterceptor; 22 23 import org.omg.IOP.*; 24 import org.omg.CORBA.*; 25 import org.omg.CORBA.portable.*; 26 import org.omg.PortableInterceptor.*; 27 import org.omg.Dynamic.Parameter ; 28 import org.omg.PortableServer.Servant ; 29 30 import org.apache.avalon.framework.logger.*; 31 32 import java.util.Enumeration ; 33 34 import org.jacorb.orb.dsi.ServerRequest; 35 36 44 45 public class ServerRequestInfoImpl 46 extends RequestInfoImpl 47 implements ServerRequestInfo 48 { 49 50 private byte[] adapter_id = null; 52 private String target_most_derived_interface = null; 53 54 private Servant servant = null; 55 private org.jacorb.orb.ORB orb = null; 56 57 public ServerRequest request = null; 58 59 public Any sending_exception = null; 60 61 public ServerRequestInfoImpl( org.jacorb.orb.ORB orb, 62 ServerRequest request, 63 Servant servant) 64 { 65 super(); 66 67 this.orb = orb; 68 this.request = request; 69 if (servant != null){ 70 setServant(servant); 71 } 72 73 setRequestServiceContexts(request.getServiceContext()); 74 75 sending_exception = orb.create_any(); 76 } 77 78 83 84 public void setServant(Servant servant) 85 { 86 this.servant = servant; 87 org.jacorb.poa.POA poa = (org.jacorb.poa.POA) servant._poa(); 88 adapter_id = poa.getPOAId(); 89 String [] all_ifs = servant._all_interfaces(poa, servant._object_id()); 90 target_most_derived_interface = all_ifs[0]; 91 } 92 93 96 97 public void update() 98 { 99 if (! request.streamBased()) 100 { 101 Any user_ex = request.except(); 102 if (user_ex != null) 103 sending_exception = user_ex; 104 } 105 106 SystemException sys_ex = request.getSystemException(); 107 if (sys_ex != null) 108 org.jacorb.orb.SystemExceptionHelper.insert(sending_exception, sys_ex); 109 110 forward_reference = request.getForwardReference(); 111 } 112 113 public Enumeration getReplyServiceContexts() 114 { 115 return reply_ctx.elements(); 116 } 117 118 121 122 public org.omg.CORBA.Object target() 123 { 124 return servant._this_object(); 125 } 126 127 129 public Parameter [] arguments() 130 { 131 if (!(caller_op == ServerInterceptorIterator.RECEIVE_REQUEST) && 132 !(caller_op == ServerInterceptorIterator.SEND_REPLY)) 133 throw new BAD_INV_ORDER("The attribute \"arguments\" is currently invalid!", 134 10, CompletionStatus.COMPLETED_MAYBE); 135 136 if (arguments == null) 137 throw new NO_RESOURCES("Stream-based skeletons/stubs do not support this op", 138 1, CompletionStatus.COMPLETED_MAYBE); 139 else 140 return arguments; 141 } 142 143 public TypeCode[] exceptions() 144 { 145 throw new NO_RESOURCES("This feature is not supported on the server side", 146 1, CompletionStatus.COMPLETED_MAYBE); 147 } 148 149 public Any result() 150 { 151 if ( caller_op != ServerInterceptorIterator.SEND_REPLY ) 152 throw new BAD_INV_ORDER("The attribute \"result\" is currently invalid!", 153 10, CompletionStatus.COMPLETED_MAYBE); 154 155 Any result = null; 156 try 157 { 158 result = request.result(); 159 } 160 catch(Exception e) 161 { 162 } 163 164 if (result == null) 165 { 166 throw new NO_RESOURCES("Stream-based skeletons/stubs do not support this op", 167 1, CompletionStatus.COMPLETED_MAYBE); 168 } 169 else 170 return result; 171 } 172 173 public short sync_scope() { 174 return org.omg.Messaging.SYNC_WITH_TRANSPORT.value; 175 } 176 177 public short reply_status() { 178 if ((caller_op == ServerInterceptorIterator.RECEIVE_REQUEST) || 179 (caller_op == ServerInterceptorIterator.RECEIVE_REQUEST_SERVICE_CONTEXTS)) 180 throw new BAD_INV_ORDER("The attribute \"reply_status\" is currently invalid!", 181 10, CompletionStatus.COMPLETED_MAYBE); 182 183 return reply_status; 184 } 185 186 public org.omg.CORBA.Object forward_reference() { 187 if (! (caller_op != ServerInterceptorIterator.SEND_OTHER) || 188 (reply_status != LOCATION_FORWARD.value)) 189 throw new BAD_INV_ORDER("The attribute \"forward_reference\" is currently " + 190 "invalid!", 10, CompletionStatus.COMPLETED_MAYBE); 191 192 return forward_reference; 193 } 194 195 public ServiceContext get_reply_service_context(int id) { 196 if ((caller_op == ServerInterceptorIterator.RECEIVE_REQUEST) || 197 (caller_op == ServerInterceptorIterator.RECEIVE_REQUEST_SERVICE_CONTEXTS)) 198 throw new BAD_INV_ORDER("The operation \"get_reply_service_context\" is " + 199 "currently invalid!", 10, 200 CompletionStatus.COMPLETED_MAYBE); 201 202 return super.get_reply_service_context(id); 203 } 204 205 public String operation() { 206 return request.operation(); 207 } 208 209 public int request_id() { 210 return request.requestId(); 211 } 212 213 public boolean response_expected() { 214 return request.responseExpected(); 215 } 216 217 public Any sending_exception() { 219 if (caller_op != ServerInterceptorIterator.SEND_EXCEPTION) 220 throw new BAD_INV_ORDER("The attribute \"sending_exception\" is " + 221 "currently invalid!", 10, 222 CompletionStatus.COMPLETED_MAYBE); 223 224 return sending_exception; 225 } 226 227 public byte[] object_id() { 228 if (caller_op == ServerInterceptorIterator.RECEIVE_REQUEST_SERVICE_CONTEXTS) 229 throw new BAD_INV_ORDER("The attribute \"object_id\" is currently invalid!", 230 10, CompletionStatus.COMPLETED_MAYBE); 231 232 return request.objectId(); 233 } 234 235 public byte[] adapter_id() { 236 if (caller_op == ServerInterceptorIterator.RECEIVE_REQUEST_SERVICE_CONTEXTS) 237 throw new BAD_INV_ORDER("The attribute \"adapter_id\" is currently invalid!", 238 10, CompletionStatus.COMPLETED_MAYBE); 239 240 return adapter_id; 241 } 242 243 public String target_most_derived_interface() { 244 if (caller_op == ServerInterceptorIterator.RECEIVE_REQUEST_SERVICE_CONTEXTS) 245 throw new BAD_INV_ORDER("The attribute \"target_most_derived_interface\" is " + 246 "currently invalid!", 10, 247 CompletionStatus.COMPLETED_MAYBE); 248 249 return target_most_derived_interface; 250 } 251 252 256 public Policy get_server_policy(int type) { 257 if (! orb.hasPolicyFactoryForType(type)) 258 throw new INV_POLICY("No PolicyFactory for type " + type + 259 " has been registered!", 2, 260 CompletionStatus.COMPLETED_MAYBE); 261 262 try{ 263 org.jacorb.orb.ServantDelegate delegate = (org.jacorb.orb.ServantDelegate) servant._get_delegate(); 264 return delegate._get_policy(servant._this_object(), type); 265 }catch(INV_POLICY _e){ 266 _e.minor = 2; 267 throw _e; 268 } 269 } 270 271 public void set_slot(int id, Any data) throws InvalidSlot { 272 current.set_slot(id, data); 273 } 274 275 public boolean target_is_a(String id) { 276 if (caller_op == ServerInterceptorIterator.RECEIVE_REQUEST_SERVICE_CONTEXTS) 277 throw new BAD_INV_ORDER("The operation \"target_is_a\" is currently invalid!", 278 10, CompletionStatus.COMPLETED_MAYBE); 279 280 return servant._is_a(id); 281 } 282 283 public void add_reply_service_context(ServiceContext service_context, 284 boolean replace) { 285 286 Integer _id = new Integer (service_context.context_id); 287 288 if (! replace && reply_ctx.containsKey(_id)) 289 throw new BAD_INV_ORDER("The ServiceContext with id " + _id.toString() 290 + " has already been set!", 11, 291 CompletionStatus.COMPLETED_MAYBE); 292 293 reply_ctx.put(_id, service_context); 294 } 295 } 297 298 299 300 301 302 | Popular Tags |