Activation of remote objects

Similar documents
Activation of remote objects

Java RMI Activation: A running example We have the following classes: MyRemoteInterface: the remote interface. Client: the client that invokes a

Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma. Distributed and Agent Systems RMI

JAVA RMI Java, summer semester

Remote Procedure Calls

JAVA RMI. Remote Method Invocation

Remote Method Invocation in Java

Remote Method Invocation

Generic architecture

The UNIVERSITY of EDINBURGH. SCHOOL of INFORMATICS. CS4/MSc. Distributed Systems. Björn Franke. Room 2414

RMI Case Study. A Typical RMI Application

5.4. Events and notifications

Last Class: Network Overview. Today: Distributed Systems

RPC and RMI. 2501ICT Nathan

Written by: Dave Matuszek

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

RMI. Remote Method Invocation. 16-Dec-16

presentation DAD Distributed Applications Development Cristian Toma

RMI. (Remote Method Invocation)

Java. Java. Java. Java. java. java. test.java. smalltalk. java. static. java virtual machine. java. C++ virtual

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

RMI Example RMI. CmpE 473 Internet Programming RMI

Java. Java. Java. Java. java. smalltalk. java. java virtual machine. java. C++ virtual. interface C++ Operator overloading Template C++ test.

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development:

Remote Procedure Call

Remote Method Invocation

CS193k, Stanford Handout #12. Threads 4 / RMI

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Desarrollo de Aplicaciones en Red RMI. Introduction. Considerations. Considerations. RMI architecture

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Modulo II Socket, RMI e Corba

Component-Based Software Engineering

Applications. RMI, RPC and events. Request reply protocol External data representation. Operating System

Distributed Software Systems

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

Remote Objects and RMI

A Typical RMI Application

A Typical RMI Application. Case Study

Remote Method Invocation

Course Snapshot. The Next Few Classes. Parallel versus Distributed Systems. Distributed Systems. We have covered all the fundamental OS components:

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017

Course Snapshot. The Next Few Classes

Distributed Programming in Java. Distribution (2)

Distributed Computing

#,!" $* ( #+,$ $$ $# -.,$ / 0' ".12 $ $$ 5/ #$" " " $ $ " # $ / 4 * # 6/ 8$8 ' # 6 $! 6$$ #$ * $ $$ ** 4 # 6 # * 0; & *! # #! #(' 7 / $#$ -.

Distributed Systems COMP 212. Lecture 10 Othon Michail

Reflection/RMI 4/28/2009

CS 5523 Operating Systems: Remote Objects and RMI

REMOTE METHOD INVOCATION INTRODUCTION TO RMI, A JAVA API FOR RPC-STYLE INVOCATION OF REMOTE OBJECT METHODS

Verteilte Systeme (Distributed Systems)

Chapter 5 Distributed Objects and Remote Invocation

Chapter 4: Processes. Process Concept. Process State

IBD Intergiciels et Bases de Données

Sockets and RMI. CS151 Chris Pollett Dec. 5, 2005.

Distributed object component middleware I - Java RMI

Distributed Objects SPL/ SPL 201 / 0 1

Distributed object component middleware I - Java RMI

Distributed Systems. 5. Remote Method Invocation

Remote Method Invocation Benoît Garbinato

Remote Method Invocation. Benoît Garbinato

How are classes loaded into the Java Virtual Machine (JVM)? from the local file system (CLASSPATH). by an instance of ClassLoader

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP)

Bharati Vidyapeeth s Institute of Computer Applications and Management A-4, Paschim Vihar, New Delhi-63.

Remote Method Invocation R.M.I.

Distributed Programming with RMI. Overview CORBA DCOM. Prepared By: Shiba R. Tamrakar

IJESRT. http: //

Chapter 4 Remote Procedure Calls and Distributed Transactions

Communication and Distributed Processing

1 interface TemperatureSensor extends java.rmi.remote 2 { 3 public double gettemperature() throws java.rmi.remoteexception; 4 public void

Lab 2 : Java RMI. request sayhello() Hello interface remote object. local object. response "Hello world"

2018/2/5 话费券企业客户接入文档 语雀

Java and Distributed Systems

Communication and Distributed Processing

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9,

Creating a Client Program

CSci Introduction to Distributed Systems. Communication: RPC In Practice

Java WebStart, Applets & RMI

EAST WEST UNIVERSITY

JAC444 - Lecture 11. Remote Method Invocation Segment 2 - Develop RMI Application. Jordan Anastasiade Java Programming Language Course

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

Communication Basics, RPC & RMI. CS403/534 Distributed Systems Erkay Savas Sabanci University

Title: DISTRIBUTED COMPUTING USING JINI -Example Author: Elango Sundaram

Chapter 15: Distributed Communication. Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration

4:40pm - 6:10pm (90 min)

Info 408 Distributed Applications programming 2 nd semester of Credits: 5 Lecturer: Antoun Yaacoub Ph.D.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

BEA WebLogic Server. Programming WebLogic RMI

Are Sockets a Good Programming Paradigm? EDA095 Remote Method Invocation. The Remote Procedure Call Model. The Remote Procedure Call Architecture

Remote Method Invocation Java RMI & Web-Services

Outline. Chapter 4 Remote Procedure Calls and Distributed Transactions. Remote Procedure Call. Distributed Transaction Processing.

Grid Computing. Java Remote Method Invocation (RMI) RMI Application. Grid Computing Fall 2006 Paul A. Farrell 9/5/2006

BEA WebLogic. Server. Programming WebLogic RMI

EDA095 Remote Method Invocation

Advanced Java Programming

EDA095 Remote Method Invocation

Distributed Objects. Remote Method Invokation

Department of Computer Science & Engineering. M.Tech(CSE)-I Year-II Semester WEB SERVICES AND SERVICE ORIENTED ARCHITECHTURE (B1513) Mr.K.

Distributed Applications Programming. Lab 4

Transcription:

Activation of remote objects The Activatable class Prior to the release of Java 2 SDK, an instance of a UnicastRemoteObject could be accessed from a server program that created an instance of the remote object ran all the time With the introduction of the class java.rmi.activation.activatable and the RMI daemon, rmid, programs can be written to register information about remote object implementations that should be created and execute "on demand, rather than running all the time The RMI daemon, rmid, provides a Java virtual machine from which other JVM instances may be spawned

import java.rmi.*; The Remote Interface public interface MyRemoteInterface extends Remote { public Object callmeremotely() throws RemoteException; import java.rmi.*; The Client public class Client { public static void main(string args[]) { String server = "localhost"; System.setSecurityManager(new RMISecurityManager()); try { String location = "rmi://" + server + "/ActivatableImplementation"; MyRemoteInterface mri = (MyRemoteInterface)Naming.lookup(location); String result = "failure"; System.out.println("Making remote call to the server"); result = (String)mri.callMeRemotely(); System.out.println("Returned from remote call"); System.out.println("Result: " + result); catch (Exception e) {e.printstacktrace();

The Remote Interface Implementation There are four steps to create animplementation class Make the appropriate imports in the implementation class Extend your class from java.rmi.activation.activatable Declare a two-argument constructor in the implementation class Implement the remote interface methods The Remote Interface Implementation import java.rmi.*; import java.rmi.activation.*; public class ActivatableImplementation extends Activatable implements MyRemoteInterface { public ActivatableImplementation(ActivationID id, MarshalledObject data) throws RemoteException { super(id, 0); public Object callmeremotely() throws RemoteException { return "Success";

The Setup Class The job of the "setup" class is to create all the information necessary for the activatable class, without necessarily creating an instance of the remote object The setup class passes the information about the activatable class to rmid, registers a remote reference (an instance of the activatable class's stub class) and an identifier (name) with the rmiregistry, and then the setup class may exit The Setup Class /2 There are sevensteps to create a setup class: Make the appropriate imports Install a security manager Create an ActivationGroup instance Create an ActivationDesc instance Declare aninstance of your remote interface and register with rmid Bind the stub to a name in the rmiregistry Quit the setup application

The Setup Class /3 In this example, for simplicity, we use a policy file that gives globalpermission to anyone from anywhere Do not use this policy file in a production environment In the setup application, the job of the activation group descriptor is to provide all the information that rmid will require to contact the appropriate existing JVM or spawn a new JVM for the activatable object The Setup Class /4 import java.rmi.*; import java.rmi.activation.*; import java.util.properties; public class Setup { public static void main(string[] args) throws Exception { System.setSecurityManager(new RMISecurityManager()); Properties props = new Properties(); props.put("java.security.policy", "/home/rmi/activation/policy"); ActivationGroupDesc.CommandEnvironment ace = null; ActivationGroupDesc examplegroup = new ActivationGroupDesc(props, ace); ActivationGroupID agi = ActivationGroup.getSystem(). registergroup(examplegroup); [to be continued ]

The Setup Class /5 String location = "file:/home/rmi/activation/"; MarshalledObject data = null; ActivationDesc desc = new ActivationDesc(agi, "ActivatableImplementation", location, data); MyRemoteInterface mri = (MyRemoteInterface)Activatable.register(desc); System.out.println("Got the stub for the ActivatableImplementation"); Naming.rebind("ActivatableImplementation", mri); System.out.println("Exported ActivatableImplementation"); System.exit(0); //main //clas Setup Compiling and Running the Code There are six steps to compile and run the code: Compile the remote interface, implementation, client, and setup classes Run rmic on the implementation class Start the rmiregistry Start the activation daemon, rmid for Sun s implementation rmid -J-Dsun.rmi.activation.execPolicy=none Run the setup program Run the client

More Information about RMI /1 Other activation features Activation of an object thatdoes notextend java.rmi.activation.activatable Activation of a UnicastRemoteObject http://java.sun.com/j2se/1.4.2/docs/ guide/rmi/activation More Information about RMI /2 Java security http://java.sun.com/products/jdk/1.2/doc /guide/security Use of RMI with SSL Custom socket factories for RMI-based communication An applicationcan export a remote object to use an RMI socket factory that creates SSL sockets, so it can use SSL socket communication instead of the default socket communication Java 2 SDK, v1.4 includes the Java Secure Socket Extension (JSSE) API which provides an implementation of SSL sockets http://java.sun.com/products/jsse/

More Information about RMI /3 The java.sun.com Web site William Grosso, Java RMI, O Reilly, 2001