KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > interceptors > ServerRequestInfoImpl


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              
9 import org.omg.CORBA.Any JavaDoc;
10 import org.omg.CORBA.BAD_INV_ORDER JavaDoc;
11 import org.omg.CORBA.CompletionStatus JavaDoc;
12 import org.omg.CORBA.INTERNAL JavaDoc;
13 import org.omg.CORBA.LocalObject JavaDoc;
14 import org.omg.CORBA.NO_IMPLEMENT JavaDoc;
15 import org.omg.CORBA.NO_RESOURCES JavaDoc;
16 import org.omg.CORBA.NVList JavaDoc;
17 import org.omg.CORBA.Object JavaDoc;
18 import org.omg.CORBA.Policy JavaDoc;
19 import org.omg.CORBA.TypeCode JavaDoc;
20
21 import org.omg.PortableServer.Servant JavaDoc;
22
23 import org.omg.IOP.TaggedProfile JavaDoc;
24 import org.omg.IOP.ServiceContext JavaDoc;
25
26 import org.omg.Dynamic.Parameter JavaDoc;
27
28 import org.omg.PortableInterceptor.InvalidSlot JavaDoc;
29 import org.omg.PortableInterceptor.ServerRequestInfo JavaDoc;
30 import org.omg.PortableInterceptor.LOCATION_FORWARD JavaDoc;
31 import org.omg.PortableInterceptor.SUCCESSFUL JavaDoc;
32 import org.omg.PortableInterceptor.SYSTEM_EXCEPTION JavaDoc;
33 import org.omg.PortableInterceptor.TRANSPORT_RETRY JavaDoc;
34 import org.omg.PortableInterceptor.USER_EXCEPTION JavaDoc;
35
36 import com.sun.corba.se.spi.oa.ObjectAdapter;
37 import com.sun.corba.se.spi.presentation.rmi.StubAdapter;
38
39 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
40
41 import com.sun.corba.se.spi.servicecontext.ServiceContexts;
42 import com.sun.corba.se.spi.orb.ORB;
43
44 import com.sun.corba.se.spi.ior.ObjectKeyTemplate;
45 import com.sun.corba.se.spi.ior.ObjectAdapterId ;
46
47 import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
48
49 import java.util.*;
50
51 /**
52  * Implementation of the ServerRequestInfo interface as specified in
53  * orbos/99-12-02 section 5.4.3.
54  */

55 public final class ServerRequestInfoImpl
56     extends RequestInfoImpl
57     implements ServerRequestInfo JavaDoc
58 {
59     // The available constants for startingPointCall
60
static final int CALL_RECEIVE_REQUEST_SERVICE_CONTEXT = 0;
61     
62     // The available constants for intermediatePointCall. The default (0)
63
// is receive_request, but can be set to none on demand.
64
static final int CALL_RECEIVE_REQUEST = 0;
65     static final int CALL_INTERMEDIATE_NONE = 1;
66     
67     // The available constants for endingPointCall
68
static final int CALL_SEND_REPLY = 0;
69     static final int CALL_SEND_EXCEPTION = 1;
70     static final int CALL_SEND_OTHER = 2;
71
72     //////////////////////////////////////////////////////////////////////
73
//
74
// NOTE: IF AN ATTRIBUTE IS ADDED, PLEASE UPDATE RESET();
75
//
76
//////////////////////////////////////////////////////////////////////
77

78     // Set to true if the server ending point raised ForwardRequest at some
79
// point in the ending point.
80
private boolean forwardRequestRaisedInEnding;
81
82     // Sources of server request information:
83
private CorbaMessageMediator request;
84     private java.lang.Object JavaDoc servant;
85     private byte[] objectId;
86     private ObjectKeyTemplate oktemp ;
87
88     // Information cached from calls to oktemp
89
private byte[] adapterId;
90     private String JavaDoc[] adapterName;
91
92     private ArrayList addReplyServiceContextQueue;
93     private ReplyMessage replyMessage;
94     private String JavaDoc targetMostDerivedInterface;
95     private NVList JavaDoc dsiArguments;
96     private Any JavaDoc dsiResult;
97     private Any JavaDoc dsiException;
98     private boolean isDynamic;
99     private ObjectAdapter objectAdapter;
100     private int serverRequestId;
101
102     // Cached information:
103
private Parameter JavaDoc[] cachedArguments;
104     private Any JavaDoc cachedSendingException;
105     // key = Integer, value = IOP.ServiceContext.
106
private HashMap cachedRequestServiceContexts;
107     // key = Integer, value = IOP.ServiceContext.
108
private HashMap cachedReplyServiceContexts;
109     
110     //////////////////////////////////////////////////////////////////////
111
//
112
// NOTE: IF AN ATTRIBUTE IS ADDED, PLEASE UPDATE RESET();
113
//
114
//////////////////////////////////////////////////////////////////////
115

116
117     /**
118      * Reset the info object so that it can be reused for a retry,
119      * for example.
120      */

121     void reset() {
122         super.reset();
123
124         // Please keep these in the same order as declared above.
125

126         forwardRequestRaisedInEnding = false;
127
128         request = null;
129     servant = null;
130     objectId = null;
131     oktemp = null;
132
133     adapterId = null;
134     adapterName = null;
135
136     addReplyServiceContextQueue = null;
137     replyMessage = null;
138     targetMostDerivedInterface = null;
139     dsiArguments = null;
140     dsiResult = null;
141     dsiException = null;
142     isDynamic = false;
143     objectAdapter = null;
144     serverRequestId = myORB.getPIHandler().allocateServerRequestId();
145
146     // reset cached attributes:
147
cachedArguments = null;
148     cachedSendingException = null;
149     cachedRequestServiceContexts = null;
150     cachedReplyServiceContexts = null;
151
152         startingPointCall = CALL_RECEIVE_REQUEST_SERVICE_CONTEXT;
153         intermediatePointCall = CALL_RECEIVE_REQUEST;
154         endingPointCall = CALL_SEND_REPLY;
155     }
156     
157     /*
158      **********************************************************************
159      * Access protection
160      **********************************************************************/

161
162     // Method IDs for all methods in ServerRequestInfo. This allows for a
163
// convenient O(1) lookup for checkAccess().
164
protected static final int MID_SENDING_EXCEPTION = MID_RI_LAST + 1;
165     protected static final int MID_OBJECT_ID = MID_RI_LAST + 2;
166     protected static final int MID_ADAPTER_ID = MID_RI_LAST + 3;
167     protected static final int MID_TARGET_MOST_DERIVED_INTERFACE
168                                                            = MID_RI_LAST + 4;
169     protected static final int MID_GET_SERVER_POLICY = MID_RI_LAST + 5;
170     protected static final int MID_SET_SLOT = MID_RI_LAST + 6;
171     protected static final int MID_TARGET_IS_A = MID_RI_LAST + 7;
172     protected static final int MID_ADD_REPLY_SERVICE_CONTEXT
173                                                            = MID_RI_LAST + 8;
174     protected static final int MID_SERVER_ID = MID_RI_LAST + 9;
175     protected static final int MID_ORB_ID = MID_RI_LAST + 10;
176     protected static final int MID_ADAPTER_NAME = MID_RI_LAST + 11;
177     
178     // ServerRequestInfo validity table (see ptc/00-08-06 table 21-2).
179
// Note: These must be in the same order as specified in contants.
180
protected static final boolean validCall[][] = {
181         // LEGEND:
182
// r_rsc = receive_request_service_contexts
183
// r_req = receive_request
184
// s_rep = send_reply
185
// s_exc = send_exception
186
// s_oth = send_other
187
//
188
// A true value indicates call is valid at specified point.
189
// A false value indicates the call is invalid.
190
//
191
// NOTE: If the order or number of columns change, update
192
// checkAccess() accordingly.
193
//
194
// { r_rsc, r_req, s_rep, s_exc, s_oth }
195
// RequestInfo methods:
196
/*request_id*/ { true , true , true , true , true },
197         /*operation*/ { true , true , true , true , true },
198         /*arguments*/ { false, true , true , false, false },
199         /*exceptions*/ { false, true , true , true , true },
200         /*contexts*/ { false, true , true , true , true },
201         /*operation_context*/ { false, true , true , false, false },
202         /*result*/ { false, false, true , false, false },
203         /*response_expected*/ { true , true , true , true , true },
204         /*sync_scope*/ { true , true , true , true , true },
205         /*reply_status*/ { false, false, true , true , true },
206         /*forward_reference*/ { false, false, false, false, true },
207         /*get_slot*/ { true , true , true , true , true },
208         /*get_request_service_context*/ { true , true , true , true , true },
209         /*get_reply_service_context*/ { false, false, true , true , true },
210         //
211
// ServerRequestInfo methods::
212
/*sending_exception*/ { false, false, false, true , false },
213         /*object_id*/ { false, true , true , true , true },
214         /*adapter_id*/ { false, true , true , true , true },
215         /*target_most_derived_inte...*/ { false, true , false, false, false },
216         /*get_server_policy*/ { true , true , true , true , true },
217         /*set_slot*/ { true , true , true , true , true },
218         /*target_is_a*/ { false, true , false, false, false },
219         /*add_reply_service_context*/ { true , true , true , true , true },
220         /*orb_id*/ { false, true , true , true , true },
221         /*server_id*/ { false, true , true , true , true },
222         /*adapter_name*/ { false, true , true , true , true }
223     };
224     
225     /*
226      **********************************************************************
227      * Public interfaces
228      **********************************************************************/

229     
230     /**
231      * Creates a new ServerRequestInfo implementation.
232      * The constructor is package scope since no other package need create
233      * an instance of this class.
234      */

235     ServerRequestInfoImpl( ORB myORB ) {
236         super( myORB );
237         startingPointCall = CALL_RECEIVE_REQUEST_SERVICE_CONTEXT;
238         intermediatePointCall = CALL_RECEIVE_REQUEST;
239         endingPointCall = CALL_SEND_REPLY;
240     serverRequestId = myORB.getPIHandler().allocateServerRequestId();
241     }
242     
243     /**
244      * Any containing the exception to be returned to the client.
245      */

246     public Any JavaDoc sending_exception () {
247         checkAccess( MID_SENDING_EXCEPTION );
248
249     if( cachedSendingException == null ) {
250         Any JavaDoc result = null ;
251
252         if( dsiException != null ) {
253         result = dsiException;
254         } else if( exception != null ) {
255         result = exceptionToAny( exception );
256         } else {
257         // sending_exception should not be callable if both dsiException
258
// and exception are null.
259
throw wrapper.exceptionUnavailable() ;
260         }
261
262         cachedSendingException = result;
263     }
264
265     return cachedSendingException;
266     }
267     
268     /**
269      * The opaque object_id describing the target of the operation invocation.
270      */

271     public byte[] object_id () {
272         checkAccess( MID_OBJECT_ID );
273
274     if( objectId == null ) {
275         // For some reason, we never set object id. This could be
276
// because a servant locator caused a location forward or
277
// raised an exception. As per ptc/00-08-06, section 21.3.14,
278
// we throw NO_RESOURCES
279
throw stdWrapper.piOperationNotSupported6() ;
280     }
281
282     // Good citizen: In the interest of efficiency, we will assume
283
// interceptors will not change the resulting byte[] array.
284
// Otherwise, we would need to make a clone of this array.
285

286     return objectId;
287     }
288
289     private void checkForNullTemplate()
290     {
291     if (oktemp == null) {
292         // For some reason, we never set the ObjectKeyTemplate
293
// because a servant locator caused a location forward or
294
// raised an exception. As per ptc/00-08-06, section 21.3.14,
295
// we throw NO_RESOURCES
296
throw stdWrapper.piOperationNotSupported7() ;
297     }
298     }
299     
300     public String JavaDoc server_id()
301     {
302     checkAccess( MID_SERVER_ID ) ;
303     checkForNullTemplate() ;
304
305     // Good citizen: In the interest of efficiency, we will assume
306
// interceptors will not change the resulting byte[] array.
307
// Otherwise, we would need to make a clone of this array.
308

309     return Integer.toString( oktemp.getServerId() ) ;
310     }
311
312     public String JavaDoc orb_id()
313     {
314     checkAccess( MID_ORB_ID ) ;
315
316     return myORB.getORBData().getORBId() ;
317     }
318
319     synchronized public String JavaDoc[] adapter_name()
320     {
321     checkAccess( MID_ADAPTER_NAME ) ;
322
323     if (adapterName == null) {
324         checkForNullTemplate() ;
325
326         ObjectAdapterId oaid = oktemp.getObjectAdapterId() ;
327         adapterName = oaid.getAdapterName() ;
328     }
329
330     return adapterName ;
331     }
332
333     /**
334      * The opaque identifier for the object adapter.
335      */

336     synchronized public byte[] adapter_id ()
337     {
338         checkAccess( MID_ADAPTER_ID );
339
340     if( adapterId == null ) {
341         checkForNullTemplate() ;
342         adapterId = oktemp.getAdapterId() ;
343     }
344
345     return adapterId;
346     }
347     
348     /**
349      * The RepositoryID for the most derived interface of the servant.
350      */

351     public String JavaDoc target_most_derived_interface () {
352         checkAccess( MID_TARGET_MOST_DERIVED_INTERFACE );
353     return targetMostDerivedInterface;
354     }
355     
356     /**
357      * Returns the policy in effect for this operation for the given policy
358      * type.
359      */

360     public Policy JavaDoc get_server_policy (int type) {
361     // access is currently valid for all states:
362
//checkAccess( MID_GET_SERVER_POLICY );
363

364     Policy JavaDoc result = null;
365
366     if( objectAdapter != null ) {
367         result = objectAdapter.getEffectivePolicy( type );
368     }
369
370     // _REVISIT_ RTF Issue: get_server_policy spec not in sync with
371
// get_effective_policy spec.
372

373     return result;
374     }
375     
376     /**
377      * Allows an Interceptor to set a slot in the Current that is in the scope
378      * of the request. If data already exists in that slot, it will be
379      * overwritten. If the ID does not define an allocated slot, InvalidSlot
380      * is raised.
381      */

382     public void set_slot (int id, Any JavaDoc data) throws InvalidSlot JavaDoc {
383     // access is currently valid for all states:
384
//checkAccess( MID_SET_SLOT );
385

386         slotTable.set_slot( id, data );
387     }
388     
389     /**
390      * Returns true if the servant is the given RepositoryId, false if it is
391      * not.
392      */

393     public boolean target_is_a (String JavaDoc id) {
394         checkAccess( MID_TARGET_IS_A );
395
396     boolean result = false ;
397     if( servant instanceof Servant JavaDoc ) {
398         result = ((Servant JavaDoc)servant)._is_a( id );
399     } else if (StubAdapter.isStub( servant )) {
400         result = ((org.omg.CORBA.Object JavaDoc)servant)._is_a( id );
401     } else {
402         throw wrapper.servantInvalid() ;
403     }
404
405     return result;
406     }
407     
408     /**
409      * Allows Interceptors to add service contexts to the request.
410      */

411     public void add_reply_service_context ( ServiceContext JavaDoc service_context,
412                                             boolean replace )
413     {
414     // access is currently valid for all states:
415
//checkAccess( MID_ADD_REPLY_SERVICE_CONTEXT );
416

417         if( currentExecutionPoint == EXECUTION_POINT_ENDING ) {
418         ServiceContexts scs = replyMessage.getServiceContexts();
419
420         // May be null. If this is null, create a new one in its place.
421
if( scs == null ) {
422         scs = new ServiceContexts( myORB );
423         replyMessage.setServiceContexts( scs );
424         }
425
426         if( cachedReplyServiceContexts == null ) {
427         cachedReplyServiceContexts = new HashMap();
428         }
429
430         // This is during and ending point, so we now have enough
431
// information to add the reply service context.
432
addServiceContext( cachedReplyServiceContexts, scs,
433                    service_context, replace );
434     }
435
436     // We enqueue all adds for the following reasons:
437
//
438
// If we are not in the ending point then we do not yet have a
439
// pointer to the ServiceContexts object so we cannot access the
440
// service contexts until we get to the ending point.
441
// So we enqueue this add reply service context request.
442
// It is added when we do have a handle on the service contexts object.
443
//
444
// If we are in the ending point and we just add directly to the
445
// SC container but then an interceptor raises a SystemException
446
// then that add will be lost since a new container is created
447
// for the SystemException response.
448
//
449
// Therefore we always enqueue and never dequeue (per request) so
450
// that all adds will be completed.
451

452     AddReplyServiceContextCommand addReply =
453         new AddReplyServiceContextCommand();
454     addReply.service_context = service_context;
455     addReply.replace = replace;
456
457     if( addReplyServiceContextQueue == null ) {
458         addReplyServiceContextQueue = new ArrayList();
459     }
460
461     // REVISIT: this does not add to the cache.
462
enqueue( addReply );
463     }
464
465     // NOTE: When adding a method, be sure to:
466
// 1. Add a MID_* constant for that method
467
// 2. Call checkAccess at the start of the method
468
// 3. Define entries in the validCall[][] table for interception points.
469

470     /*
471      **********************************************************************
472      * Public RequestInfo interfaces
473      *
474      * These are implemented here because they have differing
475      * implementations depending on whether this is a client or a server
476      * request info object.
477      **********************************************************************/

478
479     /**
480      * See ServerRequestInfo for javadocs.
481      */

482     public int request_id (){
483         // access is currently valid for all states:
484
//checkAccess( MID_REQUEST_ID );
485
/*
486      * NOTE: The request id in server interceptors is NOT the
487      * same as the GIOP request id. The ORB may be servicing several
488      * connections, each with possibly overlapping sets of request ids.
489      * Therefore we create a request id specific to interceptors.
490      */

491         return serverRequestId;
492     }
493
494     /**
495      * See ServerRequestInfo for javadocs.
496      */

497     public String JavaDoc operation (){
498         // access is currently valid for all states:
499
//checkAccess( MID_OPERATION );
500
return request.getOperationName();
501     }
502
503     /**
504      * See ServerRequestInfo for javadocs.
505      */

506     public Parameter JavaDoc[] arguments (){
507         checkAccess( MID_ARGUMENTS );
508
509     if( cachedArguments == null ) {
510         if( !isDynamic ) {
511         throw stdWrapper.piOperationNotSupported1() ;
512         }
513
514         if( dsiArguments == null ) {
515         throw stdWrapper.piOperationNotSupported8() ;
516         }
517
518         // If it is a DSI request then get the arguments from the DSI req
519
// and convert that into parameters.
520
cachedArguments = nvListToParameterArray( dsiArguments );
521     }
522
523         // Good citizen: In the interest of efficiency, we assume
524
// interceptors will be "good citizens" in that they will not
525
// modify the contents of the Parameter[] array. We also assume
526
// they will not change the values of the containing Anys.
527

528     return cachedArguments;
529     }
530
531     /**
532      * See ServerRequestInfo for javadocs.
533      */

534     public TypeCode JavaDoc[] exceptions (){
535         checkAccess( MID_EXCEPTIONS );
536
537     // _REVISIT_ PI RTF Issue: No exception list on server side.
538

539     throw stdWrapper.piOperationNotSupported2() ;
540     }
541
542     /**
543      * See ServerRequestInfo for javadocs.
544      */

545     public String JavaDoc[] contexts (){
546         checkAccess( MID_CONTEXTS );
547
548     // We do not support this because our ORB does not send contexts.
549

550     throw stdWrapper.piOperationNotSupported3() ;
551     }
552
553     /**
554      * See ServerRequestInfo for javadocs.
555      */

556     public String JavaDoc[] operation_context (){
557         checkAccess( MID_OPERATION_CONTEXT );
558
559     // We do not support this because our ORB does not send
560
// operation_context.
561

562     throw stdWrapper.piOperationNotSupported4() ;
563     }
564
565     /**
566      * See ServerRequestInfo for javadocs.
567      */

568     public Any JavaDoc result (){
569         checkAccess( MID_RESULT );
570
571     if( !isDynamic ) {
572         throw stdWrapper.piOperationNotSupported5() ;
573     }
574
575     if( dsiResult == null ) {
576         throw wrapper.piDsiResultIsNull() ;
577     }
578
579     // Good citizen: In the interest of efficiency, we assume that
580
// interceptors will not modify the contents of the result Any.
581
// Otherwise, we would need to create a deep copy of the Any.
582

583     return dsiResult;
584     }
585
586     /**
587      * See ServerRequestInfo for javadocs.
588      */

589     public boolean response_expected (){
590         // access is currently valid for all states:
591
//checkAccess( MID_RESPONSE_EXPECTED );
592
return !request.isOneWay();
593     }
594
595     /**
596      * See ServerRequestInfo for javadocs.
597      */

598     public Object JavaDoc forward_reference (){
599         checkAccess( MID_FORWARD_REFERENCE );
600         // Check to make sure we are in LOCATION_FORWARD
601
// state as per ptc/00-08-06, table 21-2
602
// footnote 2.
603
if( replyStatus != LOCATION_FORWARD.value ) {
604         throw stdWrapper.invalidPiCall1() ;
605         }
606
607     return getForwardRequestException().forward;
608     }
609
610     /**
611      * See ServerRequestInfo for javadocs.
612      */

613     public org.omg.IOP.ServiceContext JavaDoc get_request_service_context( int id ) {
614         checkAccess( MID_GET_REQUEST_SERVICE_CONTEXT );
615
616     if( cachedRequestServiceContexts == null ) {
617         cachedRequestServiceContexts = new HashMap();
618     }
619
620     return getServiceContext( cachedRequestServiceContexts,
621                   request.getRequestServiceContexts(), id );
622     }
623
624     /**
625      * See ServerRequestInfo for javadocs.
626      */

627     public org.omg.IOP.ServiceContext JavaDoc get_reply_service_context( int id ) {
628         checkAccess( MID_GET_REPLY_SERVICE_CONTEXT );
629
630     if( cachedReplyServiceContexts == null ) {
631         cachedReplyServiceContexts = new HashMap();
632     }
633
634         return getServiceContext( cachedReplyServiceContexts,
635                   replyMessage.getServiceContexts(), id );
636     }
637
638     /*
639      **********************************************************************
640      * Private-scope classes and methods
641      **********************************************************************/

642
643     // A command encapsulating a request to add a reply service context.
644
// These commands are enqueued until we have a handle on the actual
645
// reply service context, at which point they are executed.
646
private class AddReplyServiceContextCommand {
647     ServiceContext JavaDoc service_context;
648     boolean replace;
649     }
650
651     // Adds the given add reply service context command to the queue of
652
// such commands. If a command is detected to have the same id as
653
// the service context in this command, and replace is false,
654
// BAD_INV_ORDER is thrown. If replace is true, the original command
655
// in the queue is replaced by this command.
656
private void enqueue( AddReplyServiceContextCommand addReply ) {
657     int size = addReplyServiceContextQueue.size();
658     boolean found = false;
659
660     for( int i = 0; i < size; i++ ) {
661         AddReplyServiceContextCommand cmd =
662         (AddReplyServiceContextCommand)
663         addReplyServiceContextQueue.get( i );
664
665         if( cmd.service_context.context_id ==
666         addReply.service_context.context_id )
667         {
668         found = true;
669         if( addReply.replace ) {
670             addReplyServiceContextQueue.set( i, addReply );
671         } else {
672             throw stdWrapper.serviceContextAddFailed(
673             new Integer JavaDoc( cmd.service_context.context_id ) ) ;
674         }
675         break;
676         }
677     }
678
679     if( !found ) {
680         addReplyServiceContextQueue.add( addReply );
681     }
682     }
683
684     /*
685      **********************************************************************
686      * Package and protected-scope methods
687      **********************************************************************/

688
689     /**
690      * Overridden from RequestInfoImpl. This version calls the super
691      * and then, if we are changing to ending points, executes all
692      * enqueued AddReplyServiceContextCommands.
693      */

694     protected void setCurrentExecutionPoint( int executionPoint ) {
695     super.setCurrentExecutionPoint( executionPoint );
696
697     // If we are transitioning to ending point, we will now have a pointer
698
// to the reply service contexts, so we can execute all queued
699
// add reply service context requests.
700
if( (executionPoint == EXECUTION_POINT_ENDING) &&
701         (addReplyServiceContextQueue != null) )
702     {
703         int size = addReplyServiceContextQueue.size();
704         for( int i = 0; i < size; i++ ) {
705         AddReplyServiceContextCommand addReply =
706             (AddReplyServiceContextCommand)
707             addReplyServiceContextQueue.get( i );
708         try {
709             add_reply_service_context( addReply.service_context,
710                            addReply.replace );
711             }
712         catch( BAD_INV_ORDER JavaDoc e ) {
713             // _REVISIT_ The only way this can happen is if during
714
// rrsc or rr, the interceptor tried to add with
715
// replace=false to a service context that is present in
716
// the reply message. At that time there was no way for
717
// us to check for this, so the best we can do is ignore
718
// the original request.
719
}
720         }
721
722         // We specifically do not empty the SC queue so that if
723
// the interceptor raises an exception the queued service contexts
724
// will be put in the exception response.
725
}
726     }
727
728     /**
729      * Stores the various sources of information used for this info object.
730      */

731     protected void setInfo( CorbaMessageMediator request, ObjectAdapter oa,
732     byte[] objectId, ObjectKeyTemplate oktemp )
733     {
734         this.request = request;
735         this.objectId = objectId;
736     this.oktemp = oktemp;
737     this.objectAdapter = oa ;
738     this.connection = (com.sun.corba.se.spi.legacy.connection.Connection)
739         request.getConnection();
740     }
741
742     /**
743      * Stores the various sources of information used for this info object.
744      */

745     protected void setDSIArguments( NVList JavaDoc arguments ) {
746     this.dsiArguments = arguments;
747     }
748
749     /**
750      * Stores the various sources of information used for this info object.
751      */

752     protected void setDSIException( Any JavaDoc exception ) {
753     this.dsiException = exception;
754
755     // Clear cached exception value:
756
cachedSendingException = null;
757     }
758
759     /**
760      * Stores the various sources of information used for this info object.
761      */

762     protected void setDSIResult( Any JavaDoc result ) {
763     this.dsiResult = result;
764     }
765
766     /**
767      * Sets the exception to be returned by received_exception and
768      * received_exception_id.
769      */

770     protected void setException( Exception JavaDoc exception ) {
771     super.setException( exception );
772
773     // Make sure DSIException is null because this is the more recent one.
774
this.dsiException = null;
775
776     // Clear cached exception value:
777
cachedSendingException = null;
778     }
779     
780     /**
781      * Stores the various sources of information used for this info object.
782      */

783     protected void setInfo( java.lang.Object JavaDoc servant,
784                 String JavaDoc targetMostDerivedInterface )
785     {
786         this.servant = servant;
787     this.targetMostDerivedInterface = targetMostDerivedInterface;
788     this.isDynamic =
789         (servant instanceof
790         org.omg.PortableServer.DynamicImplementation JavaDoc) ||
791         (servant instanceof org.omg.CORBA.DynamicImplementation JavaDoc);
792     }
793     
794     /**
795      * Set reply message
796      */

797     void setReplyMessage( ReplyMessage replyMessage ) {
798     this.replyMessage = replyMessage;
799     }
800
801     /**
802      * Overridden from RequestInfoImpl. Calls the super class, then
803      * sets the ending point call depending on the reply status.
804      */

805     protected void setReplyStatus( short replyStatus ) {
806         super.setReplyStatus( replyStatus );
807         switch( replyStatus ) {
808         case SUCCESSFUL.value:
809             endingPointCall = CALL_SEND_REPLY;
810             break;
811         case SYSTEM_EXCEPTION.value:
812         case USER_EXCEPTION.value:
813             endingPointCall = CALL_SEND_EXCEPTION;
814             break;
815         case LOCATION_FORWARD.value:
816         case TRANSPORT_RETRY.value:
817             endingPointCall = CALL_SEND_OTHER;
818             break;
819         }
820     }
821     
822     /**
823      * Release the servant object so the user has control over its lifetime.
824      * Called after receive_request is finished executing.
825      */

826     void releaseServant() {
827         this.servant = null;
828     }
829     
830     /**
831      * Sets the forwardRequestRaisedInEnding flag to true, indicating that
832      * a server ending point has raised location forward at some point.
833      */

834     void setForwardRequestRaisedInEnding() {
835     this.forwardRequestRaisedInEnding = true;
836     }
837
838     /**
839      * Returns true if ForwardRequest was raised by a server ending point
840      * or false otherwise.
841      */

842     boolean isForwardRequestRaisedInEnding() {
843     return this.forwardRequestRaisedInEnding;
844     }
845
846     /**
847      * Returns true if this is a dynamic invocation, or false if not
848      */

849     boolean isDynamic() {
850       return this.isDynamic;
851     }
852
853     /**
854      * See description for RequestInfoImpl.checkAccess
855      */

856     protected void checkAccess( int methodID )
857     {
858         // Make sure currentPoint matches the appropriate index in the
859
// validCall table:
860
int validCallIndex = 0;
861         switch( currentExecutionPoint ) {
862         case EXECUTION_POINT_STARTING:
863             validCallIndex = 0;
864             break;
865         case EXECUTION_POINT_INTERMEDIATE:
866             validCallIndex = 1;
867             break;
868         case EXECUTION_POINT_ENDING:
869             switch( endingPointCall ) {
870             case CALL_SEND_REPLY:
871                 validCallIndex = 2;
872                 break;
873             case CALL_SEND_EXCEPTION:
874                 validCallIndex = 3;
875                 break;
876             case CALL_SEND_OTHER:
877                 validCallIndex = 4;
878                 break;
879             }
880             break;
881         }
882         
883         // Check the validCall table:
884
if( !validCall[methodID][validCallIndex] ) {
885         throw stdWrapper.invalidPiCall2() ;
886         }
887     }
888     
889 }
890
Popular Tags