RMI Basics - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

RMI Basics

Description:

... to make communications between two programs running ... over the network. Demarshalls data. and invokes server. method. Invokes methods. implemented by ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 11
Provided by: tklak
Category:

less

Transcript and Presenter's Notes

Title: RMI Basics


1
RMI Basics
Celsina Bignoli bignolic_at_smccd.net
2
Socket-based code components
  • business logic
  • user interface for client
  • marshalling/demarshalling
  • launch and configuration of the application
  • robustness (load balancing, threading)

TAKEN CARE OF AUTOMATICALLY BY RMI
3
RMI
  • RMI was designed to make communications between
    two programs running in different JVMs as close
    as possible to method calls inside a single
    process
  • relies on two objects that are automatically
    generated by the RMI compiler
  • stub
  • skeleton

4
Stubs and Skeletons
Client
Server
Invokes methods implemented by server
Network
Stub
Skeleton
Marshalls data and sends invocation over the
network
Demarshalls data and invokes server method
5
RMI Compiler (rmic)
  • rmic is a command line compiler shipped as part
    of the JDK
  • Usage
  • rmic full class name including packages
  • Example
  • rmic com.ora.rmiexample.RMITest
  • generates
  • com.ora.rmiexample.RMITest_Stub
  • com.ora.rmiexample.RMITest_Skel
  • Use option -keep to generate the source code for
    the stub and skeleton classes

6
Passing by Value vs. by Reference
  • RMI distinguishes between
  • Remote objects
  • receive remote method invocations
  • have a fixed location
  • passed by reference
  • Serializable objects
  • location is not relevant to their state
  • encapsulate data
  • are mobile between JVMs
  • passed by value
  • primitive data types are passed by value
  • objects that are not Serializable nor Remote
    cause an exception to be thrown

7
Naming Service
  • runs on a central server and functions like a
    phone book
  • client must
  • connect to naming service to find out where
    server is running
  • connect to server
  • stable applications
  • simple APIs that change rarely

8
RMI Registry
  • Default naming service for the Sun version of the
    JDK
  • Methods are defined in nava.rmi.Naming
  • Names in it are formatted as
  • //host-nameport-number/human-readable-name
  • host-name name of the host where the RMI
    Registry run
  • port-number port for the RMI registry
  • human-readable-name name used by the registry to
    identify the server

9
Architecture
Server
Client
Printer
network
local connection
Registry
10
Serialization
  • process of transforming an object in a stream of
    bytes
  • classes intended to be serialized must implement
    the Serializable interface
  • class must be obviously serializable or
  • declared transient
  • implement readObject() and writeObject() methods
    to be used by the serialization algorithm.
  • obviously serializable is a class which
    references primitive values or classes that are
    serializable
Write a Comment
User Comments (0)
About PowerShow.com