Distributed Objects 分布对象(2) Institute of Computer Software 2022-2-27 Nanjing University
分布对象(2) Distributed Objects 2022-2-27 Institute of Computer Software Nanjing University 1
&雪扇 摘要 0o2 UNIVER 2 More about RMI 口J2EE/EJB Institute of Computer Software 2022-2-27 Nanjing University
摘要 More about RMI J2EE/EJB 2022-2-27 Institute of Computer Software Nanjing University 2
&雪扇 摘要 0o2 UNIVER 3 More about RMI 口J2EE/EJB Institute of Computer Software 2022-2-27 Nanjing University
摘要 More about RMI J2EE/EJB 2022-2-27 Institute of Computer Software Nanjing University 3
&扇 RMI UNIVE 口Java语言之内,充分利用这一点! 口Stub可下载! 口可以传“对象”! ▣Garbage Collection! 口传“引用” java.rmi.Remote (RemoteException) Institute of Computer Software 2022-2-27 Nanjing University
RMI Java语言之内,充分利用这一点! Stub可下载! 可以传“对象”! Garbage Collection! 传“引用” java.rmi.Remote (RemoteException) 2022-2-27 Institute of Computer Software Nanjing University 4
Java RMI Server VM Client VM Client Ref obi ↑ Stub obi Skel obi Transport obi Transport obi Name Server VM Stub obi RMIregistry Transport obi Institute of Computer Software 5 2022-2-27 Nanjing University
2022-2-27 Institute of Computer Software Nanjing University 5
102 Some important parts of RMI 6 Stubs: Each remote object class has an associated stub class,which implements the same remote interfaces.An instance of the stub class is needed on each client.Client-side remote invocations are "actually"local invocations on the stub class. Serialization: ▣Arguments and results have to be“marshalled”-converted to a representation that can be sent over the Net.In general this is a non- trivial transformation for Java objects.Serialization is also used for distributing stubs. The Server-side "Run-time System": This is responsible for listening for invocating requests on suitable IP ports,and dispatching them to the proper,local resident,remote object. Institute of Computer Software 2022-2-27 Nanjing University
Some important parts of RMI Stubs: Each remote object class has an associated stub class, which implements the same remote interfaces. An instance of the stub class is needed on each client. Client-side remote invocations are “actually” local invocations on the stub class. Serialization: Arguments and results have to be “marshalled”—converted to a representation that can be sent over the Net. In general this is a nontrivial transformation for Java objects. Serialization is also used for distributing stubs. The Server-side “Run-time System”: This is responsible for listening for invocating requests on suitable IP ports, and dispatching them to the proper, local resident, remote object. 2022-2-27 Institute of Computer Software Nanjing University 6
&扇 RMI Architecture overview RMI Layers Stub/skeleton layer Application Application objects used by client and server RMI Clent RMI Server applications 多 意 Remote reference layer Stubs Skeleton creation/management of remote 意 Remote Remote references Reference Virtual layer connection Reference layer distributed garbage collection 多 多 Transport protocol layer Transport Network Transport layer connection layer ▣binary data protocol By using a layered architecture each layer could be enhanced or replaced without affecting the rest of the system:-transport layer: UDP/IP layer or secure sockets(SSL). Institute of Computer Software 2022-2-27 Nanjing University
RMI Architecture overview RMI Layers Stub/skeleton layer objects used by client and server applications Remote reference layer creation/management of remote references distributed garbage collection Transport protocol layer binary data protocol 2022-2-27 Institute of Computer Software Nanjing University 7 By using a layered architecture each layer could be enhanced or replaced without affecting the rest of the system: → transport layer: UDP/IP layer or secure sockets (SSL)
Remote Reference Layer 8 ▣RemoteRef Interprets and manages references to remote objects. The stub objects use the invoke()method in RemoteRef to forward the method call.The RemoteRef object understands the invocation semantics for remote services. aLeasing for distributed garbage collection Naming/Registry Service--rmiregistry Institute of Computer Software 2022-2-27 Nanjing University
Remote Reference Layer RemoteRef Interprets and manages references to remote objects. The stub objects use the invoke() method in RemoteRef to forward the method call. The RemoteRef object understands the invocation semantics for remote services. Leasing for distributed garbage collection Naming/Registry Service -- rmiregistry 2022-2-27 Institute of Computer Software Nanjing University 8
&扇 Remote Reference Layer 102 UNIVE 9 Invocation Semantics v1.1:unicast point-to-point. v1.2:support for activation of dormant remote service objects: Remote Object Activation RMI will instantiate a dormant object and restore its state from disk. As now:No multicast semantics. Institute of Computer Software 2022-2-27 Nanjing University
2022-2-27 Institute of Computer Software Nanjing University 9 Remote Reference Layer Invocation Semantics v1.1: unicast / point-to-point. v1.2: support for activation of dormant remote service objects: Remote Object Activation RMI will instantiate a dormant object and restore its state from disk. As now: No multicast semantics
&扇 Using RMI 1902 10 1.Define interfaces for remote classes 2.Create and compile implementation of the remote classes 3.Create stub and skeleton classes using the rmic compiler No longer necessary in Java 1.5 because Java 1.5 adds support for the dynamic generation of stub classes at runtime. rmic must still be used to pre-generate stub classes for remote objects that need to support clients running on Java versions 1.4. Institute of Computer Software 2022-2-27 Nanjing University
Using RMI 1. Define interfaces for remote classes 2. Create and compile implementation of the remote classes 3. Create stub and skeleton classes using the rmic compiler No longer necessary in Java 1.5 because Java 1.5 adds support for the dynamic generation of stub classes at runtime. rmic must still be used to pre-generate stub classes for remote objects that need to support clients running on Java versions ≤ 1.4. 2022-2-27 Institute of Computer Software Nanjing University 10