SlideShare a Scribd company logo
1 of 14
Remote Method Invocation(RMI)Concept
A java object runs within a Java Virtual Machine
(JVM), Likewise J2EE applications runs within a JVM;
however objects used by a j2ee application do not need
to run on the same JVM as the J2EE application. This is
because a J2ee application and its components can
invoke objects located on a different JVM by using the
Java Remote Invocation system.
RMI is used for remote communication between Java
application and components, both of which must be
written in the Java programming language.
RMI
• RMI is used to connect together a client and a server.
• A client is an application or component that requires the services of
an object to fulfill a request.
• A server creates an object and makes the object available to clients.
• A client contacts the server to reference and invoke the object by
using RMI.
• A client locates a remote object by either using the RMI naming
registry or by passing a string that reference the remote object .
•In either case, RMI returns a reference to the remote object, which
is then invoked by the client as if the object was on the local JVM.
RMI Process
 There are three steps necessary to make an object
available to remote clients.
1. to design an object,
2. to compile the object,
3. to make the object accessible to remote clients over the
network.
 Besides defining the business logic of an object, the
developer must define a remote interface for the object,
which identifies the methods that are available to remote
clients. Likewise those methods must be defined in the
object. In addition to methods that can be invoked by client ,
the developer must also define other methods that supports
the processing of the client-invoked methods. These are
referred to as server methods, while methods invoked by a
client are called client methods.
 Compilation of the object is a two-step process that
begins by compiling the object using the javac
compiler. The object must contain implementation of
the remote interface, and server and client methods.
 Once the object is compiled, you must create a stub
for the object. This is done by calling the RMI
compiler called rmic.
 The compiled object is then made accessible over
the network by loading the object to a server. Make
sure that RMI remote object registry is running;
otherwise, a remote client will be unable to access
the object. To start the RMI registry on windows NT,
type the following at the command line:
c:>start rmiregistry
Server Side
The sever side of a remote object invocation consists of a remote
interface and methods.
The remote interface is at the center of every remote object because the
remote interface defines how the client views the object. Methods provide
the business logic that fulfills a client’s request whenever the client
remotely invokes the method.
Import java.rmi.Remote;
Import java.rmi.RemoteException;
Public interface myApplication extends Remote
{
String myMethod() throws RemoteException;
}
It illustrates the remote interface definition and makes one method called
myMethod() available to clients. This method doesn’t requires an argument
and returns a String object, There would be many additional methods
appearing in a remote interface in a real-world J2EE application.
Implementing the remote Interface
import java.rmi.*;
import java.rmi.server.*;
public class myApplicationServer extends
UnicasteRemoteObject implements myApplication
{
public myApplicationserver() throws RemoteException
{
super();
}
public String myMethod()
{
returns “I’m here to server.n”;
}
public static void main(String [] args)
{
if(System.getSecurityManager()==null)
{
system.setSecurityManager(new RMISecurityManager());
}
String app=“//localhost/myApplication”;
Try
{
myApplicationserver=new myApplicationServer();
Naming.rebind(app,server);
}
Catch(Exception error)
{
system.err.println(“myApplicationServer
exception”+error.getMessage());
}
}
}
The program begins by importing the necessary packages that are
required to implement RMI and implements the myApplication remote
interface defined in the above.
Next the program defines the constructor and myMethod, which is the
only method contained in the object. This method simply returns the
String “I’m here to serve.n”. You can modify the method as
necessary based on the business rules that are implemented by the
object.
The program proceeds to create and install a security manager. A
security manager serves as a firewall and grants or rejects
downloaded code access to the local file system and similar
privileged operations. RMI requires that server-side applications
install a security manager. In this example the getSecurityManager()
method associates the server-side program with the securityManager
object.
Then the server-side program creates an instance of
myApplication and makes the remote object myMethod available to
remote clients by calling the rebind() method.
The rebind() method registers the remote object with the RMI
remote object registry or with another naming service. The object’s
name is “//host/myApplication” where host is the name or IP
address of the server.
Client-Side
The Client-Side program calls the
remote object defined in last program
which returns a String object that the
client-side program displays.
A real-world application requires the
remote object to perform complicated
operations that simply return a String
object.
import java.rmi.*;
public class myApplicationClient
{
public static void main(String[ ] args)
{
if(System.getsecurityManager()==null)
{
System.setSecurityManager(new RMISecurityManager());
}
try
{
String app=“//localhost/myApplication”;
myApplication mApp=(myApplication) Naming. lookup(app);
System.out.println(mApp.myMethod());
}
catch(Exception error)
{
System.err.println(“myApplicationClient exception:”+error.getMessage());
}
}
}
This example begins by creating a security manager
using the same method as described previously in the
server-side program.
Next, the lookup() method is used to locate the remote
object, which is called myApplication. The lookup()
method returns a reference to the object called myApp.
And the program calls the myMethod() method to invoke
the myMethod of the remote object. The myMethod
method returns a String object that is passed to the
println() method, which displays the contents of the
String object on the screen.
Any exceptions that are thrown while the client-side
program runs are trapped by the catch() block. The
catch() block calls the getMessage() method to retrieve
the error message that is associated with the exception.
The error message is then displayed on the Screen.
Before running the client, you need to
 Compile the source code.
 Compile the server class using the rmic compiler, which produces the
skeleton and the stub classes.
 Start the rmiregistry.
 Start the server.
 Run the client.
You’ll need to define the security properties as command-line
arguments when running the client program.
java –Djava.security.policy=c:/javacode/src/policy myApplicationServer
Here is the command-line necessary to run the server program:
java –Djava.rmi.server.codebase=file://c:/javacode/classes/-Djava.
security.Policy=c:/javacode/src/policy myApplicationServer
The Djava.rmi.server.codebase argument identifies the location of the
class Files. One or three forward slashes must precede the path
depending on the operating environment. The Djava.security.policy
argument identifies the location of the policy file.
grant
{
Permission java.security.AllPermission;
};

More Related Content

What's hot

Java RMI(Remote Method Invocation)
Java RMI(Remote Method Invocation)Java RMI(Remote Method Invocation)
Java RMI(Remote Method Invocation)Nilesh Valva
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method InvocationPaul Pajo
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocationashishspace
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocationDew Shishir
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Sonali Parab
 
Java remote method invocation
Java remote method invocationJava remote method invocation
Java remote method invocationVan Dawn
 
Java RMI Detailed Tutorial
Java RMI Detailed TutorialJava RMI Detailed Tutorial
Java RMI Detailed TutorialMasud Rahman
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMIbackdoor
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Peter R. Egli
 
Java RMI Presentation
Java RMI PresentationJava RMI Presentation
Java RMI PresentationMasud Rahman
 
remote method invocation
remote method invocationremote method invocation
remote method invocationRavi Theja
 

What's hot (20)

Rmi ppt-2003
Rmi ppt-2003Rmi ppt-2003
Rmi ppt-2003
 
Java rmi tutorial
Java rmi tutorialJava rmi tutorial
Java rmi tutorial
 
Java RMI(Remote Method Invocation)
Java RMI(Remote Method Invocation)Java RMI(Remote Method Invocation)
Java RMI(Remote Method Invocation)
 
Java rmi
Java rmiJava rmi
Java rmi
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Java RMI
Java RMIJava RMI
Java RMI
 
Rmi
RmiRmi
Rmi
 
Rmi architecture
Rmi architectureRmi architecture
Rmi architecture
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Rmi
RmiRmi
Rmi
 
Java remote method invocation
Java remote method invocationJava remote method invocation
Java remote method invocation
 
Java RMI Detailed Tutorial
Java RMI Detailed TutorialJava RMI Detailed Tutorial
Java RMI Detailed Tutorial
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
 
Java RMI Presentation
Java RMI PresentationJava RMI Presentation
Java RMI Presentation
 
Introduction To Rmi
Introduction To RmiIntroduction To Rmi
Introduction To Rmi
 
remote method invocation
remote method invocationremote method invocation
remote method invocation
 
Java RMI
Java RMIJava RMI
Java RMI
 

Viewers also liked

remote method invocation
remote method invocationremote method invocation
remote method invocationArun Nair
 
Java networking programs - theory
Java networking programs - theoryJava networking programs - theory
Java networking programs - theoryMukesh Tekwani
 
Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)eLink Business Innovations
 
Nature Of Financial Management-B.V.Raghunandan
Nature Of Financial Management-B.V.RaghunandanNature Of Financial Management-B.V.Raghunandan
Nature Of Financial Management-B.V.RaghunandanSVS College
 
Financial management ppt @ mba
Financial management ppt @ mbaFinancial management ppt @ mba
Financial management ppt @ mbaBabasab Patil
 
Financial Management Lesson Notes
Financial Management Lesson NotesFinancial Management Lesson Notes
Financial Management Lesson NotesEkrem Tufan
 
OBJECTIVES OF FINANCIAL MANAGEMENT
OBJECTIVES OF FINANCIAL MANAGEMENTOBJECTIVES OF FINANCIAL MANAGEMENT
OBJECTIVES OF FINANCIAL MANAGEMENTAnurag Chakraborty
 
Curriculum its meaning, nature and scope
Curriculum   its meaning, nature and scopeCurriculum   its meaning, nature and scope
Curriculum its meaning, nature and scopevalarpink
 
Importance of Financial Management
Importance of Financial ManagementImportance of Financial Management
Importance of Financial ManagementDr. Vickram Aadityaa
 
ppt on financial management
 ppt on financial management ppt on financial management
ppt on financial managementAanchal
 

Viewers also liked (17)

Ravi Tuppad
Ravi TuppadRavi Tuppad
Ravi Tuppad
 
Basic java
Basic java Basic java
Basic java
 
remote method invocation
remote method invocationremote method invocation
remote method invocation
 
Networking
NetworkingNetworking
Networking
 
Java networking programs - theory
Java networking programs - theoryJava networking programs - theory
Java networking programs - theory
 
Jdbc 1
Jdbc 1Jdbc 1
Jdbc 1
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
Java servlets
Java servletsJava servlets
Java servlets
 
Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)
 
Nature Of Financial Management-B.V.Raghunandan
Nature Of Financial Management-B.V.RaghunandanNature Of Financial Management-B.V.Raghunandan
Nature Of Financial Management-B.V.Raghunandan
 
Financial management ppt @ mba
Financial management ppt @ mbaFinancial management ppt @ mba
Financial management ppt @ mba
 
Financial Management Lesson Notes
Financial Management Lesson NotesFinancial Management Lesson Notes
Financial Management Lesson Notes
 
OBJECTIVES OF FINANCIAL MANAGEMENT
OBJECTIVES OF FINANCIAL MANAGEMENTOBJECTIVES OF FINANCIAL MANAGEMENT
OBJECTIVES OF FINANCIAL MANAGEMENT
 
Curriculum its meaning, nature and scope
Curriculum   its meaning, nature and scopeCurriculum   its meaning, nature and scope
Curriculum its meaning, nature and scope
 
Importance of Financial Management
Importance of Financial ManagementImportance of Financial Management
Importance of Financial Management
 
ppt on financial management
 ppt on financial management ppt on financial management
ppt on financial management
 
Software testing ppt
Software testing pptSoftware testing ppt
Software testing ppt
 

Similar to Rmi (20)

Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Rmi
RmiRmi
Rmi
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
 
17rmi
17rmi17rmi
17rmi
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
 
Rmi3
Rmi3Rmi3
Rmi3
 
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
 
Java RMI
Java RMIJava RMI
Java RMI
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Rmi
RmiRmi
Rmi
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
 
Call Back
Call BackCall Back
Call Back
 
Module 1 Introduction
Module 1   IntroductionModule 1   Introduction
Module 1 Introduction
 
Call Back
Call BackCall Back
Call Back
 
Call Back
Call BackCall Back
Call Back
 
Call Back
Call BackCall Back
Call Back
 
Rmi
RmiRmi
Rmi
 

More from Jafar Nesargi

Network adpater,cabel,cards ,types, network devices
Network adpater,cabel,cards ,types, network devicesNetwork adpater,cabel,cards ,types, network devices
Network adpater,cabel,cards ,types, network devicesJafar Nesargi
 
An introduction to networking
An introduction to networkingAn introduction to networking
An introduction to networkingJafar Nesargi
 
Computer basics Intro
Computer basics IntroComputer basics Intro
Computer basics IntroJafar Nesargi
 
Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database languageJafar Nesargi
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
Chapter 4 record storage and primary file organization
Chapter 4 record storage and primary file organizationChapter 4 record storage and primary file organization
Chapter 4 record storage and primary file organizationJafar Nesargi
 
Introduction to-oracle
Introduction to-oracleIntroduction to-oracle
Introduction to-oracleJafar Nesargi
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheetsJafar Nesargi
 
Session1 gateway to web page development
Session1   gateway to web page developmentSession1   gateway to web page development
Session1 gateway to web page developmentJafar Nesargi
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jspJafar Nesargi
 
Record storage and primary file organization
Record storage and primary file organizationRecord storage and primary file organization
Record storage and primary file organizationJafar Nesargi
 
Introduction to-oracle
Introduction to-oracleIntroduction to-oracle
Introduction to-oracleJafar Nesargi
 

More from Jafar Nesargi (20)

Network adpater,cabel,cards ,types, network devices
Network adpater,cabel,cards ,types, network devicesNetwork adpater,cabel,cards ,types, network devices
Network adpater,cabel,cards ,types, network devices
 
An introduction to networking
An introduction to networkingAn introduction to networking
An introduction to networking
 
Computer basics Intro
Computer basics IntroComputer basics Intro
Computer basics Intro
 
Css
CssCss
Css
 
Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database language
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
Chapter 4 record storage and primary file organization
Chapter 4 record storage and primary file organizationChapter 4 record storage and primary file organization
Chapter 4 record storage and primary file organization
 
Chapter3
Chapter3Chapter3
Chapter3
 
Introduction to-oracle
Introduction to-oracleIntroduction to-oracle
Introduction to-oracle
 
Chapter2
Chapter2Chapter2
Chapter2
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Session1 gateway to web page development
Session1   gateway to web page developmentSession1   gateway to web page development
Session1 gateway to web page development
 
Introduction to jsp
Introduction to jspIntroduction to jsp
Introduction to jsp
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Java bean
Java beanJava bean
Java bean
 
Networking
NetworkingNetworking
Networking
 
Chapter2 j2ee
Chapter2 j2eeChapter2 j2ee
Chapter2 j2ee
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 
Record storage and primary file organization
Record storage and primary file organizationRecord storage and primary file organization
Record storage and primary file organization
 
Introduction to-oracle
Introduction to-oracleIntroduction to-oracle
Introduction to-oracle
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

Rmi

  • 1. Remote Method Invocation(RMI)Concept A java object runs within a Java Virtual Machine (JVM), Likewise J2EE applications runs within a JVM; however objects used by a j2ee application do not need to run on the same JVM as the J2EE application. This is because a J2ee application and its components can invoke objects located on a different JVM by using the Java Remote Invocation system. RMI is used for remote communication between Java application and components, both of which must be written in the Java programming language.
  • 2. RMI • RMI is used to connect together a client and a server. • A client is an application or component that requires the services of an object to fulfill a request. • A server creates an object and makes the object available to clients. • A client contacts the server to reference and invoke the object by using RMI. • A client locates a remote object by either using the RMI naming registry or by passing a string that reference the remote object . •In either case, RMI returns a reference to the remote object, which is then invoked by the client as if the object was on the local JVM.
  • 3. RMI Process  There are three steps necessary to make an object available to remote clients. 1. to design an object, 2. to compile the object, 3. to make the object accessible to remote clients over the network.  Besides defining the business logic of an object, the developer must define a remote interface for the object, which identifies the methods that are available to remote clients. Likewise those methods must be defined in the object. In addition to methods that can be invoked by client , the developer must also define other methods that supports the processing of the client-invoked methods. These are referred to as server methods, while methods invoked by a client are called client methods.
  • 4.  Compilation of the object is a two-step process that begins by compiling the object using the javac compiler. The object must contain implementation of the remote interface, and server and client methods.  Once the object is compiled, you must create a stub for the object. This is done by calling the RMI compiler called rmic.  The compiled object is then made accessible over the network by loading the object to a server. Make sure that RMI remote object registry is running; otherwise, a remote client will be unable to access the object. To start the RMI registry on windows NT, type the following at the command line: c:>start rmiregistry
  • 5. Server Side The sever side of a remote object invocation consists of a remote interface and methods. The remote interface is at the center of every remote object because the remote interface defines how the client views the object. Methods provide the business logic that fulfills a client’s request whenever the client remotely invokes the method. Import java.rmi.Remote; Import java.rmi.RemoteException; Public interface myApplication extends Remote { String myMethod() throws RemoteException; } It illustrates the remote interface definition and makes one method called myMethod() available to clients. This method doesn’t requires an argument and returns a String object, There would be many additional methods appearing in a remote interface in a real-world J2EE application.
  • 6. Implementing the remote Interface import java.rmi.*; import java.rmi.server.*; public class myApplicationServer extends UnicasteRemoteObject implements myApplication { public myApplicationserver() throws RemoteException { super(); } public String myMethod() { returns “I’m here to server.n”; } public static void main(String [] args) {
  • 7. if(System.getSecurityManager()==null) { system.setSecurityManager(new RMISecurityManager()); } String app=“//localhost/myApplication”; Try { myApplicationserver=new myApplicationServer(); Naming.rebind(app,server); } Catch(Exception error) { system.err.println(“myApplicationServer exception”+error.getMessage()); } } }
  • 8. The program begins by importing the necessary packages that are required to implement RMI and implements the myApplication remote interface defined in the above. Next the program defines the constructor and myMethod, which is the only method contained in the object. This method simply returns the String “I’m here to serve.n”. You can modify the method as necessary based on the business rules that are implemented by the object. The program proceeds to create and install a security manager. A security manager serves as a firewall and grants or rejects downloaded code access to the local file system and similar privileged operations. RMI requires that server-side applications install a security manager. In this example the getSecurityManager() method associates the server-side program with the securityManager object.
  • 9. Then the server-side program creates an instance of myApplication and makes the remote object myMethod available to remote clients by calling the rebind() method. The rebind() method registers the remote object with the RMI remote object registry or with another naming service. The object’s name is “//host/myApplication” where host is the name or IP address of the server.
  • 10. Client-Side The Client-Side program calls the remote object defined in last program which returns a String object that the client-side program displays. A real-world application requires the remote object to perform complicated operations that simply return a String object.
  • 11. import java.rmi.*; public class myApplicationClient { public static void main(String[ ] args) { if(System.getsecurityManager()==null) { System.setSecurityManager(new RMISecurityManager()); } try { String app=“//localhost/myApplication”; myApplication mApp=(myApplication) Naming. lookup(app); System.out.println(mApp.myMethod()); } catch(Exception error) { System.err.println(“myApplicationClient exception:”+error.getMessage()); } } }
  • 12. This example begins by creating a security manager using the same method as described previously in the server-side program. Next, the lookup() method is used to locate the remote object, which is called myApplication. The lookup() method returns a reference to the object called myApp. And the program calls the myMethod() method to invoke the myMethod of the remote object. The myMethod method returns a String object that is passed to the println() method, which displays the contents of the String object on the screen. Any exceptions that are thrown while the client-side program runs are trapped by the catch() block. The catch() block calls the getMessage() method to retrieve the error message that is associated with the exception. The error message is then displayed on the Screen.
  • 13. Before running the client, you need to  Compile the source code.  Compile the server class using the rmic compiler, which produces the skeleton and the stub classes.  Start the rmiregistry.  Start the server.  Run the client. You’ll need to define the security properties as command-line arguments when running the client program. java –Djava.security.policy=c:/javacode/src/policy myApplicationServer Here is the command-line necessary to run the server program: java –Djava.rmi.server.codebase=file://c:/javacode/classes/-Djava. security.Policy=c:/javacode/src/policy myApplicationServer
  • 14. The Djava.rmi.server.codebase argument identifies the location of the class Files. One or three forward slashes must precede the path depending on the operating environment. The Djava.security.policy argument identifies the location of the policy file. grant { Permission java.security.AllPermission; };