1 l Enterprise Computing -- 3-tier and multi-tier applications l Enterprise JavaBeans n EJB Features n Types of EJBs l Example – A Currency Converter n.

Slides:



Advertisements
Similar presentations
Question examples. Session 1 Objectives Why certify? Positioning of the non-technical version What is Java? Key advantages of Java Java Applications vs.
Advertisements

J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
3 Copyright © 2005, Oracle. All rights reserved. Designing J2EE Applications.
J2EE Overview.
Apache Struts Technology
Distributed System Using Java 2 Enterprise Edition (J2EE) B.Ramamurthy.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Layers & Tiers Umair Javed Lec - 41.
Java 2 Platform, Enterprise Edition (J2EE). Source: Computer, August 2000 J2EE and Other Java 2 Platform Editions.
J2EE Java 2 Enterprise Edition. Relevant Topics in The Java Tutorial Topic Web Page JDBC orial/jdbc
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
CS 483 Enterprise and Web Application Programming
M.Sc. Course, Dept. of Informatics and Telecommunications, University of Athens S.Hadjiefthymiades “Web Application Servers” Basics on WAS WAS are necessary.
Understanding and Managing WebSphere V5
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Web Application Architecture: multi-tier (2-tier, 3-tier) & mvc
Java Pet Store Application. Outline Introduction Introduction Information Layer Information Layer Application Layer Application Layer Infrastructure Layer.
Web-based Software Development - An introduction.
Distributed System Using Java 2 Enterprise Edition (J2EE)
INTRODUCTION TO WEB DATABASE PROGRAMMING
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Distributed Multitiered Applications The J2EE platform uses a multitiered distributed application model. Application logic is divided into components 1.
Notes of J2EE Tutorial Matt Tsai. 2 Outline Chapter 1: Overview Chapter 1: Overview Chapter 2: Understanding XML Chapter 2: Understanding XML Chapter.
1 Lecture 15 George Koutsogiannakis SUMMER 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
1 Stateful Session Beans Stateless Session Beans Michael Brockway Sajjad Shami Northumbria University School of Computing, Engineering & Information Sciences.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
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.
Introduction to J2EE Architecture Portions by Kunal Mehta.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
® IBM Software Group © 2007 IBM Corporation J2EE Web Component Introduction
Enterprise Java Beans Java for the Enterprise Server-based platform for Enterprise Applications Designed for “medium-to-large scale business, enterprise-wide.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
1 Java EE Programming Enterprise JavaBeans. 2 Topics J2EE Overview Enterprise JavaBeans Overview Enterprise Entity Beans Case Study How to build them.
Introduction to Enterprise JavaBeans Topics In Systems Architecture Barry Herbold
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.
J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise.
Enterprise JavaBeans Session Beans. Session beans are a type of Enterprise JavaBean component designed to implement business logic responsible for managing.
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.
1 Distributed System using J2EE. 2 What is J2EE?  J2EE (Java2 Enterprise Edition) offers a suite of software specification to design, develop, assemble.
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.
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.
©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.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
EJB Enterprise Java Beans JAVA Enterprise Edition
EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications.
Topics to be covered (ni) Client side validation JSF (free tools as well) Webservices Tell Resources e.g. sites Packaging and deploying web applications.
Intro to J2EE Concepts Mimi Opkins Fall 2016 CECS493.
J2EE Platform Overview (Application Architecture)
Running a Forms Developer Application
EJB (Enterprise Java Beans)
Introduction to J2EE Architecture
MSIS 655 Advanced Business Applications Programming
J2EE Application Development
Distributed System Using Java 2 Enterprise Edition (J2EE)
Understanding and Designing with EJB
JavaServer Faces: The Fundamentals
Component-based Applications
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Understanding and Designing with EJB
Enterprise Java Beans.
Intro to J2EE Concepts.
Presentation transcript:

1 l Enterprise Computing -- 3-tier and multi-tier applications l Enterprise JavaBeans n EJB Features n Types of EJBs l Example – A Currency Converter n Packaging the Session EJB n Deploying the Bean n Running the Client Introduction to Enterprise JavaBeans CG0165: Advanced Applications Development in Java Michael Brockway, Sajjad Shami School of Computing, Engineering & Information Sciences Northumbria University

2 Introduction to EJBs l References: n Tutorial and reference material from the sun web site - Enterprise Edition pages u u u n The relevant material in the Tutorial is in chapter 1: Overview, chapter 20: Enterprise Beans, and chapter 21: Getting Started with Enterprise Beans

3 Enterprise Computing l Same as distributed computing: n computation done by groups of programs communicating over a network l Not necessarily a major corporation, university, government agency … l Small businesses also engage in plenty of distributed computing l The architecture of Enterprise applications can be thought of as consisting of three logical tiers n Presentation (Client side, User) u displays data to client n Application u provides business logic to Presentation tier u holds business components & objects n Data Systems u central data storage/ retrieval

4 Three Tiers Presentation Tier Application Tier Data Systems Tier/ EIS Business components Application 2 Application 1 /Client Backend / backoffice Database/ legacy sys Application 3 Server

5 Multi-tier applications l This architecture generalises: l In general an enterprise application involves client-to-server communication. Stock control server Inventory DB server Goods purchasing system 1 Goods purchasing system n Goods purchasing system 2 Client(s) = application tier = data systems tier

6 Multi-tier applications l For a rationale, imagine a client who manages an inventory for a chain of shops n Has web-based (thin client) interfaces to a number of server- based applications u the chain's own inventory u the goods purchasing system for supplier no 1 u the goods purchasing system for supplier no 2 u.... u the goods purchasing system for supplier no n n There is a set of logical rules: one for each inventory item, which causes a certain quantity of the item to be ordered-in (from the appropriate supplier) when stocks fall below a pre-determined threshold. n It would clearly be silly for all this logic to occur in the client l Better: n The goods ordering logic is implemented on a server which talks to all the other servers

7 Multi-tier applications l A further development is the Thin Client n The clients run web browsers or other very light-weight software n The presentation tier resides in a web server Web server Application server communication with clients Business logic servlets, JSPs Client(s): HTTP requests, XHTML responses

8 Enterprise JavaBeans (EJBs) l (Other) Technologies for implementing business & presentation logic in multi-tier applications: n Java Servlets n JSPs l Enterprise JavaBeans are a technology for the application server side n and provide a component model for building business logic in enterprise Java applications l References: n Deitel, Deitel & Santry Advanced Java 2 HTP, chap 14 n Tutorial and reference material on the SUN web site - Enterprise Edition pages l They provide a component model n Component developers write component "building blocks" that implement business logic Application developers hook up these pre-built components into finished applications, which may themselves be components. l Not to be Confused with JavaBeans!!!

9 Multi-Tier Apps in Java EE

10 Multi-Tier Apps in Java EE

11 Java EE Components l Java EE applications are made up of components l A Java EE component is a self-contained functional software unit that is assembled into a Java EE application n with its related classes and files and that communicates with other components. l The Java EE specification defines the following Java EE components: n Application clients and applets are components that run on the client. n Java Servlet, JavaServer Faces, and JavaServer Pages™ (JSP™) technology components are web components that run on the server. n Enterprise JavaBeans™ (EJB™) components (enterprise beans) are business components that run on the server.

12 Java EE Clients l Web Client n two parts: n (1) dynamic web pages containing various types of markup language (HTML, XML, etc), which are generated by web components running in the web tier, and n (2) a web browser, which renders the pages received from the server. n A web client is sometimes called a thin client. l Applets n A web page received from the web tier can include an embedded applet. n An applet is a small client application written in the Java programming language u that executes in the Java virtual machine installed in the web browser

13 Java EE Clients …contd. l Application Client n runs on a client machine n typically has a graphical user interface (GUI) u a command-line interface is also possible. n directly access enterprise beans running in the business tier n can also open an HTTP connection to establish communication with a servlet running in the web tier n application clients written in languages other than Java can interact with Java EE 5 servers u enabling the Java EE 5 platform to interoperate with legacy systems, clients, and non-Java languages.

14 EJB Features l EJBs improve distributed transactions n By ensuring data integrity across databases and application servers l EJBs utilise Java EE’s distributed transaction features and update data across several databases l To develop an enterprise bean, the following files are required: Enterprise bean class: Implements the methods defined in the business interface. Business Interfaces: The business interface defines the method implemented by the enterprise bean class. Helper classes: Other classes needed by the enterprise bean class, such as exception and utility classes.

15 Packaging of an Enterprise Bean l The three files are packaged into an EJB JAR file, the module that stores the enterprise bean. An EJB JAR file is portable and can be used for different applications. l To assemble a Java EE application, package one or more modules—such as EJB JAR files—into an EAR file, the archive file that holds the application. l When deploying the EAR file that contains the bean’s EJB JAR file, also deploy the enterprise bean to the Application Server. l Note: An EJB JAR that is not contained in an EAR file can also be deployed

16 Advantages of Enterprise Beans l enterprise beans simplify the development of large, distributed applications: l 1) as the EJB container provides system-level services to enterprise beans, the bean developer can concentrate on solving business problems l 2) the client developer can focus on the presentation of the client n does not have to code the routines that implement business rules or access databases. n result: clients are thinner l 3) the application assembler can build new applications from existing beans n can run on any compliant Java EE server

17 When to Use Enterprise Beans l the application must be scalable. n to accommodate a growing number of users, may need to distribute an application’s components across multiple machines. l transactions must ensure data integrity n Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects l the application will have a variety of clients n with only a few lines of code, remote clients can easily locate enterprise beans. n these clients can be thin, various, and numerous.

18 EAR File Structure

19 The EJB Implementation and the EJB Container l The EJB Implementation n implements the business logic methods declared in the EJB remote interface l The EJB Container n within the application server n manages client interactions n invocations from a client first go to the EJB container which then delegates to the EJB Implementation n manages life cycles of its EJBs n can create new EJB instances and remove existing ones

20 Types of EJBs l Session EJBs n distributed objects which do jobs within the business logic / application server n can manipulate data in a database u...but are not persistent n lost if EJB container crashes n two types: u Stateful u Stateless l Message-driven EJBs – will not be discussed in detail

21 Sun Java System Application Server Platform Ed. 9 l is a fully compliant implementation of the Java EE 5 platform. l In addition to supporting all the APIs the Application Server includes a number of Java EE tool and instructions l for starting and stopping the Application Server, starting the Admin Console, and starting and stopping the Java DB database server. l Admin Console l asadmin l asant l appclient l …..

22 A First EJB Example – A Currency Converter l See listings given out with the lecture notes n a stateless Session Enterprise Java Bean with remote interface. n a very primitive application: has just two business methods u a method to convert dollars to yen u a method to convert yen to euro. u you will get an opportunity to upgrade this application as a practical exercise. Converter.java n the remote interface for the Enterprise Bean n declares the business methods described above.

23 Converter.java package converter.ejb; import java.math.BigDecimal; import public interface Converter { public BigDecimal dollarToYen(BigDecimal dollars); public BigDecimal yenToEuro(BigDecimal yen); }

24 Example – Currency Converter ConverterBean.java n the EJB implementation n a stateless session EJB for performing currency conversions in effect, this class implements the business methods declared in Converter remote interface

25 ConverterBean.java package converter.ejb; import java.math.BigDecimal; import public class ConverterBean implements converter.ejb.Converter { private BigDecimal euroRate = new BigDecimal("0.0070"); private BigDecimal yenRate = new BigDecimal("112.58") public BigDecimal dollarToYen(BigDecimal dollars) { BigDecimal result = dollars.multiply(yenRate); return result.setScale(2, BigDecimal.ROUND_UP); } public BigDecimal yenToEuro(BigDecimal yen) { BigDecimal result = yen.multiply(euroRate); return result.setScale(2, BigDecimal.ROUND_UP); }

26 Compiling and Packaging l compile the remote business interface (Converter.java) and the enterprise bean class (ConverterBean.java), and package the compiled classes into an enterprise bean JAR. l 1. In a terminal window, go to this directory: /javaeetutorial5/examples/ejb/converter/ l 2. Type the following command: ant

27 The Application Client l is a program written in the Java programming language l at runtime, the client program executes in a different virtual machine than the Application Server l The application client in this example requires two JAR files. l The first JAR file is for the Java EE component of the client. This JAR file contains the client’s deployment descriptor and class files l The second JAR file contains all the classes that are required by the client program at runtime. These classes enable the client to access the enterprise beans that are running in the Application Server.

28 ConverterClient.java package converter.client; import converter.ejb.Converter; import java.math.BigDecimal; import javax.ejb.EJB; public class ConverterClient private static Converter converter; /** Creates a new instance of Client */ public ConverterClient(String[] args) { } /** args the command line arguments */ public static void main(String[] args) { ConverterClient client = new ConverterClient(args); client.doConversion(); }

29 ConverterClient.java … contd. public void doConversion() { try { BigDecimal param = new BigDecimal("100.00"); BigDecimal yenAmount = converter.dollarToYen(param); System.out.println("$" + param + " is " + yenAmount + " Yen."); BigDecimal euroAmount = converter.yenToEuro(yenAmount); System.out.println(yenAmount + " Yen is " + euroAmount + " Euro."); System.exit(0); } catch (Exception ex) { System.err.println("Caught an unexpected exception!"); ex.printStackTrace(); }

30 Running the Application Client l ant l ant deploy l ant run l In the terminal window, the client displays these lines:... $ is Yen Yen is Euro.... That's it! you have deployed the primitive EJB application in the application server, and used a client program to connect to it.

31 Extension l The Converter application is an example provided as part of Sun's Java EE tutorial: u l You can make the Converter much more versatile and useful than this – refer to the practical work sheet.

32 The Web Client Interface