DIFFERENCE BETWEEN APPLET AND APPLICATION

Size: px
Start display at page:

Download "DIFFERENCE BETWEEN APPLET AND APPLICATION"

Transcription

1 Module 4 Network Programming with Java - *Features of Java Applets & Application Life cycle of applets - Security features for applets - Inter applet communication *Threads & Thread synchronization TCP/IP Programming with Java Iterative & Concurrent servers. Datagrams, IP multicasting, RMI (Structure and Working of a simple RMI Program only) *Covered already in module 3 APPLETS You have learned to create applications in Java. To create a user interactive application, you use the command-line arguments, which are restricted and not very user friendly. A better alternative is to use forms to interact with the user. To accept data from the user, you can create applets in Java. Java provides Java Development Kit (JDK) that enables to create user interactive forms in applets.jdk consists of a package called Abstract Window Toolkit (AWT). AWT is an Application Programming Interface (API) that is responsible for building the Graphical User Interface (GUI) in Java. The API of the AWT package consists of a collection of classes and methods that enables you to design and manage the Graphical User Interface (GUI) applications. The AWT package supports applets, which help in creating containers, such as frames or panels that run in the GUI environment. Java programs are categorized into applications and applets. An application is a Java program that runs by using the Java interpreter from the command line. Java applications support the Character User Interface (CUI). An applet is a Java program that can be embedded in an HTML Web page. An applet is compiled on one computer and can run on another computer through a Java enabled Web browser or an appletviewer. Applets are developed to support the GUI in Java. DIFFERENCE BETWEEN APPLET AND APPLICATION

2 PACKAGES AND CLASSES FOR APPLETS The java.applet package consists of the classes required to do applet programming. The java.applet package contains a class called Applet which is most significant as far as applet programming is concerned. Any a applet program should extend this class CLASS HIEARCHY OF Applet class The Applet class extends from the Panel class, which further extends from the Container, Component, and Object classes. The Object class is the member of java.lang package and is located at the top hierarchy of all the Java packages. The Object class is automatically imported in all programs. The Component, Container, and Panel classes are the members of the java.awt package and provide components, such as label, button, or text fields. The Applet class is the only member of the java.applet package. The Applet class contains various methods that are used to display text and image, play an audio file, and respond when you interact with an applet. The following table lists the various methods of the Applet class:

3 CREATING AN APPLET To create an applet, you need to follow these steps: 1. Create a Java program for the Applet. 2. Compile the Java program.

4 3. Create a Web page that contains an applet. 4. Run the applet. You can use the following code to create an applet that displays text: import java.applet.*; // Importing the applet package import java.awt.*; // importing the awt package public class myapplet extends Applet public void paint(graphics g) g.drawstring("hello, This is my first Java Applet", 50, 100); In the preceding code, the myapplet class imports the java.applet and the java.awt packages to include the declaration of various built-in methods that are required for running an applet. The extends keyword inherits the properties of the Applet class. You need the Graphics class to write in an applet. The myapplet class contains the paint() method that overrides the default behavior of the Graphics class. You use the drawstring() method of the Graphics class within the paint() method to display text on an applet. The drawstring() method consists of three arguments. The first argument represents the String that you want to display on an applet. The second and third arguments represent the starting co-ordinates of x and y-axis for displaying the text at the desired position on an applet. You need to save the preceding Java program as myapplet.java and compile the program to create its class file. You create an HTML file to run the applet that embeds an applet in the Web page by using the <APPLET> tag. You need to save the HTML file as myapplet.html. You can use the following code to create an HTML Web page that embeds an applet: <HTML> <HEAD> <TITLE> </TITLE> </HEAD> <BODY> <APPLET CODE ="myapplet.class" HEIGHT = 300 WIDTH = 250> </APPLET> </BODY> </HTML> In the preceding code, the <APPLET> tag contains the CODE attribute, which embeds the class file of the HTML file. The attributes of the <APPLET> tag, HEIGHT and WIDTH, set the dimension of the applet window. You can also specify the <APPLET> tag as a comment inside the Java applet source file, instead of creating a separate HTML file. You can use the following code to specify the <APPLET> tag inside the Java source file: /* <APPLET CODE = "myapplet.class" HEIGHT = 300 WIDTH = 250> </APPLET> */

5 You view the output of the preceding code in an appletviewer by giving the following command on the command prompt. appletviewer myapplet.html The following figure shows the output of the preceding code in an appletviewer: You can also view the preceding code in a Web browser. You need to invoke the HTML file in the browser to run the applet by typing the location of the HTML file in the address bar. The output shown in a web browser is as shown below. You need to include a java class file in an HTML file to load that file in a Web browser. The APPLET tag is used to embed an applet in an HTML document. The APPLET tag is

6 written within the BODY tag of the HTML document. The following syntax shows how to specify different parameters in an APPLET tag: <HTML> <HEAD> </HEAD> <BODY> <APPLET CODE="name of the.class file" CODEBASE=" path of the class file" HEIGHT=height of the applet in pixels WIDTH=width of the applet in pixels VSPACE=vertical space between the applet and the HTML in pixels HSPACE= horizontal space between the applet and the HTML in pixels ALIGN=alignment of the applet ALT=alternate text to be displayed if the applet is not supported by the browser> <PARAM NAME= parameter_name VALUE=value of the parameter> </APPLET> </BODY> APPLET LIFE-CYCLE The life cycle of an applet describes the sequence of stages, which begin when an applet is loaded in an appletviewer or a Web browser and ends when the applet is destroyed. An applet inherits the properties and methods of the Applet class. Java provides init(), start(), stop(), paint(), and destroy() as the basic applet methods to control the execution of an applet. The different stages of an applet life cycle are: Initializing an applet Starting the applet Stopping the applet Destroying the applet Initializing an Applet The init() method initializes an applet when the applet is loaded for the first time. It defines the objects and variables that are required to execute an applet. You apply the settings for fonts, colors, and initial parameters, such as variables and constants in the init() method. The init() method is also used to add components, such as buttons and check boxes to an applet. The following syntax shows how to define the init() method: public void init() /* init() method definitions. */

7 Starting an Applet The start() method is called to start the execution of an applet after it s initialized with the init() method. The start() method can be called more than once in an applet. The following syntax shows how to define the start() method: public void start() /* start() method definitions. */ Stopping an Applet The stop() method suspends the execution of an applet. The stop() method is called when either an end user stops an applet or an applet loses the focus. You can use the stop() method to reset the variables and stop a running applet. The following syntax shows how to define the stop() method: public void stop() /* stop() method definitions. */ Destroying an Applet The destroy() method is called when an applet is destroyed. When you want to exit from the Web browser or appletviewer of Java, an applet calls this method to release the resources, such as parameters and images. This method occurs only once in the life cycle of an applet. The following syntax shows how to define the destroy() method: public void destroy() /* destroy() method definitions. */ The following figure depicts the life-cycle of an apple

8 APPLET SECURITY FEATURES Because applets are designed to be loaded from a remote site and then executed locally, security becomes vital. If a user enables Java in the browser, the browser will download all the applet code on the web page and execute it immediately. The user never gets a chance to confirm or to stop individual applets from running. For this reason, applets (unlike applications) are restricted in what they can do. The applet security manager throws a SecurityException whenever an applet attempts to violate one of the access rules. What can applets do on all platforms? They can show images and play sounds, get keystrokes and mouse clicks from the user, and send user input back to the host from which they were loaded. That is enough functionality to show facts and figures or to get user input for placing an order. The restricted execution environment for applets is often called the "sandbox." Applets playing in the "sandbox" cannot alter the user's system or spy on it. In this chapter, we look only at applets that run inside the sandbox. In particular, when running in the sandbox, Applets can never run any local executable program. Applets cannot communicate with any host other than the server from which they were downloaded; that server is called the originating host. This rule is often called "applets can only phone home." The rule protects applet users from applets that might try to spy on intranet resources. Applets cannot read from or write to the local computer's file system. Applets cannot find out any information about the local computer, except for the Java version used, the name and version of the operating system, and the characters used to separate files (for instance, / or \), paths (such as : or ;), and lines (such as \n or \r\n). In particular, applets cannot find out the user's name, e- mail address, and so on. All windows that an applet pops up carry a warning message. All this is possible only because applets are executed by the Java virtual machine and not directly by the CPU on the user's computer. Because the virtual machine checks all critical instructions and program areas, a hostile (or poorly written) applet will almost certainly not be able to crash the computer, overwrite system memory, or change the privileges granted by the operating system. Inter-Applet Communication A web page can contain more than one applet. If a web page contains multiple applets from the same codebase, they can communicate with each other. Naturally, this is an advanced technique that you probably will not need very often.

9 If you give name attributes to each applet in the HTML file, you can use the getapplet method of the AppletContext interface to get a reference to the applet. For example, if your HTML file contains the tag <applet code="chart.class" width="100" height="100" name="chart1"> then the call Applet chart1 = getappletcontext().getapplet("chart1"); gives you a reference to the applet. What can you do with the reference? Provided you give the Chart class a method to accept new data and redraw the chart, you can call this method by making the appropriate cast. ((Chart) chart1).setdata(3, "Earth", 9000); PROGRAM TO ILLUSTRATE INTER-APPLET COMMUNICATION firstapplet.java import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <applet code="firstapplet.class" width="400" height="400" name="first"> </applet> <applet code="secondapplet.class" width="400" height="400" name="second"> </applet> */ public class firstapplet extends JApplet implements ActionListener JTextField txt; JTextArea ta; JButton b; public void init() Container c=getcontentpane(); c.setlayout(new FlowLayout(FlowLayout.LEFT)); txt=new JTextField(20); ta=new JTextArea(20,60); ta.seteditable(false); b=new JButton("SEND"); b.addactionlistener(this); c.add(txt);

10 c.add(b); c.add(ta); public void actionperformed(actionevent e) JApplet second=(japplet)getappletcontext().getapplet("second"); ((secondapplet)second).ta.append("first:"+txt.gettext()+"\n"); ta.append("first:"+txt.gettext()+"\n"); txt.settext(""); secondapplet.java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class secondapplet extends JApplet implements ActionListener JTextField txt; JTextArea ta; JButton b; public void init() Container c=getcontentpane(); c.setlayout(new FlowLayout(FlowLayout.LEFT)); txt=new JTextField(20); ta=new JTextArea(20,60); ta.seteditable(false); b=new JButton("SEND"); b.addactionlistener(this); c.add(txt); c.add(b); c.add(ta); public void actionperformed(actionevent e) JApplet first=(japplet)getappletcontext().getapplet("first"); ((firstapplet)first).ta.append("second:"+txt.gettext()+"\n"); ta.append("second:"+txt.gettext()+"\n");

11 txt.settext(""); Screen Shots For Applet Communication

12 NETWORK PROGRAMMING WITH JAVA(TCP/IP PROGRAMMING) NETWORKING BASICS IP ADDRESS Logically similar to the traditional mailing address An address uniquely identifies particular object. Each computer connected to the Internet has a unique IP address. A 32-bit number used to uniquely identify each computer connected to the Internet docs.rinet.ru PORTS Definition A 16-bit number that identifies each service offered by a network server Using a particular service to establish a line of communication through a specific protocol and the need to connect to the appropriate port Standard ports: Numbers specifically associated with a particular type of service Examples: >The FTP service is located on port 21 >The HTTP service is located on port 80 Given port values below 1024 Port values above 1024 Available for custom communication SOCKETS AND SOCKETS COMMUNICATIONS Sockets provide an interface for programming networks at the transport layer. Network communication using Sockets is very much similar to performing file I/O In fact, socket handle is treated like file handle. The streams used in file I/O operation are also applicable to socket-based I/O Socket-based communication is programming language independent. That means, a socket program written in Java language can also communicate to a program written in Java or non-java socket program. A server (program) runs on a specific computer and has a socket that is bound to a specific port. The server waits and listens to the socket for a client to make a connection request.

13 If everything goes well, the server accepts the connection. Upon acceptance, the server gets a new socket bounds to a different port. It needs a new socket (consequently a different port number) so that it can continue to listen to the original socket for connection requests while serving the connected client. A socket is an endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data destined to be sent. Java s.net package provides two classes: Socket for implementing a client ServerSocket for implementing a server IMPLEMENTING SERVER AND CLIENT SERVER 1. Open the Server Socket: ServerSocket server; DataOutputStream os; DataInputStream is; server = new ServerSocket( PORT ); 2. Wait for the Client Request: Socket client = server.accept(); 3. Create I/O streams for communicating to the client is = new DataInputStream( client.getinputstream() ); os = new DataOutputStream( client.getoutputstream() ); 4. Perform communication with client Receive from client: String line = is.readline(); Send to client: os.writebytes("hello\n"); 5. Close sockets: client.close(); For multithreaded server: while(true) i. wait for client requests (step 2 above) ii. create a thread with client socket as parameter (the thread creates streams (as in step (3) and does communication as stated in (4). Remove thread once service is provided. CLIENT 1. Create a Socket Object: client = new Socket( server, port_id ); 2. Create I/O streams for communicating with the server. is = new DataInputStream(client.getInputStream() );

14 os = new DataOutputStream( client.getoutputstream() ); 3. Perform I/O or communication with the server: Receive data from the server: String line = is.readline(); Send data to the server: os.writebytes("hello\n"); 4. Close the socket when done: CHAT USING TCP/IP...CLIENT SERVER COMMUNICATION IN ONE WAY PROGRAM Server.java import java.io.*; import java.net.*; class Server public static void main(string arg[]) throws Exception ServerSocket ss=new ServerSocket(1000); Socket s=ss.accept(); BufferedReader in=new BufferedReader (new InputStreamReader(s.getInputStream())); String inputline; while(true) if((inputline=in.readline())!=null) if(inputline.equals("bye")) break; System.out.println(inputLine); s.close(); ss.close(); in.close(); Client.java import java.io.*; import java.net.*; class Client

15 public static void main(string arg[])throws Exception Socket s=new Socket("localhost",1000); PrintWriter out=new PrintWriter(s.getOutputStream(),true); BufferedReader stdln=new BufferedReader (new InputStreamReader(System.in)); String userinput; while(true) if((userinput=stdln.readline())!=null) out.println(userinput); if(userinput.equals("bye")) break; s.close(); out.close(); stdln.close(); OutPut For One Way Chat

16 RMI -INTRODUCTION APPLICATION DEVOLEPMENT APPROACHES Over the years, there have been three different approaches to application Development traditional approach client/server approach 3 tier approach component-based approach. In the traditional approach, there was a single application that handled the presentation logic, business logic, and database interactivity. These applications were also called monolithic applications. With no inherent advantages (being the only known method for application development), the drawback of this approach was that if even a minor change, extension, or enhancement was required in an application, the entire application had to be recompiled and integrated again. For example, a minor change in the database structure would require all functions or methods in the application to be changed. This made the cost of updating and redistributing the application very high. Due to the disadvantages of the traditional approach, the client/server architecture (also called the two-tier architecture) was introduced. In this architecture, data is separated from the client-side and is stored at a centralized location that acts as a server. The business logic is combined with the presentation logic either at the clientside or at the server-side that has the database connectivity code. If the business logic is combined with the presentation logic at the client-side, the client is called a fat client. If the business logic is combined with the database server, the server is called a fat server.however, the client/server architecture also has certain disadvantages: Any change in business policies requires a change in the business logic. To change the business logic, either the presentation logic or the database connectivity code needs to change, depending on the location of the business logic. Applications implemented using a two-tier architecture might be difficult to scale-up because of the limited number of database connections available to a client. Connection requests beyond a particular limit are simply rejected by the server. The disadvantages with the client/server architecture led to the development of the threetier architecture. In the three-tier architecture, the presentation logic resides at the clientside, the database access is controlled by the server-side, and the business logic resides between the two layers. This business logic layer is referred to as application server (also called the middle-tier of a component-based three-tier architecture). This type of architecture is called server-centric, because it enables components on application to run on the middle-tier application servers implementing the business rules, independent of both the presentation interface and the database implementation. These components can be developed using any programming language that allows the creation of components.

17 The components can be centralized for easy development, maintenance, and deployment. Since the middle-tier handles the business logic, the workload is balanced between the client, the database server, and the server handling the business logic. 3 tier architecture This architecture also provides efficient data access. The problem with database connection limitation is minimized since the database sees only the business logic layer and not all its clients. In the case of a two-tier application, a database connection is established early and is maintained, whereas in a three-tier application, a database connection is established only when data access is required and released as soon as the data is retrieved or sent to the server. RMI RMI is a technology used for creating distributed applications. RMI is implemented on the middle-tier of the three-tier architecture framework. A distributed application can be created using many technologies like sockets, CORBA, DCOM etc which are language neutral.a distributed application developed using RMI can communicate only between one JVM to another JVM. RMI is a specification that enables one Java Virtual Machine (JVM) to invoke methods in an object located in another JVM. These two JVMs, could be running on different computers or running as separate processes on the same computer. RMI is implemented on the middle-tier of the three-tier architecture framework, thereby facilitating the programmers to invoke distributed components across a networked environment. Sun introduced RMI as an easy alternative to the complex coding involved in server-socket programming. If pure socket programming is done for establishing client/server communication, marshalling of data is required to pass data over the network.

18 Note: Data marshalling is the process of gathering data and transforming it into a standard format before it is transmitted over a network so that the data can transcend network boundaries. In order for an object to be moved around a network, it must be converted into a data stream that corresponds with the packet structure of the network transfer protocol. This conversion is known as data marshalling. Data pieces are collected in a message buffer before they are marshaled. When the data is transmitted, the receiving computer converts the marshaled data back into an object. Data marshalling is required when passing the output parameters of a program written in one language as input to a program written in another language For using RMI, the programmer need not know socket programming or multi-threading and needs to solely concentrate on developing the business logic.java s RMI is an alternative to low level sockets. A remote method invocation is a form of the RPC that is available on other systems. Instead of creating objects on local machines you create some of the objects on other machines and you communicate with those objects as you would normally would with local objects We are able to put the two classes on different computers It enables software developers to write distributed applications in which the methods of remote objects can be invoked from other JVMs Components of RMI Application A distributed RMI application has two components: RMI server RMI client

19 The RMI server contains the objects whose methods are to be invoked remotely. The server creates several remote objects and makes a reference of these objects in the RMI registry. The RMI registry is a service that runs on the RMI server. The remote objects created by the server are registered by the objects unique name in this registry. The client gets the reference of one or more remote objects from the RMI registry by looking up the object name. The client then invokes the methods on the remote object(s) to access the services of the remote object(s). The following figure illustrates the functionality of applications in RMI. Once the client gets the reference of the remote object, the methods in the remote object are invoked just like the methods of a local object. The difference cannot be identified in terms of whether the methods are invoked on the remote object or are invoked on the local objects in the client. The RMI Architecture The RMI architecture consists of three layers: Stub/Skeleton layer Remote Reference layer Transport layer

20 Stub/Skeleton Layer The Stub/Skeleton layer listens to remote method calls made by a client and redirects these calls to the remote RMI services on the server. This layer consists of a stub and a skeleton.to invoke methods of a remote object, the request on the client-side starts with a stub. A stub is a client-side proxy representing the remote object. It is referenced by programs as any other local object running on the client and provides methods of a remote object. The stub communicates the method invocations to the remote object through a skeleton that is implemented on the server.the skeleton is a server-side proxy that continues communication with the stub by: Reading the parameters for the method call Making the call to the remote service implementation object Accepting the return value Writing the return value back to the stub Remote Reference Layer The Remote Reference Layer (RRL) interprets and manages the references made by a client to a remote object on a server. This layer is present on the client as well as the server. The RRL on the client-side receives a request for methods from a stub that is transferred as a marshaled stream of data to the RRL on the server-side. Marshalling is a process in which parameters passed by a client are converted to a format that can be transferred across a network. The server-side RRL unmarshals the parameters that are sent to a remote method through the skeleton. Unmarshaling is a process in which the marshaled parameters passed by the client-side RRL through the server-side RRL are converted to a format that the Skeleton understands. While returning a value from the skeleton, the data is again marshaled and communicated to the client through the serverside RRL. Transport Layer The transport layer is a link between the RRL on server-side and the RRL on client side. The transport layer is responsible for setting up new connections and managing existing connections. It is also responsible for handling remote objects that are residing in transport layer address space. The following steps explain how the client is connected to the server: 1. On receiving a request from the client-side RRL, the transport layer establishes a socket connection to the server through a server-side RRL. 2. Then, the transport layer passes the established connection to the client-side RRL and adds a remote reference to the connection in its table.

21 RMI Packages RMI packages consist of various classes and interfaces for creating and running the distributed applications using RMI. Java provides the following packages for remote method invocation: The java.rmi package provides the Remote interface, a class for accessing the remote names registered on the server, and a security manager for RMI.The java.rmi.registry package provides classes and interfaces that are used by the remote registry. The java.rmi.server package provides classes and interfaces used to implement remote objects, stubs and skeletons, and support for RMI communication. The java.rmi.dgc package provides classes and interfaces that are used by the RMI-distributed garbage collector The java.rmi Package The java.rmi package declares the the following classes/interfaces Remote interface Naming RMISecurityManager It also defines a number of exception classes that are used with RMI. Remote Interface:All remote objects must implement the Remote interface. This interface does not have methods and is used for identifying remote objects. Naming class: Provides static methods for accessing remote objects through URLs. This class supports the following methods: rebind(): Binds a remote object name to a specified URL and is normally used by the server object. unbind(): Removes the binding between an object name and a URL. lookup(): Returns the remote object specified by a URL and is normally used by the client object. list(): Returns the list of URLs that are currently known to the RMI registry.

22 RMISecurityManager class: Defines the default security policy for remote object stubs. It applies only to applications. Applets use the AppletSecurityManager class for RMI. The setsecuritymanager() method of the System class is used to set an RMISecurityManager object as the security manager to be used for RMI stubs.the java.rmi package defines a number of exceptions. The RemoteException class is the parent of all the exceptions that are generated during RMI. The java.rmi.registry Package The java.rmi.registry package provides the Registry and RegistryHandler interfaces and locates the registry. These interfaces are used to register and access remote objects by a name. Remote objects are registered when they are bound to the registry process of a host. The registry process is started when the start rmiregistry command is executed. The command defines the rebind(), unbind(), list(), and lookup() methods that are used by the Naming class to associate the names and RMI URLs. The java.rmi.server Package The java.rmi.server package implements the interfaces and classes that support both the client and the server parts of the RMI. The java.rmi.server package consists of the following classes and interfaces: RemoteObject class: Implements the Remote interface and provides remote implementation of the Object class. All objects that implement remote objects extend the RemoteObject class. RemoteServer class: Extends the RemoteObject class and is a common class that is subclassed by specific types of remote object implementations. UnicastRemoteObject class: Extends the RemoteServer class and provides the default RemoteObject implementation. Classes that implement RemoteObject usually subclass the UnicastRemoteObject. By extending from the UnicastRemoteObject, the subclass can: Use RMI s default socket-based transport for communication. Run all the time. RemoteStub class: Provides an abstract implementation of the client-side stubs.the static setref() method is used to associate a client-side stub with its corresponding remote objects. RemoteCall interface: Provides methods that are used by all the stubs and skeletons of RMI. Skeleton interface: Provides the method to access methods of the remote object and this interface is implemented by the remote skeletons.

23 Unreferenced interface: Enables to determine when a client no longer references a remote object. This interface is implemented by the Remote class. CREATING AND RUNNING RMI APPLICATIONS Creating of RMI application involves identifying the classes, writing the code of classes, and compiling these classes. Running of RMI applications involves generating the stub and the skeleton, starting the RMI registry, and starting the server and the client. Creating the RMI involves the following steps Create a remote interface Implement the remote interface. Create an RMI server Create an RMI Client Run the RMI Application Creating a Remote Interface A remote interface specifies the methods that can be invoked remotely by a client. The remote interface needs to declare each of the methods that has to be invoked from other JVMs. Remote interfaces have the following characteristics: A remote interface must be declared public. This is because, in most applications, clients are not part of the same package as the remote interface. A remote interface extends the java.rmi.remote interface. Each method must declare java.rmi.remoteexception in its throw clause to trap network connection and server problems. You can use the following code to declare a remote interface that represents a remote object: import java.rmi.*; public interface Hello extends Remote /* Declare the remote method */ public String sayhello() throws RemoteException; In the preceding code, the Hello interface declares the sayhello() method, which throws the RemoteException. Implementing the Remote Interface You need to implement the remote interface to create a remote service class that provides information about server objects. The remote service class defines all the methods that

24 are declared in the remote interface. You need to import two packages,java.rmi and java.rmi.server. You can use the following code snippet to import Java packages: import java.rmi.*; import java.rmi.server.*; The remote service class extends the UnicastRemoteObject class for implementing a method of remote interface. The UnicastRemoteObject class extends the RemoteServer class of java.rmi and defines all the methods of the RemoteServer class. The following figure shows the hierarchy of the UnicastRemoteObject class: You can create a remote service class, HelloImpl, by implementing the remote interface, Hello after importing the Java packages. You can use the following code snippet to create remote service class: public class HelloImpl implements Hello extends UnicastRemoteObject.... The remote object instance needs to be exported. This enables the remote object to accept remote method requests by listening at a particular port. Since the HelloImpl class extends the UnicastRemoteObject class, it is exported, automatically. The super() method invokes the constructor of the UnicastRemoteObject class,which exports the remote object. You can use the following code snippet to define the default constructor of the remote service class: public HelloImpl() throws RemoteException super(); You define all the methods of the remote interface in the remote service class after defining the default constructor. You can use the following code snippet to define the remote method in the remote service class: public String sayhello() throws RemoteException

25 return "Hello! Peter Smith."; You can use the following code to implement remote interface in the remote service class: import java.rmi.*; import java.rmi.server.*; public class HelloImpl extends UnicastRemoteObject implements Hello /* Define the default constructor */ public HelloImpl() throws RemoteException super(); /* Define the remote method */ public String sayhello() throws RemoteException return "Hello! Peter Smith."; In the preceding code, the HelloImpl service class consists of the implementation of sayhello() method declared in the Hello interface. Creating an RMI Server The RMI server class contains the server objects that are invoked by the client remotely. You need to create the object of the remote service class in the main() method of the RMI server class to create the server object. You can use the following statement to create a server object: Hello h = new HelloImpl(); You need to register the server object in the bootstrap registry before the server object is ready to accept request from the client. You pass the name and reference of a server object in the RMI registry to register the server objects. The name of server object is used to access the stub object using the lookup mechanism. You can use the following statement to register a server object in the registry: Naming.rebind("server",h); The rebind() method takes two parameters: The first parameter is a URL string that contains the location and name of the remote object. If the port number is not specified, the RMI registry uses the default port, If the user has to define the port, the URL string has to be changed to "rmi://ipaddress: 1234/server".

26 The second parameter is a reference to the object implementation. The setsecuritymanager() method of SecurityManager class is used in the server class to set the security manager for the RMI application, so any unauthorized client cannot invoke the server object. To authenticate a RMI client, you need to create the security policy file that contains all the required permissions. You can use the following code to create an RMI server for a distributed application: import java.rmi.*; import java.rmi.server.*; public class HelloServer public static void main(string args[]) try /* Set the security manager */ System.setSecurityManager(new RMISecurityManager()); /* Create the remote object */ Hello h = new HelloImpl(); /* Bind the remote object to the RMI registry */ Naming.rebind("server",h); System.out.println("Object is registered."); System.out.println("Now server is waiting for client request..."); catch(exception e) System.out.println("Error : "+e); In the preceding code, the rebind() method of Naming class throws a remote exception. As a result, you define the rebind() method within the try-catch block. Creating an RMI Client The client uses a stub object to access the remote object that exists on the server. You specify the name of the server object in the lookup() method of the java.rmi.naming class to find the stub object. You can use the following statement to access a stub object using the lookup() method: Hello h = (Hello)Naming.lookup("rmi:// /server"); In the preceding statement, the lookup() method throws a remote exception. As a result the lookup() method should be enclosed within the try-catch block. The server

27 represents the name of the server object. When you are running this application on local computer then you use localhost instead of IP address of RMI server. You can use the following code to create an RMI client for the distributed application: import java.rmi.*; public class HelloClient public static void main(string args[]) try /* Find the remote object in the RMI registry */ Hello h = (Hello)Naming.lookup("rmi:// /server"); System.out.println("Client: Hello!"); System.out.println("Server: " + h.sayhello()); catch(exception e) System.out.println("Error : "+e); Once the creation of RMI files is done we need to run RMI application Running the RMI involves the following steps: Generate the stub and skeleton of the remote service class. Start the RMI registry. Run the RMI server of distributed application. Run the RMI client of distributed application. Generating Stub and Skeleton The RMI compiler, rmic, compiles the remote service class that implements the remote interface and generates the stub and skeleton. The stub enables the client to communicate with a particular remote object. The skeleton represents the object of client that is located on the remote host. The command to generate the stub and skeleton is: rmic [option] <ClassFile> In the preceding command, the ClassFile represents the name of the remote service class. The command to generate the stub and skeleton for an RMI application:

28 rmic HelloImpl The two files, HelloImpl_Stub.class and HelloImpl_Skel.class, are generated in the same folder where you store the remote service class, HelloImpl. You can test the distributed application on the local computer by storing all the files in the same folder before deploying it on the network. To run the application on the network, you have to create two folders, server folder on server computer and client folder on client computer. The files that are saved in the server folder of the server computer are: Hello.class HelloImpl.class HelloServer.class HelloImpl_Stub.class The command to generate the stub and skeleton for an RMI application: rmic HelloImpl The two files, HelloImpl_Stub.class and HelloImpl_Skel.class, are generated in the same folder where you store the remote service class, HelloImpl. You can test the distributed application on the local computer by storing all the files in the same folder before deploying it on the network. To run the application on the network, you have to create two folders, server folder on server computer and client folder on client computer. The files that are saved in the server folder of the server computer are: Hello.class HelloImpl.class HelloClient.class HelloImpl_Stub.class 2. Starting the RMI Registry To start the RMI Registry on the server, execute the start rmiregistry command at the command prompt. By default, the registry runs on port 1099.To start the RMI Registry on a different port, you need to specify the port number on the command line as follows: start rmiregistry 1234 If the registry is running on a port other than 1099, you will have to specify the port number in the URL string specified in the rebind() and the lookup() methods of the Naming class. The command to start the RMI registry at the default port number is as follows: start rmiregistry

29 The preceding command opens a new Command Prompt window in which rmiregistry runs. Note:You must stop and restart the rmiregistry service whenever you modify the remote interface. 3. Running an RMI Server You need to start the server to service the client requests. The command to run the HelloServer RMI server is: java HelloServer The following figure shows the output of the RMI server application: 4. Running an RMI Client The command to run the RMI client is: java HelloClient Note:If you are running a client from the same computer, give the command from a separate command prompt window. The following figure shows the output of the RMI client application: The RMI client invokes the sayhello() method to display the message received from

30 the RMI server. The following figure shows the communication between the RMI client and server: ITERATIVE AND CONCURRENT SERVERS Iterative Model An iterative server handles both the connection request and the transaction involved in the call itself. Iterative servers are fairly simple and are suitable for transactions that do not last long. However, if the transaction takes more time, queues can build up quickly. In Figure after Client A starts a transaction with the server, Client B cannot make a call until A has finished.

31 Steps 1. Create a socket 2. Bind it to a local address 3. Listen (make TCP/IP aware that the socket is available) 4. Select (wait for a connection request) 5. Accept the connection request 6. Read or write the data 7. Close The advantages of the Iterative model are: Simplicity Reduced network overhead and delay because a TRM exchange sequence is not required Less CPU intensive Higher single-threaded transaction throughput The disadvantages of the Iterative model are: Severely limits concurrent access to TPs that run for a long time Server application contains all of the SEAPI calls (Create to Close) Each TP has its own Listener, which means duplicate code Select with timeout causes a CICS region to sleep So, for lengthy transactions, a different sort of server is needed the concurrent server, as shown in Figure Figure 5. Here, Client A has already established a connection with the server, which has then created a child server process to handle the transaction. This allows the server to process Client B's request without waiting for A's transaction to complete. More than one child server can be started in this way.

32 1. Create a Listening socket 2. Bind it to a local address 3. Listen (make TCP/IP aware that the socket is available) 4. Select (wait for a connection request) 5. Accept the connection 6. Read the TRM 7. Check the validity of the requested transaction ID (TRANID) 8. Give a socket (prepare TCP/IP for the transfer of the socket) 9. Start the task 10. Synchronize on the worker task acceptance of the socket 11. Select (wait for connection request) The Worker task of the Concurrent model follows this procedure: 1. Take a socket (accept the socket request from the Listener). 2. Write a response to the TRM. 3. Read or write application data. 4. Close. The advantages of the Concurrent model are: Easy to implement concurrent access to TPs that run for a long time.

33 One Listener is shared by many TPs. Server TCP/IP logic is simple. The disadvantages of the Concurrent model are: Increased network overhead and delays due to the requirement of the TRM exchange. More CPU and resource intensive than is the Iterative model. What Is a Datagram? Some applications that you write to communicate over the network will not require the reliable, point-to-point channel provided by TCP. Rather, your applications might benefit from a mode of communication that delivers independent packages of information whose arrival and order of arrival are not guaranteed. The UDP protocol provides a mode of network communication whereby applications send packets of data, called datagrams, to one another. A datagram is an independent, self-contained message sent over the network whose arrival, arrival time, and content are not guaranteed. The DatagramPacket and DatagramSocket classes in the java.net package implement system-independent datagram communication using UDP. Clients and servers that communicate via a reliable channel, such as a TCP socket, have a dedicated point-to-point channel between themselves, or at least the illusion of one. To communicate, they establish a connection, transmit the data, and then close the connection. All data sent over the channel is received in the same order in which it was sent. This is guaranteed by the channel. In contrast, applications that communicate via datagrams send and receive completely independent packets of information. These clients and servers do not have and do not need a dedicated point-to-point channel. The delivery of datagrams to their destinations is not guaranteed. Nor is the order of their arrival. Definition: A datagram is an independent, self-contained message sent over the network whose arrival, arrival time, and content are not guaranteed.

34 IP Multicasting The great bulk of TCP/IP communications uses the Internet Protocol to send messages from one source device to one recipient device; this is called unicast communications. This is the type of messaging we normally use TCP/IP for; when you use the Internet you are using unicast for pretty much everything. For this reason, most of my discussion of IP has been oriented around describing unicast messaging. IP does, however, also support the ability to have one device send a message to a set of recipients. This is called multicasting. IP multicasting has been officially supported since IPv4 was first defined, but has not seen widespread use over the years, due largely to lack of support for multicasting in many hardware devices. Interest in multicasting has increased in recent years, and support for multicasting was made a standard part of the next generation IP version 6 protocol. Therefore, I felt it worthwhile to provide a brief overview of IP multicasting. It's a large and very complex subject, so I will not be getting into it in detail you'll have to look elsewhere for a full description of IP multicasting. (Sorry, it was either a brief summary or nothing; maybe I'll write more on multicasting in the future.) The idea behind IP multicasting is to allow a device on an IP internetwork to send datagrams not to just one recipient but to an arbitrary collection of other devices. IP multicasting is modeled after the similar function used in the data link layer to allow a single hardware device to send to various members of a group. Multicasting is relatively easy at the data link layer, however, because all the devices can communicate directly. In contrast, at the network layer, we are connecting together devices that may be quite far away from each other, and must route datagrams between these different networks. This necessarily complicates multicasting when done using IP (except in the special case where we use IP multicasting only between devices on the same data link layer network.) There are three primary functions that must be performed to implement IP multicasting: addressing, group management, and datagram processing / routing. Multicast Addressing Special addressing must be used for multicasting. These multicast addresses identify not single devices but rather multicast groups of devices that listen for certain datagrams sent to them. In IPv4, 1/16th of the entire address space was set aside for multicast addresses: the Class D block of the original classful addressing scheme. Special techniques are used to define the meaning of addresses within this block, and to define a mapping between IP multicast and data link layer multicast addresses.

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

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development: RMI (Remote Method Invocation) History: Over the year, there have been 3 different approaches to application development: 1. the traditional approach. 2. the client / server approach and 3. the component-

More information

Last Class: Network Overview. Today: Distributed Systems

Last Class: Network Overview. Today: Distributed Systems Last Class: Network Overview =>Processes in a distributed system all communicate via a message exchange. Physical reality: packets Abstraction: messages limited size arbitrary size unordered (sometimes)

More information

Distributed Computing

Distributed Computing Distributed Computing Computing on many systems to solve one problem Why? - Combination of cheap processors often more cost-effective than one expensive fast system - Flexibility to add according to needs

More information

JAVA RMI. Remote Method Invocation

JAVA RMI. Remote Method Invocation 1 JAVA RMI Remote Method Invocation 2 Overview Java RMI is a mechanism that allows one to invoke a method on an object that exists in another address space. The other address space could be: On the same

More information

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

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9, Distributed Object Systems 2 Java RMI Piet van Oostrum Distributed Systems What should a distributed system provide? Illusion of one system while running on multiple systems Transparancy Issues Communication,

More information

Remote Method Invocation

Remote Method Invocation Remote Method Invocation A true distributed computing application interface for Java, written to provide easy access to objects existing on remote virtual machines Provide access to objects existing on

More information

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

Course Snapshot. The Next Few Classes. Parallel versus Distributed Systems. Distributed Systems. We have covered all the fundamental OS components: Course Snapshot The Next Few Classes We have covered all the fundamental OS components: Architecture and OS interactions Processes and threads Synchronization and deadlock Process scheduling Memory management

More information

Course Snapshot. The Next Few Classes

Course Snapshot. The Next Few Classes Course Snapshot We have covered all the fundamental OS components: Architecture and OS interactions Processes and threads Synchronization and deadlock Process scheduling Memory management File systems

More information

JAVA RMI Java, summer semester

JAVA RMI Java, summer semester JAVA RMI Overview Remote Method Invocation usage of remote object objects in a different VM (on the same computer or over the network) as there would be local objects (almost) calls just take longer time

More information

Distributed Systems. 5. Remote Method Invocation

Distributed Systems. 5. Remote Method Invocation Distributed Systems 5. Remote Method Invocation Werner Nutt 1 Remote Method Invocation 5.1 Communication between Distributed Objects 1. Communication between Distributed Objects 2. RMI 2 Middleware Middleware

More information

Chapter 4: Processes. Process Concept. Process State

Chapter 4: Processes. Process Concept. Process State Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems 4.1 Process Concept An operating

More information

COMP 6231: Distributed System Design

COMP 6231: Distributed System Design COMP 6231: Distributed System Design Remote Invocation and RMI Based on Chapters 5, 7 of the text book and the slides from Prof. M.L. Liu, California Polytechnic State University COMP 6231, Fall 2013 Remote

More information

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

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017 Distributed Systems 02r. Java RMI Programming Tutorial Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017 1 Java RMI RMI = Remote Method Invocation Allows a method to be invoked that resides

More information

Core Java SYLLABUS COVERAGE SYLLABUS IN DETAILS

Core Java SYLLABUS COVERAGE SYLLABUS IN DETAILS Core Java SYLLABUS COVERAGE Introduction. OOPS Package Exception Handling. Multithreading Applet, AWT, Event Handling Using NetBean, Ecllipse. Input Output Streams, Serialization Networking Collection

More information

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine.

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine. Q.1) What is Remote method invocation (RMI)? A. RMI allows us to invoke a method of java object that executes on another machine. B. RMI allows us to invoke a method of java object that executes on another

More information

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4 EEC-681/781 Distributed Computing Systems Lecture 4 Department of Electrical and Computer Engineering Cleveland State University wenbing@ieee.org Outline Inter-process communications Computer networks

More information

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

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2) Introduction Objective To support interoperability and portability of distributed OO applications by provision of enabling technology Object interaction vs RPC Java Remote Method Invocation (RMI) RMI Registry

More information

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01 Introduction & RMI Basics CS3524 Distributed Systems Lecture 01 Distributed Information Systems Distributed System: A collection of autonomous computers linked by a network, with software to produce an

More information

IBD Intergiciels et Bases de Données

IBD Intergiciels et Bases de Données IBD Intergiciels et Bases de Données RMI-based distributed systems Fabien Gaud, Fabien.Gaud@inrialpes.fr Overview of lectures and practical work Lectures Introduction to distributed systems and middleware

More information

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

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A Contents Java RMI G53ACC Chris Greenhalgh Java RMI overview A Java RMI example Overview Walk-through Implementation notes Argument passing File requirements RPC issues and RMI Other problems with RMI 1

More information

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

How are classes loaded into the Java Virtual Machine (JVM)? from the local file system (CLASSPATH). by an instance of ClassLoader 36 ClassLoader How are classes loaded into the Java Virtual Machine (JVM)? from the local file system (CLASSPATH). by an instance of ClassLoader... and when? - When they are needed the first time. class

More information

Connecting to a Server Implementing Servers Making URL Connections Advanced Socket Programming

Connecting to a Server Implementing Servers Making URL Connections Advanced Socket Programming Course Name: Advanced Java Lecture 11 Topics to be covered Connecting to a Server Implementing Servers Making URL Connections Advanced Socket Programming Introduction Internet and WWW have emerged as global

More information

RMI. (Remote Method Invocation)

RMI. (Remote Method Invocation) RMI (Remote Method Invocation) Topics What is RMI? Why RMI? Architectural components Serialization & Marshaled Objects Dynamic class loading Code movement Codebase ClassLoader delegation RMI Security Writing

More information

presentation DAD Distributed Applications Development Cristian Toma

presentation DAD Distributed Applications Development Cristian Toma Lecture 8 S4 - Core Distributed Middleware Programming in JEE presentation DAD Distributed Applications Development Cristian Toma D.I.C.E/D.E.I.C Department of Economic Informatics & Cybernetics www.dice.ase.ro

More information

RMI. Remote Method Invocation. 16-Dec-16

RMI. Remote Method Invocation. 16-Dec-16 RMI Remote Method Invocation 16-Dec-16 The network is the computer Consider the following program organization: method SomeClass call AnotherClass returned object computer 1 computer 2 If the network is

More information

Remote Method Invocation in Java

Remote Method Invocation in Java Remote Method Invocation in Java Ajay Khatri Senior Assistant Professor,Department IT Acropolis Institute of Technology & Research ajay.acropolis@gmail.com What is RMI RMI is an API that provides a mechanism

More information

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

The UNIVERSITY of EDINBURGH. SCHOOL of INFORMATICS. CS4/MSc. Distributed Systems. Björn Franke. Room 2414 The UNIVERSITY of EDINBURGH SCHOOL of INFORMATICS CS4/MSc Distributed Systems Björn Franke bfranke@inf.ed.ac.uk Room 2414 (Lecture 3: Remote Invocation and Distributed Objects, 28th September 2006) 1 Programming

More information

Written by: Dave Matuszek

Written by: Dave Matuszek RMI Remote Method Invocation Written by: Dave Matuszek appeared originally at: http://www.cis.upenn.edu/~matuszek/cit597-2003/ 28-May-07 The network is the computer * Consider the following program organization:

More information

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

REMOTE METHOD INVOCATION INTRODUCTION TO RMI, A JAVA API FOR RPC-STYLE INVOCATION OF REMOTE OBJECT METHODS RMI Remote Method RMI Invocation REMOTE METHOD INVOCATION INTRODUCTION TO RMI, A JAVA API FOR RPC-STYLE INVOCATION OF REMOTE OBJECT METHODS Peter R. Egli 1/19 Contents 1. What is RMI? 2. Important RMI

More information

Advanced Java Programming

Advanced Java Programming Advanced Java Programming Length: 4 days Description: This course presents several advanced topics of the Java programming language, including Servlets, Object Serialization and Enterprise JavaBeans. In

More information

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

Chapter 15: Distributed Communication. Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration Sockets Defined as an endpoint for communcation Concatenation of IP

More information

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION SUMMARY REMOTE METHOD INVOCATION PROGRAMMAZIONE CONCORRENTE E DISTR. Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2015 2016 rcardin@math.unipd.it Introduction

More information

5.4. Events and notifications

5.4. Events and notifications 5.4. Events and notifications Distributed event-based systems extend local event model Allowing multiple objects at diff. locations to be notified of events taking place at an object Two characteristics:

More information

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

Bharati Vidyapeeth s Institute of Computer Applications and Management A-4, Paschim Vihar, New Delhi-63. Bharati Vidyapeeth s Institute of Computer Applications and Management A-4, Paschim Vihar, New Delhi-63. MCA III rd Semester Second Internal: Java Programming (MCA-205) Note: All the questions are compulsory.

More information

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

Distributed Programming with RMI. Overview CORBA DCOM. Prepared By: Shiba R. Tamrakar Distributed Programming with RMI Overview Distributed object computing extends an object-oriented programming system by allowing objects to be distributed across a heterogeneous network, so that each of

More information

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

DISTRIBUTED OBJECTS AND REMOTE INVOCATION DISTRIBUTED OBJECTS AND REMOTE INVOCATION Introduction This chapter is concerned with programming models for distributed applications... Familiar programming models have been extended to apply to distributed

More information

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

Distributed Systems. 6. Remote Method Invocation. Werner Nutt Distributed Systems 6. Remote Method Invocation Werner Nutt 1 Remote Method Invocation 6.1 Communication between Distributed Objects 1. Communication between Distributed Objects 2. Java RMI 3. Dynamic

More information

Component-Based Software Engineering

Component-Based Software Engineering Component-Based Software Engineering Remote Method Invocation Paul Krause Introduction to RMI Lecture 11 - RMI Simple Example - DivideServer Demo of this example Review a more complex example - StudentEnrollment

More information

Distributed Software Systems

Distributed Software Systems RMI Programming Distributed Software Systems RMI Programming RMI software Generated by IDL compiler Proxy Behaves like remote object to clients (invoker) Marshals arguments, forwards message to remote

More information

5 Distributed Objects: The Java Approach

5 Distributed Objects: The Java Approach 5 Distributed Objects: The Java Approach Main Points Why distributed objects Distributed Object design points Java RMI Dynamic Code Loading 5.1 What s an Object? An Object is an autonomous entity having

More information

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Course Overview This course teaches programmers the skills necessary to create Java programming system applications and satisfies the

More information

Verteilte Systeme (Distributed Systems)

Verteilte Systeme (Distributed Systems) Verteilte Systeme (Distributed Systems) Karl M. Göschka Karl.Goeschka@tuwien.ac.at http://www.infosys.tuwien.ac.at/teaching/courses/ VerteilteSysteme/ Lecture 3: Communication (Part 2) Remote Procedure

More information

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1 Message Passing vs. Distributed Objects 5/15/2009 Distributed Computing, M. L. Liu 1 Distributed Objects M. L. Liu 5/15/2009 Distributed Computing, M. L. Liu 2 Message Passing versus Distributed Objects

More information

Distributed Systems COMP 212. Lecture 10 Othon Michail

Distributed Systems COMP 212. Lecture 10 Othon Michail Distributed Systems COMP 212 Lecture 10 Othon Michail RMI: Remote Method Invocation Allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine.

More information

Remote Method Invocation

Remote Method Invocation Remote Method Invocation RMI Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in 1 Agenda Introduction Creating

More information

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications Distributed Objects and Remote Invocation Programming Models for Distributed Applications Extending Conventional Techniques The remote procedure call model is an extension of the conventional procedure

More information

Remote Procedure Call

Remote Procedure Call Remote Procedure Call Suited for Client-Server structure. Combines aspects of monitors and synchronous message passing: Module (remote object) exports operations, invoked with call. call blocks (delays

More information

Remote Method Invocation

Remote Method Invocation Non-101samples available here: https://github.com/101companies/101repo/tree/master/languages/aspectj/javarmisamples Remote Method Invocation Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages

More information

Distributed object component middleware I - Java RMI

Distributed object component middleware I - Java RMI Prof. Dr. Claudia Müller-Birn Institute for Computer Science, Networked Information Systems Distributed object component middleware I - Java RMI Nov 15th, 2011 Netzprogrammierung (Algorithmen und Programmierung

More information

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

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University CS 555: DISTRIBUTED SYSTEMS [RMI] Frequently asked questions from the previous class survey Shrideep Pallickara Computer Science Colorado State University L21.1 L21.2 Topics covered in this lecture RMI

More information

Distributed object component middleware I - Java RMI

Distributed object component middleware I - Java RMI Prof. Dr. Claudia Müller-Birn Institute for Computer Science, Networked Information Systems Distributed object component middleware I - Java RMI Nov 15th, 2011 Netzprogrammierung (Algorithmen und Programmierung

More information

THE RMI PROXY USER GUIDE

THE RMI PROXY USER GUIDE THE RMI PROXY USER GUIDE Copyright Telekinesis Pty Ltd, 2000, 2002. All rights reserved. 1 Introduction Java RMI allows Java programs executing within different Java Virtual Machines to communicate using

More information

CS 5523 Operating Systems: Remote Objects and RMI

CS 5523 Operating Systems: Remote Objects and RMI CS 5523 Operating Systems: Remote Objects and RMI Instructor: Dr. Tongping Liu Thank Dr. Dakai Zhu and Dr. Palden Lama for providing their slides. Outline Distributed/Remote Objects Remote object reference

More information

Java Remote Method Invocation Specification

Java Remote Method Invocation Specification Java Remote Method Invocation Specification Java Remote Method Invocation (RMI) is a distributed object model for the Java language that retains the semantics of the Java object model, making distributed

More information

Lecture 5: Object Interaction: RMI and RPC

Lecture 5: Object Interaction: RMI and RPC 06-06798 Distributed Systems Lecture 5: Object Interaction: RMI and RPC Distributed Systems 1 Recap Message passing: send, receive synchronous versus asynchronous No global Time types of failure socket

More information

Remote Objects and RMI

Remote Objects and RMI Outline Remote Objects and RMI Instructor: Dr. Tongping Liu Distributed/Remote Objects Remote object reference (ROR) Remote Method Invocation (RMI) Case study and example: Java RMI Other issues for objects

More information

Java WebStart, Applets & RMI

Java WebStart, Applets & RMI Java WebStart, Applets & RMI 11-13-2013 Java WebStart & Applets RMI Read: Java Web Start Tutorial Doing More with Rich Internet Applications Java Web Start guide Exam#2 is scheduled for Tues., Nov. 19,

More information

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

Communication Basics, RPC & RMI. CS403/534 Distributed Systems Erkay Savas Sabanci University Communication Basics, RPC & RMI CS403/534 Distributed Systems Erkay Savas Sabanci University 1 Communication Models 1. Remote Procedure Call (RPC) Client/Server application 2. Remote Method Invocation

More information

RMI Example RMI. CmpE 473 Internet Programming RMI

RMI Example RMI. CmpE 473 Internet Programming RMI CmpE 473 Internet Programming Pınar Yolum pinar.yolum@boun.edu.tr Department of Computer Engineering Boğaziçi University RMI Examples from Advanced Java: Internet Applications, Art Gittleman Remote Method

More information

Core JAVA Training Syllabus FEE: RS. 8000/-

Core JAVA Training Syllabus FEE: RS. 8000/- About JAVA Java is a high-level programming language, developed by James Gosling at Sun Microsystems as a core component of the Java platform. Java follows the "write once, run anywhere" concept, as it

More information

Generic architecture

Generic architecture Java-RMI Lab Outline Let first builds a simple home-made framework This is useful to understand the main issues We see later how java-rmi works and how it solves the same issues Generic architecture object

More information

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

Lab 2 : Java RMI. request sayhello() Hello interface remote object. local object. response Hello world Lab 2 : Java RMI 1. Goals In this lab you will work with a high-level mechanism for distributed communication. You will discover that Java RMI provides a mechanism hiding distribution in OO programming.

More information

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled

More information

Remote Method Invocation. Benoît Garbinato

Remote Method Invocation. Benoît Garbinato Remote Method Invocation Benoît Garbinato Fundamental idea (1) Rely on the same programming paradigm for distributed applications as for centralized applications In procedural languages, we will rely on

More information

Lecture 06: Distributed Object

Lecture 06: Distributed Object Lecture 06: Distributed Object Distributed Systems Behzad Bordbar School of Computer Science, University of Birmingham, UK Lecture 0? 1 Recap Interprocess communication Synchronous and Asynchronous communication

More information

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

Desarrollo de Aplicaciones en Red RMI. Introduction. Considerations. Considerations. RMI architecture session Desarrollo de Aplicaciones en Red José Rafael Rojano Cáceres http://www.uv.mx/rrojano RMI Remote Method Invocation Introduction Java RMI let s work calling remote methods. Underneath it works with

More information

Java Programming Language Advance Feature

Java Programming Language Advance Feature Java Programming Language Advance Feature Peter.Cheng founder_chen@yahoo.com.cn http://www.huihoo.com 2004-04 Huihoo - Enterprise Open Source http://www.huihoo.com 1 Course Goal The main goal of this course

More information

PROGRAMMING LANGUAGE 2

PROGRAMMING LANGUAGE 2 1 PROGRAMMING LANGUAGE 2 Lecture 13. Java Applets Outline 2 Applet Fundamentals Applet class Applet Fundamentals 3 Applets are small applications that are accessed on an Internet server, transported over

More information

A socket is a software endpoint that establishes bidirectional communication between a server program and one or more client programs.

A socket is a software endpoint that establishes bidirectional communication between a server program and one or more client programs. PART 24 Java Network Applications 24.1 Java Socket Programming A socket is a software endpoint that establishes bidirectional communication between a server program and one or more client programs. A server

More information

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

Sockets and RMI. CS151 Chris Pollett Dec. 5, 2005. Sockets and RMI CS151 Chris Pollett Dec. 5, 2005. Outline Echo Server with Multiple Clients Client pull/server push Remote Method Invocation Proxy Pattern Echo Server with Multiple Clients public class

More information

CS2 Advanced Programming in Java note 8

CS2 Advanced Programming in Java note 8 CS2 Advanced Programming in Java note 8 Java and the Internet One of the reasons Java is so popular is because of the exciting possibilities it offers for exploiting the power of the Internet. On the one

More information

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

Info 408 Distributed Applications programming 2 nd semester of Credits: 5 Lecturer: Antoun Yaacoub Ph.D. Lebanese University Faculty of Sciences I Master 1 degree Computer Sciences Info 408 Distributed Applications programming 2 nd semester of 2018-2019 Credits: 5 Lecturer: Antoun Yaacoub Ph.D. RMI Serialization

More information

A Report on RMI and RPC Submitted by Sudharshan Reddy B

A Report on RMI and RPC Submitted by Sudharshan Reddy B A Report on RMI and RPC Submitted by Sudharshan Reddy B Abstract: This report mainly explains the RMI and RPC technologies. In the first part of the paper the RMI technology is briefly explained and in

More information

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008 Distributed Systems Theory 4. Remote Procedure Call October 17, 2008 Client-server model vs. RPC Client-server: building everything around I/O all communication built in send/receive distributed computing

More information

CC755: Distributed and Parallel Systems

CC755: Distributed and Parallel Systems CC755: Distributed and Parallel Systems Dr. Manal Helal, Spring 2016 moodle.manalhelal.com Lecture 7: Remote Method Invocation (RMI) 1 RMI Y Daniel Liang, Introduction to JAVA Programming, 9th Edition,

More information

CSci Introduction to Distributed Systems. Communication: RPC In Practice

CSci Introduction to Distributed Systems. Communication: RPC In Practice CSci 5105 Introduction to Distributed Systems Communication: RPC In Practice Linux RPC Language-neutral RPC Can use Fortran, C, C++ IDL compiler rpgen N to generate all stubs, skeletons (server stub) Example:

More information

Advanced Java Programming. Networking

Advanced Java Programming. Networking Advanced Java Programming Networking Eran Werner and Ohad Barzilay Tel-Aviv University Advanced Java Programming, Spring 2006 1 Overview of networking Advanced Java Programming, Spring 2006 2 TCP/IP protocol

More information

Road Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets

Road Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets Java Applets Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets Introduce inheritance Introduce the applet environment html needed for applets Reading:

More information

3. Remote Procedure Call

3. Remote Procedure Call 3. Remote Procedure Call Master II Software Engineering Imed Bouchrika Dept of Mathematics & Computer Science University of Souk-Ahras imed@imed.ws Imed Bouchrika. Distributed Objects, Uni of Souk-Ahras

More information

Remote Method Invocation Benoît Garbinato

Remote Method Invocation Benoît Garbinato Remote Method Invocation Benoît Garbinato 1 Fundamental idea (1) Rely on the same programming paradigm for distributed applications as for centralized applications In procedural languages, we will rely

More information

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

Department of Computer Science & Engineering. M.Tech(CSE)-I Year-II Semester WEB SERVICES AND SERVICE ORIENTED ARCHITECHTURE (B1513) Mr.K. Department of Computer Science & Engineering M.Tech(CSE)-I Year-II Semester WEB SERVICES AND SERVICE ORIENTED ARCHITECHTURE (B1513) By Mr.K.Yellaswamy Assistant Professor CMR College of Engineering & Technology,

More information

RPC and RMI. 2501ICT Nathan

RPC and RMI. 2501ICT Nathan RPC and RMI 2501ICT Nathan Contents Client/Server revisited RPC Architecture XDR RMI Principles and Operation Case Studies Copyright 2002- René Hexel. 2 Client/Server Revisited Server Accepts commands

More information

Contents. iii Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1998, Revision B

Contents. iii Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1998, Revision B Contents About the Course...xv Course Overview... xvi Course Map... xvii Module-by-Module Overview... xviii Course Objectives... xxii Skills Gained by Module... xxiii Guidelines for Module Pacing... xxiv

More information

SNS COLLEGE OF ENGINEERING, Coimbatore

SNS COLLEGE OF ENGINEERING, Coimbatore SNS COLLEGE OF ENGINEERING, Coimbatore 641 107 Accredited by NAAC UGC with A Grade Approved by AICTE and Affiliated to Anna University, Chennai IT6503 WEB PROGRAMMING UNIT 04 APPLETS Java applets- Life

More information

9. APPLETS AND APPLICATIONS

9. APPLETS AND APPLICATIONS 9. APPLETS AND APPLICATIONS JAVA PROGRAMMING(2350703) The Applet class What is an Applet? An applet is a Java program that embedded with web content(html) and runs in a Web browser. It runs inside the

More information

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries 1 CONTENTS 1. Introduction to Java 2. Holding Data 3. Controllin g the f l o w 4. Object Oriented Programming Concepts 5. Inheritance & Packaging 6. Handling Error/Exceptions 7. Handling Strings 8. Threads

More information

Contents 8-1. Copyright (c) N. Afshartous

Contents 8-1. Copyright (c) N. Afshartous Contents 1. Classes and Objects 2. Inheritance 3. Interfaces 4. Exceptions and Error Handling 5. Intro to Concurrency 6. Concurrency in Java 7. Graphics and Animation 8. Applets 8-1 Chapter 8: Applets

More information

SELF-STUDY. Glossary

SELF-STUDY. Glossary SELF-STUDY 231 Glossary HTML (Hyper Text Markup Language - the language used to code web pages) tags used to embed an applet. abstract A class or method that is incompletely defined,

More information

Distributed Programming in Java. Distribution (2)

Distributed Programming in Java. Distribution (2) Distributed Programming in Java Distribution (2) Remote Method Invocation Remote Method Invocation (RMI) Primary design goal for RMI is transparency Should be able to invoke remote objects with same syntax

More information

15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java

15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java 15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java Dates of Interest Assigned: During class, Friday, January 26, 2007 Due: 11:59PM, Friday, February 13, 2007 Credits

More information

Java for Interfaces and Networks

Java for Interfaces and Networks Java for Interfaces and Networks Threads and Networking Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces and Networks Lecture

More information

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC) COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC) 1 2 CONVENTIONAL PROCEDURE CALL (a) (b) Parameter passing in a local procedure call: the stack before the call to read. The stack while the called procedure

More information

Activation of remote objects

Activation of remote objects 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

More information

BEA WebLogic. Server. Programming WebLogic RMI

BEA WebLogic. Server. Programming WebLogic RMI BEA WebLogic Server Programming WebLogic RMI Release 8.1 Document Revised: December 5, 2002 Copyright Copyright 2002 BEA Systems, Inc. All Rights Reserved. Restricted Rights Legend This software and documentation

More information

PART1: Choose the correct answer and write it on the answer sheet:

PART1: Choose the correct answer and write it on the answer sheet: PART1: Choose the correct answer and write it on the answer sheet: (15 marks 20 minutes) 1. Which of the following is included in Java SDK? a. Java interpreter c. Java disassembler b. Java debugger d.

More information

RMI Case Study. A Typical RMI Application

RMI Case Study. A Typical RMI Application RMI Case Study This example taken directly from the Java RMI tutorial http://java.sun.com/docs/books/tutorial/rmi/ Editorial note: Please do yourself a favor and work through the tutorial yourself If you

More information

Chapter 5 Distributed Objects and Remote Invocation

Chapter 5 Distributed Objects and Remote Invocation CSD511 Distributed Systems 分散式系統 Chapter 5 Distributed Objects and Remote Invocation 吳俊興 國立高雄大學資訊工程學系 Chapter 5 Distributed Objects and Remote Invocation 5.1 Introduction 5.2 Communication between distributed

More information

Chapter 4: Processes

Chapter 4: Processes Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems 4.1 Process Concept An operating

More information

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

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI 03 Remote invocation Request-reply RPC Coulouris 5 Birrel_Nelson_84.pdf RMI 2/16 Remote Procedure Call Implementation client process Request server process client program client stub procedure Communication

More information

Lecture 3: Socket Programming

Lecture 3: Socket Programming Lecture 3: Socket Programming Prof. Shervin Shirmohammadi SITE, University of Ottawa Fall 2005 CEG4183/ELG4183 3-1 Sockets From a logical perspective, a Socket is a communication end point. It is not a

More information