SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
© Peter R. Egli 2015
1/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
Peter R. Egli
INDIGOO.COM
INTRODUCTION TO RMI, A JAVA API FOR RPC-STYLE
INVOCATION OF REMOTE OBJECT METHODS
RMI
REMOTE METHOD INVOCATION
© Peter R. Egli 2015
2/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
Contents
1. What is RMI?
2. Important RMI Components
3. RMI Layering
4. RMI Stub and Skeleton
5. RMI Registry
6. RMI Java Packages
7. RMI Transport Layer
8. RMI IDL
9. RMI Server Class Hierarchy
10. RMI Garbage Collection
11. RMI Dynamic Class Loading
12. RMI Parameter Passing
13. RMI Callbacks
14. RMI Remote Object Activation
© Peter R. Egli 2015
3/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
1. What is RMI?
Remoting:
RMI is a lightweight Java technology that provides access to remote methods, similar to RPC,
but object-oriented. RMI basically provides remote object access for a client and object
registration for servers.
API and transport protocol:
RMI is both a Java API (java.rmi.* package) as well as a transport protocol definition for
transporting RMI calls through a network (JRMI, see below).
Java technology:
RMI is a Java technology since it requires that client and server objects run in a JVM. By using
IIOP as transport protocol, however, it is possible to connect RMI-clients to non-Java server
objects (CORBA, see below).
Client object Stub Server objectSkeleton / stubNetwork
(TCP/IP)
IIOP: Internet Inter-ORB Protocol
© Peter R. Egli 2015
4/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
2. Important RMI Components
Client:
The client looks up a remote object and calls methods on the obtained remote object.
Server:
The server registers itself in the RMI registry and accepts method invocations from the client.
RMI Registry:
The registry is a remote object lookup service. The registry may run on the same host as the
server or on a different host. The registry can also be a JNDI server.
Web Server:
A plain vanilla HTTP server may hold remote object classes for downloading by the client.
RMI Client RMI Server
RMI Registry
RMI (register an object)
RMI (remote
object call)
RMI (lookup an object)
Web Server
HTTP (code
download)
HTTP
© Peter R. Egli 2015
5/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
3. RMI Layering
RMI has 3 layers on the client and server side.
Stub layer: Interface between client application (caller) and server object.
Remote reference layer: Connects clients to remote service objects.
Transport layer: Makes connections between client VM and server VM, formats the data using
JRMP (Java Remote Method Protocol) or RMI-IIOP (Internet-Inter-ORB-
Protocol, see CORBA).
Client object
Stub
Transport layer
Server object
Skeleton / stub
Transport layer
Network
(TCP/IP)
Remote reference
layer
Remote reference
layer
Interface between application
and RMI-system
Pass calls to the right remote
object
3 layers of
RMI system
Connect client and server VMs through
TCP (or UDP) connections using JRMP or
RMI-IIOP wire-protocol
© Peter R. Egli 2015
6/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
4. RMI Stub and Skeleton
RMI uses the proxy design pattern for client and server stub / skeleton:
Client stub: Proxy object on the client for accessing the remote server object.
The client stub intercepts the calls of the client and passes it to the
remote reference layer.
Server stub/skeleton: The server stub receives calls from the remote reference layer and
passes it to the server object implementing the interface
(= RealSubject in the picture above).
<<Interface>>
Subject
+ request()
Proxy
+ request()
RealSubject
+ request()
<<implements>><<implements>>
<<has>>
The proxy lives in the
client stub layer.
Object implementing the interface
and registered by the server
application with the RMI registry.
Both client and server stub implement
the same interface.
© Peter R. Egli 2015
7/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
5. RMI Registry (1/2)
RMI registry function:
The RMI registry is a server registration and client lookup service.
It may run anywhere, i.e. does not need to be co-located with the RMI server object.
Default port for RMI registry: 1099 (may run on another port as well).
Server registration:
The servers register (export) objects that implement the service interface using bind() or
rebind():
Example: RemServer localObject = new RemServer();
Naming.rebind("MyServ", localObject);
Client references:
Clients obtain references to server objects (= proxy objects) through the RMI registry using
a URL scheme (with an optional port):
URL: rmi://<host_name> [:<name_service_port>] /<service_name>
Example: RemIf remObject = (RemIf)Naming.lookup("rmi://" + host + "/MyServ");
© Peter R. Egli 2015
8/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
5. RMI Registry (2/2)
RMI registry access to server stub classes:
The RMI registry needs to have access to the server‘s stub classes. This can be done in 2 ways
(strictly either-or, using both will not work!):
1. CLASSPATH:
Add the path to server stub class files to CLASSPATH when starting the RMI registry.
2. Codebase property:
Start the server with the codebase property. This way the server registers the remote object
along with the path to the class files.
The codebase property may be a file or HTTP URL.
N.B.: The codebase URL (file or HTTP) must contain a trailing slash / backslash as shown
below!
Example Windows file codebase property file path:
java -Djava.rmi.server.codebase=file:/c:RemServer -cp . RemServer
Example Unix codebase property file path:
java -Djava.rmi.server.codebase=file:/usr/RemServer/ -cp . RemServer
Example Windows and Unix codebase property HTTP path:
java -Djava.rmi.server.codebase=http://www.hsz-t.ch/~pegli/RemServer/ -cp . RemServer
© Peter R. Egli 2015
9/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
6. RMI Java Packages
Online RMI javadoc: https://docs.oracle.com/javase/7/docs/api/
Package Description
java.rmi.*
Core RMI package with classes and interfaces used by both client and
server. Contains interface Remote, classes Naming and
RMISecurityManager and some basic exception classes.
java.rmi.activation.*
Classes and interfaces for dynamic activation of remote objects together
with RMI daemon (rmid). More information on dynamic invocation see
below.
java.rmi.dgc.* Classes and interfaces for distributed garbage collection (DGC).
java.rmi.registry.*
Registry and LocateRegistry classes for directly interacting with a
(remote or local) registry. Registry class provides lookup(), rebind(),
list() and other methods.
java.rmi.server.*
Classes for use on the server side like class loader (RMIClassLoader) and
UnicastRemoteObject (base class for remote objects).
javax.rmi.* APIs for RMI-IIOP (interoperability between RMI and CORBA).
© Peter R. Egli 2015
10/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
7. RMI Transport Layer (1/2)
RMI allows using different wire-protocols for encoding and transporting the object requests.
Wire protocol = protocol for encoding data (objects) on the „wire“ (network).
The RMI transport layer uses stream-based TCP/IP connections only (point-to-point
connections, no multicast).
a. JRMP (Java RMI Method Protocol):
JRMP is the default wire-protocol for RMI.
N.B.: In addition to the connection setup packet exchange, the RMI protocol adds additional
overhead. Thus RMI is not suited for use on non-LAN type networks.
Client Server
TCP SYN
TCP SYN, ACK
TCP ACK
TCP 3-way handshake for connection setup.
JRMI version
JRMI protocol ack
RMI call (serialized object data)
Client and server agree on the RMI protocol and version
to use.
RMI return (with serialized object data) Actual RMI remote method call.
DgcAck Client indicates to the server that the response has been
received (signal to the distributed garbage collector to
reclaim the server-side response object).
Connection teardown (3 or 4 packets)
TCP connection teardown.
© Peter R. Egli 2015
11/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
7. RMI Transport Layer (2/2)
b. HTTP:
JRMP dynamically opens TCP connections. Firewalls may block such connections.
HTTP as wire-protocol is better suited to get through firewalls (tunneling of RMI calls through
an HTTP connection).
When the client fails to open a JRMP connection to the server, it automatically falls back to
HTTP tunneling by encapsulating the request in an HTTP POST request.
c. RMI-IIIOP (Internet Inter-ORB Protocol):
When using RMI-IIOP, RMI becomes interoperable with CORBA (an RMI client may call a CORBA
object).
For further information see https://docs.oracle.com/javase/1.5.0/docs/guide/rmi-
iiop/rmi_iiop_pg.html.
Client RMI registry
Server object
Lookup connection
Service connection
© Peter R. Egli 2015
12/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
8. RMI IDL
RMI does not have a specific syntax for the description of the interface (IDL-file) but rather
uses a compiled Java class as IDL (Java is the IDL).
Important rmic options (output of rmic help on command line):
RMI compiler
(rmic.exe)
RemServer.class RemServer_Stub.class
Class file contains
the RMI stub
Java compiler
(javac.exe)
RemServer.java
-v1.1 Create stubs/skeletons for 1.1 stub protocol version.
-vcompat Create stubs/skeletons compatible with both
1.1 and 1.2 stub protocol versions.
-v1.2 (default) Create stubs for 1.2 stub protocol version only
-iiop Create stubs for IIOP. When present, <options> also includes:
-always Create stubs even when they appear current
-alwaysgenerate (same as "-always")
-nolocalstubs Do not create stubs optimized for same process
-idl Create IDL. When present, <options> also includes:
-noValueMethods Do not generate methods for valuetypes
-always Create IDL even when it appears current
-alwaysgenerate (same as "-always")
-classpath <path> Specify where to find input class files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <path> Override location of installed extensions
-d <directory> Specify where to place generated class files
-J<runtime flag> Pass argument to the java interpreter
© Peter R. Egli 2015
13/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
9. RMI Server Class Hierarchy
A remote (server) object must implement the contracted interface (RemIf) which in turn
must extend the base interface Remote.
A remote (server) object must extend the class UnicastRemoteObject (adds serializability
among other things).
RemIf
RemServer
Remote
UnicastRemoteObject
Serializable
User defined remote object (class)
User defined interface
© Peter R. Egli 2015
14/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
10. RMI Garbage Collection
RMI runs DGC (Distributed Garbage Collection) which frees unused server objects once no
client holds a live reference anymore (reference counting algorithm).
Garbage collection is hidden to client and server, very much like local GC is hidden to
Java applications.
A server may optionally implement the Unreferenced interface to be notified about an
impending object removal (a kind of destructor call). RMI calls the method unreferenced()
before the object is removed.
RemIf
RemServer
Remote
UnicastRemoteObject
Serializable
Unreferenced
+ unreferenced()
© Peter R. Egli 2015
15/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
11. RMI Dynamic Class Loading (1/2)
For ease of deployment, stub files can be downloaded on request by the client instead of
distributing them manually to each client.
The code (stub class files) can be made available for download on a web server.
N.B.: The interface file (class file containing the compiled remote interface) is still required
both on the client and server side (otherwise client and server will not compile).
RMI Client RMI Server
RMI Registry
RMI (register an object)
RMI (remote
object call)
RMI (lookup an object)
Web Server
HTTP (code
download)
© Peter R. Egli 2015
16/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
11. RMI Dynamic Class Loading (2/2)
Both client and server need to install a security manager to be able to load classes remotely:
System.setSecurityManager( new RMISecurityManger() );
Client and server need a security policy file granting the necessary rights like opening network
connections (the following security policy file simply grants everything = no security at all):
mysecurity.policy file:
grant {
permission java.security.AllPermission;
}
Starting the server with the security policy file (note the trailing backslash in the codebase
path):
java –Djava.rmi.server.codebase="http://myserver/foo/"
–Djava.security.policy=mysecurity.policy MyServer
Starting the client with the security policy file:
java –Djava.security.policy=mysecurity.policy MyClient
© Peter R. Egli 2015
17/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
12. RMI Parameter Passing
RMI provides the same object and method call semantics as for local objects.
But: Arguments to method calls must be serializable, i.e. implement the Serializable interface.
Serialization (recursively) „flattens“ objects into a byte-stream, i.e. object attributes that
are in turn objects are serialized as well (serialization of a tree of object references).
Types that are not serializable:
• Any object that does not implement Serializable.
• Any object that would pose a security risk (e.g. FileInputStream).
• Any object whose value depends on VM-specific information (e.g. Thread).
• Any object that contains a (non-static, non-transient) unserializable object (recursively).
Serializable
MyArgument
Contained in java.io.serializable package
© Peter R. Egli 2015
18/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
13. RMI Callbacks
In certain situations it may be desirable to make calls from the server to the client, e.g. for
giving progress feedback, warnings or errors etc.
There are 2 ways to make the client callable by the server:
1. Client is an RMI server as well (extends UnicastRemoteObject).
2. Client makes itself callable through exportObject.
Instead of extending UnicastRemoteObject, the client exports itself as an RMI server:
UnicastRemoteObject.exportObject( this );
More details see
https://docs.oracle.com/cd/E13211_01/wle/rmi/callbak.htm
TimeMonitor
+ tellMeTheTime()
TimeClient
Remote
TimeServer
+ registerMonitor
TimeServer
Remote
In this example, the server provides
an interface for a client to register
itself for time updates (registerMonitor()).
The client needs to export itself through
UnicastRemoteObject.exportObject().
© Peter R. Egli 2015
19/19
Rev. 1.70
RMI – Remote Method Invocation indigoo.com
14. RMI Remote Object Activation
Server objects extending UnicastRemoteObject and registered with the RMI registry run
permanently.
This may be undesirable when there are a large number of objects (resource usage in terms
of memory and TCP connections).
RMI provides an alternative through dynamically activatable objects:
Activatable (dynamically instantiatable objects) are registered with rmid (RMI daemon) instead
of the rmiregistry daemon (see $JAVA_HOME/bin/rmid.exe).
See also https://docs.oracle.com/javase/7/docs/technotes/guides/rmi/activation/overview.html.
RemIf
RemServer
Remote
Activatable
Serializable

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

RMI
RMIRMI
RMI
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Servlet life cycle
Servlet life cycleServlet life cycle
Servlet life cycle
 
Java Beans
Java BeansJava Beans
Java Beans
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
Servlets
ServletsServlets
Servlets
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Event handling
Event handlingEvent handling
Event handling
 
JDBC
JDBCJDBC
JDBC
 
Java threads
Java threadsJava threads
Java threads
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 

Similar a Remote Method Invocation (RMI)

Similar a Remote Method Invocation (RMI) (20)

Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Rmi
RmiRmi
Rmi
 
Module 3 remote method invocation-2
Module 3   remote method  invocation-2Module 3   remote method  invocation-2
Module 3 remote method invocation-2
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Java RMI
Java RMIJava RMI
Java RMI
 
Introduction To Rmi
Introduction To RmiIntroduction To Rmi
Introduction To Rmi
 
DS
DSDS
DS
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01
 
Rmi
RmiRmi
Rmi
 
Distributed objects
Distributed objectsDistributed objects
Distributed objects
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Rmi
RmiRmi
Rmi
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI Tutorial
 
Rmi
RmiRmi
Rmi
 

Más de Peter R. Egli

LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M ScenariosLPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M ScenariosPeter R. Egli
 
Data Networking Concepts
Data Networking ConceptsData Networking Concepts
Data Networking ConceptsPeter R. Egli
 
Communication middleware
Communication middlewareCommunication middleware
Communication middlewarePeter R. Egli
 
Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)Peter R. Egli
 
Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)Peter R. Egli
 
Microsoft .NET Platform
Microsoft .NET PlatformMicrosoft .NET Platform
Microsoft .NET PlatformPeter R. Egli
 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud ComputingPeter R. Egli
 
MQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message QueueingMQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message QueueingPeter R. Egli
 
Enterprise Application Integration Technologies
Enterprise Application Integration TechnologiesEnterprise Application Integration Technologies
Enterprise Application Integration TechnologiesPeter R. Egli
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyPeter R. Egli
 
Android Native Development Kit
Android Native Development KitAndroid Native Development Kit
Android Native Development KitPeter R. Egli
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Peter R. Egli
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Peter R. Egli
 
Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)Peter R. Egli
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingPeter R. Egli
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBAPeter R. Egli
 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Peter R. Egli
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging ServicePeter R. Egli
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Peter R. Egli
 

Más de Peter R. Egli (20)

LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M ScenariosLPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
 
Data Networking Concepts
Data Networking ConceptsData Networking Concepts
Data Networking Concepts
 
Communication middleware
Communication middlewareCommunication middleware
Communication middleware
 
Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)
 
Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)
 
Microsoft .NET Platform
Microsoft .NET PlatformMicrosoft .NET Platform
Microsoft .NET Platform
 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud Computing
 
MQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message QueueingMQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message Queueing
 
Enterprise Application Integration Technologies
Enterprise Application Integration TechnologiesEnterprise Application Integration Technologies
Enterprise Application Integration Technologies
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technology
 
Android Native Development Kit
Android Native Development KitAndroid Native Development Kit
Android Native Development Kit
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)
 
Web services
Web servicesWeb services
Web services
 
Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message Queueing
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBA
 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging Service
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 

Último

ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPTiSEO AI
 

Último (20)

ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 

Remote Method Invocation (RMI)

  • 1. © Peter R. Egli 2015 1/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com Peter R. Egli INDIGOO.COM INTRODUCTION TO RMI, A JAVA API FOR RPC-STYLE INVOCATION OF REMOTE OBJECT METHODS RMI REMOTE METHOD INVOCATION
  • 2. © Peter R. Egli 2015 2/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com Contents 1. What is RMI? 2. Important RMI Components 3. RMI Layering 4. RMI Stub and Skeleton 5. RMI Registry 6. RMI Java Packages 7. RMI Transport Layer 8. RMI IDL 9. RMI Server Class Hierarchy 10. RMI Garbage Collection 11. RMI Dynamic Class Loading 12. RMI Parameter Passing 13. RMI Callbacks 14. RMI Remote Object Activation
  • 3. © Peter R. Egli 2015 3/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 1. What is RMI? Remoting: RMI is a lightweight Java technology that provides access to remote methods, similar to RPC, but object-oriented. RMI basically provides remote object access for a client and object registration for servers. API and transport protocol: RMI is both a Java API (java.rmi.* package) as well as a transport protocol definition for transporting RMI calls through a network (JRMI, see below). Java technology: RMI is a Java technology since it requires that client and server objects run in a JVM. By using IIOP as transport protocol, however, it is possible to connect RMI-clients to non-Java server objects (CORBA, see below). Client object Stub Server objectSkeleton / stubNetwork (TCP/IP) IIOP: Internet Inter-ORB Protocol
  • 4. © Peter R. Egli 2015 4/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 2. Important RMI Components Client: The client looks up a remote object and calls methods on the obtained remote object. Server: The server registers itself in the RMI registry and accepts method invocations from the client. RMI Registry: The registry is a remote object lookup service. The registry may run on the same host as the server or on a different host. The registry can also be a JNDI server. Web Server: A plain vanilla HTTP server may hold remote object classes for downloading by the client. RMI Client RMI Server RMI Registry RMI (register an object) RMI (remote object call) RMI (lookup an object) Web Server HTTP (code download) HTTP
  • 5. © Peter R. Egli 2015 5/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 3. RMI Layering RMI has 3 layers on the client and server side. Stub layer: Interface between client application (caller) and server object. Remote reference layer: Connects clients to remote service objects. Transport layer: Makes connections between client VM and server VM, formats the data using JRMP (Java Remote Method Protocol) or RMI-IIOP (Internet-Inter-ORB- Protocol, see CORBA). Client object Stub Transport layer Server object Skeleton / stub Transport layer Network (TCP/IP) Remote reference layer Remote reference layer Interface between application and RMI-system Pass calls to the right remote object 3 layers of RMI system Connect client and server VMs through TCP (or UDP) connections using JRMP or RMI-IIOP wire-protocol
  • 6. © Peter R. Egli 2015 6/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 4. RMI Stub and Skeleton RMI uses the proxy design pattern for client and server stub / skeleton: Client stub: Proxy object on the client for accessing the remote server object. The client stub intercepts the calls of the client and passes it to the remote reference layer. Server stub/skeleton: The server stub receives calls from the remote reference layer and passes it to the server object implementing the interface (= RealSubject in the picture above). <<Interface>> Subject + request() Proxy + request() RealSubject + request() <<implements>><<implements>> <<has>> The proxy lives in the client stub layer. Object implementing the interface and registered by the server application with the RMI registry. Both client and server stub implement the same interface.
  • 7. © Peter R. Egli 2015 7/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 5. RMI Registry (1/2) RMI registry function: The RMI registry is a server registration and client lookup service. It may run anywhere, i.e. does not need to be co-located with the RMI server object. Default port for RMI registry: 1099 (may run on another port as well). Server registration: The servers register (export) objects that implement the service interface using bind() or rebind(): Example: RemServer localObject = new RemServer(); Naming.rebind("MyServ", localObject); Client references: Clients obtain references to server objects (= proxy objects) through the RMI registry using a URL scheme (with an optional port): URL: rmi://<host_name> [:<name_service_port>] /<service_name> Example: RemIf remObject = (RemIf)Naming.lookup("rmi://" + host + "/MyServ");
  • 8. © Peter R. Egli 2015 8/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 5. RMI Registry (2/2) RMI registry access to server stub classes: The RMI registry needs to have access to the server‘s stub classes. This can be done in 2 ways (strictly either-or, using both will not work!): 1. CLASSPATH: Add the path to server stub class files to CLASSPATH when starting the RMI registry. 2. Codebase property: Start the server with the codebase property. This way the server registers the remote object along with the path to the class files. The codebase property may be a file or HTTP URL. N.B.: The codebase URL (file or HTTP) must contain a trailing slash / backslash as shown below! Example Windows file codebase property file path: java -Djava.rmi.server.codebase=file:/c:RemServer -cp . RemServer Example Unix codebase property file path: java -Djava.rmi.server.codebase=file:/usr/RemServer/ -cp . RemServer Example Windows and Unix codebase property HTTP path: java -Djava.rmi.server.codebase=http://www.hsz-t.ch/~pegli/RemServer/ -cp . RemServer
  • 9. © Peter R. Egli 2015 9/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 6. RMI Java Packages Online RMI javadoc: https://docs.oracle.com/javase/7/docs/api/ Package Description java.rmi.* Core RMI package with classes and interfaces used by both client and server. Contains interface Remote, classes Naming and RMISecurityManager and some basic exception classes. java.rmi.activation.* Classes and interfaces for dynamic activation of remote objects together with RMI daemon (rmid). More information on dynamic invocation see below. java.rmi.dgc.* Classes and interfaces for distributed garbage collection (DGC). java.rmi.registry.* Registry and LocateRegistry classes for directly interacting with a (remote or local) registry. Registry class provides lookup(), rebind(), list() and other methods. java.rmi.server.* Classes for use on the server side like class loader (RMIClassLoader) and UnicastRemoteObject (base class for remote objects). javax.rmi.* APIs for RMI-IIOP (interoperability between RMI and CORBA).
  • 10. © Peter R. Egli 2015 10/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 7. RMI Transport Layer (1/2) RMI allows using different wire-protocols for encoding and transporting the object requests. Wire protocol = protocol for encoding data (objects) on the „wire“ (network). The RMI transport layer uses stream-based TCP/IP connections only (point-to-point connections, no multicast). a. JRMP (Java RMI Method Protocol): JRMP is the default wire-protocol for RMI. N.B.: In addition to the connection setup packet exchange, the RMI protocol adds additional overhead. Thus RMI is not suited for use on non-LAN type networks. Client Server TCP SYN TCP SYN, ACK TCP ACK TCP 3-way handshake for connection setup. JRMI version JRMI protocol ack RMI call (serialized object data) Client and server agree on the RMI protocol and version to use. RMI return (with serialized object data) Actual RMI remote method call. DgcAck Client indicates to the server that the response has been received (signal to the distributed garbage collector to reclaim the server-side response object). Connection teardown (3 or 4 packets) TCP connection teardown.
  • 11. © Peter R. Egli 2015 11/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 7. RMI Transport Layer (2/2) b. HTTP: JRMP dynamically opens TCP connections. Firewalls may block such connections. HTTP as wire-protocol is better suited to get through firewalls (tunneling of RMI calls through an HTTP connection). When the client fails to open a JRMP connection to the server, it automatically falls back to HTTP tunneling by encapsulating the request in an HTTP POST request. c. RMI-IIIOP (Internet Inter-ORB Protocol): When using RMI-IIOP, RMI becomes interoperable with CORBA (an RMI client may call a CORBA object). For further information see https://docs.oracle.com/javase/1.5.0/docs/guide/rmi- iiop/rmi_iiop_pg.html. Client RMI registry Server object Lookup connection Service connection
  • 12. © Peter R. Egli 2015 12/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 8. RMI IDL RMI does not have a specific syntax for the description of the interface (IDL-file) but rather uses a compiled Java class as IDL (Java is the IDL). Important rmic options (output of rmic help on command line): RMI compiler (rmic.exe) RemServer.class RemServer_Stub.class Class file contains the RMI stub Java compiler (javac.exe) RemServer.java -v1.1 Create stubs/skeletons for 1.1 stub protocol version. -vcompat Create stubs/skeletons compatible with both 1.1 and 1.2 stub protocol versions. -v1.2 (default) Create stubs for 1.2 stub protocol version only -iiop Create stubs for IIOP. When present, <options> also includes: -always Create stubs even when they appear current -alwaysgenerate (same as "-always") -nolocalstubs Do not create stubs optimized for same process -idl Create IDL. When present, <options> also includes: -noValueMethods Do not generate methods for valuetypes -always Create IDL even when it appears current -alwaysgenerate (same as "-always") -classpath <path> Specify where to find input class files -bootclasspath <path> Override location of bootstrap class files -extdirs <path> Override location of installed extensions -d <directory> Specify where to place generated class files -J<runtime flag> Pass argument to the java interpreter
  • 13. © Peter R. Egli 2015 13/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 9. RMI Server Class Hierarchy A remote (server) object must implement the contracted interface (RemIf) which in turn must extend the base interface Remote. A remote (server) object must extend the class UnicastRemoteObject (adds serializability among other things). RemIf RemServer Remote UnicastRemoteObject Serializable User defined remote object (class) User defined interface
  • 14. © Peter R. Egli 2015 14/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 10. RMI Garbage Collection RMI runs DGC (Distributed Garbage Collection) which frees unused server objects once no client holds a live reference anymore (reference counting algorithm). Garbage collection is hidden to client and server, very much like local GC is hidden to Java applications. A server may optionally implement the Unreferenced interface to be notified about an impending object removal (a kind of destructor call). RMI calls the method unreferenced() before the object is removed. RemIf RemServer Remote UnicastRemoteObject Serializable Unreferenced + unreferenced()
  • 15. © Peter R. Egli 2015 15/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 11. RMI Dynamic Class Loading (1/2) For ease of deployment, stub files can be downloaded on request by the client instead of distributing them manually to each client. The code (stub class files) can be made available for download on a web server. N.B.: The interface file (class file containing the compiled remote interface) is still required both on the client and server side (otherwise client and server will not compile). RMI Client RMI Server RMI Registry RMI (register an object) RMI (remote object call) RMI (lookup an object) Web Server HTTP (code download)
  • 16. © Peter R. Egli 2015 16/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 11. RMI Dynamic Class Loading (2/2) Both client and server need to install a security manager to be able to load classes remotely: System.setSecurityManager( new RMISecurityManger() ); Client and server need a security policy file granting the necessary rights like opening network connections (the following security policy file simply grants everything = no security at all): mysecurity.policy file: grant { permission java.security.AllPermission; } Starting the server with the security policy file (note the trailing backslash in the codebase path): java –Djava.rmi.server.codebase="http://myserver/foo/" –Djava.security.policy=mysecurity.policy MyServer Starting the client with the security policy file: java –Djava.security.policy=mysecurity.policy MyClient
  • 17. © Peter R. Egli 2015 17/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 12. RMI Parameter Passing RMI provides the same object and method call semantics as for local objects. But: Arguments to method calls must be serializable, i.e. implement the Serializable interface. Serialization (recursively) „flattens“ objects into a byte-stream, i.e. object attributes that are in turn objects are serialized as well (serialization of a tree of object references). Types that are not serializable: • Any object that does not implement Serializable. • Any object that would pose a security risk (e.g. FileInputStream). • Any object whose value depends on VM-specific information (e.g. Thread). • Any object that contains a (non-static, non-transient) unserializable object (recursively). Serializable MyArgument Contained in java.io.serializable package
  • 18. © Peter R. Egli 2015 18/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 13. RMI Callbacks In certain situations it may be desirable to make calls from the server to the client, e.g. for giving progress feedback, warnings or errors etc. There are 2 ways to make the client callable by the server: 1. Client is an RMI server as well (extends UnicastRemoteObject). 2. Client makes itself callable through exportObject. Instead of extending UnicastRemoteObject, the client exports itself as an RMI server: UnicastRemoteObject.exportObject( this ); More details see https://docs.oracle.com/cd/E13211_01/wle/rmi/callbak.htm TimeMonitor + tellMeTheTime() TimeClient Remote TimeServer + registerMonitor TimeServer Remote In this example, the server provides an interface for a client to register itself for time updates (registerMonitor()). The client needs to export itself through UnicastRemoteObject.exportObject().
  • 19. © Peter R. Egli 2015 19/19 Rev. 1.70 RMI – Remote Method Invocation indigoo.com 14. RMI Remote Object Activation Server objects extending UnicastRemoteObject and registered with the RMI registry run permanently. This may be undesirable when there are a large number of objects (resource usage in terms of memory and TCP connections). RMI provides an alternative through dynamically activatable objects: Activatable (dynamically instantiatable objects) are registered with rmid (RMI daemon) instead of the rmiregistry daemon (see $JAVA_HOME/bin/rmid.exe). See also https://docs.oracle.com/javase/7/docs/technotes/guides/rmi/activation/overview.html. RemIf RemServer Remote Activatable Serializable