1 callback. 2 Client programs often react to changes or updates that occur in a server. For example, a client graph or spreadsheet program might need.

Slides:



Advertisements
Similar presentations
Slides for Chapter 20: CORBA Case Study From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 4, © Addison-Wesley 2005.
Advertisements

Java IDL Callback Object. interface Listener { void message(in string msg); }; interface MessageServer { void register(in Listener lt); };
Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
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.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 11: CORBA.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 13: CORBA.
By Dr. Jiang B. Liu 11. Java IDL and CORBA  Generic ORB Core  idltojava development tool  CORBA Object Service (COS) name service - nameserv  Java.
CORBA. A CORBA example From url: es/releases/corba/ The transient server example.
1 First app – simplechat1 Reminder: what’s the point?  To build on ocsf framework.  Simple requirements: echo all messages to all clients.  Use only.
CORBA Chapter 17 Coulouris text. Today’s Topics CORBA History and goals CORBA RMI CORBA services The Distributed Whiteboard Revisited.
Multithreading.
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
1 Java Programming II Java Network II (Distributed Objects in Java)
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
Location Based Information Service using CORBA CS597 Direct Reading Madhu Narayanan & Rahul Vaghela Advisor: Dr. Yugi Lee.
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 8: Distributed.
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
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.
Copyright (c) Qusay H. Mahmoud 1 The Naming Service (Client’s View) A tree-like directory for object references Much like a file system: provides directory.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Slide 1 CORBA Programming: Presentation of a simple “Hello World” CORBA client and server application ITONK1.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
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.
IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.
Abhishek Bachchan Vishal Patangia
CORBA/IDL Common Object Resource Broker Architecture (CORBA) Interface Definition Language (IDL) Object Management Group (OMG) ( Specification.
CORBA – Command Line CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
RMI-IIOP.  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple.
Lecture 9 Network programming. Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet.
MSc Course in Advanced Distributed Systems Session 2.2: Practical CORBA Programming
Presentation: RMI Continued 2 Using The Registry & Callbacks.
CORBA Details Three Tier Architecture CORBA API Holders and Helpers COS Naming and Naming Contexts Transient and Persistent Objects Properties Callbacks.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
Vakgroep Informatietechnologie - IBCN CORBA & RMI Design of Distributed Software.
Slides for Chapter 17: CORBA Case Study From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley 2001.
CORBA – Eclipse CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
CORBA_1/001 Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CORBA:
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Li Tak Sing COMPS311F. RMI callbacks In previous example, only the client can initiate a communication with the server. The server can only response to.
IBM TSpaces Lab 3 Transactions Event Registration.
1 CORBA. 2 What options do I have for distributed application development using java? 1.RMI-IIOP is for developers who program in the Java programming.
Server-Side Java Mapping Copyright © ZeroC, Inc. Ice Programming with Java 6. Server-Side Java Mapping.
RMI Observing the Distributed Pattern. Adrian German Lecturer, Computer Science Indiana University Bloomington.
Java Server Programming Web Interface for Java Programs.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Remote Method Invocation with Java-RMI
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Slide 1 of 15 © Ingeniørhøjskolen i Århus CORBA Programming: Presentation of a simple “Hello World” CORBA client and server application.
Java Programming II Java Network (I) Java Programming II.
1 Lecture 9: Network programming. 2 Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
RMI Example. Compilation: /home2/fccheng/temp/RMI2> javac MyObject.java /home2/fccheng/temp/RMI2> javac RemoteServer.java /home2/fccheng/temp/RMI2> javac.
Distributed Computing in Life Science Research -Presenter: Yijian Yang
IDL Models The Inheritance Model: Using the Inheritance Model, you implement the IDL interface using an implementation class that also extends the compiler-generated.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Object-Oriented Middleware (OOMI) Locating Distributed Objects Emmerich – Chapter
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
CORBA Barış COŞKUN Çağatay DİKİCİ. INTRODUCTION Computer networks are heterogenous In 1989 OMG(Object Management Group) was formed to address the problems.
Echo Networking COMP
Threads in Java Two ways to start a thread
Only small steps in CORBA programming – much complexity
Data Transport for Online & Offline Processing
The Common Object Request Broker Architecture (CORBA)
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Presentation transcript:

1 callback

2 Client programs often react to changes or updates that occur in a server. For example, a client graph or spreadsheet program might need to be updated with each stock price update on a stock market server. The client has two options in this scenario: –Periodically ask for the stock price via a method request on the stock server. This is known as the "polling" or "pull" model. –Ask to be notified by the server whenever a price change occurs. This option is referred to as a "callback" or the "push" model.

3 callback The example in this lecture illustrates –how a client program can pass a callback object to a server, and –the server can then callback to notify changes to the client. At this time, we have provided the code for an extension of a simple application. Notes about simplifying the application are contained within the code.

4 callback This lecture provides the code for: –The IDL for an example program with a callback.IDL –A server implementation that callsback to a client.server –A client that sends a callback object reference to a server.client –An implementation of the Listener.Listener –An implementation of the MessageServer.MessageServer

5 Writing the IDL file For the example application, the file callback.idl looks like this: interface Listener { void message(in string msg); }; interface MessageServer { void register(in Listener lt); };

6 Writing the Server Code import org.omg.CORBA.ORB; import org.omg.PortableServer.POA; import org.omg.PortableServer.POAHelper; import org.omg.CosNaming.NameComponent; import org.omg.CosNaming.NamingContext; import org.omg.CosNaming.NamingContextHelper; import java.util.Properties; public class Server { public static void main(String[] args) { try { //create and initialize the ORB Properties props = System.getProperties(); props.put("org.omg.CORBA.ORBInitialPort", "1050"); //Replace MyHost with the name of the host on which you are running the server props.put("org.omg.CORBA.ORBInitialHost", " "); ORB orb = ORB.init(args, props); System.out.println("Initialized ORB");

7 Writing the Server Code (cont.) //Bind reference with NameService NamingContext namingContext = NamingContextHelper.narrow( orb.resolve_initial_references("NameService")); System.out.println("Resolved NameService"); NameComponent[] nc = { new NameComponent("MessageServer", "") }; namingContext.rebind(nc, msRef); //Activate rootpoa rootPOA.the_POAManager().activate(); //Start readthread and wait for incoming requests System.out.println("Server ready and running....");

8 Writing the Server Code (cont.) //REMOVE THE NEXT LINE FOR THE SIMPLER EXAMPLE msImpl.startReadThread(); orb.run(); } catch (Exception e) { e.printStackTrace(); }

9 Writing the MessageServer Implementation The file –registers new clients, –accepts messages, –then relays the messages to the registered clients. import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Vector; import java.util.Iterator; public class MessageServerImpl extends MessageServerPOA { private Vector clients = new Vector(); private ReadThread rt = null;

10 Writing the Message Server Implementation (cont) public MessageServerImpl() { rt = new ReadThread(this); } public void register(Listener lt) { clients.add(lt); } public void startReadThread() { rt.start(); }

11 Writing the Message Server Implementation (cont) public void message(String msg) { Iterator it = clients.iterator(); while (it.hasNext()) { Listener lt = (Listener) it.next(); lt.message(msg); //FOR THE SIMPLER EXAMPLE, ADD A SIMPLE //MESSAGE TO BE CALLED BACK, FOR EXAMPLE, //SLEEP FOR 30 SECONDS, THEN SEND THE TIME }

12 Writing the Message Server Implementation (cont) //EXCLUDE THIS CLASS FOR THE SIMPLER EXAMPLE class ReadThread extends Thread { MessageServerImpl msImpl = null; public ReadThread(MessageServerImpl msImpl) { this.msImpl = msImpl; } public void run() { BufferedReader br = new BufferedReader( new InputStreamReader(System.in));

13 Writing the Message Server Implementation (cont) try { for (;;) { System.out.print("message > "); String msg = br.readLine(); msImpl.message(msg); } } catch (Exception e) { e.printStackTrace(); }

14 Writing the Client Code import java.util.Properties; import org.omg.CORBA.ORB; import org.omg.PortableServer.POA; import org.omg.PortableServer.POAHelper; import org.omg.CosNaming.NameComponent; import org.omg.CosNaming.NamingContext; import org.omg.CosNaming.NamingContextHelper; public class Client { public static void main(String[] args) { try { //initialize orb Properties props = System.getProperties(); props.put("org.omg.CORBA.ORBInitialPort", "1050"); //Replace MyHost with the name of the host on which you are running the server props.put("org.omg.CORBA.ORBInitialHost", " "); ORB orb = ORB.init(args, props); System.out.println("Initialized ORB");

15 Writing the Client Code (cont) //Instantiate Servant and create reference POA rootPOA = POAHelper.narrow( orb.resolve_initial_references("RootPOA")); ListenerImpl listener = new ListenerImpl(); rootPOA.activate_object(listener); Listener ref = ListenerHelper.narrow( rootPOA.servant_to_reference(listener)); //Resolve MessageServer MessageServer msgServer = MessageServerHelper.narrow( Server")); //Register listener reference (callback object) with MessageServer msgServer.register(ref); System.out.println("Listener registered with MessageServer");

16 Writing the Client Code //Activate rootpoa rootPOA.the_POAManager().activate(); //Wait for messages System.out.println("Wait for incoming messages"); orb.run(); } catch (Exception e) { e.printStackTrace(); }

17 Writing the Listener Implementation When the Listener identifies that a message has been received from the server, it displays the message on the client. For the example application, the ListenerImpl.java file looks like the following example. public class ListenerImpl extends ListenerPOA { public void message(String msg) { System.out.println("Message from server : " + msg); }

18 Instructions for compiling and running the example idlj -fall callback.idl javac *.java start orbd -ORBInitialPort 1050 start java Server -ORBInitialPort ORBInitialHost localhost java Client -ORBInitialPort ORBInitialHost localhost

19 Server

20 Client 1

21 Client 2

22 References dl/jidlExample3.html