正在加载图片...
package engine; import java rmi. " import java rmi server. import compute. *; public class Compute Engine extends UnicastRemoteobject implements Compute i public Compute Engined throws Remote exception supero public object execute Task(Task t) return t execute; public static void main(Stringll args) fif(system. getSecurityManagero==null) t System. setSecurityManager(new RMISecurityManagero);) String name=//host/Compute try( Compute engine= new ComputeEngine0; Naming rebind(name, engine) System. out. printIn("Compute Engine bound); 3 catch(Exception e) System. err printIn( " ComputeEngine exception: e.getMessageO);e.printstackTrace0;北 京 大 学 计 算 机 系 代 亚 非 10 9.6 一个RMI的分布式应用的实例 package engine; import java.rmi.*; import java.rmi.server.*; import compute.*; public class ComputeEngine extends UnicastRemoteObject implements Compute { public ComputeEngine() throws RemoteException { super(); } public Object executeTask(Task t) { return t.execute(); } public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } String name = "//host/Compute"; try { Compute engine = new ComputeEngine(); Naming.rebind(name, engine); System.out.println("ComputeEngine bound"); } catch (Exception e) { System.err.println("ComputeEngine exception: " + e.getMessage()); e.printStackTrace(); }}
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有