Broker in practica: Middleware

Slides:



Advertisements
Similar presentations
Remote Method Invocation in Java Bennie Lewis EEL 6897.
Advertisements

Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
1 Advanced Programming Topics - II Objectives:  Background  Remoting  Types of remoting  Marshalling  Farmatters  Channels.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
Software Engineering Recitation 7 Suhit Gupta. Review Anything from last time???
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Introduction to Remote Method Invocation (RMI)
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
1 Java Programming II Java Network II (Distributed Objects in Java)
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
ICS 123 Java RMI ICS 123 Richard N. Taylor and Eric M. Dashofy* UC Irvine * with the usual thanks to David Rosenblum.
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
RMI-IIOP.  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
Remote Method Invocation onlineTraining/rmi/RMI.html.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Distributed Objects and Middleware. Sockets and Ports Source: G. Coulouris et al., Distributed Systems: Concepts and Design.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Creating Applications Using RMI Lesson 1B / Slide 1 of 19 Network and Distributed Programming in Java Pre-assessment Questions 1.Which of the following.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Remote Method Invocation A Client Server Approach.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Remote Method Invocation RMI architecture stubs and skeletons for remote services RMI server and client in Java Creating an RMI Application step-by- step.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Presentation 24 Ultra Simple.NET Remoting to CORBA bridge.
Netprog Java RMI1 Remote Method Invocation.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Java Distributed Computing
Chapter 4 Remote Method Invocation
Broker in practice: Middleware
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
Presentation 23 .NET Remoting Introduced
What is RMI? Remote Method Invocation
Remote Method Invocation
Funcţii Excel definite de utilizator (FDU) în VBA
Instrumente CASE Curs nr. 7.
Java RMI (more) CS-328 Internet Programming.
Arhitectura serviciilor web
Broker in practica: Middleware
UPB ETTI IISC Web Interactiv Floroiu Andrei.
Broker [POSA]-Fig/P.107.
prof. mrd. Negrilescu Nicolae Colegiul National Vlaicu Voda
Apache WEB Server.
Crearea si gazduirea serviciilor
A great way to create a channel of communication
Broker in practica: Middleware
Programarea in limbajul Java 2004 Lecturer: Gavrila Cristian
Crearea unei aplicatii Windows Forms simple
Harti de imagini, Cadre, Stiluri
Broker in practica: Middleware
Remote method invocation (RMI)
Overview of RMI Architecture
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Java Remote Method Invocation
Overview of RMI Architecture
Presentation transcript:

Broker in practica: Middleware Tool Generare Proxy-uri Biblioteca(API)+ Executabile Application Developer

Implementari de referinta ale arhitecturii Broker Middleware care implementeaza tiparul Broker: RMI: Java Remote Method Invocation CORBA: Common Object Request Broker Architecture. Arhitectura de referinta elaborata de OMG (Object Management Group) Diverse implementari, comerciale sau open .NET Remoting Windows Communication Foundation (WCF) – in parte si functionalitate de tip broker WSDL web services : proxy generators (WSDL-to-language) 

Invokes methods of Remote Object via a local Proxy object Arhitectura comuna Invokes methods of Remote Object via a local Proxy object Server Client implements Remote Interface Remote Object uses implements ClientSide Proxy ServerSide Proxy Broker

Exemplu Aplicatie distribuita simpla: realizarea unui sistem StockMarket, care poate fi interogat de la distanta asupra valorii curente a actiunilor unor companii specificate Middleware (Broker) utilizat - 3 variante: RMI .NET Remoting CORBA Se compara: Suportul oferit de cele 3 implementari de Broker pentru dezvoltarea unei aplicatii distribuite simple Pasii necesari pentru realizarea aplicatiei Exemplul ajuta la intelegerea functionarii unui Broker in general

Pasi de dezvoltare ai aplicatiei 1. Definire interfata obiect la distanta INTERFACE StockMarket float get_price(Company) 2. Implementare obiect 4. Implementare Server 5. Implementare Client StockMarketServer StockMarketClient StockMarketImpl 6. Rulare aplicatie 3. Generare Proxy 3. Generare Proxy StockMarket ClientSide PROXY StockMarket ServerSide PROXY Broker

RMI: Arhitectura Server Client implements Remote Interface Remote Object uses implements Stub (ClientSide Proxy) Skeleton (ServerSide Proxy) Remote Reference Layer Transport Layer

RMI - Pas1. Definire interfata Se defineste interfata StockMarket Aceasta exporta operatia get_price: Parametru: numele companiei cotate la bursa Rezultat: valoarea actiunilor package SimpleStocks; import java.rmi.*; public interface StockMarket extends java.rmi.Remote { float get_price (String Company) throws RemoteException; } Specific RMI: Interfata trebuie sa extinda java.rmi.Remote Metodele trebuie sa poata genera exceptii RemoteException Fisier StockMarket.java

RMI - Pas 2. Implementare Obiect Se implementeaza clasa StockMarketImpl Aceasta realizeaza operatia get_price import java.rmi.*; import java.rmi.server.UnicastRemoteObject; public class StockMarketImpl extends UnicastRemoteObject implements StockMarket { public StockMarketImpl() throws RemoteException {} public float get_price(String company) { float price=12345; return price; } Specific RMI: Implementarea trebuie sa extinda UnicastRemoteObject Fisier StockMarketImpl.java

RMI - Pas 3.V1: Generare Traditionala Proxy-uri RMI Stub/Skeleton Se genereaza automat din implementarea obiectului server cu ajutorul tool-ului rmic >rmic –v1.1 –keep StockMarketImpl Argumente: -v1.1 pentru ca incepand cu versiunea Java 1.2 implicit nu se mai genereaza skeleton-ul, de aceea e optiunea –v1.1 -keep ca sa pastreze si codul sursa al claselor generate (doar ca sa il putem vedea de curiozitate) Rezulta clase pentru stub si skeleton, utilizand conventia de nume: StockMarketImpl_Stub.class StockMarketImpl_Skel.class

RMI - Pas 4. Implementare Server Se implementeaza un program StockMarketServer, care creaza un obiect de tip StockMarket, ce poate fi accesat de la distanta Obiectul creat este inregistrat sub numele “NASDAQ” import java.rmi.*; import SimpleStocks.*; public class StockMarketServer { public static void main(String[] args) { try { StockMarketImpl stockMarketImpl = new StockMarketImpl(); Naming.rebind("NASDAQ", stockMarketImpl ); } catch (Exception e) {} } Specific RMI: Naming: Obiectul Server este inregistrat cu numele “Nasdaq” Fisier StockMarketServer.java

RMI - Pas 5. Implementare Client Se implementeaza un program StockMarketClient, care acceseaza un obiect de tip StockMarket aflat la distanta, si invoca operatia get_price pentru un nume de companie Prin intermediul Broker se localizeaza obiectul cu numele “NASDAQ” import java.rmi.*; import SimpleStocks.*; public class StockMarketClient { public static void main(String[] args) { try { StockMarket market= (StockMarket) Naming.lookup("rmi://localhost/NASDAQ"); float price=market.get_price("ABC SRL"); System.out.println("Price is "+price); } catch (Exception e) { System.out.println("Exception !");} } Specific RMI: Naming.lookup: se obtine o referinta (un proxy de fapt) la obiectul server care a fost inregistrat ca “Nasdaq” Nu trebuie sa gestionez deloc adrese ! Fisier StockMarketClient.java

RMI – To Do Checklist: Cod sursa scris de programatorul aplicatiei Stockmarket: StockMarket.java, StockMarketImpl.java, StockMarketServer.java, StockMarketClient.java Compilare cod sursa : javac *.java Generare proxy-uri: rmic –v1.1 StockMarketImpl Se obtin StockMarketImpl_Stub.class si StockMarketImpl_Skel.class Deployment Server: StockMarket.class, StockMarketImpl.class, StockMarketImpl_Skel.class, StockMarketServer.class Deployment Client: StockMarket.class, StockMarketImpl_Stub.class, StockMarketClient.class

RMI - Pas 6. Rulare aplicatie RMI Registry = non-persistent Naming Service > start rmiregistry > start java StockMarketServer > java StockMarketClient Codul aplicatiei exemplu poate fi download-ad de pe pagina cursului, de la sectiunea de exemple de cod pentru cursul c7: RMI_StockMarket

RMI - Pas 3.V2: Generare Proxy - Doar Client Varianta 2: In pasul 3 se genereaza doar RMI Stub Se genereaza automat din implementarea obiectului server >rmic StockMarketImpl Rezulta clase pentru stub, utilizand conventia de nume: StockMarketImpl_Stub.class Unde a disparut skeleton-ul ? (server-side proxy ?) - in acest caz, server-side proxy-ul generat specific aplicatiei este inlocuit cu unul general, care lucreaza exploatand faptul ca Java permite invocarea de metode prin Reflection

RMI – To Do Checklist – V2: Cod sursa scris de programatorul aplicatiei Stockmarket: StockMarket.java, StockMarketImpl.java, StockMarketServer.java, StockMarketClient.java Compilare cod sursa : javac *.java Generare proxy-uri: rmic StockMarketImpl Se obtine StockMarketImpl_Stub.class Deployment Server: StockMarket.class, StockMarketImpl.class, StockMarketServer.class Deployment Client: StockMarket.class, StockMarketImpl_Stub.class, StockMarketClient.class Rulare aplicatie

RMI - Pas 3.V3: fara generare Proxy Pasul 3 – Varianta 3: incepand cu versiunea Java 1.5, nu mai este necesara pre-generarea stub-ului cu rmic ! property java.rmi.server.ignoreStubClasses: daca e falsa, se asteapta sa gaseasca un stub pregenerat (by default e falsa) daca e true, nu mai e nevoie de existenta stub-urilor pre-generate cu rmic Unde a disparul si stub-ul ? (client-side proxy ?) de fapt el exista, dar poate fi generat dinamic la runtime, in mod total transparent pentru dezvoltatorul aplicatiei, prin mecanismul de dynamic proxy

RMI – To Do Checklist – V3: Cod sursa scris de programatorul aplicatiei Stockmarket: StockMarket.java, StockMarketImpl.java, StockMarketServer.java, StockMarketClient.java Compilare cod sursa : javac *.java Generare proxy-uri: Nu se mai face nimic ! (dar va trebui setat un property la rulare!) Deployment Server: StockMarket.class, StockMarketImpl.class, StockMarketServer.class Deployment Client: StockMarket.class, StockMarketClient.class Rulare aplicatie

RMI - Pas 6 – Varianta 3: Rulare aplicatie > start rmiregistry > start java StockMarketServer > java -Djava.rmi.server.ignoreStubClasses=true StockMarketClient

ORB (Object Request Broker) CORBA: Arhitectura Server Client Remote Interface IDL Remote Object Dynamic Invocation Interface IDL Stub (ClientSide Proxy) IDL Skeleton (ServerSide Proxy) Object Adapter ORB Interface Implem Repository Interface Repository ORB (Object Request Broker)

CORBA - Pas1. Definire interfata module SimpleStocks { interface StockMarket { float get_price(in string Company); }; Se defineste interfata StockMarket Aceasta exporta operatia get_price: Parametru: numele companiei cotate la bursa Rezultat: valoarea actiunilor Specific CORBA: Interfata se defineste intr-un limbaj neutru, CORBA IDL Fisier StockMarket.idl

CORBA - Pas 2. Generare Proxy-uri CORBA IDL Stub/Skeleton Se genereaza automat din definitia interfetei IDL > idl2java StockMarket.idl Rezulta clasele/fisierele: Client Stub: _st_StockMarket.java Server Stub: _StockMarketImplBase.java

CORBA - Pas 3. Implementare Obiect Se implementeaza clasa StockMarketImpl Aceasta realizeaza operatia get_price import org.omg.CORBA.*; import SimpleStocks.*; public class StockMarketImpl extends _StockMarketImplBase { public float get_price(in string company) { float price=12345; return price; } public StockMarketImpl (String name) { super(name); Specific CORBA: Un obiect accesibil la distanta trebuie sa extinda server-side-proxy-ul generat automat din descrierea interfetei Fisier StockMarketImpl.java

CORBA - Pas 4. Implementare Server import org.omg.CORBA.*; Import SimpleStocks.*; public class StockMarketServer { public static void main(String[] args) { try { ORB orb=ORB.init(); BOA boa=orb.BOA_init(); StockMarketImpl stockMarketImpl= new StockMarketImpl(“NASDAQ”); boa.obj_is_ready(stockMarketImpl); boa. Impl_is_ready(); } catch (Exception e) {} } Se implementeaza un program StockMarketServer, care creaza un obiect de tip StockMarketImpl, ce poate fi accesat de la distanta Obiectul creat este inregistrat sub numele “NASDAQ” Specific CORBA: ORB BOA Fisier StockMarketServer.java

CORBA - Pas 5. Implementare Client import org.omg.CORBA.*; import SimpleStocks.*; public class StockMarketClient { public static void main(String[] args) { try { ORB orb=ORB.init(); StockMarket market= StockMarketHelper.bind(orb, “NASDAQ”); market.get_price(“ABC SRL”); } catch (Exception e) {} } Se implementeaza un program StockMarketClient, care acceseaza un obiect de tip StockMarket aflat la distanta, si invoca operatia get_price pentru un nume de companie Prin intermediul Broker se localizeaza obiectul cu numele “NASDAQ” Specific CORBA: ORB StockMarketHelper = proxy generat Fisier StockMarketClient.java

CORBA - Pas 6. Rulare aplicatie Location service (numele OSAgent e specific unei anumite implementari CORBA) > start osagent start java StockMarketServer start java StockMarketClient

.NET Remoting Architecture Server Client Remote Interface Remote Object TransparentProxy RealProxy Remoting system Remoting system Channel

.NET – Pas 1. Definire Interfata Remote public interface StockMarket { float get_price(string company); } Fisier StockMarket.cs Se defineste interfata StockMarket Aceasta exporta operatia get_price: Parametru: numele companiei cotate la bursa Rezultat: valoarea actiunilor Specific .NET: Interfata nu contine nimic special Nu este neaparat nevoie sa fie definita o interfata

.NET – Pas 2. Definire Obiect Remote using System; public class StockMarketImpl : MarshalByRefObject, StockMarket{ public float get_price(string company){ return 12345; } Fisier StockMarketImpl.cs Se implementeaza clasa StockMarketImpl Aceasta realizeaza operatia get_price Specific .NET: Obiectul accesibil la distanta trebuie sa extinda MarshalByRefObject

.NET – Pas 3. Implementare Server Se implementeaza un program StockMarketServer, care creaza un obiect de tip StockMarket, ce poate fi accesat de la distanta Obiectul creat este inregistrat sub numele “NASDAQ” using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; public class StockMarketServer{ public static void Main(){ StockMarketImpl myStockMarket = new StockMarketImpl(); TcpChannel m_TcpChan = new TcpChannel(9999); ChannelServices. RegisterChannel(m_TcpChan); RemotingServices.Marshal( myStockMarket, "NASDAQ"); System.Console.WriteLine( "Listening for requests. Press ENTER to quit"); System.Console.ReadLine(); } Specific .NET: ChannelServices RemotingServices Fisier StockMarketServer.cs

.NET – Pas 4. Implementare Client Se implementeaza un program StockMarketClient, care acceseaza un obiect de tip StockMarket aflat la distanta, si invoca operatia get_price pentru un nume de companie Prin intermediul Broker se localizeaza obiectul cu numele “NASDAQ” using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; public class Client{ public static void Main(){ TcpChannel tcpChan = new TcpChannel(); ChannelServices.RegisterChannel(tcpChan); StockMarket stockMarket = (StockMarket) Activator.GetObject(typeof(StockMarket), "tcp://localhost:9999/NASDAQ"); Console.WriteLine(stockMarket.get_price( "abc SRL")); } Specific .NET: ChannelServices Activator.GetObject Fisier StockMarketClient.cs

.NET - Pas 5. Rulare aplicatie > Presupunand ca Windows si .NET Framework este instalat: start StockMarketServer start StockMarketClient

.NET - Pas 6. Creare Proxy ? Crearea de Proxy este total transparenta pentru developer-ul de aplicatii Proxy se creaza automat de catre .NET Framework in timpul executiei cand un client activeaza un obiect la distanta.