当前位置: 首页>>代码示例>>Java>>正文


Java RMISocketFactory.getFailureHandler方法代码示例

本文整理汇总了Java中java.rmi.server.RMISocketFactory.getFailureHandler方法的典型用法代码示例。如果您正苦于以下问题:Java RMISocketFactory.getFailureHandler方法的具体用法?Java RMISocketFactory.getFailureHandler怎么用?Java RMISocketFactory.getFailureHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.rmi.server.RMISocketFactory的用法示例。


在下文中一共展示了RMISocketFactory.getFailureHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: continueAfterAcceptFailure

import java.rmi.server.RMISocketFactory; //导入方法依赖的package包/类
/**
 * Returns true if the accept loop should continue after the
 * specified exception has been caught, or false if the accept
 * loop should terminate (closing the server socket).  If
 * there is an RMIFailureHandler, this method returns the
 * result of passing the specified exception to it; otherwise,
 * this method always returns true, after sleeping to throttle
 * the accept loop if necessary.
 **/
private boolean continueAfterAcceptFailure(Throwable t) {
    RMIFailureHandler fh = RMISocketFactory.getFailureHandler();
    if (fh != null) {
        return fh.failure(t instanceof Exception ? (Exception) t :
                          new InvocationTargetException(t));
    } else {
        throttleLoopOnException();
        return true;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:TCPTransport.java

示例2: run

import java.rmi.server.RMISocketFactory; //导入方法依赖的package包/类
/**
 * Starts waiting for incoming remote calls. When connection from remote
 * is accepted, separate thread to process remote call is spawned. Waits
 * for connections until this thread will not be interrupted.
 */
public void run() {
    while (!Thread.interrupted()) {
        try {
            Socket s = ss.accept();
            startConnection(s);
            failedAcceptsNum = 0;
        } catch (Exception ex) {
            RMIFailureHandler rfh = RMISocketFactory.getFailureHandler();

            if (rfh != null) {
                if (rfh.failure(ex)) {
                    return;
                }
            } else {
                // We will try to immediately accept another client again,
                // but if we have a bad client which fails our accept tries
                // for a number of times, we should sleep for a while.
                if (failedAcceptsNum >= 5) {
                    try {
                        Thread.sleep(defaultFailureDelay);
                    } catch (InterruptedException ie) {
                        return;
                    }
                    failedAcceptsNum = 0;
                }
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:35,代码来源:ServerConnectionManager.java


注:本文中的java.rmi.server.RMISocketFactory.getFailureHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。