⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pihandlerimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    public void setServerPIInfo( Any result )    {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();        info.setDSIResult( result );    }    public void initializeServerPIInfo( CorbaMessageMediator request,	ObjectAdapter oa, byte[] objectId, ObjectKeyTemplate oktemp )     {	if( !hasServerInterceptors ) return;        RequestInfoStack infoStack =             (RequestInfoStack)threadLocalServerRequestInfoStack.get();        ServerRequestInfoImpl info = new ServerRequestInfoImpl( orb );	infoStack.push( info );	printPush();	// Notify request object that once response is constructed, make	// sure we execute ending points.        request.setExecutePIInResponseConstructor( true );        info.setInfo( request, oa, objectId, oktemp );    }        public void setServerPIInfo( java.lang.Object servant, 				          String targetMostDerivedInterface )     {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();        info.setInfo( servant, targetMostDerivedInterface );    }    public void cleanupServerPIRequest() {	if( !hasServerInterceptors ) return;        RequestInfoStack infoStack =             (RequestInfoStack)threadLocalServerRequestInfoStack.get();	infoStack.pop();	printPop();    }        /*      **********************************************************************     *  The following methods are private utility methods.      ************************************************************************/    /**     * 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 )     {        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 a ForwardException for easier handling:            IOR ior = info.getForwardRequestIOR();	    throw new ForwardException( orb, ior );        }    }    /**     * 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 wrapper.clientInfoStackNull() ;	}                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 wrapper.serverInfoStackNull() ;        }        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 < orb.getORBData().getORBInitializers().length; 	    i++ ) {	    ORBInitializer init = orb.getORBData().getORBInitializers()[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 < orb.getORBData().getORBInitializers().length; 	    i++ ) {	    ORBInitializer init = orb.getORBData().getORBInitializers()[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 = orb.getORBData().getORBId() ;	result = new ORBInitInfoImpl( orb, 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.     */    public 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 wrapper.typeOutOfRange( new Integer( type ) ) ;	}        String interceptorName = interceptor.name();        if( interceptorName == null ) {	    throw wrapper.nameNull() ;        }	// Register with interceptor list:	interceptorList.register_interceptor( interceptor, type );    }    public Current 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 orbutilWrapper.nullParam() ;    }    /** 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.spi.orb.ORB.      */    public org.omg.CORBA.Policy create_policy(int type, org.omg.CORBA.Any val)        throws org.omg.CORBA.PolicyError    {        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.     */    public 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 omgWrapper.policyFactoryRegFailed( new Integer( type ) ) ;        }    }        public synchronized int allocateServerRequestId ()    {	return serverRequestIdCounter++;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -