Advanced Java Session 7 New York University School of Continuing and Professional Studies.

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Advertisements

12 Copyright © 2005, Oracle. All rights reserved. Implementing Business Tasks with Session EJBs.
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.
CORBA - Common Object Request Broker Architecture.
1 Softsmith Open Learning - EJB 21-Nov Enterprise Java Beans Introduction –Application ServerApplication Server –Java 2 Enterprise EditionJava.
June 1999 EJB1 EJB and CHAIMS Dorothea Beringer Enterprise Java Beans and how to build a CHAIMS infrastructure using the EJB paradigm.
Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB.
EJB Design. Server-side components Perform –complex algorithms –high volume transactions Run in –highly available environment (365 days/year) –fault tolerant.
Application Server Lecture Paulo Barroso Kris Carver Todd Kitterman Eric Silva.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
CS 483 Enterprise and Web Application Programming
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Common Object Request Broker Architecture (CORBA) CS-328.
EJB Fundamentals Celsina Bignoli
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
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)
Entity Beans BMP Celsina Bignoli
Middleware Technology (J2EE/EJB) Entity Bean. 2 Introduction to Entity Beans Persistence Concepts Entity beans are persistent objects that can be stored.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Container-Managed Persistence (CMP) Entity Beans Lesson 3A / Slide 1 of 42J2EE Server Components Objectives In this lesson, you will learn to: Identify.
Overview Of Enterprise Java Bean (EJB) COSC 513 Presentation Mei Li March 17, 2001.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
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. 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.
Enterprise Java Bean Computer Networks Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
J2EE Structure & Definitions Catie Welsh CSE 432
+ A Short Java RMI Tutorial Usman Saleem
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Session Beans -) stateless -) stateful. Session Beans A session bean represents a single client inside the J2EE server. To access an application that.
J2EE Overview ver 1.0Page 1 © Wipro Technologies Talent Transformation J2EE Overview.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
Introduction to Enterprise JavaBeans Topics In Systems Architecture Barry Herbold
EJB Overview: Constraint Types and Enforcement in JBoss Elissa Newman Fluid Meeting 6/3/04.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Enterprise Java Bean Technology Briefing Markus Hebach.
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.
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.
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.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Middleware Technology (J2EE/EJB) EJB Fundamentals.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications.
©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 Distributed Computing
Java Distributed Computing
What is RMI? Remote Method Invocation
Knowledge Byte In this section, you will learn about:
Structure of Enterprise Java Beans
Understanding and Designing with EJB
Luca Simone Software Engineering 2 a.a. 2001/2002
Chapter 40 Remote Method Invocation
Objectives In this lesson, you will learn to:
Chapter 46 Remote Method Invocation
Understanding and Designing with EJB
Chapter 46 Remote Method Invocation
Knowledge Byte In this section, you will learn about:
Presentation transcript:

Advanced Java Session 7 New York University School of Continuing and Professional Studies

2 Objectives RMI –Overview –Example CORBA –Overview –Using CORBA in Java EJB –What is an EJB –Entity/Session Beans –Services

3 Remote Method Invocation A mechanism to invoke methods on a “remote” object and receive return values The object that makes the call is the “client” and the object that responds is the “server” Same object could be client for one call and server for another Heart of EJB and Distributed Applications Modern replacement for CORBA (and RPC)

4 Goal of RMI Make it easier to write distributed application Provide an interface that’s transparent Easy to understand Easy to use

5 Calling a Method on Remote Object ClientServer Method call

6 Role of RMI ClientServerstubrcvr

7 Stub Method Builds an information block consisting of –An identifier of the remote object to be used –A description of the method to be called –Marshalled parameters Sends this information to the server

8 Receiver Object Unmarshalls the parameters Locates the object to be called Calls the desired method Captures and marshals the return value or exception of the call Sends the package containing marshalled return value back to the stub on the client.

9 Stub Upon Return Unmarshalls the return values returned from the remote object Returns it back to the client

10 Classes and Interfaces for RMI Java.rmi package Interface that will be used by the client Implementation class – that must extend UnicastRemoteObject *and* implement the interface defined for remote clients

11 Parameter Marshalling RMI passes all parameters “by value” – it serializes the object and passes it However, if the Object extends “Remote” – a “stub” that represents it is passed Consider what happens when a Bank (server) returns an Account object (acct) to an ATM – and ATM updates the balance by calling acct.withdraw() All parameters to an RMI call must be Serializable or must extend Remote All parameters to an RMI call must be Serializable or must extend Remote

12 Parameter Marshalling All parameters to the remote method are marshalled by the client (stub) and unmarshalled by the server (rcvr) All return values are marshalled by the server (rcvr) and unmarshalled by the client (stub) Any exceptions thrown by the server are caught by the rcvr and marshalled back to the client stub which then throws them to the caller.

13 Setting up RMI Create and compile the interfaces and classes Use “rmic” to generate the stub and the receiver “glue” – no longer needed with JDK 5 Run “rmiregistry” service to provide registration/lookup services Launch the server – register the object Run the client – accesses remote method

14 RMI Examples MOTD with ShowMOTD.jsp RMIQuote with ShowQuotes.jsp Product Warehouse

15 Common Object Request Broker Architecture Proposed and maintained by OMG – Object Management Group Uses an IDL (Interface Definition Language) to define interfaces Uses an ORB (Object Request Broker) as the mediator between clients and servers.

16 CORBA advantages/disadvantages For accessing legacy applications Works across multiple programming language CORBA language bindings for scripting languages like Perl, Python Too complex Difficult to use

17 Writing CORBA clients/servers Write the interface that specifies how the object works using IDL Using the IDL compilers for the target language (idlj for java), generate the needed stub and helper classes Add the implementation code Write a server program that creates and registers the server object Write a client program that locates the server object and invokes the method Start the naming service (similar to rmiregistry), run the server program, and then run the client

18 Java and CORBA Packages Package org.omg.CORBA Package org.omg.CORBA_2_3 Classes org.omg.CORBA.ORB org.omg.CosNaming.NamingContext org.omg.CosNaming.NameComponent

19 Enterprise Java Beans Server-side component architecture Enables and simplifies the process of building enterprise-class distributed object applications that are scalable, reliable, and secure Analogous to the hardware components model

20 N-Tier Architecture Presentation logic Pricing component billing component database driver Presentation layer Business logic layer Data Layer

21 EJB Servers and Containers EJB EJB Container EJB Server Client (servlet, applet, app)

22 Enterprise Beans Session Beans –Typically represent business processes (like authorize credit card) –Last only through the duration of the client –Stateless Session Beans –Stateful Session Beans Entity Beans –Typically models permanent data objects – such as credit card, account, customer –Are long lasting, or persistent objects –Bean managed persistence –Container managed persistence

23 Enterprise Bean Model EJB EJB Server/container Client code Home Object EJB Object Get ref to Home Object create Method call delegate Home interface Remote interface

24 Services Provided by Container EJB EJB Server/Container Client (servlet, applet, app) invokes delegates Resource management Lifecycle management State management Transactions Security Persistence

25 Resource Management EJB Container is responsible for coordinating the entire effort of resource management for resources such as –Threads –Socket Connections –Database Connections

26 Lifecycle Management Controls the lifecycle of the Bean Creates or destroys beans in response to client requests Provides “instance pooling”

27 State Management Stateful beans or Entity Beans need to maintain a “state” for each clients The container provides services to maintain the state The same state may be passed on to another bean if necessary before invoking a method that a client requested

28 Transactions EJBs may participate in transactions EJB Container handles the underlying transaction operations, coordinating efforts behind the scenes. Java Transaction API is used to implement transactions for beans Variety of transaction management options are available

29 Security EJB containers add transparent Security to the Beans Enterprise Beans can automatically run as a certain security identity, or can programmatically ensure that clients are authorized to perform desired operations

30 Persistence Containers can provide transparent persistence for Entity Beans EJBs can manage their own persistence if they prefer

31 Remote Accessibility Location Transparency Converts a network-naïve component to a networked component Containers use Java RMI to specify remote accessibility Gives sysadmins the ability to upgrade a certain machine while clients are routed to another (better fault tolerance, availability)

32 Glue Code Bean Installation Tools Containers provide glue code tools. These tools are meant to integrate beans into the EJB container’s environment Glue code tools (deployment tools) are responsible for transforming an enterprise bean into a fully managed, distributed server-side component.

33 Specialized Container Features Integration to mainframe systems COM+ integration Transparent fail-over Stateful recovery Server clustering Dynamic redeployment Monitoring support Visual development environment integration

34 Bean classes and interfaces The EnterpriseBean class contains implementation details of your component. It extends Serializable. SessionBean – extends EnterpriseBean EntityBean – extends EnterpriseBean EJBObject class represents the “surrogate” object that is created instead of your Bean object Remote Interfaces for your bean must extend EJBObject EJBHome class represents the factory object Home Interfaces for your bean must extend EJBHome

35 Enterprise Bean Model EJB EJB Server/container Client code Home Object EJB Object Get ref to Home Object create Method call delegate Home interface Remote interface

36 EJBObject getEJBHome – retrieves a ref to corresponding Home object getPrimaryKey – returns the primary key for this object Remove – destroys this EJB object (and persistent store) getHandle – acquires a “handle” for this EJB obejct isIdentical – tests if two EJB Objects are identical

37 EJBHome getEJBMetaData – access info about the bean – e.g. whether it’s a session bean, or entity bean, it supports transactions or not etc. remove – destroys a particular EJB object create(…) methods – that are not part of the Interface EJBHome

38 SessionBean setSessionContext ejbPassivate ejbActivate ejbRemove ejbCreate(…) methods that are not part of the interface Other business methods

39 Bean client code Locate the Bean’s Home interface using JNDI Context ctx = new InitialContext(); IHome home = ctx.lookup(“MyHome”); Create an instance of the EJB Object IRemote remote = home.create(…); Call a business method using the Remote interface remote.authorizeCreditCard(…..);

40 Deployment Descriptor Bean home name Enterprise bean class name Home interface class name Remote interface class name Re-entrant Stateful or stateless Session timeout

41 Entity Beans Persistent objects Long-lived Survive failures Typically a view into a database Can be pooled Several Entity Beans may represent the same underlying data Can be created, removed or found

42 EntityBean interface setEntityContext unsetEntityContext ejbRemove ejbActivate ejbPassivate ejbLoad ejbStore ejbCreate is optional for entity beans and returns a primaryKey object ejbFindByPrimaryKey and other ejbFind methods

43 Thank you