1. /*
  2. * @(#)ServerRequestInfoImpl.java 1.41 04/06/21
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.impl.interceptors;
  8. import org.omg.CORBA.Any;
  9. import org.omg.CORBA.BAD_INV_ORDER;
  10. import org.omg.CORBA.CompletionStatus;
  11. import org.omg.CORBA.INTERNAL;
  12. import org.omg.CORBA.LocalObject;
  13. import org.omg.CORBA.NO_IMPLEMENT;
  14. import org.omg.CORBA.NO_RESOURCES;
  15. import org.omg.CORBA.NVList;
  16. import org.omg.CORBA.Object;
  17. import org.omg.CORBA.Policy;
  18. import org.omg.CORBA.TypeCode;
  19. import org.omg.PortableServer.Servant;
  20. import org.omg.IOP.TaggedProfile;
  21. import org.omg.IOP.ServiceContext;
  22. import org.omg.Dynamic.Parameter;
  23. import org.omg.PortableInterceptor.InvalidSlot;
  24. import org.omg.PortableInterceptor.ServerRequestInfo;
  25. import org.omg.PortableInterceptor.LOCATION_FORWARD;
  26. import org.omg.PortableInterceptor.SUCCESSFUL;
  27. import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
  28. import org.omg.PortableInterceptor.TRANSPORT_RETRY;
  29. import org.omg.PortableInterceptor.USER_EXCEPTION;
  30. import com.sun.corba.se.spi.oa.ObjectAdapter;
  31. import com.sun.corba.se.spi.presentation.rmi.StubAdapter;
  32. import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
  33. import com.sun.corba.se.spi.servicecontext.ServiceContexts;
  34. import com.sun.corba.se.spi.orb.ORB;
  35. import com.sun.corba.se.spi.ior.ObjectKeyTemplate;
  36. import com.sun.corba.se.spi.ior.ObjectAdapterId ;
  37. import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
  38. import java.util.*;
  39. /**
  40. * Implementation of the ServerRequestInfo interface as specified in
  41. * orbos/99-12-02 section 5.4.3.
  42. */
  43. public final class ServerRequestInfoImpl
  44. extends RequestInfoImpl
  45. implements ServerRequestInfo
  46. {
  47. // The available constants for startingPointCall
  48. static final int CALL_RECEIVE_REQUEST_SERVICE_CONTEXT = 0;
  49. // The available constants for intermediatePointCall. The default (0)
  50. // is receive_request, but can be set to none on demand.
  51. static final int CALL_RECEIVE_REQUEST = 0;
  52. static final int CALL_INTERMEDIATE_NONE = 1;
  53. // The available constants for endingPointCall
  54. static final int CALL_SEND_REPLY = 0;
  55. static final int CALL_SEND_EXCEPTION = 1;
  56. static final int CALL_SEND_OTHER = 2;
  57. //////////////////////////////////////////////////////////////////////
  58. //
  59. // NOTE: IF AN ATTRIBUTE IS ADDED, PLEASE UPDATE RESET();
  60. //
  61. //////////////////////////////////////////////////////////////////////
  62. // Set to true if the server ending point raised ForwardRequest at some
  63. // point in the ending point.
  64. private boolean forwardRequestRaisedInEnding;
  65. // Sources of server request information:
  66. private CorbaMessageMediator request;
  67. private java.lang.Object servant;
  68. private byte[] objectId;
  69. private ObjectKeyTemplate oktemp ;
  70. // Information cached from calls to oktemp
  71. private byte[] adapterId;
  72. private String[] adapterName;
  73. private ArrayList addReplyServiceContextQueue;
  74. private ReplyMessage replyMessage;
  75. private String targetMostDerivedInterface;
  76. private NVList dsiArguments;
  77. private Any dsiResult;
  78. private Any dsiException;
  79. private boolean isDynamic;
  80. private ObjectAdapter objectAdapter;
  81. private int serverRequestId;
  82. // Cached information:
  83. private Parameter[] cachedArguments;
  84. private Any cachedSendingException;
  85. // key = Integer, value = IOP.ServiceContext.
  86. private HashMap cachedRequestServiceContexts;
  87. // key = Integer, value = IOP.ServiceContext.
  88. private HashMap cachedReplyServiceContexts;
  89. //////////////////////////////////////////////////////////////////////
  90. //
  91. // NOTE: IF AN ATTRIBUTE IS ADDED, PLEASE UPDATE RESET();
  92. //
  93. //////////////////////////////////////////////////////////////////////
  94. /**
  95. * Reset the info object so that it can be reused for a retry,
  96. * for example.
  97. */
  98. void reset() {
  99. super.reset();
  100. // Please keep these in the same order as declared above.
  101. forwardRequestRaisedInEnding = false;
  102. request = null;
  103. servant = null;
  104. objectId = null;
  105. oktemp = null;
  106. adapterId = null;
  107. adapterName = null;
  108. addReplyServiceContextQueue = null;
  109. replyMessage = null;
  110. targetMostDerivedInterface = null;
  111. dsiArguments = null;
  112. dsiResult = null;
  113. dsiException = null;
  114. isDynamic = false;
  115. objectAdapter = null;
  116. serverRequestId = myORB.getPIHandler().allocateServerRequestId();
  117. // reset cached attributes:
  118. cachedArguments = null;
  119. cachedSendingException = null;
  120. cachedRequestServiceContexts = null;
  121. cachedReplyServiceContexts = null;
  122. startingPointCall = CALL_RECEIVE_REQUEST_SERVICE_CONTEXT;
  123. intermediatePointCall = CALL_RECEIVE_REQUEST;
  124. endingPointCall = CALL_SEND_REPLY;
  125. }
  126. /*
  127. **********************************************************************
  128. * Access protection
  129. **********************************************************************/
  130. // Method IDs for all methods in ServerRequestInfo. This allows for a
  131. // convenient O(1) lookup for checkAccess().
  132. protected static final int MID_SENDING_EXCEPTION = MID_RI_LAST + 1;
  133. protected static final int MID_OBJECT_ID = MID_RI_LAST + 2;
  134. protected static final int MID_ADAPTER_ID = MID_RI_LAST + 3;
  135. protected static final int MID_TARGET_MOST_DERIVED_INTERFACE
  136. = MID_RI_LAST + 4;
  137. protected static final int MID_GET_SERVER_POLICY = MID_RI_LAST + 5;
  138. protected static final int MID_SET_SLOT = MID_RI_LAST + 6;
  139. protected static final int MID_TARGET_IS_A = MID_RI_LAST + 7;
  140. protected static final int MID_ADD_REPLY_SERVICE_CONTEXT
  141. = MID_RI_LAST + 8;
  142. protected static final int MID_SERVER_ID = MID_RI_LAST + 9;
  143. protected static final int MID_ORB_ID = MID_RI_LAST + 10;
  144. protected static final int MID_ADAPTER_NAME = MID_RI_LAST + 11;
  145. // ServerRequestInfo validity table (see ptc/00-08-06 table 21-2).
  146. // Note: These must be in the same order as specified in contants.
  147. protected static final boolean validCall[][] = {
  148. // LEGEND:
  149. // r_rsc = receive_request_service_contexts
  150. // r_req = receive_request
  151. // s_rep = send_reply
  152. // s_exc = send_exception
  153. // s_oth = send_other
  154. //
  155. // A true value indicates call is valid at specified point.
  156. // A false value indicates the call is invalid.
  157. //
  158. // NOTE: If the order or number of columns change, update
  159. // checkAccess() accordingly.
  160. //
  161. // { r_rsc, r_req, s_rep, s_exc, s_oth }
  162. // RequestInfo methods:
  163. /*request_id*/ { true , true , true , true , true },
  164. /*operation*/ { true , true , true , true , true },
  165. /*arguments*/ { false, true , true , false, false },
  166. /*exceptions*/ { false, true , true , true , true },
  167. /*contexts*/ { false, true , true , true , true },
  168. /*operation_context*/ { false, true , true , false, false },
  169. /*result*/ { false, false, true , false, false },
  170. /*response_expected*/ { true , true , true , true , true },
  171. /*sync_scope*/ { true , true , true , true , true },
  172. /*reply_status*/ { false, false, true , true , true },
  173. /*forward_reference*/ { false, false, false, false, true },
  174. /*get_slot*/ { true , true , true , true , true },
  175. /*get_request_service_context*/ { true , true , true , true , true },
  176. /*get_reply_service_context*/ { false, false, true , true , true },
  177. //
  178. // ServerRequestInfo methods::
  179. /*sending_exception*/ { false, false, false, true , false },
  180. /*object_id*/ { false, true , true , true , true },
  181. /*adapter_id*/ { false, true , true , true , true },
  182. /*target_most_derived_inte...*/ { false, true , false, false, false },
  183. /*get_server_policy*/ { true , true , true , true , true },
  184. /*set_slot*/ { true , true , true , true , true },
  185. /*target_is_a*/ { false, true , false, false, false },
  186. /*add_reply_service_context*/ { true , true , true , true , true },
  187. /*orb_id*/ { false, true , true , true , true },
  188. /*server_id*/ { false, true , true , true , true },
  189. /*adapter_name*/ { false, true , true , true , true }
  190. };
  191. /*
  192. **********************************************************************
  193. * Public interfaces
  194. **********************************************************************/
  195. /**
  196. * Creates a new ServerRequestInfo implementation.
  197. * The constructor is package scope since no other package need create
  198. * an instance of this class.
  199. */
  200. ServerRequestInfoImpl( ORB myORB ) {
  201. super( myORB );
  202. startingPointCall = CALL_RECEIVE_REQUEST_SERVICE_CONTEXT;
  203. intermediatePointCall = CALL_RECEIVE_REQUEST;
  204. endingPointCall = CALL_SEND_REPLY;
  205. serverRequestId = myORB.getPIHandler().allocateServerRequestId();
  206. }
  207. /**
  208. * Any containing the exception to be returned to the client.
  209. */
  210. public Any sending_exception () {
  211. checkAccess( MID_SENDING_EXCEPTION );
  212. if( cachedSendingException == null ) {
  213. Any result = null ;
  214. if( dsiException != null ) {
  215. result = dsiException;
  216. } else if( exception != null ) {
  217. result = exceptionToAny( exception );
  218. } else {
  219. // sending_exception should not be callable if both dsiException
  220. // and exception are null.
  221. throw wrapper.exceptionUnavailable() ;
  222. }
  223. cachedSendingException = result;
  224. }
  225. return cachedSendingException;
  226. }
  227. /**
  228. * The opaque object_id describing the target of the operation invocation.
  229. */
  230. public byte[] object_id () {
  231. checkAccess( MID_OBJECT_ID );
  232. if( objectId == null ) {
  233. // For some reason, we never set object id. This could be
  234. // because a servant locator caused a location forward or
  235. // raised an exception. As per ptc/00-08-06, section 21.3.14,
  236. // we throw NO_RESOURCES
  237. throw stdWrapper.piOperationNotSupported6() ;
  238. }
  239. // Good citizen: In the interest of efficiency, we will assume
  240. // interceptors will not change the resulting byte[] array.
  241. // Otherwise, we would need to make a clone of this array.
  242. return objectId;
  243. }
  244. private void checkForNullTemplate()
  245. {
  246. if (oktemp == null) {
  247. // For some reason, we never set the ObjectKeyTemplate
  248. // because a servant locator caused a location forward or
  249. // raised an exception. As per ptc/00-08-06, section 21.3.14,
  250. // we throw NO_RESOURCES
  251. throw stdWrapper.piOperationNotSupported7() ;
  252. }
  253. }
  254. public String server_id()
  255. {
  256. checkAccess( MID_SERVER_ID ) ;
  257. checkForNullTemplate() ;
  258. // Good citizen: In the interest of efficiency, we will assume
  259. // interceptors will not change the resulting byte[] array.
  260. // Otherwise, we would need to make a clone of this array.
  261. return Integer.toString( oktemp.getServerId() ) ;
  262. }
  263. public String orb_id()
  264. {
  265. checkAccess( MID_ORB_ID ) ;
  266. return myORB.getORBData().getORBId() ;
  267. }
  268. synchronized public String[] adapter_name()
  269. {
  270. checkAccess( MID_ADAPTER_NAME ) ;
  271. if (adapterName == null) {
  272. checkForNullTemplate() ;
  273. ObjectAdapterId oaid = oktemp.getObjectAdapterId() ;
  274. adapterName = oaid.getAdapterName() ;
  275. }
  276. return adapterName ;
  277. }
  278. /**
  279. * The opaque identifier for the object adapter.
  280. */
  281. synchronized public byte[] adapter_id ()
  282. {
  283. checkAccess( MID_ADAPTER_ID );
  284. if( adapterId == null ) {
  285. checkForNullTemplate() ;
  286. adapterId = oktemp.getAdapterId() ;
  287. }
  288. return adapterId;
  289. }
  290. /**
  291. * The RepositoryID for the most derived interface of the servant.
  292. */
  293. public String target_most_derived_interface () {
  294. checkAccess( MID_TARGET_MOST_DERIVED_INTERFACE );
  295. return targetMostDerivedInterface;
  296. }
  297. /**
  298. * Returns the policy in effect for this operation for the given policy
  299. * type.
  300. */
  301. public Policy get_server_policy (int type) {
  302. // access is currently valid for all states:
  303. //checkAccess( MID_GET_SERVER_POLICY );
  304. Policy result = null;
  305. if( objectAdapter != null ) {
  306. result = objectAdapter.getEffectivePolicy( type );
  307. }
  308. // _REVISIT_ RTF Issue: get_server_policy spec not in sync with
  309. // get_effective_policy spec.
  310. return result;
  311. }
  312. /**
  313. * Allows an Interceptor to set a slot in the Current that is in the scope
  314. * of the request. If data already exists in that slot, it will be
  315. * overwritten. If the ID does not define an allocated slot, InvalidSlot
  316. * is raised.
  317. */
  318. public void set_slot (int id, Any data) throws InvalidSlot {
  319. // access is currently valid for all states:
  320. //checkAccess( MID_SET_SLOT );
  321. slotTable.set_slot( id, data );
  322. }
  323. /**
  324. * Returns true if the servant is the given RepositoryId, false if it is
  325. * not.
  326. */
  327. public boolean target_is_a (String id) {
  328. checkAccess( MID_TARGET_IS_A );
  329. boolean result = false ;
  330. if( servant instanceof Servant ) {
  331. result = ((Servant)servant)._is_a( id );
  332. } else if (StubAdapter.isStub( servant )) {
  333. result = ((org.omg.CORBA.Object)servant)._is_a( id );
  334. } else {
  335. throw wrapper.servantInvalid() ;
  336. }
  337. return result;
  338. }
  339. /**
  340. * Allows Interceptors to add service contexts to the request.
  341. */
  342. public void add_reply_service_context ( ServiceContext service_context,
  343. boolean replace )
  344. {
  345. // access is currently valid for all states:
  346. //checkAccess( MID_ADD_REPLY_SERVICE_CONTEXT );
  347. if( currentExecutionPoint == EXECUTION_POINT_ENDING ) {
  348. ServiceContexts scs = replyMessage.getServiceContexts();
  349. // May be null. If this is null, create a new one in its place.
  350. if( scs == null ) {
  351. scs = new ServiceContexts( myORB );
  352. replyMessage.setServiceContexts( scs );
  353. }
  354. if( cachedReplyServiceContexts == null ) {
  355. cachedReplyServiceContexts = new HashMap();
  356. }
  357. // This is during and ending point, so we now have enough
  358. // information to add the reply service context.
  359. addServiceContext( cachedReplyServiceContexts, scs,
  360. service_context, replace );
  361. }
  362. // We enqueue all adds for the following reasons:
  363. //
  364. // If we are not in the ending point then we do not yet have a
  365. // pointer to the ServiceContexts object so we cannot access the
  366. // service contexts until we get to the ending point.
  367. // So we enqueue this add reply service context request.
  368. // It is added when we do have a handle on the service contexts object.
  369. //
  370. // If we are in the ending point and we just add directly to the
  371. // SC container but then an interceptor raises a SystemException
  372. // then that add will be lost since a new container is created
  373. // for the SystemException response.
  374. //
  375. // Therefore we always enqueue and never dequeue (per request) so
  376. // that all adds will be completed.
  377. AddReplyServiceContextCommand addReply =
  378. new AddReplyServiceContextCommand();
  379. addReply.service_context = service_context;
  380. addReply.replace = replace;
  381. if( addReplyServiceContextQueue == null ) {
  382. addReplyServiceContextQueue = new ArrayList();
  383. }
  384. // REVISIT: this does not add to the cache.
  385. enqueue( addReply );
  386. }
  387. // NOTE: When adding a method, be sure to:
  388. // 1. Add a MID_* constant for that method
  389. // 2. Call checkAccess at the start of the method
  390. // 3. Define entries in the validCall[][] table for interception points.
  391. /*
  392. **********************************************************************
  393. * Public RequestInfo interfaces
  394. *
  395. * These are implemented here because they have differing
  396. * implementations depending on whether this is a client or a server
  397. * request info object.
  398. **********************************************************************/
  399. /**
  400. * See ServerRequestInfo for javadocs.
  401. */
  402. public int request_id (){
  403. // access is currently valid for all states:
  404. //checkAccess( MID_REQUEST_ID );
  405. /*
  406. * NOTE: The request id in server interceptors is NOT the
  407. * same as the GIOP request id. The ORB may be servicing several
  408. * connections, each with possibly overlapping sets of request ids.
  409. * Therefore we create a request id specific to interceptors.
  410. */
  411. return serverRequestId;
  412. }
  413. /**
  414. * See ServerRequestInfo for javadocs.
  415. */
  416. public String operation (){
  417. // access is currently valid for all states:
  418. //checkAccess( MID_OPERATION );
  419. return request.getOperationName();
  420. }
  421. /**
  422. * See ServerRequestInfo for javadocs.
  423. */
  424. public Parameter[] arguments (){
  425. checkAccess( MID_ARGUMENTS );
  426. if( cachedArguments == null ) {
  427. if( !isDynamic ) {
  428. throw stdWrapper.piOperationNotSupported1() ;
  429. }
  430. if( dsiArguments == null ) {
  431. throw stdWrapper.piOperationNotSupported8() ;
  432. }
  433. // If it is a DSI request then get the arguments from the DSI req
  434. // and convert that into parameters.
  435. cachedArguments = nvListToParameterArray( dsiArguments );
  436. }
  437. // Good citizen: In the interest of efficiency, we assume
  438. // interceptors will be "good citizens" in that they will not
  439. // modify the contents of the Parameter[] array. We also assume
  440. // they will not change the values of the containing Anys.
  441. return cachedArguments;
  442. }
  443. /**
  444. * See ServerRequestInfo for javadocs.
  445. */
  446. public TypeCode[] exceptions (){
  447. checkAccess( MID_EXCEPTIONS );
  448. // _REVISIT_ PI RTF Issue: No exception list on server side.
  449. throw stdWrapper.piOperationNotSupported2() ;
  450. }
  451. /**
  452. * See ServerRequestInfo for javadocs.
  453. */
  454. public String[] contexts (){
  455. checkAccess( MID_CONTEXTS );
  456. // We do not support this because our ORB does not send contexts.
  457. throw stdWrapper.piOperationNotSupported3() ;
  458. }
  459. /**
  460. * See ServerRequestInfo for javadocs.
  461. */
  462. public String[] operation_context (){
  463. checkAccess( MID_OPERATION_CONTEXT );
  464. // We do not support this because our ORB does not send
  465. // operation_context.
  466. throw stdWrapper.piOperationNotSupported4() ;
  467. }
  468. /**
  469. * See ServerRequestInfo for javadocs.
  470. */
  471. public Any result (){
  472. checkAccess( MID_RESULT );
  473. if( !isDynamic ) {
  474. throw stdWrapper.piOperationNotSupported5() ;
  475. }
  476. if( dsiResult == null ) {
  477. throw wrapper.piDsiResultIsNull() ;
  478. }
  479. // Good citizen: In the interest of efficiency, we assume that
  480. // interceptors will not modify the contents of the result Any.
  481. // Otherwise, we would need to create a deep copy of the Any.
  482. return dsiResult;
  483. }
  484. /**
  485. * See ServerRequestInfo for javadocs.
  486. */
  487. public boolean response_expected (){
  488. // access is currently valid for all states:
  489. //checkAccess( MID_RESPONSE_EXPECTED );
  490. return !request.isOneWay();
  491. }
  492. /**
  493. * See ServerRequestInfo for javadocs.
  494. */
  495. public Object forward_reference (){
  496. checkAccess( MID_FORWARD_REFERENCE );
  497. // Check to make sure we are in LOCATION_FORWARD
  498. // state as per ptc/00-08-06, table 21-2
  499. // footnote 2.
  500. if( replyStatus != LOCATION_FORWARD.value ) {
  501. throw stdWrapper.invalidPiCall1() ;
  502. }
  503. return getForwardRequestException().forward;
  504. }
  505. /**
  506. * See ServerRequestInfo for javadocs.
  507. */
  508. public org.omg.IOP.ServiceContext get_request_service_context( int id ) {
  509. checkAccess( MID_GET_REQUEST_SERVICE_CONTEXT );
  510. if( cachedRequestServiceContexts == null ) {
  511. cachedRequestServiceContexts = new HashMap();
  512. }
  513. return getServiceContext( cachedRequestServiceContexts,
  514. request.getRequestServiceContexts(), id );
  515. }
  516. /**
  517. * See ServerRequestInfo for javadocs.
  518. */
  519. public org.omg.IOP.ServiceContext get_reply_service_context( int id ) {
  520. checkAccess( MID_GET_REPLY_SERVICE_CONTEXT );
  521. if( cachedReplyServiceContexts == null ) {
  522. cachedReplyServiceContexts = new HashMap();
  523. }
  524. return getServiceContext( cachedReplyServiceContexts,
  525. replyMessage.getServiceContexts(), id );
  526. }
  527. /*
  528. **********************************************************************
  529. * Private-scope classes and methods
  530. **********************************************************************/
  531. // A command encapsulating a request to add a reply service context.
  532. // These commands are enqueued until we have a handle on the actual
  533. // reply service context, at which point they are executed.
  534. private class AddReplyServiceContextCommand {
  535. ServiceContext service_context;
  536. boolean replace;
  537. }
  538. // Adds the given add reply service context command to the queue of
  539. // such commands. If a command is detected to have the same id as
  540. // the service context in this command, and replace is false,
  541. // BAD_INV_ORDER is thrown. If replace is true, the original command
  542. // in the queue is replaced by this command.
  543. private void enqueue( AddReplyServiceContextCommand addReply ) {
  544. int size = addReplyServiceContextQueue.size();
  545. boolean found = false;
  546. for( int i = 0; i < size; i++ ) {
  547. AddReplyServiceContextCommand cmd =
  548. (AddReplyServiceContextCommand)
  549. addReplyServiceContextQueue.get( i );
  550. if( cmd.service_context.context_id ==
  551. addReply.service_context.context_id )
  552. {
  553. found = true;
  554. if( addReply.replace ) {
  555. addReplyServiceContextQueue.set( i, addReply );
  556. } else {
  557. throw stdWrapper.serviceContextAddFailed(
  558. new Integer( cmd.service_context.context_id ) ) ;
  559. }
  560. break;
  561. }
  562. }
  563. if( !found ) {
  564. addReplyServiceContextQueue.add( addReply );
  565. }
  566. }
  567. /*
  568. **********************************************************************
  569. * Package and protected-scope methods
  570. **********************************************************************/
  571. /**
  572. * Overridden from RequestInfoImpl. This version calls the super
  573. * and then, if we are changing to ending points, executes all
  574. * enqueued AddReplyServiceContextCommands.
  575. */
  576. protected void setCurrentExecutionPoint( int executionPoint ) {
  577. super.setCurrentExecutionPoint( executionPoint );
  578. // If we are transitioning to ending point, we will now have a pointer
  579. // to the reply service contexts, so we can execute all queued
  580. // add reply service context requests.
  581. if( (executionPoint == EXECUTION_POINT_ENDING) &&
  582. (addReplyServiceContextQueue != null) )
  583. {
  584. int size = addReplyServiceContextQueue.size();
  585. for( int i = 0; i < size; i++ ) {
  586. AddReplyServiceContextCommand addReply =
  587. (AddReplyServiceContextCommand)
  588. addReplyServiceContextQueue.get( i );
  589. try {
  590. add_reply_service_context( addReply.service_context,
  591. addReply.replace );
  592. }
  593. catch( BAD_INV_ORDER e ) {
  594. // _REVISIT_ The only way this can happen is if during
  595. // rrsc or rr, the interceptor tried to add with
  596. // replace=false to a service context that is present in
  597. // the reply message. At that time there was no way for
  598. // us to check for this, so the best we can do is ignore
  599. // the original request.
  600. }
  601. }
  602. // We specifically do not empty the SC queue so that if
  603. // the interceptor raises an exception the queued service contexts
  604. // will be put in the exception response.
  605. }
  606. }
  607. /**
  608. * Stores the various sources of information used for this info object.
  609. */
  610. protected void setInfo( CorbaMessageMediator request, ObjectAdapter oa,
  611. byte[] objectId, ObjectKeyTemplate oktemp )
  612. {
  613. this.request = request;
  614. this.objectId = objectId;
  615. this.oktemp = oktemp;
  616. this.objectAdapter = oa ;
  617. this.connection = (com.sun.corba.se.spi.legacy.connection.Connection)
  618. request.getConnection();
  619. }
  620. /**
  621. * Stores the various sources of information used for this info object.
  622. */
  623. protected void setDSIArguments( NVList arguments ) {
  624. this.dsiArguments = arguments;
  625. }
  626. /**
  627. * Stores the various sources of information used for this info object.
  628. */
  629. protected void setDSIException( Any exception ) {
  630. this.dsiException = exception;
  631. // Clear cached exception value:
  632. cachedSendingException = null;
  633. }
  634. /**
  635. * Stores the various sources of information used for this info object.
  636. */
  637. protected void setDSIResult( Any result ) {
  638. this.dsiResult = result;
  639. }
  640. /**
  641. * Sets the exception to be returned by received_exception and
  642. * received_exception_id.
  643. */
  644. protected void setException( Exception exception ) {
  645. super.setException( exception );
  646. // Make sure DSIException is null because this is the more recent one.
  647. this.dsiException = null;
  648. // Clear cached exception value:
  649. cachedSendingException = null;
  650. }
  651. /**
  652. * Stores the various sources of information used for this info object.
  653. */
  654. protected void setInfo( java.lang.Object servant,
  655. String targetMostDerivedInterface )
  656. {
  657. this.servant = servant;
  658. this.targetMostDerivedInterface = targetMostDerivedInterface;
  659. this.isDynamic =
  660. (servant instanceof
  661. org.omg.PortableServer.DynamicImplementation) ||
  662. (servant instanceof org.omg.CORBA.DynamicImplementation);
  663. }
  664. /**
  665. * Set reply message
  666. */
  667. void setReplyMessage( ReplyMessage replyMessage ) {
  668. this.replyMessage = replyMessage;
  669. }
  670. /**
  671. * Overridden from RequestInfoImpl. Calls the super class, then
  672. * sets the ending point call depending on the reply status.
  673. */
  674. protected void setReplyStatus( short replyStatus ) {
  675. super.setReplyStatus( replyStatus );
  676. switch( replyStatus ) {
  677. case SUCCESSFUL.value:
  678. endingPointCall = CALL_SEND_REPLY;
  679. break;
  680. case SYSTEM_EXCEPTION.value:
  681. case USER_EXCEPTION.value:
  682. endingPointCall = CALL_SEND_EXCEPTION;
  683. break;
  684. case LOCATION_FORWARD.value:
  685. case TRANSPORT_RETRY.value:
  686. endingPointCall = CALL_SEND_OTHER;
  687. break;
  688. }
  689. }
  690. /**
  691. * Release the servant object so the user has control over its lifetime.
  692. * Called after receive_request is finished executing.
  693. */
  694. void releaseServant() {
  695. this.servant = null;
  696. }
  697. /**
  698. * Sets the forwardRequestRaisedInEnding flag to true, indicating that
  699. * a server ending point has raised location forward at some point.
  700. */
  701. void setForwardRequestRaisedInEnding() {
  702. this.forwardRequestRaisedInEnding = true;
  703. }
  704. /**
  705. * Returns true if ForwardRequest was raised by a server ending point
  706. * or false otherwise.
  707. */
  708. boolean isForwardRequestRaisedInEnding() {
  709. return this.forwardRequestRaisedInEnding;
  710. }
  711. /**
  712. * Returns true if this is a dynamic invocation, or false if not
  713. */
  714. boolean isDynamic() {
  715. return this.isDynamic;
  716. }
  717. /**
  718. * See description for RequestInfoImpl.checkAccess
  719. */
  720. protected void checkAccess( int methodID )
  721. {
  722. // Make sure currentPoint matches the appropriate index in the
  723. // validCall table:
  724. int validCallIndex = 0;
  725. switch( currentExecutionPoint ) {
  726. case EXECUTION_POINT_STARTING:
  727. validCallIndex = 0;
  728. break;
  729. case EXECUTION_POINT_INTERMEDIATE:
  730. validCallIndex = 1;
  731. break;
  732. case EXECUTION_POINT_ENDING:
  733. switch( endingPointCall ) {
  734. case CALL_SEND_REPLY:
  735. validCallIndex = 2;
  736. break;
  737. case CALL_SEND_EXCEPTION:
  738. validCallIndex = 3;
  739. break;
  740. case CALL_SEND_OTHER:
  741. validCallIndex = 4;
  742. break;
  743. }
  744. break;
  745. }
  746. // Check the validCall table:
  747. if( !validCall[methodID][validCallIndex] ) {
  748. throw stdWrapper.invalidPiCall2() ;
  749. }
  750. }
  751. }