📄 serverrequestinfoimpl.java
字号:
// then that add will be lost since a new container is created // for the SystemException response. // // Therefore we always enqueue and never dequeue (per request) so // that all adds will be completed. AddReplyServiceContextCommand addReply = new AddReplyServiceContextCommand(); addReply.service_context = service_context; addReply.replace = replace; if( addReplyServiceContextQueue == null ) { addReplyServiceContextQueue = new ArrayList(); } // REVISIT: this does not add to the cache. enqueue( addReply ); } // NOTE: When adding a method, be sure to: // 1. Add a MID_* constant for that method // 2. Call checkAccess at the start of the method // 3. Define entries in the validCall[][] table for interception points. /* ********************************************************************** * Public RequestInfo interfaces * * These are implemented here because they have differing * implementations depending on whether this is a client or a server * request info object. **********************************************************************/ /** * See ServerRequestInfo for javadocs. */ public int request_id (){ // access is currently valid for all states: //checkAccess( MID_REQUEST_ID ); /* * NOTE: The request id in server interceptors is NOT the * same as the GIOP request id. The ORB may be servicing several * connections, each with possibly overlapping sets of request ids. * Therefore we create a request id specific to interceptors. */ return serverRequestId; } /** * See ServerRequestInfo for javadocs. */ public String operation (){ // access is currently valid for all states: //checkAccess( MID_OPERATION ); return request.getOperationName(); } /** * See ServerRequestInfo for javadocs. */ public Parameter[] arguments (){ checkAccess( MID_ARGUMENTS ); if( cachedArguments == null ) { if( !isDynamic ) { throw stdWrapper.piOperationNotSupported1() ; } if( dsiArguments == null ) { throw stdWrapper.piOperationNotSupported8() ; } // If it is a DSI request then get the arguments from the DSI req // and convert that into parameters. cachedArguments = nvListToParameterArray( dsiArguments ); } // Good citizen: In the interest of efficiency, we assume // interceptors will be "good citizens" in that they will not // modify the contents of the Parameter[] array. We also assume // they will not change the values of the containing Anys. return cachedArguments; } /** * See ServerRequestInfo for javadocs. */ public TypeCode[] exceptions (){ checkAccess( MID_EXCEPTIONS ); // _REVISIT_ PI RTF Issue: No exception list on server side. throw stdWrapper.piOperationNotSupported2() ; } /** * See ServerRequestInfo for javadocs. */ public String[] contexts (){ checkAccess( MID_CONTEXTS ); // We do not support this because our ORB does not send contexts. throw stdWrapper.piOperationNotSupported3() ; } /** * See ServerRequestInfo for javadocs. */ public String[] operation_context (){ checkAccess( MID_OPERATION_CONTEXT ); // We do not support this because our ORB does not send // operation_context. throw stdWrapper.piOperationNotSupported4() ; } /** * See ServerRequestInfo for javadocs. */ public Any result (){ checkAccess( MID_RESULT ); if( !isDynamic ) { throw stdWrapper.piOperationNotSupported5() ; } if( dsiResult == null ) { throw wrapper.piDsiResultIsNull() ; } // Good citizen: In the interest of efficiency, we assume that // interceptors will not modify the contents of the result Any. // Otherwise, we would need to create a deep copy of the Any. return dsiResult; } /** * See ServerRequestInfo for javadocs. */ public boolean response_expected (){ // access is currently valid for all states: //checkAccess( MID_RESPONSE_EXPECTED ); return !request.isOneWay(); } /** * See ServerRequestInfo for javadocs. */ public Object forward_reference (){ checkAccess( MID_FORWARD_REFERENCE ); // Check to make sure we are in LOCATION_FORWARD // state as per ptc/00-08-06, table 21-2 // footnote 2. if( replyStatus != LOCATION_FORWARD.value ) { throw stdWrapper.invalidPiCall1() ; } return getForwardRequestException().forward; } /** * See ServerRequestInfo for javadocs. */ public org.omg.IOP.ServiceContext get_request_service_context( int id ) { checkAccess( MID_GET_REQUEST_SERVICE_CONTEXT ); if( cachedRequestServiceContexts == null ) { cachedRequestServiceContexts = new HashMap(); } return getServiceContext( cachedRequestServiceContexts, request.getRequestServiceContexts(), id ); } /** * See ServerRequestInfo for javadocs. */ public org.omg.IOP.ServiceContext get_reply_service_context( int id ) { checkAccess( MID_GET_REPLY_SERVICE_CONTEXT ); if( cachedReplyServiceContexts == null ) { cachedReplyServiceContexts = new HashMap(); } return getServiceContext( cachedReplyServiceContexts, replyMessage.getServiceContexts(), id ); } /* ********************************************************************** * Private-scope classes and methods **********************************************************************/ // A command encapsulating a request to add a reply service context. // These commands are enqueued until we have a handle on the actual // reply service context, at which point they are executed. private class AddReplyServiceContextCommand { ServiceContext service_context; boolean replace; } // Adds the given add reply service context command to the queue of // such commands. If a command is detected to have the same id as // the service context in this command, and replace is false, // BAD_INV_ORDER is thrown. If replace is true, the original command // in the queue is replaced by this command. private void enqueue( AddReplyServiceContextCommand addReply ) { int size = addReplyServiceContextQueue.size(); boolean found = false; for( int i = 0; i < size; i++ ) { AddReplyServiceContextCommand cmd = (AddReplyServiceContextCommand) addReplyServiceContextQueue.get( i ); if( cmd.service_context.context_id == addReply.service_context.context_id ) { found = true; if( addReply.replace ) { addReplyServiceContextQueue.set( i, addReply ); } else { throw stdWrapper.serviceContextAddFailed( new Integer( cmd.service_context.context_id ) ) ; } break; } } if( !found ) { addReplyServiceContextQueue.add( addReply ); } } /* ********************************************************************** * Package and protected-scope methods **********************************************************************/ /** * Overridden from RequestInfoImpl. This version calls the super * and then, if we are changing to ending points, executes all * enqueued AddReplyServiceContextCommands. */ protected void setCurrentExecutionPoint( int executionPoint ) { super.setCurrentExecutionPoint( executionPoint ); // If we are transitioning to ending point, we will now have a pointer // to the reply service contexts, so we can execute all queued // add reply service context requests. if( (executionPoint == EXECUTION_POINT_ENDING) && (addReplyServiceContextQueue != null) ) { int size = addReplyServiceContextQueue.size(); for( int i = 0; i < size; i++ ) { AddReplyServiceContextCommand addReply = (AddReplyServiceContextCommand) addReplyServiceContextQueue.get( i ); try { add_reply_service_context( addReply.service_context, addReply.replace ); } catch( BAD_INV_ORDER e ) { // _REVISIT_ The only way this can happen is if during // rrsc or rr, the interceptor tried to add with // replace=false to a service context that is present in // the reply message. At that time there was no way for // us to check for this, so the best we can do is ignore // the original request. } } // We specifically do not empty the SC queue so that if // the interceptor raises an exception the queued service contexts // will be put in the exception response. } } /** * Stores the various sources of information used for this info object. */ protected void setInfo( CorbaMessageMediator request, ObjectAdapter oa, byte[] objectId, ObjectKeyTemplate oktemp ) { this.request = request; this.objectId = objectId; this.oktemp = oktemp; this.objectAdapter = oa ; this.connection = (com.sun.corba.se.spi.legacy.connection.Connection) request.getConnection(); } /** * Stores the various sources of information used for this info object. */ protected void setDSIArguments( NVList arguments ) { this.dsiArguments = arguments; } /** * Stores the various sources of information used for this info object. */ protected void setDSIException( Any exception ) { this.dsiException = exception; // Clear cached exception value: cachedSendingException = null; } /** * Stores the various sources of information used for this info object. */ protected void setDSIResult( Any result ) { this.dsiResult = result; } /** * Sets the exception to be returned by received_exception and * received_exception_id. */ protected void setException( Exception exception ) { super.setException( exception ); // Make sure DSIException is null because this is the more recent one. this.dsiException = null; // Clear cached exception value: cachedSendingException = null; } /** * Stores the various sources of information used for this info object. */ protected void setInfo( java.lang.Object servant, String targetMostDerivedInterface ) { this.servant = servant; this.targetMostDerivedInterface = targetMostDerivedInterface; this.isDynamic = (servant instanceof org.omg.PortableServer.DynamicImplementation) || (servant instanceof org.omg.CORBA.DynamicImplementation); } /** * Set reply message */ void setReplyMessage( ReplyMessage replyMessage ) { this.replyMessage = replyMessage; } /** * Overridden from RequestInfoImpl. Calls the super class, then * sets the ending point call depending on the reply status. */ protected void setReplyStatus( short replyStatus ) { super.setReplyStatus( replyStatus ); switch( replyStatus ) { case SUCCESSFUL.value: endingPointCall = CALL_SEND_REPLY; break; case SYSTEM_EXCEPTION.value: case USER_EXCEPTION.value: endingPointCall = CALL_SEND_EXCEPTION; break; case LOCATION_FORWARD.value: case TRANSPORT_RETRY.value: endingPointCall = CALL_SEND_OTHER; break; } } /** * Release the servant object so the user has control over its lifetime. * Called after receive_request is finished executing. */ void releaseServant() { this.servant = null; } /** * Sets the forwardRequestRaisedInEnding flag to true, indicating that * a server ending point has raised location forward at some point. */ void setForwardRequestRaisedInEnding() { this.forwardRequestRaisedInEnding = true; } /** * Returns true if ForwardRequest was raised by a server ending point * or false otherwise. */ boolean isForwardRequestRaisedInEnding() { return this.forwardRequestRaisedInEnding; } /** * Returns true if this is a dynamic invocation, or false if not */ boolean isDynamic() { return this.isDynamic; } /** * See description for RequestInfoImpl.checkAccess */ protected void checkAccess( int methodID ) { // Make sure currentPoint matches the appropriate index in the // validCall table: int validCallIndex = 0; switch( currentExecutionPoint ) { case EXECUTION_POINT_STARTING: validCallIndex = 0; break; case EXECUTION_POINT_INTERMEDIATE: validCallIndex = 1; break; case EXECUTION_POINT_ENDING: switch( endingPointCall ) { case CALL_SEND_REPLY: validCallIndex = 2; break; case CALL_SEND_EXCEPTION: validCallIndex = 3; break; case CALL_SEND_OTHER: validCallIndex = 4; break; } break; } // Check the validCall table: if( !validCall[methodID][validCallIndex] ) { throw stdWrapper.invalidPiCall2() ; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -