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

📄 fablistener.java

📁 移动Agent编程工具Naplet
💻 JAVA
字号:
/* @<#>FabListener.java version 0.0.1, 1/1/2000 * * THIS PROGRAM IS FREE SOFTWARE; YOU CAN DISTRIBUTED IT AND/OR * MODIFY IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION. * * THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, * BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE * GNU GENERAL PUBLIC LICENSE FOR MORE DETAILS. * * Copyright (c) 2000 Wayne State University. All Rights Reserved. */package fabonacci;import java.io.*;import java.util.*;import java.rmi.*;import java.rmi.server.*;import java.net.*; // For address conversion InetAddress.getByNameimport naplet.*;/** * The <code>FabListener</code> defines an asynchronous interface for * remote naplets to call back * * @version 0.0.1, 1/1/2000 * @author C. Xu */public class FabListener    extends UnicastRemoteObject    implements NapletListener{  public FabListener()      throws RemoteException  {};  // Collect results from a partition of hosts  public void report( Object res )      throws RemoteException  {    ArrayList result = ( ArrayList ) res;    Iterator iter = result.iterator();    System.out.println( "Sequence of Fabonacci Numbers: " );    while ( iter.hasNext() )    {      System.out.print( ( ( Integer ) iter.next() ).toString() + " " );    }    System.out.println();    try    {      String host = UnicastRemoteObject.getClientHost();      InetAddress hostAddress = InetAddress.getByName( host );      String hostName = hostAddress.getHostName();      System.out.println( "Result comes from " + hostName );    }    catch ( ServerNotActiveException se )    {      System.out.println( "report err: " + se.getMessage() );      se.printStackTrace();    }    catch ( Exception e )    {      System.out.println( "report err: " + e.getMessage() );      e.printStackTrace();    }    System.exit( 0 );  }}

⌨️ 快捷键说明

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