📄 requestinfoimpl.java
字号:
* <ul> * <li>Messaging::SYNC_NONE</li> * <li>Messaging::SYNC_WITH_TRANSPORT</li> * <li>Messaging::SYNC_WITH_SERVER</li> * <li>Messaging::SYNC_WITH_TARGET</li> * </ul> */ public short sync_scope (){ checkAccess( MID_SYNC_SCOPE ); return SYNC_WITH_TRANSPORT.value; // REVISIT - get from MessageMediator } /** * Describes the state of the result of the operation invocation. Its * value can be one of the following: * <ul> * <li>PortableInterceptor::SUCCESSFUL</li> * <li>PortableInterceptor::SYSTEM_EXCEPTION</li> * <li>PortableInterceptor::USER_EXCEPTION</li> * <li>PortableInterceptor::LOCATION_FORWARD</li> * <li>PortableInterceptor::TRANSPORT_RETRY</li> * </ul> */ public short reply_status (){ checkAccess( MID_REPLY_STATUS ); return replyStatus; } /** * Implementation for forward_reference() differs for client and server * implementations. * * If the reply_status attribute is LOCATION_FORWARD * then this attribute will contain the object * to which the request will be forwarded. It is indeterminate whether a * forwarded request will actually occur. */ abstract public Object forward_reference (); /** * Returns the data from the given slot of the PortableInterceptor::Current * that is in the scope of the request. * <p> * If the given slot has not been set, then an any containing a type code * with a TCKind value of tk_null is returned. * <p> * If the ID does not define an allocated slot, InvalidSlot is raised. */ public Any get_slot (int id) throws InvalidSlot { // access is currently valid for all states: //checkAccess( MID_GET_SLOT ); // Delegate the call to the slotTable which was set when RequestInfo was // created. return slotTable.get_slot( id ); } /** * Implementation for get_request_service_context() differs for client * and server implementations. * * This operation returns a copy of the service context with the given ID * that is associated with the request. If the request's service context * does not contain an etry for that ID, BAD_PARAM with a minor code of * TBD_BP is raised. */ abstract public org.omg.IOP.ServiceContext get_request_service_context(int id); /** * Implementation for get_reply_service_context() differs for client * and server implementations. * * This operation returns a copy of the service context with the given ID * that is associated with the reply. IF the request's service context * does not contain an entry for that ID, BAD_PARAM with a minor code of * TBD_BP is raised. */ abstract public org.omg.IOP.ServiceContext get_reply_service_context (int id); // 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 // in both ClientRequestInfoImpl and ServerRequestInfoImpl. /* ********************************************************************** * Proprietary methods **********************************************************************/ /** * @return The connection on which the request is made. * * Note: we store the connection as an internal type but * expose it here as an external type. */ public com.sun.corba.se.spi.legacy.connection.Connection connection() { return connection; } /* ********************************************************************** * Private utility methods **********************************************************************/ /** * Inserts the UserException inside the given ApplicationException * into the given Any. Throws an UNKNOWN with minor code * OMGSYstemException.UNKNOWN_USER_EXCEPTION if the Helper class could not be * found to insert it with. */ private void insertApplicationException( ApplicationException appException, Any result ) throws UNKNOWN { try { // Extract the UserException from the ApplicationException. // Look up class name from repository id: RepositoryId repId = RepositoryId.cache.getId( appException.getId() ); String className = repId.getClassName(); // Find the read method on the helper class: String helperClassName = className + "Helper"; Class helperClass = ORBClassLoader.loadClass( helperClassName ); Class[] readParams = new Class[1]; readParams[0] = org.omg.CORBA.portable.InputStream.class; Method readMethod = helperClass.getMethod( "read", readParams ); // Invoke the read method, passing in the input stream to // retrieve the user exception. Mark and reset the stream // as to not disturb it. InputStream ueInputStream = appException.getInputStream(); ueInputStream.mark( 0 ); UserException userException = null; try { java.lang.Object[] readArguments = new java.lang.Object[1]; readArguments[0] = ueInputStream; userException = (UserException)readMethod.invoke( null, readArguments ); } finally { try { ueInputStream.reset(); } catch( IOException e ) { throw wrapper.markAndResetFailed( e ) ; } } // Insert this UserException into the provided Any using the // helper class. insertUserException( userException, result ); } catch( ClassNotFoundException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ) ; } catch( NoSuchMethodException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ) ; } catch( SecurityException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ) ; } catch( IllegalAccessException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ) ; } catch( IllegalArgumentException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ) ; } catch( InvocationTargetException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ) ; } } /** * Inserts the UserException into the given Any. * Throws an UNKNOWN with minor code * OMGSYstemException.UNKNOWN_USER_EXCEPTION if the Helper class could not be * found to insert it with. */ private void insertUserException( UserException userException, Any result ) throws UNKNOWN { try { // Insert this UserException into the provided Any using the // helper class. if( userException != null ) { Class exceptionClass = userException.getClass(); String className = exceptionClass.getName(); String helperClassName = className + "Helper"; Class helperClass = ORBClassLoader.loadClass( helperClassName ); // Find insert( Any, class ) method Class[] insertMethodParams = new Class[2]; insertMethodParams[0] = org.omg.CORBA.Any.class; insertMethodParams[1] = exceptionClass; Method insertMethod = helperClass.getMethod( "insert", insertMethodParams ); // Call helper.insert( result, userException ): java.lang.Object[] insertMethodArguments = new java.lang.Object[2]; insertMethodArguments[0] = result; insertMethodArguments[1] = userException; insertMethod.invoke( null, insertMethodArguments ); } } catch( ClassNotFoundException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ); } catch( NoSuchMethodException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ); } catch( SecurityException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ); } catch( IllegalAccessException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ); } catch( IllegalArgumentException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ); } catch( InvocationTargetException e ) { throw stdWrapper.unknownUserException( CompletionStatus.COMPLETED_MAYBE, e ); } } /* ********************************************************************** * Protected utility methods **********************************************************************/ /** * Internal utility method to convert an NVList into a PI Parameter[] */ protected Parameter[] nvListToParameterArray( NVList parNVList ) { // _REVISIT_ This utility method should probably be doing a deep // copy so interceptor can't accidentally change the arguments. int count = parNVList.count(); Parameter[] plist = new Parameter[count]; try { for( int i = 0; i < count; i++ ) { Parameter p = new Parameter(); plist[i] = p; NamedValue nv = parNVList.item( i ); plist[i].argument = nv.value(); // ParameterMode spec can be found in 99-10-07.pdf // Section:10.5.22 // nv.flags spec can be found in 99-10-07.pdf // Section 7.1.1 // nv.flags has ARG_IN as 1, ARG_OUT as 2 and ARG_INOUT as 3 // To convert this into enum PARAM_IN, PARAM_OUT and // PARAM_INOUT the value is subtracted by 1. plist[i].mode = ParameterMode.from_int( nv.flags() - 1 ); } } catch ( Exception e ) { throw wrapper.exceptionInArguments( e ) ; } return plist; } /** * Utility to wrap the given Exception in an Any object and return it. * If the exception is a UserException which cannot be inserted into * an any, then this returns an Any containing the system exception * UNKNOWN. */ protected Any exceptionToAny( Exception exception ){ Any result = myORB.create_any(); if( exception == null ) { // Note: exception should never be null here since we will throw // a BAD_INV_ORDER if this is not called from receive_exception. throw wrapper.exceptionWasNull2() ; } else if( exception instanceof SystemException ) { ORBUtility.insertSystemException( (SystemException)exception, result ); } else if( exception instanceof ApplicationException ) { // Use the Helper class for this exception to insert it into an // Any. try { // Insert the user exception inside the application exception // into the Any result: ApplicationException appException = (ApplicationException)exception; insertApplicationException( appException, result ); } catch( UNKNOWN e ) { // As per ptc/00-08-06, 21.3.13.4. if we cannot find the // appropriate class, then return an any containing UNKNOWN, // with a minor code of 1. This is conveniently the same // exception that is returned from the // insertApplicationException utility method. ORBUtility.insertSystemException( e, result ); } } else if( exception instanceof UserException ) { try { UserException userException = (UserException)exception; insertUserException( userException, result ); } catch( UNKNOWN e ) { ORBUtility.insertSystemException( e, result ); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -