📄 remotesortimpl.java
字号:
// Implementation class for remote sorting (RMI). This includes the remote sort method
// and a main()...
import java.net.*; // need this for MalformedURLException
import java.rmi.server.UnicastRemoteObject;
import java.rmi.*;
import java.util.*;
// The interface must extend the Remote interface to become something
// that RMI can serve up.
public class RemoteSortImpl extends UnicastRemoteObject implements RemoteSort {
// constructor just calls the UnicastRemoteObject constructor that
// exports this object as a remote object
public RemoteSortImpl() throws RemoteException {
super();
}
// here is the actual sort - wow...
public List sort(List l) throws RemoteException {
Collections.sort(l);
return(l);
}
public static void main(String args[]) {
try {
RemoteSortImpl s = new RemoteSortImpl();
// register with the rmi registry
Naming.rebind("sort",s);
System.out.println("Sort is ready for trouble...");
} catch (RemoteException e) {
System.out.println("RemoteException: " + e.getMessage());
e.printStackTrace();
} catch (MalformedURLException m) {
System.out.println("URL Problem: " + m.getMessage());
m.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -