Docsity

J2EE and Java RMI: Building Distributed Applications with Enterprise JavaBeans, Slides of Java Programming

Toggle sidebar
bg1
J2EE
•Sun offers Java in several different editions. The two most
common versions are the standard edition (J2SE) and the
enterprise edition (J2EE). There is also a micro edition. In
general, the standard edition is for stand-alone applications
while the enterprise edition is for computing over a network.
Actually, as we have seen, most of what you need for web
applets is in J2SE. J2EE adds web servers, database
connectivity, remote method invocation and enterprise java
beans.
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d

Partial preview of the text

Download J2EE and Java RMI: Building Distributed Applications with Enterprise JavaBeans and more Slides Java Programming in PDF only on Docsity!

J2EE

  • Sun offers Java in several different editions. The two most common versions are the standard edition (J2SE) and the enterprise edition (J2EE). There is also a micro edition. In general, the standard edition is for stand-alone applications while the enterprise edition is for computing over a network. Actually, as we have seen, most of what you need for web applets is in J2SE. J2EE adds web servers, database connectivity, remote method invocation and enterprise java beans.

The J2EE SDK

  • There is a lot of software included in the J2EE SDK, including NetBeans, the Sun Application Server, and Apache Tomcat Web Server. All of this is currently provided without charge, in a package that compares favorably with development environments that cost thousands of dollars. Around 1990, I paid $20,000 for a single user copy of the Bachman Analyst, a front end case tool that did not do much more than a few diagrams.

Distributed Java Technologies

  • There are many different ways to create a distributed application with Java. We have already looked at Applets, Servlets, JDBC, and JNLP.
  • In this presentation, we will briefly look at Java Sockets, Remote Method Invocation, and Enterprise Java Beans.

Socket Example

  • Sockets simply open a connection between two network hosts to pass information between them. We will look at a simple Java program to implement a socket connection.
  • The example program implements a client, EchoClient, that connects to the Echo server. The Echo server simply receives data from its client and echoes it back. The Echo server is a service built into most operating systems.

Echo Client description

  • EchoClient creates a socket and gets a connection to the Echo server. It reads input from the user on the standard input stream, and then forwards that text to the Echo server by writing the text to the socket. The server echoes the input back through the socket to the client. The client program reads and displays the data passed back to it from the server.

Echo Client code

import import java.io.;java.net.;

public public class static void EchoClient main(String[] args){ throws IOException {

Socket PrintWriter echoSocket out = = null;null; BufferedReader in = null; try { echoSocket = new Socket("taranis", 7); out in == new new BufferedReader(new PrintWriter(echoSocket.getOutputStream(), InputStreamReader( true); } catch (UnknownHostException e)^ echoSocket.getInputStream())); { System.err.println("Don't System.exit(1); know about host: taranis."); } catch System.err.println("Couldn't (IOException e) { get I/O for " System.exit(1);^ +^ "the^ connection^ to: taranis."); }

Socket Summary

  • This client program is straightforward and simple because the Echo server implements a simple protocol. The client sends text to the server, and the server echoes it back. When your client programs are talking to a more complicated server such as an HTTP server, your client program will also be more complicated.

Java Remote Method Invocation

  • Java RMI is a distributed object model for the Java platform.
  • RMI extends the Java object model beyond a single virtual machine address space.
  • RMI uses object serialization to convert object graphs to byte streams for transport.

Parts in a RMI System

  • Interface definitions for remote services
  • Implementations of the remote services
  • Stub and Skeleton files
  • A server to host the remote services
  • An RMI Naming service that allows clients to find the remote services
  • A class file provider (an HTTP or FTP server)

RMI process

Java Client Java Server

Client Stub Server Skeleton

Client Method (^) Called Method

Network transport Network Transport

arguments results

Network

Not needed In Java 2

RMI Registry

  • The Registry tracks the addresses of the remote objects exported by applications
  • It is the central management point for RMI
  • Does not actually invoke remote methods
  • Bind() links the object in the registry
  • Rebind() replaces object with a new one

Parameter Passing

  • When a remote procedure is executed, the java.rmi runtime encodes the arguments and sends them over the network to a server that decodes them.
  • The server then invokes the method, encodes the results, and sends it back.
  • Finally, the client-side java.rmi runtime decodes the result.

Steps Involved

  • Write The HTML and Java Source Files.
  • Compile and Deploy Class Files and HTML Files.
  • Start the Remote Object Registry, Server, and Applet

Summary

  • Java RMI is a distributed object model for the Java platform.
  • RMI extends the Java object model beyond a single virtual machine address space.
  • RMI uses object serialization to convert object graphs to byte streams for transport.