1 / 19

Pre-assessment Questions

Pre-assessment Questions Which of the following refers to the component-based approach of creating distributed applications? Two-tier architecture Three-tier architecture Monolithic architecture Single-tier architecture 2. Which of the following is NOT true for RMI?

Télécharger la présentation

Pre-assessment Questions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pre-assessment Questions • Which of the following refers to the component-based approach of creating distributed applications? • Two-tier architecture • Three-tier architecture • Monolithic architecture • Single-tier architecture • 2. Which of the following is NOT true for RMI? • RMI is a specification that enables one JVM to invoke methods of an object located in another JVM. • RMI is implemented on the middle-tier of the three-tier architecture framework. • RMI application run on cross-platform specification. • RMI supports cross-language specification. Network and Distributed Programming in Java

  2. Pre-assessment Questions • 3. RMI registry is a _____. • Server • Client • Middle-tier • Service • Which of the following services is provided by the transport layer in the RMI architecture? • Creating the connection between the client and server • Creating the server objects • Registering the server object • Invoking the remote method Network and Distributed Programming in Java

  3. Pre-assessment Questions • 5. Which system property controls the lease time? • java.rmi.dgc.lease.clean • javax.rmi.dgc.leaseValue • java.rmi.dgc.leaseValue • java.rmi.dgc.lease.dirty Network and Distributed Programming in Java

  4. Solutions to Pre-assessment Questions • 1. b. Three-tier Architecture • 2. d. RMI supports cross-language specification. • 3. d. Service • 4. a. Creating the connection between the client and server • 5. c.java.rmi.dgc.leaseValue Network and Distributed Programming in Java

  5. Objectives • In this lesson, you will learn about: • Transmit files using RMI • Create application using client-side callbacks Network and Distributed Programming in Java

  6. Demonstration-Transmitting Files Using RMI • Problem Statement • Create a distributed application using RMI, where an RMI client can download a file (plain text or binary) from the RMI server. Network and Distributed Programming in Java

  7. Demonstration-Transmitting Files Using RMI (Contd.) • Solution • The steps to create the distributed application using RMI are: • Create the FileRemote interface for the RMI server. • Create the FileRemoteImpl class that implements the FileRemote interface. • Create the RMIFileServer class. • Create the RMIFileClient class. • Run the application. Network and Distributed Programming in Java

  8. Client-Side Callbacks • In client-side callbacks: • The RMI server invokes the method of the RMI client. • The RMI client acts as an RMI server. • The RMI client extends the UnicastRemoteObjcet class. Network and Distributed Programming in Java

  9. Client-Side Callbacks (Contd.) • Creating an Application using Client-Side Callbacks • Create a remote interface for the client • Create a remote interface for the server • Implement the server interface • Implement the client interface • Create an RMI server • Create an RMI client • Run the client and server applications Network and Distributed Programming in Java

  10. Client-Side Callbacks (Contd.) • Creating Remote Interface for the Client • The code to create a remote interface for the RMI client is: • public interface CRemote extends Remote • { • public void displayValue(String s) throws RemoteException; • } Network and Distributed Programming in Java

  11. Client-Side Callbacks (Contd.) • Creating Remote Interface for the Server • The code to create a remote interface for the RMI server is: • public interface SRemote extends Remote • { • public void registerClient(CRemote c) throws RemoteException; • public CRemote getCallback() throws RemoteException; • } Network and Distributed Programming in Java

  12. Client-Side Callbacks (Contd.) • Implementing the Server Interface • The code snippet to implement the server interface is: • public class SRemoteImpl extends SRemote • { public void registerClient(CRemote c) throws RemoteException • { • .. .. .. • } • public CRemote getCallback() throws RemoteException • { • .. .. .. • } • } Network and Distributed Programming in Java

  13. Client-Side Callbacks (Contd.) • Implementing the Client Interface • The code snippet to implement the client interface is: • public class CRemoteImpl extends CRemote • { • public void displayvalue(String s) throws RemoteException • { • .. .. .. • } • } Network and Distributed Programming in Java

  14. Client-Side Callbacks (Contd.) • Creating an RMI Server • The code snippet to create the RMI server is: • public class CallbackServer • { • public static void main (String args []) throws Exception • { • SRemote b = new SRemoteImpl(); • UnicastRemoteObjcet.exportObjcet(b); Naming.rebind(“callback”, b); • } • } Network and Distributed Programming in Java

  15. Client-Side Callbacks (Contd.) • Creating an RMI Client • The code snippet to create the RMI client is: • public class CallbackClient • { • public static void main (String args []) throws Exception • { • CallbackS = (SRemote)Naming.lookup(“rmi://192.168.0.52/callback”); • CallbackC = callbackS.getCallback(); • UnicastRemoteObjcet.exportObjcet(callbackC); • callbackS.registerClient(callbackC); • } • } Network and Distributed Programming in Java

  16. Client-Side Callbacks (Contd.) • Running the Application • The steps to run an RMI application using client-side callbacks are: • Compile all the Java source files. • javac *.java • Generate the stub and skeleton for the RMI server. • rmic SRemoteImpl • Generate the stub and skeleton for the RMI client. • rmic CRemoteImpl • Start the RMI registry. • start rmiregistry • Run the server-side application. • java CallbackServer • Run the client-side application. • java CallbackClient Network and Distributed Programming in Java

  17. Demonstration-Implementing a Chat Application • Problem Statement • Create a chat application using RMI where an RMI server receives a message from one client and sends that message to all other clients. Network and Distributed Programming in Java

  18. Demonstration-Implementing a Chat Application (Contd.) • Solution • The steps to create the chat application using RMI are: • Create the ServerRemote interface for the chat server • Create the ClientRemote interface for the chat client. • Create the ChatServer class that implements the ServerRemote interface. • Create the ChatClient class that implements the ClientRemote interface. • Run the chat application. Network and Distributed Programming in Java

  19. Summary • In this lesson, you learned that: • You use serialization to convert a set of objects into byte streams. The byte streams can be sent from one JVM to another JVM. • When the RMI server calls back a remote method, such as progress feedback, or an alert message to the RMI client, these method calls are called client-side callbacks. • The RMI client calls the exportObject() method of java.rmi.server.UnicastRemoteObject class to allow the RMI server to perform client side callbacks. Network and Distributed Programming in Java

More Related