&扇 Point 4 Start RMI Register 102 UNIVE 16 rmiregistry <port> ▣default port:1099 error if port is already used by another process(e.g.another rmiregistry) daemon has to be started in directory which contains used classes or the classes have to be on the CLASSPATH Code Base:You must specify where are the class files. Security policy file:You must give permission to use port 1099. Institute of Computer Software 2022-2-27 Nanjing University
Point 4 – Start RMI Register rmiregistry <port> default port: 1099 error if port is already used by another process (e.g. another rmiregistry) daemon has to be started in directory which contains used classes or the classes have to be on the CLASSPATH Code Base: You must specify where are the class files. Security policy file: You must give permission to use port 1099. 2022-2-27 Institute of Computer Software Nanjing University 16
般感 load classes dynamically 17 Required classes can be loaded over the network: e.g.provided by a web server via http; other protocols are also possible (file://,ftp://,....) RMI class loading and security.Two conditions must be met: 1.a special class loader is provided:RMIClassLoader 2.a security manager has to support remote class loading System.setSecurityManager(new RMISecurityManager()) Start of RMI-Registry in this case: rmiregistry must not contain the needed classes in its path(otherwise what is the point of dynamically load the classes?) Institute of Computer Software 2022-2-27 Nanjing University
load classes dynamically Required classes can be loaded over the network: e.g. provided by a web server via http; other protocols are also possible (file://, ftp://, ….) RMI class loading and security. Two conditions must be met: 1. a special class loader is provided: RMIClassLoader 2. a security manager has to support remote class loading System.setSecurityManager(new RMISecurityManager()) Start of RMI-Registry in this case: rmiregistry must not contain the needed classes in its path (otherwise what is the point of dynamically load the classes?) 2022-2-27 Institute of Computer Software Nanjing University 17
&扇 load classes dynamically 18 0 Start of server: specify codebase for downloading class files java-Djava.rmi.server.codebase=http://10.0.2.112:8080/calculator.jar nju.ics.yuping.dc.rmi.CalculatorServer Start of client: permission to access server has to be provided(due to security manager): java-Djava.security.policy=java.policy nju.ics.yuping.dc.rmi.CalculatorClient Policy file: grant /connect to or accept connections on unprivileged ports //(ports greater than 1024)on host loki.cs.fh-aargau.ch permission java.net.SocketPermission "10.0.2.112:2001-","connect,.resolve'", } Institute of Computer Software 2022-2-27 Nanjing University
load classes dynamically Start of server: specify codebase for downloading class files java -Djava.rmi.server.codebase=http://10.0.2.112:8080/calculator.jar nju.ics.yuping.dc.rmi.CalculatorServer Start of client: permission to access server has to be provided (due to security manager): java -Djava.security.policy=java.policy nju.ics.yuping.dc.rmi.CalculatorClient Policy file: grant { // connect to or accept connections on unprivileged ports // (ports greater than 1024) on host loki.cs.fh-aargau.ch permission java.net.SocketPermission ”10.0.2.112:2001-" , " connect,resolve " ; }; 2022-2-27 Institute of Computer Software Nanjing University 18
&雪扇 NAN Point 5 Codebase 102 19 2.Client makesa Naminglookup call RMI 1.Serverregisters a remote object,bound registry to a name RMI dient 3.The registry returs an instance of the remote Server that object's stub exported a remote object 4.Client requests the stub class from the codebase ★ java.mi server.codebase= http://myHost/mydir/ myHost 5.The HTTP server returs URL the remote object's stub class location (file,ftp,or http) RMI registry RMIdient Server that exported a remote 6.Makes a remote method call remote object object mnstance -Djava.rmi.server.codebase=file:///e:\course\codelrmi\server\ java.mi.server.codebase- http://myHost/mydir/ -Djava.rmi.server.codebase=http://10.0.2.112:8080/calculator.jar Institute of Computer Software 2022-2-27 Nanjing University
Point 5 - Codebase 2022-2-27 Institute of Computer Software Nanjing University 19 -Djava.rmi.server.codebase=file:///e:\course\code\rmi\server\ -Djava.rmi.server.codebase=http://10.0.2.112:8080/calculator.jar
&扇 Point 6-Marshalling 102 20 How are parameters transferred to remote objects? Primitive Parameters passed by value,in a machine-independent format Serializable Objects serializable objects are copied-call by value Remote Object Parameters only the reference to the remote object is passed,i.e.a new proxy is generated-call by reference Non-Serializable/Remote Objects cannot be transferred checked at runtime(not by rmic!) Institute of Computer Software 2022-2-27 Nanjing University
Point 6 - Marshalling How are parameters transferred to remote objects? Primitive Parameters passed by value, in a machine-independent format Serializable Objects serializable objects are copied → call by value Remote Object Parameters only the reference to the remote object is passed, i.e. a new proxy is generated → call by reference Non-Serializable/Remote Objects cannot be transferred checked at runtime (not by rmic!) 2022-2-27 Institute of Computer Software Nanjing University 20