15 - RMI/EJBCSC4071 Distributed Objects Java Remote Method Invocation Enterprise Java Beans.

Slides:



Advertisements
Similar presentations
12 Copyright © 2005, Oracle. All rights reserved. Implementing Business Tasks with Session EJBs.
Advertisements

15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
Remote Method Invocation in Java Bennie Lewis EEL 6897.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 1 Topics: Java Remote Method Invocation (RMI) Enterprise JavaBeans (EJB) Overview.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
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
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
Introduction to Remote Method Invocation (RMI)
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
SEI/CBS Initiative Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
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.
1 Java Programming II Java Network II (Distributed Objects in Java)
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)
Entity Beans BMP Celsina Bignoli
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Enterprise JavaBeans Umer Farooq CS6704: Design Patterns & Component FrameworksFebruary 25, 2002.
The Triad of Beans I Oleh: Dini Addiati ( ) Fahrurrozi Rahman ( Y) Irfan Hilmy ( ) Salman Azis A ( ) Aziiz Surahman.
Presented By Pradeep K Sahu. What will be the Contents of the Seminar ? What is EJB ? EJB Architecture Types of EJB Session Entity Why EJB ? Writing a.
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.
Enterprise Java Bean Computer Networks Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
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
Remote Method Invocation onlineTraining/rmi/RMI.html.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
© jGuru.com Enterprise JavaBeans Fundamentals.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Enterprise Java Bean Technology Briefing Markus Hebach.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Enterprise Java Beans N.V.RAJASEKHAR REDDY. Definition of EJB EJBs are the components that are the set of classes and interfaces deployed within a container.
Copyright © 2002 ProsoftTraining. All rights reserved. Enterprise JavaBeans.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
13 Copyright © 2004, Oracle. All rights reserved. Managing Persistent Data in the Business Tier Entity EJBs.
Remote Method Invocation A Client Server Approach.
Enterprise JavaBeans: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
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.
Enterprise JavaBeans™ Trademark of Sun Microsystems, Inc.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
14 Copyright © 2004, Oracle. All rights reserved. Achieving State Management in the Business Tier.
©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)
Remote Method Invocation
Remote Method Invocation
Structure of Enterprise Java Beans
Objectives In this lesson, you will learn to:
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Java Remote Method Invocation
Presentation transcript:

15 - RMI/EJBCSC4071 Distributed Objects Java Remote Method Invocation Enterprise Java Beans

15 - RMI/EJBCSC4072 DO Basic Idea distributed object registry clerver/servent A B C ABCABC

15 - RMI/EJBCSC4073 Marshalling Parameters clientserver stubskeleton

15 - RMI/EJBCSC4074 Marshalling Parameters int result = arithmeticServer.addOne(1) stub skeleton public int addOne(int x) { return x+1; } oid, “addOne”, 1 2

15 - RMI/EJBCSC4075 Three Major Standards CORBA –Common Object Request Broker Architecture –Industry sponsored standard DCOM –Distributed Component Object Model Microsoft from COM from OLE Java RMI –Remote Method Invocation all can be made to be inter-operable

15 - RMI/EJBCSC4076 Java RMI Client Code public interface ArithmeticServer extends java.rmi.Remote { public int addOne(int i) throws java.rmi.RemoteException; } public class ArithmeticClient { public static void main(String args[]) throws Exception { ArithmeticServer = (ArithmeticServer)java.rmi.Naming.lookup( "rmi://penny.dhcp/ArithmeticServer"); System.out.println(as.addOne(1)); }

15 - RMI/EJBCSC4077 Java RMI Server Code public interface ArithmeticServer extends java.rmi.Remote { public int addOne(int i) throws java.rmi.RemoteException; } public class ArithmeticServerImpl extends java.rmi.server.UnicastRemoteObject implements ArithmeticServer { public ArithmeticServerImpl() throws java.rmi.RemoteException { super(); } public int addOne(int i) { return i+1; } public static void main(String[] args) throws Exception { java.rmi.Naming.rebind("ArithmeticServer", new ArithmeticServerImpl()); }

15 - RMI/EJBCSC4078 Compilation [CLIENT] % javac ArithmeticServer.java ArithmeticClient.java [SERVER] % javac ArithmeticServer.java ArithmeticServerImpl.java % rmic –keep ArithmeticServerImpl % javac ArithmeticServer_Stub.java ArithmeticServer_Skel.java

15 - RMI/EJBCSC4079 Generated Stub Code public final class ArithmeticServerImpl_Stub extends RemoteStub implements ArithmeticServer, Remote { private static final java.rmi.server.Operation[] operations = { new java.rmi.server.Operation("int addOne(int)") }; private static final long interfaceHash = L; public int addOne(int param_int_1) throws java.rmi.RemoteException { java.rmi.server.RemoteCall call = super.ref.newCall( (java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); java.io.ObjectOutput out = call.getOutputStream(); out.writeInt(param_int_1); super.ref.invoke(call); int result; java.io.ObjectInput in = call.getInputStream(); result = in.readInt(); ref.done(call); return result; }

15 - RMI/EJBCSC40710 Generated Skeleton Code public final class ArithmeticServerImpl_Skel implements java.rmi.server.Skeleton { public void dispatch(Remote obj, RemoteCall call, int opnum, long hash) { if (hash != interfaceHash) throw new SkeletonMismatchException("interface hash mismatch"); ArithmeticServerImpl server = (ArithmeticServerImpl) obj; switch (opnum) { case 0: // addOne(int) { int param_int_1; java.io.ObjectInput in = call.getInputStream(); param_int_1 = in.readInt(); call.releaseInputStream(); int $result = server.addOne(param_int_1); java.io.ObjectOutput out = call.getResultStream(true); out.writeInt($result); break; } default: throw new UnmarshalException(“invalid method number”); }

15 - RMI/EJBCSC40711 Execution % rmiregistry & % java -Djava.security.policy=myServerPolicy.prop -Djava.rmi.server.codebase= TimeServerImpl % java -Djava.security.policy=myClientPolicy.prop TimeClient % httpd & TimeServer.classTimeServerImpl.classTimeServer.class TimeClient.class TimeServerImpl_Stub.class TimeServerImpl_Skel.class % rmic

15 - RMI/EJBCSC40712 Performance Latency: arithmeticServer.addOne(1); –Local method calls.07 usec –Remote method call (same machine) 656 usec –Remote method call (network) 2000 usec DB access 1600 usec

15 - RMI/EJBCSC40713 Enterprise Java Beans Component Object Model –Distributed –Persistent –Secure –Transactional ACID –Atomicity: all or none –Consistency: database will always be in a consistent state –Isolation: intermediate state not visible until completed –Durability: when completed, the changes are stored permanently EJBs are a standard –allows application developers to write simple, standard code –allows implementers to get all the underlying stuff done well

15 - RMI/EJBCSC40714 EJB Architecture Client EJB Server EJB Container EJB Home Interface EJB Remote Interface EJB Bean

15 - RMI/EJBCSC40715 Context public interface javax.ejb.EJBContext { public abstract Identity getCallerIdentity(); public abstract EJBHome getEJBHome(); public abstract Properties getEnvironment(); public abstract boolean getRollbackOnly(); public abstract UserTransaction getUserTransaction(); public abstract boolean isCallerInRole(Identity role); public abstract void setRollbackOnly(); }

15 - RMI/EJBCSC40716 Types of EJBs Two types of beans: –Session bean encapsulates transactional operations stateful/stateless –Entity bean encapsulates persistent state container-managed persistence / bean-managed persistence

15 - RMI/EJBCSC40717 EJBs Remote Interface public interface GroceryOrder extends javax.ejb.EJBObject { public Date getDate() throws RemoteException; public void setDate() throws RemoteException; … } Home Interface public interface GroceryOrderHome extends javax.ejb.EJBHome { public GroceryOrder create(int id) throws CreateException, RemoteException; public GroceryOrder findByPrimaryKey(GroceryOrderPK pk) throws FinderException, RemoteException; }

15 - RMI/EJBCSC40718 EJB Implementation Class public class GroceryOrderBean implements javax.ejb.EntityBean { public int id; public Date date; public void ejbCreate(int id) { this.id = id; } public void ejbPostCreate(int id) { } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public void setEntityContext(EntityContext ctx) { } public void unsetEntityContext() { } public void ejbActivate() { } public void ejbPassivate() { } public void ejbLoad() { } public void ejbStore() { } public void ejbRemote() { } }

15 - RMI/EJBCSC40719 Session Beans public class ShopperBean implement javax.ejb.SessionBean { public Customer customer; public GorceryOrder order; public void ejbCreate(Customer cust) { customer = cust; } public Receipt processOrder(CreditCard card) throws RemoteException, IncompleteConversationalState, BadCredit { if(customer==null||order==null) throw new IncompleteConversationalState(); ProcessOrderHome poh = (ProcessOrderHome)getHome(“ProcessOrderHome”); ProcessOrder po = poh.create(customer, order); ProcessPaymentHome pph = (ProcessPaymentHome)getHome(“ProcessPaymentHome”); ProcessPayment pp = ppHome.create(); pp.byCreditCard(customer, card, order.price()); po.process(); Receipt r = new Receipt(customer, order, card); return r; }

15 - RMI/EJBCSC40720 EJB Summary Transparent –Distribution ejb can be anywhere –Replication & Load-Balancing ejb can be moved around ejb can be replicated (e.g., Toronto – London) –Resource Management ejb shells can be reused persistent data can be cached –Persistence Management ejb automatically mapped to persistent storage –Transaction Management session beans mapped to transactional system –Security Identities, roles, access control lists

15 - RMI/EJBCSC40721 EJB Implementations Still pretty flaky and none support everything on the previous list. –WebLogic –EJBHome –SapphireWeb –BEA –Gemstone –IBM CICS/EJB, ComponentBroker, WebSphere –NetDynamics –Oracle Application Server –…