?? agentservice.java
字號:
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
public class AgentService extends UnicastRemoteObject
implements Agent
{
public AgentService() throws RemoteException {
super();
}
public static void main(String[] args) {
if(args.length < 1) {
System.out.println("usage [hostname]");
System.exit(1);
}
String hostname = args[0];
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
String name = "//" + hostname + "/Agent";
try {
Agent agent = new AgentService();
Naming.rebind(name, agent);
System.out.println("AgentService bound");
} catch (Exception e) {
System.err.println("AgentService exception: " +
e.getMessage());
e.printStackTrace();
}
}
// implementation of the Agent interface
public String talk() {
return "P2P is very cool";
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -