SlideShare a Scribd company logo
1 of 31
Download to read offline
REMOTE METHOD INVOCATION
PROGRAMMAZIONE CONCORRENTE E DISTR.
Università degli Studi di Padova
Dipartimento di Matematica
Corso di Laurea in Informatica, A.A. 2015 – 2016
rcardin@math.unipd.it
Programmazione concorrente e distribuita
SUMMARY
 Introduction
 Remote interfaces
 Dynamic code loading
 Serialization
 Security manager
 Exporting remote objects
 Compiling
 Running
 Distributed garbage collection
2Riccardo Cardin
Programmazione concorrente e distribuita
INTRODUCTION
 RMI allows applications to call object methods
located remotely
 A server program creates some remote objects
 A client program obtains a remote reference and
then invokes methods on them
 Distributed object application
 Sharing resources, processing load across systems
 RMI provides mechanism by which the server and the
client communicate
 Using low level communication (i.e. sockets) is harder and
less performing
 Serialization has a cost and its difficult to share some state
3Riccardo Cardin
Programmazione concorrente e distribuita
INTRODUCTION
 Distributed object applications need to do the
following
 Locate remote objects
 Application can register its remote objects with RMI's simple
naming facility, the RMI registry
 Communicate with remote objects
 Details of communication between remote objects are
handled by RMI
 Load class definitions for objects that are passed
around
 RMI provides mechanisms for loading an object's class
definitions as well as for transmitting an object's data
4Riccardo Cardin
Programmazione concorrente e distribuita
INTRODUCTION
5Riccardo Cardin
1
2
3
4
5
6
Client side Server side
Programmazione concorrente e distribuita
CREATING DISTRIBUTED APPLICATIONS
 Developing a distributed application using RMI
involves these general steps:
 Designing and implementing the components
 Defining the remote interfaces
 Implementing the remote objects
 Implementing the clients
 Compiling sources
 Making classes network accessible
 Typically a web server is used for this purpose
 Starting the application
 Registry, server, client, ...
6Riccardo Cardin
Programmazione concorrente e distribuita
CREATING DISTRIBUTED APPLICATIONS
7Riccardo Cardin
Programmazione concorrente e distribuita
REMOTE INTERFACES
 Distributed application are made up of remote
interfaces and classes
 Objects with methods that can be invoked across Java
virtual machines are called remote objects.
 A remote interfaces has the following characteristics
 Extends the interface java.rmi.Remote
 Each method of the interface
declares java.rmi.RemoteException in its throws clause
 Remote objects are treated like an object reference
 A local representation (remote stub) is sent to other JVMs
 Implementation of the Remote proxy pattern
 Any other object is copied before being sent
8Riccardo Cardin
Programmazione concorrente e distribuita
REMOTE INTERFACES
 Each interface defines a specific protocol
 It’s important to clearly separate methods’ interfaces
from their implementation
 Methods of an interface that extends Remote can be
invoked from another JVM
 Remote methods MUST throw a RemoteException
 A checked exception used to indicate either a communication
failure or a protocol error
 Remote interfaces are defined server side
9Riccardo Cardin
// The interface implements java.rmi.Remote and its unique method
// throws a java.rmi.RemoteException
public interface Compute extends Remote {
<T> T executeTask(Task<T> t) throws RemoteException;
}
Programmazione concorrente e distribuita
REMOTE INTERFACES
 A remote interface must be implemented
 The implementing class can declare more methods,
but these will not be seen by the clients
 Parameters of remote methods follow these rules:
 Remote objects are passed by reference. Changes made
remotely are reflected in the original remote object
 A stub is a proxy to the remote object that communicates
with the original remote object
 Local objects are passed by copy, using serialization
 Changes are not propagated back in any way
10Riccardo Cardin
public class ComputeEngine implements Compute {
// Implement at least remote methods
}
Programmazione concorrente e distribuita
REMOTE INTERFACES
11Riccardo Cardin
Programmazione concorrente e distribuita
DYNAMIC CODE LOADING
 Interfaces that are not marked as remote must
be serializable
 Type that are not marked as remote are passed by
copy, using serialization
 Use java.io.Serializable has a marked interface
 The implementation will be dinamically downloaded
by RMI into the host JVM
 This is possibile beacuse all objects are written in Java
12Riccardo Cardin
// This is not a remote intefaces, but it is used in the protocol
// defined by a remote method. It’s implementation must implement
// also the Serializable interface
public interface Task<T> {
T execute();
}
Programmazione concorrente e distribuita
SERIALIZATION
 Representation of an object as a sequence of
bytes, that includes data as well as type
 The process is JVM independent
 Serialization process uses the stream API
 ObjectInputStream and ObjectOutputStream types
 Deserialization is the opposite process
 The type must implement java.io.Serializable
 All fields in the class must be serializable. If a field is not, it
must be marked as transient
 Transient fields are not serialized and are lost intentionally
 A transient variable cannot be final or static
 Serialization is used by RMI, EJB and so on
13Riccardo Cardin
Programmazione concorrente e distribuita
SECURITY MANAGER
 Defines the outer boundaries of the sandbox for
downloaded (untrusted) code
 It descends from class java.lang.SecurityManager
 Security policies specify actions that are unsafe
 Accept or open a socket from/to a host and port
 Modify a thread (change its priority, ...)
 Interact with file system
 Interact with system properties
 Exit an application
 For every unsafe action there is a corresponding
checkXXX method
 Actions not allowed throw a SecurityException
14Riccardo Cardin
Programmazione concorrente e distribuita
SECURITY MANAGER
 RMI programs must install a security manager
 Otherwise RMI will not download classes
 Only one security manager can be installed
 By default, an application has no security manager installed
 Policies are specified using *.policy files
 Server and client application must specify their policy file
 Default file: java.home/lib/security/java.policy
 Use -Djava.security.policy property specify a file
15Riccardo Cardin
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
grant codeBase "file:/home/ann/src/" {
permission java.security.AllPermission;
};
Programmazione concorrente e distribuita
SECURITY MANAGER
16Riccardo Cardin
Programmazione concorrente e distribuita
EXPORTING REMOTE OBJECTS
 Remote objects need to be exported to the RMI
runtime
 Exporting means create stub objects that expose the
remote methods to clients
 Stub is the client placeholder for the remote object
 The stub implements the remote interface
 It is a remote proxy to the remote object
 2° arg to exportObject is the listening port for incoming
connection
17Riccardo Cardin
Compute engine = new ComputeEngine();
// Listening to port 0 means to listen on every port
Compute stub =
(Compute) UnicastRemoteObject.exportObject(engine, 0);
Programmazione concorrente e distribuita
EXPORTING REMOTE OBJECTS
18Riccardo Cardin
Programmazione concorrente e distribuita
EXPORTING REMOTE OBJECTS
 RMI Registry: a remote map for other remote
objects, indexed by names
 The server register a remote object (stub), the client
retrieve it using the same name
 The java.rmi.Naming type provides methods for
storing and obtaining references to remote objects
 Available methods are bind, unbind and rebind
 The name argument specifies the host and port of the registry
 The object represents the remote object (stub) to expose to
clients
19Riccardo Cardin
// Name is a string that represents an URL without the scheme
// //host:port/name
Naming.bind(name, object)
Programmazione concorrente e distribuita
EXPORTING REMOTE OBJECTS
 RMI Registry
 The creation and lookup of a new Registry can be
done using the type LocateRegistry
 A registry is a remote object binded to a fixed name
 This type offers also an API to interact with the registry
 For security reasons, an application can bind an object with a
registry running on the same host
 Using the lookup method, a client can retrieve a stub
20Riccardo Cardin
// Retrieves the default registry listening on port 1099
Registry registry = LocateRegistry.getRegistry();
// Asks the registry to bind a stub to a name
registry.rebind(name, stub);
// The name was the same used to bind the object
Compute comp = (Compute) registry.lookup(name);
Programmazione concorrente e distribuita
EXPORTING REMOTE OBJECTS
21Riccardo Cardin
A client looks up from the
RMI registry a stub binded
to a name
A server bind a stub to a
specific name in a RMI
registry
The client calls remote
methods, passing
serializable type as
arguments
1
2
3
Programmazione concorrente e distribuita
COMPILING
 Compilation of an RMI program requires a series
of different steps
 Create an archive (JAR) with remote interfaces
 This archive will be shared across server and clients
 The above jar needs to be shared with the registry
 Definitions that can be automatically downloaded
have to be placed in a public folder
 For example, use an HTTP web server for this purpose
 Build server classes
22Riccardo Cardin
javac compute/Compute.java compute/Task.java
jar cvf compute.jar compute/*.class
javac -cp c:homeannpublic_htmlclassescompute.jar
engineComputeEngine.java
Programmazione concorrente e distribuita
COMPILING
 Compilation of an RMI program requires a series
of different steps
 Build client classes
 The Task interface needs to be public accessible
 The client needs also the jar of remote interfaces
 Defining security policies for server and clients
 Create a *.policy file for each actor, specifying which
actions are allowed to be performed by the downloaded code
23Riccardo Cardin
javac -cp /home/jones/public_html/classes/compute.jar
client/ComputePi.java client/Pi.java
cp client/Pi.class /home/jones/public_html/classes/client
grant codeBase "file:/home/ann/src/" {
permission java.security.AllPermission;
};
Programmazione concorrente e distribuita
RUNNING
 Starting the server components
 Start the RMI registry, given with the JDK platform
 Start the server program
 Use java.rmi.server.codebase to specify the location of
remote interfaces archive
 Use java.rmi.server.hostname to specify the host for
stubs exported from the server JVM
 By default RMI uses the the IP address of the host
 Use java.security.policy to specify the policy file
24Riccardo Cardin
start rmiregistry 1099 :: By default the registry run on port 1099
java -cp c:homeannsrc;c:classescompute.jar
-Djava.rmi.server.codebase= file:/c:/classes/compute.jar
-Djava.rmi.server.hostname=mycomputer.example.com
-Djava.security.policy=server.policy engine.ComputeEngine
Programmazione concorrente e distribuita
RUNNING
 Starting the client component
 Start the client program
 Use java.rmi.server.codebase to specify the location of
client’s interfaces implementation
 Use java.security.policy to specify the policy file
 The host name of the server can be supplied as an argument
of the program
25Riccardo Cardin
java -cp c:homejonessrc;c:classescompute.jar
-Djava.rmi.server.codebase=file:/c:/classes/
-Djava.security.policy=client.policy
client.ComputePi mycomputer.example.com 45
Programmazione concorrente e distribuita
RUNNING
26Riccardo Cardin
The registry search the stub
implementation into the web
server
The implementation of client
interfaces are loaded by the
server from the public codebase
Programmazione concorrente e distribuita
RUNNING
27Riccardo Cardin
Programmazione concorrente e distribuita
DISTRIBUTED GARBAGE COLLECTION
 RMI uses a reference-counting algorithm
 Keeps track of all live references within each JVM
 The first reference to a remote object sends a “referenced”
message to the server for that object. Reference count is
incremented
 As live references are found to be unreferenced in local JVM,
the count is decremented. When the last reference has been
discarded, an unreferenced message is sent
 When a remote object is not referenced by any client, the
RMI runtime refers to it using a weak reference
 Due to connection delays, it is possible that
premature collection of remote object will occur
 A reference to this object will thrown a RemoteException
28Riccardo Cardin
Programmazione concorrente e distribuita
EXAMPLES
29Riccardo Cardin
https://github.com/rcardin/pcd-snippets
Programmazione concorrente e distribuita
REFERENCES
 The Java Tutorials: RMI
https://docs.oracle.com/javase/tutorial/rmi/
 The Java Tutorials: Security Manager
https://docs.oracle.com/javase/tutorial/essential/environment/sec
urity.html
 Java security: How to install the security manager and customize
your security policy
http://www.javaworld.com/article/2077067/core-java/java-
security---how-to-install-the-security-manager-and-customize-your-
security-policy.html
 Default Policy Implementation and Policy File Syntax
http://docs.oracle.com/javase/7/docs/technotes/guides/security/P
olicyFiles.html
30Riccardo Cardin
Programmazione concorrente e distribuita
REFERENCES
 Java RMI : What is the role of the stub-skeleton that are generated
by the rmic compiler
http://stackoverflow.com/questions/16886889/java-rmi-what-is-
the-role-of-the-stub-skeleton-that-are-generated-by-the-rmic
 Java – Serialization
http://www.tutorialspoint.com/java/java_serialization.htm
 Garbage Collection of Remote Objects
https://docs.oracle.com/javase/8/docs/platform/rmi/spec/rmi-
arch4.html
31Riccardo Cardin

More Related Content

What's hot

Advanced Reflection in Java
Advanced Reflection in JavaAdvanced Reflection in Java
Advanced Reflection in Javakim.mens
 
Javainterview
JavainterviewJavainterview
JavainterviewAmarjit03
 
Introduction to-vhdl
Introduction to-vhdlIntroduction to-vhdl
Introduction to-vhdlNeeraj Gupta
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in javakim.mens
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedyearninginjava
 
Managing Binary Compatibility in Scala (Scala Days 2011)
Managing Binary Compatibility in Scala (Scala Days 2011)Managing Binary Compatibility in Scala (Scala Days 2011)
Managing Binary Compatibility in Scala (Scala Days 2011)mircodotta
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Courseparveen837153
 
Detecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJDetecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJCoen De Roover
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Coen De Roover
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsMahika Tutorials
 
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
The SOUL Tool Suite for Querying Programs in Symbiosis with EclipseThe SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
The SOUL Tool Suite for Querying Programs in Symbiosis with EclipseCoen De Roover
 

What's hot (20)

javarmi
javarmijavarmi
javarmi
 
Advanced Reflection in Java
Advanced Reflection in JavaAdvanced Reflection in Java
Advanced Reflection in Java
 
Designing Better API
Designing Better APIDesigning Better API
Designing Better API
 
J3d hibernate
J3d hibernateJ3d hibernate
J3d hibernate
 
Javainterview
JavainterviewJavainterview
Javainterview
 
Introduction to-vhdl
Introduction to-vhdlIntroduction to-vhdl
Introduction to-vhdl
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experienced
 
Managing Binary Compatibility in Scala (Scala Days 2011)
Managing Binary Compatibility in Scala (Scala Days 2011)Managing Binary Compatibility in Scala (Scala Days 2011)
Managing Binary Compatibility in Scala (Scala Days 2011)
 
Introduction to VHDL
Introduction to VHDLIntroduction to VHDL
Introduction to VHDL
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
Detecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJDetecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJ
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012
 
Lecture1
Lecture1Lecture1
Lecture1
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Core java
Core java Core java
Core java
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
The SOUL Tool Suite for Querying Programs in Symbiosis with EclipseThe SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
 
Java faq's
Java faq'sJava faq's
Java faq's
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 

Viewers also liked

Design Pattern Strutturali
Design Pattern StrutturaliDesign Pattern Strutturali
Design Pattern StrutturaliRiccardo Cardin
 
Java - Processing input and output
Java - Processing input and outputJava - Processing input and output
Java - Processing input and outputRiccardo Cardin
 
Design pattern architetturali Model View Controller, MVP e MVVM
Design pattern architetturali   Model View Controller, MVP e MVVMDesign pattern architetturali   Model View Controller, MVP e MVVM
Design pattern architetturali Model View Controller, MVP e MVVMRiccardo Cardin
 
Java Graphics Programming
Java Graphics ProgrammingJava Graphics Programming
Java Graphics ProgrammingRiccardo Cardin
 
Errori comuni nei documenti di Analisi dei Requisiti
Errori comuni nei documenti di Analisi dei RequisitiErrori comuni nei documenti di Analisi dei Requisiti
Errori comuni nei documenti di Analisi dei RequisitiRiccardo Cardin
 
Introduzione ai Design Pattern
Introduzione ai Design PatternIntroduzione ai Design Pattern
Introduzione ai Design PatternRiccardo Cardin
 
Java - Collections framework
Java - Collections frameworkJava - Collections framework
Java - Collections frameworkRiccardo Cardin
 
Presto updates to 0.178
Presto updates to 0.178Presto updates to 0.178
Presto updates to 0.178Kai Sasaki
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java ProgrammersEnno Runne
 
Software architecture patterns
Software architecture patternsSoftware architecture patterns
Software architecture patternsRiccardo Cardin
 
SOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignSOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignRiccardo Cardin
 
Design Pattern Architetturali - Dependency Injection
Design Pattern Architetturali - Dependency InjectionDesign Pattern Architetturali - Dependency Injection
Design Pattern Architetturali - Dependency InjectionRiccardo Cardin
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyBozhidar Bozhanov
 

Viewers also liked (16)

Diagrammi delle Classi
Diagrammi delle ClassiDiagrammi delle Classi
Diagrammi delle Classi
 
Design Pattern Strutturali
Design Pattern StrutturaliDesign Pattern Strutturali
Design Pattern Strutturali
 
Java - Processing input and output
Java - Processing input and outputJava - Processing input and output
Java - Processing input and output
 
Design pattern architetturali Model View Controller, MVP e MVVM
Design pattern architetturali   Model View Controller, MVP e MVVMDesign pattern architetturali   Model View Controller, MVP e MVVM
Design pattern architetturali Model View Controller, MVP e MVVM
 
Java Graphics Programming
Java Graphics ProgrammingJava Graphics Programming
Java Graphics Programming
 
Errori comuni nei documenti di Analisi dei Requisiti
Errori comuni nei documenti di Analisi dei RequisitiErrori comuni nei documenti di Analisi dei Requisiti
Errori comuni nei documenti di Analisi dei Requisiti
 
Introduzione ai Design Pattern
Introduzione ai Design PatternIntroduzione ai Design Pattern
Introduzione ai Design Pattern
 
Java - Collections framework
Java - Collections frameworkJava - Collections framework
Java - Collections framework
 
Diagrammi di Sequenza
Diagrammi di SequenzaDiagrammi di Sequenza
Diagrammi di Sequenza
 
Presto updates to 0.178
Presto updates to 0.178Presto updates to 0.178
Presto updates to 0.178
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java Programmers
 
Software architecture patterns
Software architecture patternsSoftware architecture patterns
Software architecture patterns
 
SOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignSOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented Design
 
Design Pattern Architetturali - Dependency Injection
Design Pattern Architetturali - Dependency InjectionDesign Pattern Architetturali - Dependency Injection
Design Pattern Architetturali - Dependency Injection
 
Java - Sockets
Java - SocketsJava - Sockets
Java - Sockets
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very ugly
 

Similar to Java - Remote method invocation

Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMIbackdoor
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMIbackdoor
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVAJalpesh Vasa
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method InvocationSonali Parab
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocationashishspace
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Sonali Parab
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVAPrankit Mishra
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVAelliando dias
 
Module 3 remote method invocation-2
Module 3   remote method  invocation-2Module 3   remote method  invocation-2
Module 3 remote method invocation-2Ankit Dubey
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingGera Paulos
 
A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI TutorialGuo Albert
 

Similar to Java - Remote method invocation (20)

Rmi
RmiRmi
Rmi
 
Rmi
RmiRmi
Rmi
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
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
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
Rmi ppt
Rmi pptRmi ppt
Rmi ppt
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Oracle docs rmi applications
Oracle docs rmi applicationsOracle docs rmi applications
Oracle docs rmi applications
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Java RMI
Java RMIJava RMI
Java RMI
 
Java RMI
Java RMIJava RMI
Java RMI
 
Rmi
RmiRmi
Rmi
 
Basic java
Basic java Basic java
Basic java
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
 
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, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
 
A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI Tutorial
 

More from Riccardo Cardin

Design Pattern Comportamentali
Design Pattern ComportamentaliDesign Pattern Comportamentali
Design Pattern ComportamentaliRiccardo Cardin
 
Design Pattern Creazionali
Design Pattern CreazionaliDesign Pattern Creazionali
Design Pattern CreazionaliRiccardo Cardin
 
Mvc e di spring e angular js
Mvc e di   spring e angular jsMvc e di   spring e angular js
Mvc e di spring e angular jsRiccardo Cardin
 
Reactive programming principles
Reactive programming principlesReactive programming principles
Reactive programming principlesRiccardo Cardin
 

More from Riccardo Cardin (7)

Design Pattern Comportamentali
Design Pattern ComportamentaliDesign Pattern Comportamentali
Design Pattern Comportamentali
 
Design Pattern Creazionali
Design Pattern CreazionaliDesign Pattern Creazionali
Design Pattern Creazionali
 
Diagrammi di Attività
Diagrammi di AttivitàDiagrammi di Attività
Diagrammi di Attività
 
Diagrammi Use Case
Diagrammi Use CaseDiagrammi Use Case
Diagrammi Use Case
 
Introduzione a UML
Introduzione a UMLIntroduzione a UML
Introduzione a UML
 
Mvc e di spring e angular js
Mvc e di   spring e angular jsMvc e di   spring e angular js
Mvc e di spring e angular js
 
Reactive programming principles
Reactive programming principlesReactive programming principles
Reactive programming principles
 

Recently uploaded

Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxAS Design & AST.
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 

Recently uploaded (20)

Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptx
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 

Java - Remote method invocation

  • 1. REMOTE METHOD INVOCATION PROGRAMMAZIONE CONCORRENTE E DISTR. Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2015 – 2016 rcardin@math.unipd.it
  • 2. Programmazione concorrente e distribuita SUMMARY  Introduction  Remote interfaces  Dynamic code loading  Serialization  Security manager  Exporting remote objects  Compiling  Running  Distributed garbage collection 2Riccardo Cardin
  • 3. Programmazione concorrente e distribuita INTRODUCTION  RMI allows applications to call object methods located remotely  A server program creates some remote objects  A client program obtains a remote reference and then invokes methods on them  Distributed object application  Sharing resources, processing load across systems  RMI provides mechanism by which the server and the client communicate  Using low level communication (i.e. sockets) is harder and less performing  Serialization has a cost and its difficult to share some state 3Riccardo Cardin
  • 4. Programmazione concorrente e distribuita INTRODUCTION  Distributed object applications need to do the following  Locate remote objects  Application can register its remote objects with RMI's simple naming facility, the RMI registry  Communicate with remote objects  Details of communication between remote objects are handled by RMI  Load class definitions for objects that are passed around  RMI provides mechanisms for loading an object's class definitions as well as for transmitting an object's data 4Riccardo Cardin
  • 5. Programmazione concorrente e distribuita INTRODUCTION 5Riccardo Cardin 1 2 3 4 5 6 Client side Server side
  • 6. Programmazione concorrente e distribuita CREATING DISTRIBUTED APPLICATIONS  Developing a distributed application using RMI involves these general steps:  Designing and implementing the components  Defining the remote interfaces  Implementing the remote objects  Implementing the clients  Compiling sources  Making classes network accessible  Typically a web server is used for this purpose  Starting the application  Registry, server, client, ... 6Riccardo Cardin
  • 7. Programmazione concorrente e distribuita CREATING DISTRIBUTED APPLICATIONS 7Riccardo Cardin
  • 8. Programmazione concorrente e distribuita REMOTE INTERFACES  Distributed application are made up of remote interfaces and classes  Objects with methods that can be invoked across Java virtual machines are called remote objects.  A remote interfaces has the following characteristics  Extends the interface java.rmi.Remote  Each method of the interface declares java.rmi.RemoteException in its throws clause  Remote objects are treated like an object reference  A local representation (remote stub) is sent to other JVMs  Implementation of the Remote proxy pattern  Any other object is copied before being sent 8Riccardo Cardin
  • 9. Programmazione concorrente e distribuita REMOTE INTERFACES  Each interface defines a specific protocol  It’s important to clearly separate methods’ interfaces from their implementation  Methods of an interface that extends Remote can be invoked from another JVM  Remote methods MUST throw a RemoteException  A checked exception used to indicate either a communication failure or a protocol error  Remote interfaces are defined server side 9Riccardo Cardin // The interface implements java.rmi.Remote and its unique method // throws a java.rmi.RemoteException public interface Compute extends Remote { <T> T executeTask(Task<T> t) throws RemoteException; }
  • 10. Programmazione concorrente e distribuita REMOTE INTERFACES  A remote interface must be implemented  The implementing class can declare more methods, but these will not be seen by the clients  Parameters of remote methods follow these rules:  Remote objects are passed by reference. Changes made remotely are reflected in the original remote object  A stub is a proxy to the remote object that communicates with the original remote object  Local objects are passed by copy, using serialization  Changes are not propagated back in any way 10Riccardo Cardin public class ComputeEngine implements Compute { // Implement at least remote methods }
  • 11. Programmazione concorrente e distribuita REMOTE INTERFACES 11Riccardo Cardin
  • 12. Programmazione concorrente e distribuita DYNAMIC CODE LOADING  Interfaces that are not marked as remote must be serializable  Type that are not marked as remote are passed by copy, using serialization  Use java.io.Serializable has a marked interface  The implementation will be dinamically downloaded by RMI into the host JVM  This is possibile beacuse all objects are written in Java 12Riccardo Cardin // This is not a remote intefaces, but it is used in the protocol // defined by a remote method. It’s implementation must implement // also the Serializable interface public interface Task<T> { T execute(); }
  • 13. Programmazione concorrente e distribuita SERIALIZATION  Representation of an object as a sequence of bytes, that includes data as well as type  The process is JVM independent  Serialization process uses the stream API  ObjectInputStream and ObjectOutputStream types  Deserialization is the opposite process  The type must implement java.io.Serializable  All fields in the class must be serializable. If a field is not, it must be marked as transient  Transient fields are not serialized and are lost intentionally  A transient variable cannot be final or static  Serialization is used by RMI, EJB and so on 13Riccardo Cardin
  • 14. Programmazione concorrente e distribuita SECURITY MANAGER  Defines the outer boundaries of the sandbox for downloaded (untrusted) code  It descends from class java.lang.SecurityManager  Security policies specify actions that are unsafe  Accept or open a socket from/to a host and port  Modify a thread (change its priority, ...)  Interact with file system  Interact with system properties  Exit an application  For every unsafe action there is a corresponding checkXXX method  Actions not allowed throw a SecurityException 14Riccardo Cardin
  • 15. Programmazione concorrente e distribuita SECURITY MANAGER  RMI programs must install a security manager  Otherwise RMI will not download classes  Only one security manager can be installed  By default, an application has no security manager installed  Policies are specified using *.policy files  Server and client application must specify their policy file  Default file: java.home/lib/security/java.policy  Use -Djava.security.policy property specify a file 15Riccardo Cardin if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } grant codeBase "file:/home/ann/src/" { permission java.security.AllPermission; };
  • 16. Programmazione concorrente e distribuita SECURITY MANAGER 16Riccardo Cardin
  • 17. Programmazione concorrente e distribuita EXPORTING REMOTE OBJECTS  Remote objects need to be exported to the RMI runtime  Exporting means create stub objects that expose the remote methods to clients  Stub is the client placeholder for the remote object  The stub implements the remote interface  It is a remote proxy to the remote object  2° arg to exportObject is the listening port for incoming connection 17Riccardo Cardin Compute engine = new ComputeEngine(); // Listening to port 0 means to listen on every port Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0);
  • 18. Programmazione concorrente e distribuita EXPORTING REMOTE OBJECTS 18Riccardo Cardin
  • 19. Programmazione concorrente e distribuita EXPORTING REMOTE OBJECTS  RMI Registry: a remote map for other remote objects, indexed by names  The server register a remote object (stub), the client retrieve it using the same name  The java.rmi.Naming type provides methods for storing and obtaining references to remote objects  Available methods are bind, unbind and rebind  The name argument specifies the host and port of the registry  The object represents the remote object (stub) to expose to clients 19Riccardo Cardin // Name is a string that represents an URL without the scheme // //host:port/name Naming.bind(name, object)
  • 20. Programmazione concorrente e distribuita EXPORTING REMOTE OBJECTS  RMI Registry  The creation and lookup of a new Registry can be done using the type LocateRegistry  A registry is a remote object binded to a fixed name  This type offers also an API to interact with the registry  For security reasons, an application can bind an object with a registry running on the same host  Using the lookup method, a client can retrieve a stub 20Riccardo Cardin // Retrieves the default registry listening on port 1099 Registry registry = LocateRegistry.getRegistry(); // Asks the registry to bind a stub to a name registry.rebind(name, stub); // The name was the same used to bind the object Compute comp = (Compute) registry.lookup(name);
  • 21. Programmazione concorrente e distribuita EXPORTING REMOTE OBJECTS 21Riccardo Cardin A client looks up from the RMI registry a stub binded to a name A server bind a stub to a specific name in a RMI registry The client calls remote methods, passing serializable type as arguments 1 2 3
  • 22. Programmazione concorrente e distribuita COMPILING  Compilation of an RMI program requires a series of different steps  Create an archive (JAR) with remote interfaces  This archive will be shared across server and clients  The above jar needs to be shared with the registry  Definitions that can be automatically downloaded have to be placed in a public folder  For example, use an HTTP web server for this purpose  Build server classes 22Riccardo Cardin javac compute/Compute.java compute/Task.java jar cvf compute.jar compute/*.class javac -cp c:homeannpublic_htmlclassescompute.jar engineComputeEngine.java
  • 23. Programmazione concorrente e distribuita COMPILING  Compilation of an RMI program requires a series of different steps  Build client classes  The Task interface needs to be public accessible  The client needs also the jar of remote interfaces  Defining security policies for server and clients  Create a *.policy file for each actor, specifying which actions are allowed to be performed by the downloaded code 23Riccardo Cardin javac -cp /home/jones/public_html/classes/compute.jar client/ComputePi.java client/Pi.java cp client/Pi.class /home/jones/public_html/classes/client grant codeBase "file:/home/ann/src/" { permission java.security.AllPermission; };
  • 24. Programmazione concorrente e distribuita RUNNING  Starting the server components  Start the RMI registry, given with the JDK platform  Start the server program  Use java.rmi.server.codebase to specify the location of remote interfaces archive  Use java.rmi.server.hostname to specify the host for stubs exported from the server JVM  By default RMI uses the the IP address of the host  Use java.security.policy to specify the policy file 24Riccardo Cardin start rmiregistry 1099 :: By default the registry run on port 1099 java -cp c:homeannsrc;c:classescompute.jar -Djava.rmi.server.codebase= file:/c:/classes/compute.jar -Djava.rmi.server.hostname=mycomputer.example.com -Djava.security.policy=server.policy engine.ComputeEngine
  • 25. Programmazione concorrente e distribuita RUNNING  Starting the client component  Start the client program  Use java.rmi.server.codebase to specify the location of client’s interfaces implementation  Use java.security.policy to specify the policy file  The host name of the server can be supplied as an argument of the program 25Riccardo Cardin java -cp c:homejonessrc;c:classescompute.jar -Djava.rmi.server.codebase=file:/c:/classes/ -Djava.security.policy=client.policy client.ComputePi mycomputer.example.com 45
  • 26. Programmazione concorrente e distribuita RUNNING 26Riccardo Cardin The registry search the stub implementation into the web server The implementation of client interfaces are loaded by the server from the public codebase
  • 27. Programmazione concorrente e distribuita RUNNING 27Riccardo Cardin
  • 28. Programmazione concorrente e distribuita DISTRIBUTED GARBAGE COLLECTION  RMI uses a reference-counting algorithm  Keeps track of all live references within each JVM  The first reference to a remote object sends a “referenced” message to the server for that object. Reference count is incremented  As live references are found to be unreferenced in local JVM, the count is decremented. When the last reference has been discarded, an unreferenced message is sent  When a remote object is not referenced by any client, the RMI runtime refers to it using a weak reference  Due to connection delays, it is possible that premature collection of remote object will occur  A reference to this object will thrown a RemoteException 28Riccardo Cardin
  • 29. Programmazione concorrente e distribuita EXAMPLES 29Riccardo Cardin https://github.com/rcardin/pcd-snippets
  • 30. Programmazione concorrente e distribuita REFERENCES  The Java Tutorials: RMI https://docs.oracle.com/javase/tutorial/rmi/  The Java Tutorials: Security Manager https://docs.oracle.com/javase/tutorial/essential/environment/sec urity.html  Java security: How to install the security manager and customize your security policy http://www.javaworld.com/article/2077067/core-java/java- security---how-to-install-the-security-manager-and-customize-your- security-policy.html  Default Policy Implementation and Policy File Syntax http://docs.oracle.com/javase/7/docs/technotes/guides/security/P olicyFiles.html 30Riccardo Cardin
  • 31. Programmazione concorrente e distribuita REFERENCES  Java RMI : What is the role of the stub-skeleton that are generated by the rmic compiler http://stackoverflow.com/questions/16886889/java-rmi-what-is- the-role-of-the-stub-skeleton-that-are-generated-by-the-rmic  Java – Serialization http://www.tutorialspoint.com/java/java_serialization.htm  Garbage Collection of Remote Objects https://docs.oracle.com/javase/8/docs/platform/rmi/spec/rmi- arch4.html 31Riccardo Cardin