Remote Method Invocation (RMI) allows programmers to execute remote functions and calls using the same semantics as local function calls. RMI uses stubs and skeletons, where the stub acts as a proxy for the remote object on the client side and the skeleton receives the calls on the server side. To use RMI, an interface must be defined and implemented on the server, stub and skeleton classes are generated, the remote object is registered with an RMI registry, and then clients can look up and invoke methods on the remote object.
Remote Method Invocation, Distributed Programming in java, Java Distributed Programming, Network Programming in JAVA, Core Java, Introduction to RMI, Getting Started with RMI, Getting Started with Remote Method Invocation, Distributed Programming, Java, J2SE
RMI allows Java objects to make remote calls to methods on other Java objects located in different JVMs. The document discusses how to create remote objects that implement remote interfaces, generate stubs and skeletons, and look up and invoke methods on remote objects. It provides an example "Hello World" RMI application to demonstrate the basic steps of developing and running an RMI client and server.
RMI allows Java objects to invoke methods on remote Java objects located in another Java Virtual Machine. It handles marshaling parameters, transportation between client and server, and unmarshaling results. To create an RMI application, interfaces define remote services, servers implement interfaces and register with the RMI registry, and clients lookup services and invoke remote methods similarly to local calls. Stub and skeleton objects handle communication between remote VMs.
Remote Method Invocation (RMI) allows Java objects to invoke methods on remote Java objects located on other hosts or machines. RMI uses stubs and skeletons as proxies to make remote calls appear local. The stubs act as local representatives for remote objects, while skeletons on the remote host receive the calls and forward them to the actual remote objects. RMI handles object serialization and deserialization to transfer objects between clients and servers.
This document provides an overview of Java RMI (Remote Method Invocation), which allows objects to invoke methods on remote Java objects located elsewhere on a network. Key points:
- RMI allows one JVM to communicate with another and invoke methods remotely as if they were local.
- Remote interfaces define the methods that can be invoked remotely. The interface is shared between client and server code.
- When a remote method is invoked, a stub on the client side packages the parameters and sends them to the server, where the method is executed and results returned.
- Typical RMI applications have a server that creates remote objects and a client that looks them up and invokes their methods. The client interacts
This document provides an overview of Java RMI (Remote Method Invocation), which allows objects to invoke methods on remote Java objects located elsewhere on a network. Key points:
- RMI allows one JVM to communicate with another and invoke methods remotely as if they were local.
- Remote interfaces define the methods that can be invoked remotely. The interface is shared between client and server code.
- When a remote method is invoked, a stub on the client side packages the parameters and sends them to the server, where the method is executed and results returned.
- Typical RMI applications have a server that creates remote objects and a client that looks them up and invokes their methods remotely.
This document discusses Remote Method Invocation (RMI) in Java. It describes the basic concepts and architecture of RMI, including how remote objects are represented by stubs and skeletons. It then provides step-by-step instructions for building a simple RMI application with four required classes: an interface for the remote object, the client, the remote object implementation, and the server. It also gives an example of building a more complex RMI application for performing numerical integration remotely.
RMI allows objects in one Java Virtual Machine (JVM) to invoke methods on objects residing in another JVM. It uses stub and skeleton objects to enable remote communication between Java programs. The stub on the client side sends a call to the server-side skeleton, which then invokes the actual remote object. The key steps to build an RMI application are: defining the remote interface, implementing it, generating stub and skeleton objects, starting the RMI registry, running the server, and making calls from the client.
This document discusses Remote Method Invocation (RMI) in Java. It explains that RMI allows a Java object to invoke methods on an object running on another machine, enabling remote communication between Java programs. It then describes the basic concepts of an RMI application including client/server architecture using stub and skeleton objects. Finally, it outlines the steps to implement a simple RMI application with an interface, client, and server classes.
If you have an access to an object on a different machine,
you can call methods of the remote object.of course, the method parameters must somehow be shipped to the other machine,the server must be informed to execute the method & the return value must be shipped back.
In RMI, the object whose methods makes the remote call is called the client object. The remote object is called the server object.The computer running the java code that calls the remote method is the client for that call.
The computer hosting the object that processes the call is the server for that call.
The document describes developing a distributed RMI application with a database. It involves:
1) Creating a remote interface and implementation class to access the database.
2) Compiling the class and starting the RMI registry.
3) Creating and running a server that binds the remote object.
4) Creating and running a client that looks up the remote object and invokes its methods.
Remote Method Invocation (RMI) allows objects running in one Java virtual machine to invoke methods on objects running in another Java virtual machine. RMI uses object serialization to marshal and unmarshal parameters and supports true object-oriented polymorphism. RMI is implemented using three layers - stub, remote reference, and transport connection layers. The stub and skeleton hide the underlying network implementation details and allow remote objects to be called similar to local objects. Security is an important consideration in RMI and a security manager must be installed and permissions configured to control access to remote objects and classes.
Recently The Java Remote Method Invocation (RMI) system allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine. RMI provides for remote communication between programs written in the Java programming language.
RMI allows Java objects to invoke methods on remote Java objects located in another JVM. It uses stubs and skeletons as proxies for remote objects. The client calls methods on the local stub which forwards the call to the remote skeleton which then calls methods on the actual remote object. Objects must implement the Remote interface and are registered with an RMI registry for lookup. The server implements the remote interface and registers objects with the registry, while the client looks up remote objects from the registry to invoke methods on them.
Remote Method Invocation (RMI) allows Java objects to communicate remotely. The RMI architecture consists of interfaces, stubs, skeletons, and transport layers. Interfaces define remote services while stubs and skeletons handle remote calls. The transport layer connects clients and servers over TCP/IP. Clients lookup remote objects by name in an RMI registry.
The document discusses Remote Method Invocation (RMI) in Java. RMI allows objects to invoke methods on objects residing in another Java Virtual Machine (JVM). It uses stub and skeleton objects to enable remote communication between applications. The stub acts as a client-side proxy and the skeleton receives incoming requests on the server-side. The document provides an example to demonstrate creating a remote interface, implementing it, compiling the stub and skeleton, starting the registry, and running a client and server application to invoke the remote method.
The document discusses how to implement callbacks in Java RMI using remote method invocation. It describes defining a listener interface and event source interface, implementing the event source to notify listeners, implementing a listener client, and registering the listener with the event source. It provides code examples for implementing and registering both the event source and listener.
The document discusses how to implement callbacks in Java RMI using remote method invocation. It describes defining a listener interface and event source interface, implementing the event source to notify listeners, implementing a listener client, and registering the listener with the event source. It provides code examples for implementing the event source and listener interfaces, starting the event source server, and having the listener client look up and register with the event source.
The document discusses how to implement callbacks in Java RMI using remote method invocation. It describes defining a listener interface and event source interface, implementing the event source to notify listeners, implementing a listener client, and registering the listener with the event source. It provides code examples for implementing the event source and listener interfaces, starting the event source server, and having the listener client look up and register with the event source.
The document discusses using remote method invocation (RMI) in Java to implement callbacks. It describes defining a listener interface that other classes can implement to be notified of events. An event source interface is defined to allow listeners to register and receive notifications. The event source is implemented as an RMI server that notifies all registered listeners when temperature changes. A client implements the listener interface and registers with the server to receive remote callbacks of temperature changes.
The document discusses how to implement callbacks in Java RMI using remote method invocation. It describes defining a listener interface and event source interface, implementing the event source to notify listeners, implementing a listener client, and registering the listener with the event source. It provides code examples for implementing the event source and listener interfaces, starting the event source server, and having the listener client look up and register with the event source.
This document discusses Java Remote Method Invocation (RMI), which allows Java objects to invoke methods on other Java objects running in another Java Virtual Machine (JVM). It describes how RMI works using a client-server model, with an interface defining remote methods, an implementation class on the server exporting objects, and clients looking them up by name. It provides code examples of an RMI server interface, implementation class, and client class, along with steps for compiling, running the rmiregistry, and potential error sources.
This document discusses distributed programming with Java RMI. It explains the key components of client-server systems and different distributed computing models like DCE, DCOM, CORBA, and Java RMI. It then describes how Java RMI works, the packages involved, and provides steps to implement a basic RMI application with a remote interface, server implementation, and client.
This document discusses distributed programming with Java RMI. It explains the key components of client-server systems and different distributed computing models like DCE, DCOM, CORBA, and Java RMI. It then describes how Java RMI works, the packages involved, and provides steps to implement a basic RMI application with a remote interface, server implementation, and client.
This Presentation shows the working of Java RMI technology, it's advantage over RPC, it's class hierarchy API and finally implementation of Factorial program using Java RMI.
Remote Method Invocation (RMI) allows developers to invoke methods on remote Java objects. RMI handles the details of communication between remote objects transparently so that remote calls appear as local method calls. The RMI registry provides naming services that allow clients to lookup remote objects by name, simplifying the specification of remote objects' locations. Developers define interfaces for remote objects, generate stubs and skeletons, implement remote objects, register them with the RMI registry, and have clients lookup and invoke methods on remote objects.
This document provides an overview of Remote Method Invocation (RMI) in Java. RMI allows objects running in one Java Virtual Machine (JVM) to invoke methods on objects running in another JVM. It describes the RMI process which involves defining a remote interface, compiling the remote object, and making the object accessible over the network. The client locates the remote object and invokes its methods similarly to a local object. The server implements the remote interface and provides the business logic to fulfill client requests.
Sql and plsql syntax and commands aaaaaaSql and plsql syntax and commands aaaaaaSql and plsql syntax and commands aaaaaaSql and plsql syntax and commands aaaaaa
RMI allows objects in one Java Virtual Machine (JVM) to invoke methods on objects residing in another JVM. It uses stub and skeleton objects to enable remote communication between Java programs. The stub on the client side sends a call to the server-side skeleton, which then invokes the actual remote object. The key steps to build an RMI application are: defining the remote interface, implementing it, generating stub and skeleton objects, starting the RMI registry, running the server, and making calls from the client.
This document discusses Remote Method Invocation (RMI) in Java. It explains that RMI allows a Java object to invoke methods on an object running on another machine, enabling remote communication between Java programs. It then describes the basic concepts of an RMI application including client/server architecture using stub and skeleton objects. Finally, it outlines the steps to implement a simple RMI application with an interface, client, and server classes.
If you have an access to an object on a different machine,
you can call methods of the remote object.of course, the method parameters must somehow be shipped to the other machine,the server must be informed to execute the method & the return value must be shipped back.
In RMI, the object whose methods makes the remote call is called the client object. The remote object is called the server object.The computer running the java code that calls the remote method is the client for that call.
The computer hosting the object that processes the call is the server for that call.
The document describes developing a distributed RMI application with a database. It involves:
1) Creating a remote interface and implementation class to access the database.
2) Compiling the class and starting the RMI registry.
3) Creating and running a server that binds the remote object.
4) Creating and running a client that looks up the remote object and invokes its methods.
Remote Method Invocation (RMI) allows objects running in one Java virtual machine to invoke methods on objects running in another Java virtual machine. RMI uses object serialization to marshal and unmarshal parameters and supports true object-oriented polymorphism. RMI is implemented using three layers - stub, remote reference, and transport connection layers. The stub and skeleton hide the underlying network implementation details and allow remote objects to be called similar to local objects. Security is an important consideration in RMI and a security manager must be installed and permissions configured to control access to remote objects and classes.
Recently The Java Remote Method Invocation (RMI) system allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine. RMI provides for remote communication between programs written in the Java programming language.
RMI allows Java objects to invoke methods on remote Java objects located in another JVM. It uses stubs and skeletons as proxies for remote objects. The client calls methods on the local stub which forwards the call to the remote skeleton which then calls methods on the actual remote object. Objects must implement the Remote interface and are registered with an RMI registry for lookup. The server implements the remote interface and registers objects with the registry, while the client looks up remote objects from the registry to invoke methods on them.
Remote Method Invocation (RMI) allows Java objects to communicate remotely. The RMI architecture consists of interfaces, stubs, skeletons, and transport layers. Interfaces define remote services while stubs and skeletons handle remote calls. The transport layer connects clients and servers over TCP/IP. Clients lookup remote objects by name in an RMI registry.
The document discusses Remote Method Invocation (RMI) in Java. RMI allows objects to invoke methods on objects residing in another Java Virtual Machine (JVM). It uses stub and skeleton objects to enable remote communication between applications. The stub acts as a client-side proxy and the skeleton receives incoming requests on the server-side. The document provides an example to demonstrate creating a remote interface, implementing it, compiling the stub and skeleton, starting the registry, and running a client and server application to invoke the remote method.
The document discusses how to implement callbacks in Java RMI using remote method invocation. It describes defining a listener interface and event source interface, implementing the event source to notify listeners, implementing a listener client, and registering the listener with the event source. It provides code examples for implementing and registering both the event source and listener.
The document discusses how to implement callbacks in Java RMI using remote method invocation. It describes defining a listener interface and event source interface, implementing the event source to notify listeners, implementing a listener client, and registering the listener with the event source. It provides code examples for implementing the event source and listener interfaces, starting the event source server, and having the listener client look up and register with the event source.
The document discusses how to implement callbacks in Java RMI using remote method invocation. It describes defining a listener interface and event source interface, implementing the event source to notify listeners, implementing a listener client, and registering the listener with the event source. It provides code examples for implementing the event source and listener interfaces, starting the event source server, and having the listener client look up and register with the event source.
The document discusses using remote method invocation (RMI) in Java to implement callbacks. It describes defining a listener interface that other classes can implement to be notified of events. An event source interface is defined to allow listeners to register and receive notifications. The event source is implemented as an RMI server that notifies all registered listeners when temperature changes. A client implements the listener interface and registers with the server to receive remote callbacks of temperature changes.
The document discusses how to implement callbacks in Java RMI using remote method invocation. It describes defining a listener interface and event source interface, implementing the event source to notify listeners, implementing a listener client, and registering the listener with the event source. It provides code examples for implementing the event source and listener interfaces, starting the event source server, and having the listener client look up and register with the event source.
This document discusses Java Remote Method Invocation (RMI), which allows Java objects to invoke methods on other Java objects running in another Java Virtual Machine (JVM). It describes how RMI works using a client-server model, with an interface defining remote methods, an implementation class on the server exporting objects, and clients looking them up by name. It provides code examples of an RMI server interface, implementation class, and client class, along with steps for compiling, running the rmiregistry, and potential error sources.
This document discusses distributed programming with Java RMI. It explains the key components of client-server systems and different distributed computing models like DCE, DCOM, CORBA, and Java RMI. It then describes how Java RMI works, the packages involved, and provides steps to implement a basic RMI application with a remote interface, server implementation, and client.
This document discusses distributed programming with Java RMI. It explains the key components of client-server systems and different distributed computing models like DCE, DCOM, CORBA, and Java RMI. It then describes how Java RMI works, the packages involved, and provides steps to implement a basic RMI application with a remote interface, server implementation, and client.
This Presentation shows the working of Java RMI technology, it's advantage over RPC, it's class hierarchy API and finally implementation of Factorial program using Java RMI.
Remote Method Invocation (RMI) allows developers to invoke methods on remote Java objects. RMI handles the details of communication between remote objects transparently so that remote calls appear as local method calls. The RMI registry provides naming services that allow clients to lookup remote objects by name, simplifying the specification of remote objects' locations. Developers define interfaces for remote objects, generate stubs and skeletons, implement remote objects, register them with the RMI registry, and have clients lookup and invoke methods on remote objects.
This document provides an overview of Remote Method Invocation (RMI) in Java. RMI allows objects running in one Java Virtual Machine (JVM) to invoke methods on objects running in another JVM. It describes the RMI process which involves defining a remote interface, compiling the remote object, and making the object accessible over the network. The client locates the remote object and invokes its methods similarly to a local object. The server implements the remote interface and provides the business logic to fulfill client requests.
Sql and plsql syntax and commands aaaaaaSql and plsql syntax and commands aaaaaaSql and plsql syntax and commands aaaaaaSql and plsql syntax and commands aaaaaa
The document discusses backtracking algorithms. It defines backtracking as a systematic method for exploring all possible solutions to a problem by incrementally building candidates and abandoning partial candidates that fail to satisfy constraints or lead to dead ends. The document outlines the key concepts of backtracking including representation as a state space tree, types of nodes, constraints, solution space, and generation and bounding functions. Examples provided include solving a maze, coloring a map, and solving a puzzle. Pseudocode for the general backtracking algorithm and analysis of efficiency are also presented.
How to create Record rules in odoo 18 - Odoo 際際滷sCeline George
油
Record rules allow us to restrict which records are displayed to users. Creating record rules in Odoo 18 is essential for managing data access and ensuring that users can only see or interact with records they are authorized to access.
Taxonomy and Systematics: Classification and Diversity of Insects.pptxArshad Shaikh
油
Classification and Taxonomy of Insects:
Insect classification and taxonomy involve grouping insects based on their shared characteristics and evolutionary relationships. Insects are classified into a hierarchical system, including Kingdom (Animalia), Phylum (Arthropoda), Class (Insecta), Order, Family, Genus, and Species. Taxonomists use morphological, molecular, and behavioral traits to identify and categorize insects, enabling researchers to understand their diversity, evolution, and ecological roles. Accurate classification is essential for pest management, conservation, and understanding ecosystem dynamics.
Leveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdfTechSoup
油
Explore how AI tools can enhance operational efficiency for nonprofits. Learn practical strategies for automating repetitive tasks, optimizing resource allocation, and driving organizational impact. Gain actionable insights into implementing AI solutions tailored to nonprofit needs.
How to Manage Blanket Order in Odoo 18 - Odoo 際際滷sCeline George
油
In this slide, well discuss on how to manage blanket order in Odoo 18. A Blanket Order in Odoo 18 is a long-term agreement with a vendor for a specific quantity of goods or services at a predetermined price.
Automated Actions (Automation) in the Odoo 18Celine George
油
In this slide, well discuss the automated actions in the Odoo 18. Automated actions in Odoo 18 enable users to set predefined actions triggered automatically by specified conditions or events.
This article explores the miraculous event of the Splitting of the Moon (Shaqq al-Qamar) as recorded in Islamic scripture and tradition. Drawing from the Qur'an, authentic hadith collections, and classical tafsir, the article affirms the event as a literal miracle performed by Prophet Muhammad 鏃 in response to the Qurayshs demand for a sign. It also investigates external historical accounts, particularly the legend of Cheraman Perumal, a South Indian king who allegedly witnessed the miracle and embraced Islam. The article critically examines the authenticity and impact of such regional traditions, while also discussing the lack of parallel astronomical records and how scholars have interpreted this event across centuries. Concluding with the theological significance of the miracle, the article offers a well-rounded view of one of Islams most discussed supernatural events.
How to Automate Activities Using Odoo 18 CRMCeline George
油
In Odoo 18, the CRM module's activity feature is designed to help users manage and track tasks related to customer interactions. These tasks could include phone calls, meetings, emails, or follow-ups, and are essential for progressing through sales and customer management processes.
he Grant Preparation Playbook: Building a System for Grant SuccessTechSoup
油
Learn what it takes to successfully prepare for grants, apply with confidence, and build a sustainable funding system. This workshop offers a structured approach to grant readiness by covering essential document collection, aligning programs with funder's priorities, and leveraging in-kind contributions to strengthen your budget. You'll also get a step-by-step framework to keep your grant efforts on track year-round, plus insights from nonprofits that have navigated this process successfully.
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...TechSoup
油
Thousands of nonprofits rely on donated Microsoft 365 Business Premium and Office 365 E1 subscriptions. In this webinar, TechSoup discuss Microsoft's May 14 announcement that the donated versions of these licenses would no longer be available to nonprofits after July 1, 2025, and which options are best for nonprofits moving forward as they transition off these licenses.
For more information about my speaking and training work, visit: https://www.pookyknightsmith.com/speaking/
Session overview:
Maslows Toolbox: Creating Classrooms Where Every Child Thrives
Using Maslows Hierarchy of Needs as a practical lens, this session explores how meeting childrens basic physical, emotional, and psychological needs can transform behaviour, engagement, and learning. With a strong focus on inclusion, well look at how small, manageable changes can create classrooms where all childrenincluding autistic pupils, ADHD learners, and those with experiences of traumafeel safe, valued, and ready to thrive. Youll leave with simple, low-cost strategies that are easy to implement and benefit every student, without singling anyone out.
By the end of this session, participants will be able to:
Identify unmet needs that may be driving behaviour or disengagement
Make quick, effective adjustments that improve focus and wellbeing
Create a safer, more predictable classroom environment
Support students to feel calm, confident and included
Build a stronger sense of belonging and connection
Foster self-esteem through success-focused strategies
Apply practical tools the very next dayno extra budget required
2. Unit -2
Java RMI
What Is Java RMI?
A distributed interoperability technology for Java
Packages java.rmi, java.rmi.server and java.rmi.registry
Tools rmic and rmiregistry
Javas answer to CORBA
Java is the interface definition language
Key limitation: both client and server must be written in Java
Part of Enterprise JavaBeans
Along with JDBC (Java DataBase Connectivity), Java Security, Java
Messaging Services, Java Transactions Services, Java IDL, other APIs
like CORBAs common object services
Detailed documentation is available at
http://java.sun.com/
Java RMI = Java Remote Method Invocation
4. Unit -2
Java RMI
Client/Server Programming
with Java RMI (I)
Define an extension of interface
java.rmi.Remote
Declare the methods the remote object exports
Declare each such method to throw java.rmi.RemoteException
Define a subclass of
java.rmi.server.UnicastRemoteObject that also
implements the extension of java.rmi.Remote
defined in step 1
Write a server program that creates an instance
of the class defined in step 2
Use synchronized wherever necessary to make server thread-safe
The server program must register the instance with a registry service
Default registry server is started by running rmiregistry
5. Unit -2
Java RMI
Client/Server Programming
with Java RMI (II)
Compile server program with javac, and then use
rmic to generate stub and skeleton classes for
the remote object
Stub and skeleton take care of all networking
Limitation of rmic: the remote object class cannot be nested
Write a client program that uses the remote
object
The client uses class Naming to obtain a reference to the remote
object, using the interface name from step 1 (not the class name)
The client invokes methods on the remote object through this
reference
Run the server and then run the client
7. Unit -2
Java RMI
Client/Server Execution
with Java RMI (II)
Client Server
Remote
Object
Clients machine Servers machine
Registry
Server
8. Unit -2
Java RMI
Client/Server Execution
with Java RMI (III)
Client Server
Remote
Object
Naming.rebind()
skeleton
Clients machine Servers machine
Registry
Server
9. Unit -2
Java RMI
Client/Server Execution
with Java RMI (IV)
Client Server
Remote
Object
Naming.lookup()
skeleton
stub
Clients machine Servers machine
Registry
Server
10. 0
Unit -2
Java RMI
Client/Server Execution
with Java RMI (V)
Client Server
Remote
Object
skeleton
stub
Remote Method
Invocation
Clients machine Servers machine
Registry
Server
11. 1
Unit -2
Java RMI
Default RMI Registry
Server on machine.com registers object with local
RMI registry using some string name
Naming.rebind(remoteObj, referenceToRemoteObj)
Client refers to objects with URL
Local client: rmi:///remoteObj
Remote client: rmi://machine.com/remoteObj
If client code contains
Naming.lookup(rmi:// + objName)
損 objName would be /remoteObj for local object
損 objName would be machine.com/remoteObj for remote
object
Registry is bound to port 1099 by default
Accepts optional port number as argument
Non-default port number must then be added to URL
12. 2
Unit -2
Java RMI
Example:
Air Traffic Control
Air traffic control is divided into several sectors
Each sector is managed by a different controller
Airplanes check in with a controller and then
periodically send the controller position reports
The controller analyzes position reports and tells
an airplane when its position is too close to other
planes
13. 3
Unit -2
Java RMI
Air Traffic Control:
ATC Exception
package ATC;
public class ATCException extends Exception {
public ATCException(String msg) { super(msg); }
}
For server-specific exceptions
Different from RemoteException, which is thrown as a
result of RMI failure
14. 4
Unit -2
Java RMI
Air Traffic Control:
Position Report Data
package ATC;
public class PositionReport implements java.io.Serializable {
public int Latitude;
public int Longitude;
public int Heading;
public int Airspeed;
public PositionReport(int la, int lo, int h, int a) {
Latitude = la;
Longitude = lo;
Heading = h;
Airspeed = a;
}
}
Java objects can be passed in RMIs, as long as they are
serializable
Usually accomplished with an implementation of (empty) interface
Serializable
Stub and skeleton take care of serialization/deserialization
15. 5
Unit -2
Java RMI
Remote Controllers
Interface
package ATC;
import java.rmi.*;
public interface ControllerInterface extends Remote {
public void CheckIn(int flight) throws RemoteException;
public void CurrentPosition(int flight, PositionReport pos)
throws RemoteException, ATCException;
}
16. 6
Unit -2
Java RMI
Air Traffic Control:
Remote Controller Class (I)
package ATC;
import java.net.*; // for InetAddress
import java.rmi.*;
import java.rmi.server.*;
public class Controller extends UnicastRemoteObject
implements ControllerInterface {
protected String myName;
public Controller(String port, String name) throws RemoteException {
super();
try {
myName = "//" + InetAddress.getLocalHost().getHostName() +
":" + port + "/" + name;
Naming.rebind(myName, this);
}
catch (Exception ex) { System.err.println("Exception " + ex); }
}
}
17. 7
Unit -2
Java RMI
Air Traffic Control:
Remote Controller Class (II)
public class Controller extends UnicastRemoteObject
implements ControllerInterface {
public void CheckIn(int flight) throws RemoteException
{
record existence of new flight
}
public void CurrentPosition(int flight, PositionReport pos)
throws RemoteException, ATCException
{
if (pos.latitude < -90 || pos.latitude > 90
|| pos.longitude < -180 || pos.longitude > 180
|| pos.heading < 1 || pos.heading > 360
|| pos.airspeed < 50 || pos.airspeed > 700)
throw new ATCException("flight " + String.valueOf(flight) +
": invalid position");
else if ( flight is too close to other airplanes )
throw new ATCException("flight " + String.valueOf(flight) +
": dangerous position");
}
}
18. 8
Unit -2
Java RMI
Air Traffic Control:
ATC Server
package ATC;
import java.rmi.*;
public class ATCServer {
public static void main(String[] args) {
try {
Controller c = new Controller(args[0], args[1]);
}
catch (Exception ex) {
System.err.println("Exception " + ex);
System.err.println("usage: java ATCServer port# controllerName");
}
}
}
19. 9
Unit -2
Java RMI
Air Traffic Control:
Airplane Client (I)
package ATC;
import java.rmi.*;
public class Airplane {
protected int myFlightNumber;
protected String myController;
protected PositionReport myPosition
= new PositionReport(34, -118, 180, 350);
public static void main(String[] args) {
try {
myFlightNumber = Integer.parseInt(args[0]);
myController = args[1];
ControllerInterface c = // The interface, not the class!
(ControllerInterface)Naming.lookup("rmi://" + myController);
c.CheckIn(myFlightNumber);
}
}
}
20. 0
Unit -2
Java RMI
Air Traffic Control:
Airplane Client (II)
public class Airplane {
public static void main(String[] args) {
try {
for (;;) {
c.CurrentPosition(myFlightNumber, myPosition);
java.lang.Thread.sleep(200);
update position
}
}
catch (RemoteException ex)
{ System.err.println("RemoteException " + ex); }
catch (ATCException ex)
{ System.err.println("ATCException " + ex); }
catch (Exception ex) {
System.err.println("Exception " + ex);
System.err.println("usage: java Airplane flight# controllerName");
}
}
}
22. 2
Unit -2
Java RMI
Compiling the Example
elysees 1332> ls
ATC/ GNUmakefile
elysees 1333> ls ATC
ATCException.java Controller.java
ATCServer.java ControllerInterface.java
Airplane.java PositionReport.java
elysees 1334> gmake all
+elysees+ javac ATC/ATCException.java
+elysees+ javac ATC/ATCServer.java
+elysees+ javac ATC/Airplane.java
+elysees+ rmic ATC.Controller
+elysees+ mv -f Controller_Skel.class Controller_Stub.class ATC
elysees 1335> ls ATC
ATCException.class Controller.java
ATCException.java ControllerInterface.class
ATCServer.class ControllerInterface.java
ATCServer.java Controller_Skel.class
Airplane.class Controller_Stub.class
Airplane.java PositionReport.class
Controller.class PositionReport.java
elysees 1336>
23. 3
Unit -2
Java RMI
Running the Example:
Local Client and Server
Server on elysees (using the default registry port number):
Client on elysees:
elysees 1355> java ATC.Airplane 100 /LosAngeles
ATCException ATC.ATCException: flight 100: invalid position
elysees 1356> java ATC.Airplane 100 elysees.ics.uci.edu/LosAngeles
ATCException ATC.ATCException: flight 100: invalid position
elysees 1357>
elysees 1352> rmiregistry &
[1] 5398
elysees 1353> java ATC.ATCServer 1099 LosAngeles &
[2] 5407
elysees 1354>
24. 4
Unit -2
Java RMI
Running the Example:
Remote Client and Server
Server on elysees (using a non-default registry port number):
Client on octavian:
octavian 1356> java ATC.Airplane 100 /LosAngeles
RemoteException java.rmi.ConnectException: Connection refused
to host: [octavian.ics.uci.edu:1099]; nested exception is:
java.net.ConnectException: Connection refused
octavian 1357> java ATC.Airplane 100 elysees.ics.uci.edu/LosAngeles
RemoteException java.rmi.ConnectException: Connection refused
to host: [elysees.ics.uci.edu:1099]; nested exception is:
java.net.ConnectException: Connection refused
octavian 1358> java ATC.Airplane 100 elysees.ics.uci.edu:1033/LosAngeles
ATCException ATC.ATCException: flight 100: invalid position
octavian 1359>
elysees 1352> rmiregistry 1033 &
[1] 5398
elysees 1353> java ATC.ATCServer 1033 LosAngeles &
[2] 5407
elysees 1354>
25. 5
Unit -2
Java RMI
Other Possible
Architectures
A program or remote object can act as both a
client and a server
Example: 3-Tiered Client/Server
Client
Program
Legacy
Program
Remote
Data
Object
Remote
Data
Object
Server
Program
Remote
Business
Object
Remote
Business
Object
26. 6
Unit -2
Java RMI
Principal Similarities
Between CORBA and RMI
Suitable for distributed, object-oriented,
client/server systems
Synchronous interaction via remote procedure
call (RPC)
RPC implemented via client stubs and server
skeletons, which hide networking and data
representation
Objects can be both client and server
27. 7
Unit -2
Java RMI
Principal Differences
Between CORBA and RMI
CORBA
Independent of implementation language
Operation invocations can be formed statically or dynamically
Object implementation binding can be static or dynamic
The CORBA object adapters define various object execution
semantics
Many integrated object services are available
RMI
Requires objects to be programmed in Java
Objects are platform independent
Operation invocations are formed statically
Mapping of names to objects is static
Many object services are being defined within Enterprise JavaBeans
Mobile code support
28. 8
Unit -2
Java RMI
Sidebar Discussion:
Dynamic Proxies in Java
Introduced in J2SEv1.3 (JDK1.3)
Created using the java.lang.reflect.Proxy class
Allows dynamic creation of objects that
implement an arbitrary interface class without
writing code
All methods are called through a single invoke()
method, which you implement:
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
You can get a proxy with a call like this:
ActionListener listener =
(ActionListener)Proxy.createProxy(myInvocationHandler,
ActionListener.class);
損 Some detail omitted for clarity
29. 9
Unit -2
Java RMI
Why are Dynamic Proxies
useful?
A generic listener for Java events
Consider a generic debugging framework for Swing events that can
print every event to the screen
損 Dont need to create a new implementation for each type of
listener (ActionListener, WindowListener, MouseListener, etc.)
Dynamically create stubs for an RMI-like
middleware
This is implemented in a middleware called LJM (Lightweight Java
Middleware), which ships with ArchStudio 3
LJM allows you to do basically what RMI does except without
having to use rmic
LJM does not currently support mobile code aspects of RMI
30. 0
Unit -2
Java RMI
Discussion
How would we extend the example to allow a
Controller to give an Airplane instructions for
avoiding a dangerous position?
How would we extend the example to allow the
Controller to indicate an ATC exception condition
outside of a call to CurrentReport()?
How would we extend the example to allow the
Controller to tell the Airplane to check in with a
different Controller?