本文整理汇总了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;
}
}
示例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;
}
}
}
}
}