requestinfoimpl.java
来自「java jdk 1.4的源码」· Java 代码 · 共 982 行 · 第 1/3 页
JAVA
982 行
* 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.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 * MinorCodes.UNKNOWN_USER_EXCEPTION if the Helper class could not be * found to insert it with. */ private void insertApplicationException( ApplicationException appException, Any result ) throws UNKNOWN { boolean success = false; 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 ) { // What can we do here? We are unsure if the // stream is reset or not! throw new INTERNAL( "Reset failed on Application Exception.", MinorCodes.MARK_AND_RESET_FAILED, CompletionStatus.COMPLETED_NO ); } } // Insert this UserException into the provided Any using the // helper class. insertUserException( userException, result ); // If insertUserException did not throw UNKNOWN, success! success = true; } catch( ClassNotFoundException e ) { success = false; } catch( NoSuchMethodException e ) { success = false; } catch( SecurityException e ) { success = false; } catch( IllegalAccessException e ) { success = false; } catch( IllegalArgumentException e ) { success = false; } catch( InvocationTargetException e ) { success = false; } if( !success ) { // We couldn't insert the UserException into an Any. throw new UNKNOWN( "Could not insert UserException into Any", MinorCodes.UNKNOWN_USER_EXCEPTION, CompletionStatus.COMPLETED_MAYBE ); } } /** * Inserts the UserException into the given Any. * Throws an UNKNOWN with minor code * MinorCodes.UNKNOWN_USER_EXCEPTION if the Helper class could not be * found to insert it with. */ private void insertUserException( UserException userException, Any result ) throws UNKNOWN { boolean success = false; 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 ); // If we got this far without an exception, it is a success: success = true; } } catch( ClassNotFoundException e ) { success = false; } catch( NoSuchMethodException e ) { success = false; } catch( SecurityException e ) { success = false; } catch( IllegalAccessException e ) { success = false; } catch( IllegalArgumentException e ) { success = false; } catch( InvocationTargetException e ) { success = false; } if( !success ) { // We couldn't insert the UserException into an Any. throw new UNKNOWN( "Could not insert UserException into Any", MinorCodes.UNKNOWN_USER_EXCEPTION, CompletionStatus.COMPLETED_MAYBE ); } } /* ********************************************************************** * 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 new INTERNAL( "Exception in Requestnfo.arguments()", MinorCodes.EXCEPTION_IN_ARGUMENTS, CompletionStatus.COMPLETED_NO ); } 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 = piOrb.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 new INTERNAL( "Exception was null in received_exception", MinorCodes.EXCEPTION_WAS_NULL_2, CompletionStatus.COMPLETED_NO ); } 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 ); } } return result; } /** * Utility method to look up a service context with the given id and * convert it to an IOP.ServiceContext. Uses the given HashMap as * a cache. If not found in cache, the result is inserted in the cache. */ protected org.omg.IOP.ServiceContext getServiceContext ( HashMap cachedServiceContexts,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?