orb.java

来自「java jdk 1.4的源码」· Java 代码 · 共 546 行 · 第 1/2 页

JAVA
546
字号
	    hostName.equals( getLocalHostName() ) ;    }    public boolean isLocalServerId( int subcontractId, int serverId )    {	// If we instantiated this ORB version, we only have a transient subcontract.	return serverId == transientServerId ;     }    // Check to see if the given port is equal to any of the ORB Server Ports.    public boolean isLocalServerPort( int port ) {        Collection serverEndPoints = giopTransport.getServerEndpoints( );        if( serverEndPoints != null ) {            Iterator iterator = serverEndPoints.iterator( );            EndPoint endPoint;            while( iterator.hasNext( ) ) {                 endPoint = (EndPoint) iterator.next( );                if( endPoint.getPort() == port ) {                    return true;                }            }        }        return false;    }    /* keeping a copy of the getLocalHostName so that it can only be called      * internally and the unauthorized clients cannot have access to the     * localHost information, originally, the above code was calling getLocalHostName     * from Connection.java.  If the hostname is cached in Connection.java, then     * it is a security hole, since any unauthorized client has access to     * the host information.  With this change it is used internally so the     * security problem is resolved.  Also in Connection.java, the getLocalHost()     * implementation has changed to always call the      * InetAddress.getLocalHost().getHostAddress()     * The above mentioned method has been removed from the connection class     */    private static String localHostString = null;    private synchronized String getLocalHostName() {        if (localHostString == null) {            try {		localHostString = 		    InetAddress.getLocalHost().getHostAddress();            } catch (Exception ex) {                throw new INTERNAL( MinorCodes.GET_LOCAL_HOST_FAILED,		    CompletionStatus.COMPLETED_NO );            }	}	return localHostString ;    }    //    // Handle Throwable.    //    public SystemException convertThrowableToSystemException(        Throwable throwable,	CompletionStatus completionStatus)    {	if (throwable instanceof SystemException) {	    return (SystemException)throwable;	}	if (throwable instanceof RequestCanceledException) {	    return new TRANSIENT("RequestCanceled",				 MinorCodes.REQUEST_CANCELED,				 CompletionStatus.COMPLETED_NO);	}	// If user code throws a non-SystemException report it generically.	String errorString =	    "Unknown Application exception on server: " 	    + throwable.getClass().getName();	return new UNKNOWN(errorString,			   MinorCodes.RUNTIMEEXCEPTION,			   completionStatus);    }    public ServerResponse handleThrowableDuringServerDispatch(        ServerRequest serverRequest,	Throwable throwable,	CompletionStatus completionStatus)    {	return handleThrowableDuringServerDispatch(serverRequest,						   throwable,						   completionStatus,						   1);    }    private ServerResponse handleThrowableDuringServerDispatch(        ServerRequest serverRequest,	Throwable throwable,	CompletionStatus completionStatus,	int iteration)    {	if (iteration > 10) {	    throw new RuntimeException(	        "handleThrowableDuringServerDispatch: " +		"cannot create response.");	}	try {	    if (throwable instanceof InternalRuntimeForwardRequest) {		ObjectImpl objectImpl = (ObjectImpl)		    ((InternalRuntimeForwardRequest)throwable).forward;		ClientSubcontract delegate = (ClientSubcontract)		    objectImpl._get_delegate();		return serverRequest.createLocationForward(delegate.marshal(),							   null);	    }	    SystemException sex =		convertThrowableToSystemException(throwable, completionStatus);	    return serverRequest.createSystemExceptionResponse(sex, null);	} catch (Throwable throwable2) {	    // User code (e.g., postinvoke, interceptors) may change	    // the exception, so we end up back here.	    // Report the changed exception.	    return handleThrowableDuringServerDispatch(serverRequest,						       throwable2,						       completionStatus,						       iteration + 1);	}    }    /******************************************************************************     *  The following public methods are for ORB shutdown.     ******************************************************************************/    protected void shutdownServants(boolean wait_for_completion) {        if (ShutdownUtilDelegate.instance != null) {            ShutdownUtilDelegate.instance.unregisterTargetsForORB(this);        }    }    protected void destroyConnections() {        giopTransport.destroyConnections();    }    /*     **************************************************************************     *  The following methods are hooks for Portable Interceptors.     *  They have empty method bodies so that we may ship with or without     *  PI support.  The actual implementations can be found in      *  Interceptors.PIORB.  The uppermost implementations can be found     *  in corba.ORB.  Some are explicitly overridden here in protected      *  scope so that we can access them from the classes in the iiop package.     *************************************************************************/    /*     *****************     * Client PI hooks     *     *****************/    /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    // REVISIT: not sure if this is necessary in this package.    protected void sendCancelRequestIfFinalFragmentNotSent() {        super.sendCancelRequestIfFinalFragmentNotSent();    }        /*     *****************     * Server PI hooks     *****************/        /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void invokeServerPIStartingPoint()         throws InternalRuntimeForwardRequest    {        super.invokeServerPIStartingPoint();    }        /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void invokeServerPIIntermediatePoint()         throws InternalRuntimeForwardRequest    {        super.invokeServerPIIntermediatePoint();    }        /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void invokeServerPIEndingPoint( ReplyMessage replyMessage )        throws InternalRuntimeForwardRequest    {        super.invokeServerPIEndingPoint( replyMessage );    }        /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void initializeServerPIInfo( ServerRequest request, 	java.lang.Object poaimpl, byte[] objectId, byte[] adapterId )     {        super.initializeServerPIInfo( request, poaimpl, objectId, adapterId );    }       /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void setServerPIInfo( java.lang.Object servant, 				    String targetMostDerivedInterface )     {        super.setServerPIInfo( servant, targetMostDerivedInterface );    }        /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void setServerPIInfo( Exception exception ) {        super.setServerPIInfo( exception );    }    /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void setServerPIInfo( NVList arguments ) {        super.setServerPIInfo( arguments );    }        /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void setServerPIExceptionInfo( Any exception ) {        super.setServerPIExceptionInfo( exception );    }    /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void setServerPIInfo( Any result ) {        super.setServerPIInfo( result );    }    /**     * Overridden from corba.ORB.     * See description in corba.ORB.     */    protected void cleanupServerPIRequest() {	super.cleanupServerPIRequest();    }} // Class ORB

⌨️ 快捷键说明

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