Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 1 Topics: Java Remote Method Invocation (RMI) Enterprise JavaBeans (EJB) Overview.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
CORBA Case Study By Jeffrey Oliver March March 17, 2003CORBA Case Study by J. T. Oliver2 History The CORBA (Common Object Request Broker Architecture)
Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
1. Introducing Java Computing  What is Java Computing?  Why Java Computing?  Enterprise Java Computing  Java and Internet Web Server.
Application Server Lecture Paulo Barroso Kris Carver Todd Kitterman Eric Silva.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Beyond DHTML So far we have seen and used: CGI programs (using Perl ) and SSI on server side Java Script, VB Script, CSS and DOM on client side. For some.
EJB Fundamentals Celsina Bignoli
Brad Rippe Fullerton College. What you need to get started? JDK 1.3 standard for compilation J2EE - SDK1.2.1 App Server - An EJB Container/Web Container.
15 - RMI/EJBCSC4071 Distributed Objects Java Remote Method Invocation Enterprise Java Beans.
Enterprise Java Beans CS-422. Application Servers In the late 1980s and though the mid 1990s a number of corporations (Broadvision, Netscape…) marketed.
1 Session Bean Chuyên đề Lập trình Java & J2EE Chương 14 Biên soạn: Th.S Nguyễn văn Lành.
J2EE Part 2: Enterprise JavaBeans CSCI 4300 Images and code samples from jGuru EJB tutorial,
Enterprise Java Beans - (EJB)
Seminar: Enterprise JavaBeans. Agenda Agenda Java™ 2 Platform Java™ 2 Platform Java™ 2 Platform,Enterprise Edition(J2EE) Java™ 2 Platform,Enterprise Edition(J2EE)
CORBA Celsina Bignoli Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Enterprise JavaBeans. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
Enterprise Java Beans Java for the Enterprise Server-based platform for Enterprise Applications Designed for “medium-to-large scale business, enterprise-wide.
+ A Short Java RMI Tutorial Usman Saleem
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
Client Call Back Client Call Back is useful for multiple clients to keep up to date about changes on the server Example: One auction server and several.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
Distributed Objects and Middleware. Sockets and Ports Source: G. Coulouris et al., Distributed Systems: Concepts and Design.
© jGuru.com Enterprise JavaBeans Fundamentals.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
CORBA Common Object Request Broker Architecture. Basic Architecture A distributed objects architecture. Logically, an object client makes method calls.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Copyright © 2002 ProsoftTraining. All rights reserved. Enterprise JavaBeans.
13 Copyright © 2004, Oracle. All rights reserved. Managing Persistent Data in the Business Tier Entity EJBs.
Remote Method Invocation A Client Server Approach.
©NIIT Introducing Enterprise JavaBeans (EJB) Lesson 1A / Slide 1 of 43J2EE Server Components Objectives In this lesson, you will learn about: The features.
Enterprise JavaBeans: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
Alan L. Batongbacal CS 4244 / 01 Nov 2000
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
Middleware Technology (J2EE/EJB) EJB Fundamentals.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Java Distributed Object Model A remote object is one whose methods can be invoked from another JVM on a different host. It implements one or more remote.
©NIIT Session Beans Lesson 1B/ Slide 1 of 37J2EE Server Components Objectives In this lesson, you will learn to: Describe the characteristics of session.
Java Remote Method Invocation (RMI)
Distributed Computing
Java Remote Method Invocation (RMI)
Java RMI CS-328 Internet Programming.
What is RMI? Remote Method Invocation
Understanding and Designing with EJB
Presentation transcript:

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 1 Topics: Java Remote Method Invocation (RMI) Enterprise JavaBeans (EJB) Overview

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 2 distributed object computing development of distributed Java programs same syntax and semantics as in non-distributed programs Computer A class AClass: myAClassMethod(){} Computer B class BClass: AClass a; /* initialize a */ a.myClassMethod(); RMI Java RMI

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 3 The RMI achitecture defines how objects behave how and when exceptions can occur how memory is managed how parameters are passed to and returned from remote methods RMI architecture

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 4 RMI separates: definition of behaviour implementation of that behaviour each of them is allowed to run on different JVMs interfaces: define definition classes: define implementation Principle of RMI (1)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 5 2 classes that implement the same interface service implementation on server service proxy on client client program makes method calls to proxy RMI sends request to remote JVM return values are sent back to proxy / client program Principle of RMI (2)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 6 3 abstract layers: Stubs & Skeletons Layer Remote Reference Layer Transport Layer RMI architecture layers advantages of layer architecture: implementation of layers independent from each other each layer can be enhanced / replaced without affecting rest of the system

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 7 lies just beneath developer intercepts method calls made by client redirects them to remote RMI service (= remote object) Stubs & Skeletons Layer (1) Proxy Pattern (Book: Design Patterns by Gamma, Helm, Johnson) : one object in one context represented by another object (the proxy) in another context proxy forwards method calls between participating objects in RMI, stub class is the proxy

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 8 proxy represents the RealSubject in RMI: stub class Stubs & Skeletons Layer (2)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 9 ClientServer skeleton class: helper class on server generated for RMI to use communicates with stub accross the link reads parameters for the method call from the link makes the call to the service object accepts the return value, writes it back to the stub service object skeletonstub network link << parameters return values >> Stubs & Skeletons Layer (3) client program

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 10 defines & supports the invocation semantics of the RMI connection client gets remote reference to remote objects via naming service (discussed later) Remote Reference Layer manages these remote reference provides RemoteRef object (represents link to remote object) stub object: forwards method calls by RemoteRef.invoke() in JDK 1.1: unicast point-to-point connection service must be instantiated and exported to the RMI system, before client can use it in Java 2 SDK: multicast and other types of connection semantics activatable objects Remote Reference Layer

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 11 Transport Layer: stream-based network connections that use TCP/IP basic connectivity and firewall penetration strategies on top of TCP/IP, RMI uses Java Remote Method Protocol (JRMP) RMI-IIOP: instead of JRMP, OMG IIOP is used to communicate between clients and servers Transport Layer

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 12 RMI-IIOP: co-production of Sun and IBM uses Object Management Group Internet Inter-ORB Protocol (OMG IIOP) OMG: defines a vendor-neutral, distributed object architecture called Common Object Request Broker Architecture (CORBA) CORBA Object Request Broker (ORB) servers and clients use IIOP for communication RMI-IIOP: RMI programs can inter-operate with CORBA ORBs modifications on the source code: RMI programs can be compiled with rmic –iiop to use IIOP EJB: based on RMI / RMI-IIOP communication with CORBA ORBs easier with same protocol RMI-IIOP

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 13 clients: find remote services by using a naming or directory service, running on a well known host and port number RMI can use different directory services, e.g. the Java Naming and Directory Service (JNDI) includes simple service called RMI Registry ( rmiregistry, default on port 1099) host: server program creates a remote service by creating a local object that implements the service exporting that object to RMI after exporting, server registers object in the RMI Registry under a public name RMI creates a listening service that waits for client connections and requests for the service Naming Remote Objects (1)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 14 client: RMI Registry is accessed through the static class Naming client uses its method lookup() to query registry method lookup() accepts a URL that specifies the server host name and the name of the desired service if needed: class files downloaded from server method returns a remote reference to the service object URLs accepted by Naming.lookup() : rmi:// [: ]/ Naming Remote Objects (2) host (continued): provides needed class files for client (HTTP, FTP,...)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 15 Using RMI working RMI system: interface definitions for the remote services implementation of the remote services stub and skeleton files a server to host the remote services an RMI Naming service for clients to find the remote services a class file provider (HTTP or FTP server) a client program that needs the remote services

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 16 Enterprise Java Beans (EJB) architecture for development of transactional 'distributed object applications'-based server-side software based on RMI / RMI-IIOP enterprise beans: server-side components distributed objects short name for such a component: "bean" hosted in container (Enterprise JavaBeans) provide remote services for clients distributed thoughout the network

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 17 EJB Containers (1) enterprise beans: software components that run in a special environment called EJB container container: hosts and manages an enterprise bean hosting comparable to webserver that hosts a servlet browser that hosts an applet enterprise bean can't function outside an EJB container EJB container manages at runtime: remote access, security persistence, transactions concurrency access to and pooling of resources

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 18 EJB Containers (2) EJB container: isolates enterprise bean from direct access by client application client invokes a method call on an enterprise bean: container intercepts invocation automatically manages persistence, transactions, security developer doesn't have to care about writing that code bean doesn't contain any of this logic

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 19 EJB Containers (3) containers: pool resources, manage life cycles of all beans reduces memory consumption and processing (scalability) client application is unaware of this resource management enterprise bean depends on container for everything: JDBC connections connections to other beans identity of caller reference to itself

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 20 Interaction bean-container (1) 3 types of interaction enterprise bean  EJB container 1.callback methods every bean implements a subtype of the EnterpriseBean interface this i/f defines several "callback methods" container invokes these methods to activate a bean persist its state to the database end a transaction remove the bean from memory...

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 21 2.EJBContext object EJBContext : reference to container provides methods to interact with the container e.g. request information about the bean's environment: identity of its client status of transaction remote reference to itself... Interaction bean-container (2)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 22 3.Java Naming and Directory Service (JNDI) standard extension to the Java platform for accessing naming systens like LDAP NetWare file systens... bean has access to a special naming system Environment Naming Context (ENC) JNDI ENC allows access to JDBC connections other enterprise beans properties specific to that bean Interaction bean-container (3)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 23 Enterprise Beans 2 interfaces + 1 implementation class client uses interfaces to interact with the bean interfaces: remote & home i/f expose the capabilities of the bean provide all methods needed to create, update, interact with, delete the bean implementation class: represents a business concept (like a addressbook / contact)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 24 Interfaces & types of beans interfaces: home interface remote (or business) interface entity beans container managed persistence (CMP) bean managed persistence (BMP) session beans stateful beans stateless beans

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 25 Remote & Home interfaces home interface: extends javax.ejb.EJBHome life cycle methods to create, find and destroy a bean remote interface: extends javax.ejb.EJBObject represents business methods

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 26 Life cycle methods home interface provides life cycle methods for creating for destroying for locating beans represent behaviours that are not specific to a single bean instance separated from remote interface /* some imports */ public interface ContactHome extends EJBHome{ public Contact create(int number) throws RemoteException, CreateException; public Contact findByPrimaryKey(int pk) throws FinderException; } /* some imports */ public interface ContactHome extends EJBHome{ public Contact create(int number) throws RemoteException, CreateException; public Contact findByPrimaryKey(int pk) throws FinderException; }

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 27 Business methods (1) can perform tasks this type of bean is called session bean import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface AddressBook extends EJBObject{ public Contact findByContactData(String name, String firstname, String ) throws RemoteException; public Enumeration findByName(String firstname) throws RemoteException; public Contact findBy (String ) throws RemoteException; } import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface AddressBook extends EJBObject{ public Contact findByContactData(String name, String firstname, String ) throws RemoteException; public Enumeration findByName(String firstname) throws RemoteException; public Contact findBy (String ) throws RemoteException; }

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 28 Business methods (2) can also represent business data stored in a database this type of business object is called entity bean idnamefirstname each instance of an enterprise bean represents 1 row in a table database tableentity beans bean1 bean2 bean3

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 29 Entity type beans (1) example for an entity bean (remote interface): import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface Contact extends EJBObject{ public String getName() throws RemoteException; public String setName(String name) throws RemoteException; public String getFirstName() throws RemoteException; public String setFirstName(String firstname) throws RemoteException; public String get Address() throws RemoteException; public String set Address(String addres) throws RemoteException; } import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface Contact extends EJBObject{ public String getName() throws RemoteException; public String setName(String name) throws RemoteException; public String getFirstName() throws RemoteException; public String setFirstName(String firstname) throws RemoteException; public String get Address() throws RemoteException; public String set Address(String addres) throws RemoteException; }

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 30 Entity type beans (2) two types of entity beans: Container-Managed Persistence (CMP) Bean-Managed Persistence (BMP) CMP: container (EJB server) manages persistence developer doesn't have to write db access code programmer has to specify in deployment desciptor which fields (instance variables/columns) are to be managed BMP: entity bean contains db access code (via JDBC) responsible for reading and writing its own state to the database

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 31 Session type beans (1) session beans: manage interactions of entity and other session beans access resources perform tasks on behalf of the client not persistent business objects, do not represent data in db interface javax.ejb.SessionBean provides methods ejcActivate() and ejbPassivate() two types of session beans: stateless session beans stateful session beans

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 32 Session type beans (2) stateless beans: made up of business methods that behave like procedures operate only on passed through arguments on invocation do not maintain business state between method invocations each invocation of a business method is independent from previous invocations doesn't remember anything from one invocation to the other faster request processing, less resources used don't use ejbActivate() and ejbPassivate() methods (overridden with empty implementation)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 33 Session type beans (3) stateful beans: encapsulate business logic and state specific to a client dedicated to one client clients do not share stateful beans maintain business state / conversational state between method invocations held in memory, not persistent

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 34 Access to beans access to beans from outside: client application (as mentioned) Java Server Pages (JSP) or Servlets popularly used method: JSP HTML pages with embedded Java code client opens JSP page in browser server processes page beans can be used to perform tasks or access database results are sent back to browser (HTML)

Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 35 Using EJB working EJB system: for each bean home interface remote interface implementation EJB server (e.g. j2ee) naming service (usually JNDI) a class file provider (HTTP or FTP server) for entity beans: relational database (e.g. cloudscape) client program