<JSTORM> (RMI) - JSTORM http://wwwjstormpekr
(RMI)- Document title: Document file name: Revision number: <10> Issued by: Document Information (RMI)- rmi finaldoc <JSTORM> Issue Date: <2001/08/08 > Status: final Content Information Audience Abstract Reference Benchmark information, RMI (http://developerjavasuncom/developer/techni calarticles/rmi/creatingapps/indexhtml) JSTORM <2/13>
(RMI)- Table of Contents (RMI) 4 RMI 6 6 7 ( Setting up a security manager ) 9 11 RMI 11 class 11 Registry 12 12 13 13 JSTORM <3/13>
(RMI)- RMI(Remote Method Invocation) ( ) RMI RMI, RMI 1,, 2 3 RMI (rmic) 4 class 5 registry 6 7 JDK 11 NT 40 JSTORM <4/13>
(RMI)- JSTORM <5/13>
(RMI)- RMI public URL (URL-based naming scheme) (name registry service) rmi://localhost/lookupserver, RMI TCP/IP (serialization) RMI : // Lookupjava import javarmi*; public interface Lookup extends Remote { public String findinfo( String info) throws RemoteException; JSTORM <6/13>
(RMI)- javarmiremote (empty marker interface) Lookup javarmiremoteexception // LookupServerjava import javaio*; import javautil*; import javarmi*; import javarmiserver*; public class LookupServer extends UnicastRemoteObject implements Lookup { private Vector save = new Vector(); public LookupServer(String db) throws RemoteException { try { FileReader fr = new FileReader(db); BufferedReader br = new BufferedReader(fr); String s = null; while ((s = brreadline())!= null) saveaddelement(s); frclose(); catch (Throwable e) { Systemerrprintln("exception"); Systemexit(1); JSTORM <7/13>
(RMI)- public String findinfo(string info) { if (info == null) return null; info = infotolowercase(); int n = savesize(); for (int i = 0; i < n; i++) { String dbs = (String)saveelementAt(i); if (dbstolowercase()indexof(info)!= -1) return dbs; return null; public static void main(string args[]) { try { RMISecurityManager security = new RMISecurityManager(); SystemsetSecurityManager(security); String db = args[0]; LookupServer server = new LookupServer(db); Namingrebind("LookupServer", server); Systemerrprintln("LookupServer ready"); catch (Throwable e) { Systemerrprintln("exception: " + e); Systemexit(1); findinfo Smith, Joan 204-9987 Jones, Milton 898-9749 Brown, Gertrude 598-1265 JSTORM <8/13>
(RMI)- LookupServer javarmiserverunicastremoteobject Lookup ( Setting up a security manager ) main RMI class, RMI class class class RMI public class LookupServer_Stub extends javarmiserverremotestub implements Lookup, javarmiremote { public class LookupServer_Skel implements javarmiserverskeleton { javap -c LookupServer_Stub JSTORM <9/13>
(RMI)- ( ) TCP/IP // LookupClientjava import javarmi*; import javarmiserver*; public class LookupClient { public static void main(string args[]) { try { RMISecurityManager security = new RMISecurityManager(); SystemsetSecurityManager(security); String host = "localhost"; String server = "LookupServer"; String name = "rmi://" + host + "/" + server; Lookup look_obj = (Lookup)Naminglookup(name); String results = look_objfindinfo(args[0]); if (results == null) Systemerrprintln("** not found **"); else Systemoutprintln(results); catch (Throwable e) { Systemerrprintln("exception: " + e); Systemexit(1); URL registry JSTORM <10/13>
(RMI)- Naminglookup URL rmi://localhost/lookupserver localhost (loopback) ( IP address = 127001 ) lookupjava, LookupServerjava, LookupClientjava javac Lookupjava javac LookupServerjava javac LookupClientjava RMI RMI (rmic) rmic LookupServer LookupServer_Skelclass LookupServer_Stubclass class JSTORM <11/13>
(RMI)- (Lookupclass, LookupClientclass, LookupServer_Stubclass) ( Lookupclass, LookupServerclass, LookupServer_Skelclass LookupServer_Stubclass) public PC C C:\ Registry registry JDK11 registry Start rmiregistry rmiregistry& rmiregistry rmiregistry java LookupServer database_name (Window ) java LookupServer database_name & (Unix ) C:\PHONETXT java LookupServer C:\PHONETXT OS java LookupServer /Phonetxt & & JSTORM <12/13>
(RMI)- java LookupClient smith smith RMI ( ) Java-To-Java RMI JAVA 2 JDK12 deprecate 11( rmic vcombat 12 11 ) rmic JDK12 JDK12 rmic v12 JSTORM <13/13>