piorb.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,284 行 · 第 1/4 页
JAVA
1,284 行
// Notify request object that once response is constructed, make // sure we execute ending points. request.setExecutePIInResponseConstructor( true ); info.setInfo( request, (POAImpl)poaimpl, objectId, adapterId ); } /** * Notifies PI of additional information reqired for ServerRequestInfo. */ final protected void setServerPIInfo( java.lang.Object servant, String targetMostDerivedInterface ) { if( !hasServerInterceptors ) return; ServerRequestInfoImpl info = peekServerRequestInfoImplStack(); info.setInfo( servant, targetMostDerivedInterface ); } /** * Overridden from corba.ORB. * See description in corba.ORB. */ final protected void cleanupServerPIRequest() { if( !hasServerInterceptors ) return; RequestInfoStack infoStack = (RequestInfoStack)threadLocalServerRequestInfoStack.get(); infoStack.pop(); } /* ********************************************************************** * The following methods are private utility methods for the PIORB's * use. ************************************************************************/ /** * Handles exceptions for the starting and intermediate points for * server request interceptors. This is common code that has been * factored out into this utility method. * <p> * This method will NOT work for ending points. */ private void serverPIHandleExceptions( ServerRequestInfoImpl info ) throws InternalRuntimeForwardRequest { int endingPointCall = info.getEndingPointCall(); if(endingPointCall == ServerRequestInfoImpl.CALL_SEND_EXCEPTION) { // If a system exception was thrown, throw it to caller: throw (SystemException)info.getException(); } else if( (endingPointCall == ServerRequestInfoImpl.CALL_SEND_OTHER) && (info.getForwardRequestException() != null) ) { // If an interceptor throws a forward request, convert it // into an InternalRuntimeForwardRequest for easier handling: ForwardRequest forwardRequest = info.getForwardRequestException(); throw new InternalRuntimeForwardRequest( forwardRequest.forward ); } } /** * Utility method to convert a PI reply status short to a ReplyMessage * constant. This is a reverse lookup on the table defined in * REPLY_MESSAGE_TO_PI_REPLY_STATUS. The reverse lookup need not be * performed as quickly since it is only executed in exception * conditions. */ private int convertPIReplyStatusToReplyMessage( short replyStatus ) { int result = 0; for( int i = 0; i < REPLY_MESSAGE_TO_PI_REPLY_STATUS.length; i++ ) { if( REPLY_MESSAGE_TO_PI_REPLY_STATUS[i] == replyStatus ) { result = i; break; } } return result; } /** * Convenience method to get the ClientRequestInfoImpl object off the * top of the ThreadLocal stack. Throws an INTERNAL exception if * the Info stack is empty. */ private ClientRequestInfoImpl peekClientRequestInfoImplStack() { RequestInfoStack infoStack = (RequestInfoStack)threadLocalClientRequestInfoStack.get(); ClientRequestInfoImpl info = null; if( !infoStack.empty() ) { info = (ClientRequestInfoImpl)infoStack.peek(); } else { throw new INTERNAL( "Assertion failed: Client Request Info Stack is null.", MinorCodes.CLIENT_INFO_STACK_NULL, CompletionStatus.COMPLETED_NO ); } return info; } /** * Convenience method to get the ServerRequestInfoImpl object off the * top of the ThreadLocal stack. Returns null if there are none. */ private ServerRequestInfoImpl peekServerRequestInfoImplStack() { RequestInfoStack infoStack = (RequestInfoStack)threadLocalServerRequestInfoStack.get(); ServerRequestInfoImpl info = null; if( !infoStack.empty() ) { info = (ServerRequestInfoImpl)infoStack.peek(); } else { throw new INTERNAL( "Assertion failed: Server Request Info Stack is null.", MinorCodes.SERVER_INFO_STACK_NULL, CompletionStatus.COMPLETED_NO ); } return info; } /** * Convenience method to determine whether Client PI is enabled * for requests on this thread. */ private boolean isClientPIEnabledForThisThread() { RequestInfoStack infoStack = (RequestInfoStack)threadLocalClientRequestInfoStack.get(); return (infoStack.disableCount == 0); } /** * Call pre_init on all ORB initializers */ private void preInitORBInitializers( ORBInitInfoImpl info ) { // Inform ORBInitInfo we are in pre_init stage info.setStage( ORBInitInfoImpl.STAGE_PRE_INIT ); // Step through each initializer instantiation and call its // pre_init. Ignore any exceptions. for( int i = 0; i < orbInitializers.length; i++ ) { ORBInitializer init = orbInitializers[i]; if( init != null ) { try { init.pre_init( info ); } catch( Exception e ) { // As per orbos/99-12-02, section 9.3.1.2, "If there are // any exceptions, the ORB shall ignore them and proceed." } } } } /** * Call post_init on all ORB initializers */ private void postInitORBInitializers( ORBInitInfoImpl info ) { // Inform ORBInitInfo we are in post_init stage info.setStage( ORBInitInfoImpl.STAGE_POST_INIT ); // Step through each initializer instantiation and call its post_init. // Ignore any exceptions. for( int i = 0; i < orbInitializers.length; i++ ) { ORBInitializer init = orbInitializers[i]; if( init != null ) { try { init.post_init( info ); } catch( Exception e ) { // As per orbos/99-12-02, section 9.3.1.2, "If there are // any exceptions, the ORB shall ignore them and proceed." } } } } /** * Creates the ORBInitInfo object to be passed to ORB intializers' * pre_init and post_init methods */ private ORBInitInfoImpl createORBInitInfo() { ORBInitInfoImpl result = null; // arguments comes from set_parameters. May be null. // _REVISIT_ The spec does not specify which ID this is to be. // We currently get this from the corba.ORB, which reads it from // the ORB_ID_PROPERTY property. String orbId = this.orbId; // codecFactory comes from constructor of PIORB. result = new ORBInitInfoImpl( this, arguments, orbId, codecFactory ); return result; } /** * Called by ORBInitInfo when an interceptor needs to be registered. * The type is one of: * <ul> * <li>INTERCEPTOR_TYPE_CLIENT - ClientRequestInterceptor * <li>INTERCEPTOR_TYPE_SERVER - ServerRequestInterceptor * <li>INTERCEPTOR_TYPE_IOR - IORInterceptor * </ul> * * @exception DuplicateName Thrown if an interceptor of the given * name already exists for the given type. */ void register_interceptor( Interceptor interceptor, int type ) throws DuplicateName { // We will assume interceptor is not null, since it is called // internally. if( (type >= InterceptorList.NUM_INTERCEPTOR_TYPES) || (type < 0) ) { throw new BAD_PARAM( "Interceptor type out of range: " + type ); } String interceptorName = interceptor.name(); if( interceptorName == null ) { throw new BAD_PARAM( "Interceptor's name is null. " + "Use empty string for anonymous interceptors." ); } // Register with interceptor list: interceptorList.register_interceptor( interceptor, type ); } /** * return the PICurrent instance created during ORB initialization. */ PICurrent getPICurrent( ) { return current; } /** * Called when an invalid null parameter was passed. Throws a * BAD_PARAM with a minor code of 1 */ private void nullParam() throws BAD_PARAM { throw new BAD_PARAM( com.sun.corba.se.internal.orbutil.MinorCodes.NULL_PARAM, CompletionStatus.COMPLETED_NO ); } /** This is the implementation of standard API defined in org.omg.CORBA.ORB * class. This method finds the Policy Factory for the given Policy Type * and instantiates the Policy object from the Factory. It will throw * PolicyError exception, If the PolicyFactory for the given type is * not registered. * _REVISIT_, Once Policy Framework work is completed, Reorganize * this method to com.sun.corba.se.internal.core.ORB. */ public org.omg.CORBA.Policy create_policy(int type, org.omg.CORBA.Any val) throws org.omg.CORBA.PolicyError { checkShutdownState(); if( val == null ) { nullParam( ); } if( policyFactoryTable == null ) { throw new org.omg.CORBA.PolicyError( "There is no PolicyFactory Registered for type " + type, BAD_POLICY.value ); } PolicyFactory factory = (PolicyFactory)policyFactoryTable.get( new Integer(type) ); if( factory == null ) { throw new org.omg.CORBA.PolicyError( " Could Not Find PolicyFactory for the Type " + type, BAD_POLICY.value); } org.omg.CORBA.Policy policy = factory.create_policy( type, val ); return policy; } /** This method registers the Policy Factory in the policyFactoryTable, * which is a HashMap. This method is made package private, because * it is used internally by the Interceptors. */ void registerPolicyFactory( int type, PolicyFactory factory ) { if( policyFactoryTable == null ) { policyFactoryTable = new HashMap(); } Integer key = new Integer( type ); java.lang.Object val = policyFactoryTable.get( key ); if( val == null ) { policyFactoryTable.put( key, factory ); } else { throw new BAD_INV_ORDER( "Failure in registerPolicyFactory, Trying to register a " + "PolicyFactory with the Type " + type + " which is already " + " registered", MinorCodes.POLICY_FACTORY_REG_FAILED, CompletionStatus.COMPLETED_NO ); } } synchronized int allocateServerRequestId () { return serverRequestIdCounter++; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?