Java IDL Callback Object. interface Listener { void message(in string msg); }; interface MessageServer { void register(in Listener lt); };

Slides:



Advertisements
Similar presentations
CS Network Programming CS 3331 Fall CS 3331 Outline Socket programming Remote method invocation (RMI)
Advertisements

Using RMI–IIOP in the Development of Distributed Applications Dr. P.G.Sarang, President & ABCOM Information Systems Private. Limited.,
Practical Session 6 Multitasking vs. multithreading Threads Concurrency vs. Parallelism Java Threads Thread confinement Object/Class Immutability.
Input review If review Common Errors in Selection Statement Logical Operators switch Statements Generating Random Numbers practice.
SOCKET PROGRAMMING WITH MOBILE SOCKET CLIENT DEARTMENT OF COMPUTER SCIENCE IOWA STATE UNIVERSITY.
Slides for Chapter 20: CORBA Case Study From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 4, © Addison-Wesley 2005.
Remote method invocation. Introduction First introduced in JDK 1.1. Allows distributed Java programs to work with each others by behaving as if they are.
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Slide 1 Objektorienteret Middleware (OOMI) CORBA Programming: Presentation of a simple “Hello World” CORBA client and server application.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
MASIPE How does it work? Mobile Agent Systems Integration into Parallel Environments.
Integration with CORBA Page 1 Integration with CORBA Liang Tian April 23, 2001.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
RMI Varun SainiYing Chen. What is RMI? RMI is the action of invoking a method of a remote interface on a remote object. It is used to develop applications.
Ade Azurat, Advanced Programming 2004 (Based on LYS Stefanus’s slides) Advanced Programming 2004, Based on LYS Stefanus’s slides Slide 2.1 Multithreading.
Using TCP sockets in Java Created by M Bateman, A Ruddle & C Allison As part of the TCP View project.
1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. Mr. Colin Zhang With Thanks.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 11: CORBA.
Java Threads A tool for concurrency. OS schedules processes Ready Running 200 Blocked A process loses the CPU and another.
A First Java ORB Application 1  Object Request Broker (ORB)  This is the object manager in CORBA  Mechanisms for specifying interfaces  Interface Definition.
Java Networking -- Socket Server socket class: ServerSocket wait for requests from clients. after a request is received, a client socket is generated.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 13: CORBA.
Outline CORBA Programming Elements CORBA Programming Elements Server & Client Basics Server & Client Basics IDL Compiler IDL Compiler CORBA Naming Service.
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 Chapter 17 Coulouris text. Today’s Topics CORBA History and goals CORBA RMI CORBA services The Distributed Whiteboard Revisited.
Multithreading.
1 Aniruddha Gokhale Vanderbilt University, Spring 2003 Intro to TAO Programming Study the Hello example in ACE_wrappers/TAO/tests –Show IDL definition,
Programming with CORBA Hongtao Shi 04/23/01. §CORBA Overview §Advantages of CORBA §Interface Definition Language §Application: Address Book Outline.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
Distributed Objects and Remote Invocation: RMI and CORBA Most concepts are drawn from Chapter 17 © Pearson Education Rajkumar Buyya, Xingchen Chu, Rodrigo.
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 8: Distributed.
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.
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
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.
MSc Course in Advanced Distributed Systems Session 2.2: Practical CORBA Programming
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
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.
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.
Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction.
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:
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.
1 CSCD 330 Network Programming Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 9 Client-Server Programming.
Part 4: Network Applications Client-server interaction, example applications.
Remote Method Invocation with Java-RMI
1 Naming Service. 2 Naming service The CORBA COS (Common Object Services) Naming Service provides a tree- like directory for object references –It is.
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.
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.
IDL Models The Inheritance Model: Using the Inheritance Model, you implement the IDL interface using an implementation class that also extends the compiler-generated.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
Object-Oriented Middleware (OOMI) Locating Distributed Objects Emmerich – Chapter
Liang, Oreilly, Herbert Schildt, Joseph O’Neil, Simon Roberts, IBM Corp Advanced Java Programming CSE 7345/5345/ NTU 531 Multithreaded/Sockets/Server Welcome.
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.
Only small steps in CORBA programming – much complexity
Remote Method Invocation
L3. Necessary Java Programming Techniques
L3. Necessary Java Programming Techniques
The Common Object Request Broker Architecture (CORBA)
Remote method invocation (RMI)
Presentation transcript:

Java IDL Callback Object

interface Listener { void message(in string msg); }; interface MessageServer { void register(in Listener lt); };

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 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"); //Instantiate Servant and create reference POA rootPOA = POAHelper.narrow( orb.resolve_initial_references("RootPOA")); MessageServerImpl msImpl = new MessageServerImpl(); rootPOA.activate_object(msImpl); MessageServer msRef = MessageServerHelper.narrow( rootPOA.servant_to_reference(msImpl)); //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...."); //REMOVE THE NEXT LINE FOR THE SIMPLER EXAMPLE msImpl.startReadThread(); orb.run(); } catch (Exception e) { e.printStackTrace(); }

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; public MessageServerImpl() { rt = new ReadThread(this); } public void register(Listener lt) { clients.add(lt); } public void startReadThread() { rt.start(); } 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 }

//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)); try { for (;;) { System.out.print("message > "); String msg = br.readLine(); msImpl.message(msg); } } catch (Exception e) { e.printStackTrace(); }

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"); //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(

//Register listener reference (callback object) with MessageServer msgServer.register(ref); System.out.println("Listener registered with MessageServer"); //Activate rootpoa rootPOA.the_POAManager().activate(); //Wait for messages System.out.println("Wait for incoming messages"); orb.run(); } catch (Exception e) { e.printStackTrace(); }

public class ListenerImpl extends ListenerPOA { public void message(String msg) { System.out.println("Message from server : " + msg); }