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


Java RMIFailureHandler类代码示例

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


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

示例1: main

import java.rmi.server.RMIFailureHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:CloseServerSocketOnTermination.java

示例2: continueAfterAcceptFailure

import java.rmi.server.RMIFailureHandler; //导入依赖的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

示例3: run

import java.rmi.server.RMIFailureHandler; //导入依赖的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

示例4: testGetSetFailureHandler

import java.rmi.server.RMIFailureHandler; //导入依赖的package包/类
public void testGetSetFailureHandler() {
    RMIFailureHandler fh = new RMIFailureHandler() {
        public boolean failure(Exception ex) {
            return false;
        }
    };

    RMISocketFactory.setFailureHandler(fh);
    assertSame(fh, RMISocketFactory.getFailureHandler());
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:11,代码来源:RMISocketFactoryTest.java


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