Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.

Slides:



Advertisements
Similar presentations
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Advertisements

An architecture for webb applications, J2EE
Distributed System Using Java 2 Enterprise Edition (J2EE) B.Ramamurthy.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Enterprise Java Beans Welcome to the world of “Distributed System” Presented By: Sameer Nanda Date: 12/17/03.
Application Server Lecture Paulo Barroso Kris Carver Todd Kitterman Eric Silva.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Point Of Sale(POS) J2EE Application Department : Computer Science Degree : Master Student : Woojin Choi ID : (POS J2EE Application with JRun)
J2EE Java2 Enterprise Edition by Damian Borth. Contents Introduction Architectures styles Components Scenarios Roles Processing a HTTP request.
J2EE Java 2 Enterprise Edition. Relevant Topics in The Java Tutorial Topic Web Page JDBC orial/jdbc
Enterprise Programming By J Pearce. Enterprise Software Sales HR Inventory Customer Support Shipping.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
CS 483 Enterprise and Web Application Programming
Chapter 4 Servlets Concept of Servlets (What, Why, and How) Servlet API Third-party tools to run servlets Examples of Using Servlets HTML tag with GET.
Understanding and Managing WebSphere V5
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Java Pet Store Application. Outline Introduction Introduction Information Layer Information Layer Application Layer Application Layer Infrastructure Layer.
Distributed System Using Java 2 Enterprise Edition (J2EE)
Distributed Multitiered Applications The J2EE platform uses a multitiered distributed application model. Application logic is divided into components 1.
4-Tier Model Client Tier Web Tier Business Tier EIS Tier.
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.
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,
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Writing Enterprise Applications with J2EE (Second lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
Entity Beans BMP Celsina Bignoli
© D. Wong  Indexes  JDBC  JDBC in J2EE (Java 2 Enterprise Edition)
Entity Java Beans Jorg Janke Open Source ERP & CRM.
Container-Managed Persistence (CMP) Entity Beans Lesson 3A / Slide 1 of 42J2EE Server Components Objectives In this lesson, you will learn to: Identify.
Enterprise Java Beans Part II Kyungmin Cho 2001/04/13.
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.
Introduction to J2EE Architecture Portions by Kunal Mehta.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
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,
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
MACIASZEK, L.A. (2001): Requirements Analysis and System Design. Developing Information Systems with UML, Addison Wesley Chapter 6 - Tutorial Guided Tutorial.
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.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
Entity Beans & Persistence Chris Alexander CS 486 Spring 2001.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
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.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Copyright © 2002 ProsoftTraining. All rights reserved. Enterprise JavaBeans.
©NIIT Introducing Enterprise JavaBeans (EJB) Lesson 1A / Slide 1 of 43J2EE Server Components Objectives In this lesson, you will learn about: The features.
Introduction – ORM, Helloworld Application
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
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.
©NIIT Session Beans Lesson 1B/ Slide 1 of 37J2EE Server Components Objectives In this lesson, you will learn to: Describe the characteristics of session.
Point Of Sale(POS) J2EE Application
Introduction to J2EE Architecture
J2EE Application Development
Distributed System Using Java 2 Enterprise Edition (J2EE)
Understanding and Designing with EJB
Objectives In this lesson, you will learn to:
Understanding and Designing with EJB
Enterprise Java Beans.
Presentation transcript:

Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of J2EE Concept of Deployment Steps in Developing an EJB Applications A simple Example Entity Beans and Session Beans Example of an Entity Bean Application Example of an Session Bean Application In-class Exercises

Concepts of EJB What is an EJB? –Part of J2EE (Java 2 Enterprise Edition) –Three-tier or multi-tier client/server applications –Distributed applications Why EJB? –Components-based architecture makes application development easier and faster –Platform independent –Developers concentrate on business logic rather than presentation –GUI deployment tools make packaging and deploying an EJB application easier and faster –Integrated Java technology –Hidden-details in Client/server communications and JDBC connectivity

Concepts of EJB (continue) Multi-tiered Applications

Concepts of EJB (continue) J2EE server communications with other tiers

Concepts of EJB (continue) Closer look of Web tier

Concepts of EJB (continue) Closer look of Business and EIS (Enterprise Info Sys) tier

Concepts of EJB (continue) J2EE Server and Containers

Three Components in Creating an EJB Coding the remote interface –define the business methods that a client may call, i.e, retrieve a message or compute data –name convention of the code: ProgRemote.java Coding the home interface –define the methods that allow a client to create, find, or remove an EJB –name convention of the code: ProHome.java Coding the bean –implement the methods of the remote interface. The methods will be called by the container-generated code after the deployment –name convention of the code: ProEJB.java or ProBean.java Note: to use the EJB, one must create a client code

Installation and Configuration of J2EE Download J2EE from J2EE requires J2SDK to be installed Follow the instruction to install J2EE Setup environment variables (for example) –set JAVA_HOME=c:\j2sdk1.4.1 –set J2EE_HOME=c:\j2sdkee1.3.1 Other links –J2EE API: –J2EE tutorial: ord=EJB ord=EJB –general topic tutorials:

Starting/Stopping J2EE Server and Deployment Tool To start the server, click on j2ee.bat in the J2EE_HOME\bin directory, or type the following command in command console: start %J2EE_HOME%\bin\j2ee -verbose To start the deployment tool, click on deploytool.bat in the J2EE_HOME\bin directory, or type the following command in command console: start %J2EE_HOME%\bin\deploytool To stop the server, use the following command %J2EE_HOME%\bin\j2ee -stop

Application Deployment Tool in J2EE deploytool provides GUI for assembling, verifying, packaging, configuring, and deploying J2EE applications It manages your development and production environments It creates a JAR file, ProEJB.jar, for the EJB, and an application file, Pro.ear, for development in the EJB container It will also create additional files needed for communications with the clients, and a deployment descriptor

Steps in Developing an EJB Applications Step 1: Create the EJB –code the remote interface (ProRemote.java) –code the home interface (ProHome.java) –code the bean (ProgEJB.java) –compile all three components using the following command: javac -classpath.;%J2EE_HOME%\lib\j2ee.jar Pro*.java Step 2: Start J2EE Server (see previous slide) Step 3: Deploy the EJB Using deploytool (see previous slide) Step 4: Create and compile a client code Step 5: Execute the client code

A simple Example (p. 389) HelloRemote.java - define the business method as remote interface to retrieve hello message (p. 390) HelloHome.java - define the method that allow a client to create, find, or remove an EJB (p. 391) HelloEJB.java - implement the methods of the remote interface as SessionBean, more specifically, return the hello message To compile: javac -classpath.;%J2EE_HOME%\lib\j2ee.jar Hello*.java To deploy the Hello application, follow the steps on p. 8 of newupdatech10.doc

A simple Example (continue) (p. 393) HelloClient.java - a client application using the EJB to display the message To execute the client application: - compile the HelloClient.java javac -classpath.;%J2EE_HOME%\lib\j2ee.jar HelloClient.java - execute the application: java -classpath.;%J2EE_HOME%\lib\j2ee.jar;HelloClient.jar HelloClient

Entity Beans and Session Beans Entity beans model business objects such as customers, orders, and prodcuts Entity beans have a persistent representation, usually in a database; J2EE server uses Cloudscape database Session beans perform operations on the business objects such as place an order, or reserve a flight A session bean presents a client in the J2EE server The client invokes the session bean’s methods to access an application deployed in the server Session beans are not persistent. Session beans can be stateless or stateful –a stateful bean saves information so it can interact with the client –a stateless bean requires no continuing interaction with the client

Entity Beans Entity beans model business objects such as customers, orders, and products Entity beans have a persistent representation, usually in a database; J2EE server uses Cloudscape database Entity beans can be Container-Managed Persistence (CMP) or Bean-Managed Persistence (BMP) In CMP, the persistence of a bean’s state to the underlying database is automatically managed by the container In MBP, the programmers create code in the bean to manage the persistence

Entity Beans (continue) As in developing a session bean, we need to write the Home interface, the Remote interface, and the implementation of the entity bean As in developing a session bean, we need also to write the client code as a particular application to use the entity bean In the Remote interface we extend EJBObject and declare the get() and set() methods as the business methods (see CustomerRemote.java) In the Home interface, we extend EJBHome and declare the required Create() method, the required findByPrimaryKey(), and other finder methods (see CustomerHome.java)

Entity Beans (continue) In the implementation we implement EntityBean, the methods declared in the interfaces, and other methods (see CustomerEJB.java in p. 397) After we deploy the entity bean, the find() methods become as SQL queries generated by the container automatically. We may modify them if it’s necessary In the developing the client applications, multiple clients can access an entity bean, the persistence and synchronization are automatically managed

Entity Beans (continue) In a client code, it looks up the bean, may create database table, call the finder methods, or get() and set() methods to do the transactions and manipulations of the data stored in the database (see CustomerClient.java) Steps in deployment of the entity bean (see p. 18 in newupdatech10.doc) Steps in deployment of the client (see p. 20 in newupdatech10.doc) Steps in the execution (see p. 21 in newupdatech10.doc)

Example of an Entity Bean Application (p. 395) CustimerRemot.java - remote interface to define the business methods for customer EJB (p. 396) CustomerHome.java - define the method that allow a client to create and find a customer (p. 397) CustomerEJB.java - entity bean representing a customer (See p. 16 in newupdatech10.doc) (p. 402) CustomerClient.java - client code to create customers and test out the find method (See p. 21 in newupdatech10.doc) Deployment steps (see p in newupdatech10.doc) Note: Steps may be vary depending upon the different versions of J2EE

Example of an Session Bean Application A session bean may be stateful in which it holds the client state across the method calls A session bean may be deployed to the entity bean, so the data in the entity bean can be used Agent bean example has these features above (p. 404) AgentRemote.java - define the business method for agent EJB (p. 404) AgentHome.java - define the methode to create an agent bean (p. 405) AgentEJB.java - a stateful entity bean to place an order

Example of an Session Bean Application (continue) (p. 408/p. 29) SalesClient.java - client code to use agent bean to retrieve the required customer names Deployment steps (see p in newupdatch10.doc)

Using EJB in Servlet and JSP Clients For a Web application, we can include the web components from J2EE application, so the clients can access EJB from the web and dynamically update the web The client can be a servlet client, or JSP client. As a servlet client, we can write the HTML file to invoke the J2EE application in which it will invoke the packaged servlet As a JSP client, we can write a JSP code that focuses on the presentation of the form shown in the client’s web, then we can write a Java program to focus on the looking up the bean and the business methods In either way, we package the servlet or JSP in J2EE, then we deploy the application using deployment tools

Using EJB in Servlet and JSP Clients(continue) Examples to develop a servlet client to access the Agent Bean: –Develop a HTML that calls the J2EE application “SalesAlias” that invokes a sales servlet, and passes Customer ID and Salesperson ID to the servlet using the POST method (see updatch10.doc – SalesServlet.html) –Develop a servlet program that connects with the Agent bean, updates the client’s web, displays a form, creates object of Agent bean with the table having Item number, Quantity, and Price entered by the client, and displays the records in the table to the client’s web (see updatech10.doc – SalesServlet.java) –Compile the servlet program using the command: javac -classpath.;c:\j2sdkee1.3.1\lib\j2ee.jar SalesServlet.java –Start J2EE server, Cloudscape server, and deploytool

Using EJB in Servlet and JSP Clients(continue) –Package the servlet (see newupdatech10.doc – package the servlet) –Deploy the application (see newupdatech10.doc – the next page) –Execute the application (The HTML will invoke the EJB application “SalesAlias” after user click on the Submit Query button)

Using EJB in Servlet and JSP Clients(continue) Examples to develop a JSP client to access the Customer Bean (CustomerEJB): –Develop a Java program that looks up the Customer bean and perform the business logics (set() and get() methods, see newupdatech10.doc – CustomerBean.java) –Compile the Java code using the command: javac –classpath.;%j2ee_home%\bin\j2ee.jar;CustomerClient.jar CustomerBean.java

Using EJB in Servlet and JSP Clients(continue) – Develop a JSP program that will present a form in the client’s web, call the methods defined in the Java code, and interact between client and the server using the EJB (see newupdatech10.doc – Customer.jsp) –Start J2EE server, Cloudscape server, and deploytool –Package the JSP (see newupdatech10.doc – Package the JSP and JavaBean) –Deploy the application (see newupdatech10.doc – Deploy the Application) –Execute Open a Web browser, and type:

In-class Exercises -Test examples HelloXXX, CustomerXXX, AgentXXX, and SalesXXX. -Try-It-Yourself 3, 5, 9 and 11