1 Java EE Programming Enterprise JavaBeans. 2 Topics J2EE Overview Enterprise JavaBeans Overview Enterprise Entity Beans Case Study How to build them.

Slides:



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

11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Apache Struts Technology
Approaches to EJB Replication. Overview J2EE architecture –EJB, components, services Replication –Clustering, container, application Conclusions –Advantages.
An architecture for webb applications, J2EE
6/1/20151 Luca Simone Software Engineering 2 a.a. 2001/2002.
1 Softsmith Open Learning - EJB 21-Nov Enterprise Java Beans Introduction –Application ServerApplication Server –Java 2 Enterprise EditionJava.
Technical Architectures
Distributed System Using Java 2 Enterprise Edition (J2EE) B.Ramamurthy.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Enterprise Applications & Java/J2EE Technologies Dr. Douglas C. Schmidt Professor of EECS.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
J2EE Java 2 Enterprise Edition. Relevant Topics in The Java Tutorial Topic Web Page JDBC orial/jdbc
Nikolaos Korfiatis The Java 2 Enterprise Edition Platform Dept. of Management & Technology-Athens University of Economics and Business Java 2 Platform.
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
CS 483 Enterprise and Web Application Programming
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Distributed System Using Java 2 Enterprise Edition (J2EE)
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
EJB Overview Celsina Bignoli Distributed Business Applications Server DB Client DB Server DB.
Distributed Multitiered Applications The J2EE platform uses a multitiered distributed application model. Application logic is divided into components 1.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
Enterprise Java Beans CS-422. Application Servers In the late 1980s and though the mid 1990s a number of corporations (Broadvision, Netscape…) marketed.
Enterprise Java Beans Part I Kyungmin Cho 2001/04/10.
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.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
第十四章 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.
J2EE Overview ver 1.0Page 1 © Wipro Technologies Talent Transformation J2EE Overview.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Introduction to Enterprise JavaBeans Topics In Systems Architecture Barry Herbold
Jini Architecture Introduction System Overview An Example.
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.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise.
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.
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.
Intro to J2EE Concepts Mimi Opkins Fall 2016 CECS493.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
J2EE Platform Overview (Application Architecture)
EJB (Enterprise Java Beans)
Introduction to J2EE Architecture
Web-Services-based Systems Architecture, Design and Implementation
Distributed System Using Java 2 Enterprise Edition (J2EE)
Understanding and Designing with EJB
Luca Simone Software Engineering 2 a.a. 2001/2002
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 Java EE Programming Enterprise JavaBeans

2 Topics J2EE Overview Enterprise JavaBeans Overview Enterprise Entity Beans Case Study How to build them

3 Distributed Multi-tiered Applications The J2EE platform uses a distributed multi- tiered application model for enterprise applications Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multi-tiered J2EE environment to which the application component belongs.

Multi-tiered Applications

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

6 J2EE Server Communications

7 J2EE Clients Web Clients A web client consists of two parts: (1) Dynamic web pages containing various types of markup language (HTML, XML, and so on), which are generated by web components running in the web tier, and (2) Web browser, which renders the pages received from the server.

8 J2EE Clients Applets A web page received from the web tier can include an embedded applet. An applet is a small client application written in the Java programming language that executes in the Java virtual machine installed in the web browser. Application Clients An application client runs on a client machine and provides a way for users to handle tasks that require a richer user interface than can be provided by a markup language. It typically has a graphical user interface (GUI) created from the Swing API, but a command-line interface is certainly possible.

9 Why use EJB? EJB provides developers architectural independence EJB insulates developers from the underlying middleware because the only environment an EJB developer sees is the Java environment. It also helps the EJB server/container vendor to change and make improvements on the underlying middleware layer without affecting a user’s existing enterprise applications. WORA (Write-once-run-anywhere) for server- side components Because EJB is based on Java technology, both the developer and the user are guaranteed that their components are Write Once, Run Anywhere (WORA). As long as an EJB server faithfully conforms to the EJB specification, any third-party EJB component should run within that server. EJB establishes roles for application development The EJB specification assigns specific roles for project participants charged with enterprise application development using EJBs.

10 Why use EJB? EJB takes care of transaction management The EJB container vendor is required to provide transaction control. The EJB developer who is writing the business functionality need not worry about starting and terminating transactions. EJB provides distributed transaction support EJB provides transparency for distributed transactions. This means a client can begin a transaction and then invoke methods on EJBs present within two different servers, running on different machines, platforms, or Java virtual machines. Methods in one EJB can call methods in the other EJB with the assurance they will execute in the same transaction context. EJB helps create portable and scalable solutions EJBs conforming to the EJB API will install and run in a portable fashion on any EJB server.

11 Why use EJB? EJB seamlessly integrates with CORBA EJB and CORBA are a natural combination that complement each other. For example, EJBs may provide CORBA/IIOP for a robust transport mechanism or pure CORBA clients can access EJBs as EJB clients. Currently, a highlight of OMG’s CORBAServices is the wide range of features they provide to an enterprise application developer. In the future, rather than trying to rewrite these services, EJB server vendors may simply wrap them with a simplified API, so EJB developers can use them without being CORBA experts. EJB provides for vendor specific enhancements Because the EJB specification provides considerable flexibility for the vendors to create their own enhancements, the EJB environment may end up being feature-rich.

12 The JavaBeans™ Component Architecture The server and client tiers might also include components based on the Java-Beans component architecture (JavaBeans components) to manage the data flow between an application client or applet and components running on the J2EE server, or between server components and a database. JavaBeans components are not considered J2EE components by the J2EE specification. JavaBeans components have properties and have get and set methods for accessing the properties. JavaBeans components used in this way are typically simple in design and implementation but should conform to the naming and design conventions outlined in the JavaBeans component architecture.

13 Web Tier and J2EE Applications

14 Web Components J2EE web components are either servlets or pages created using JSP technology (JSP pages). Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content. Static HTML pages and applets are bundled with web components during application assembly but are not considered web components by the J2EE specification. Server-side utility classes can also be bundled with web components and, like HTML pages, are not considered web components

15 Business and EIS Tiers

16 Business Components Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier. Previous slide shows how an enterprise bean receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client program.

17 Types of Enterprise Beans Three kinds of enterprise beans: session beans, entity beans, and message-driven beans. A session bean represents a transient conversation with a client. When the client finishes executing, the session bean and its data are gone. An entity bean represents persistent data stored in one row of a database table. If the client terminates or if the server shuts down, the underlying services ensure that the entity bean data is saved. A message-driven bean combines features of a session bean and a Java Message Service (JMS) message listener, allowing a business component to receive JMS messages asynchronously.

18 Enterprise Information System Tier The enterprise information system tier handles EIS software and includes enterprise infrastructure systems such as: enterprise resource planning (ERP) mainframe transaction processing database systems, and other legacy information systems. For example, J2EE application components might need access to enterprise information systems for database connectivity.

19 J2EE Containers Normally, thin-client multi-tiered applications are hard to write because they involve many lines of intricate code to handle transaction and state management, multithreading, resource pooling, and other complex low-level details. The component-based and platform-independent J2EE architecture makes J2EE applications easier to write because business logic is organized into reusable components. In addition, the J2EE server provides underlying services in the form of a container for every component type. Because you do not have to develop these services yourself, you are free to concentrate on solving the business problem at hand.

20 Container Services Containers are the interface between a component and the low-level platform specific functionality that supports the component. Before a web component, enterprise bean, or application client component can be executed, it must be assembled into a J2EE module and deployed into its container. The assembly process involves specifying container settings for each component in the J2EE application and for the J2EE application itself. Container settings customize the underlying support provided by the J2EE server, including services such as security, transaction management, Java Naming and Directory Interface™ (JNDI) lookups, and remote connectivity

21 Container Services - Highlights The J2EE security model lets you configure a web component or enterprise bean so that system resources are accessed only by authorized users. The J2EE transaction model lets you specify relationships among methods that make up a single transaction so that all methods in one transaction are treated as a single unit. JNDI lookup services provide a unified interface to multiple naming and directory services in the enterprise so that application components can access naming and directory services. The J2EE remote connectivity model manages low-level communications between clients and enterprise beans. After an enterprise bean is created, a client invokes methods on it as if it were in the same virtual machine.

22 Container Types

23 Container Types J2EE server The runtime portion of a J2EE product. A J2EE server provides EJB and web containers. Enterprise JavaBeans (EJB) container Manages the execution of enterprise beans for J2EE applications. Enterprise beans and their container run on the J2EE server. Web container Manages the execution of JSP page and servlet components for J2EE applications. Web components and their container run on the J2EE server. Application client container Manages the execution of application client components. Application clients and their container run on the client. Applet container Manages the execution of applets. Consists of a web browser and Java Plugin running on the client together.

24 Packaging Applications

25 What are Transactions? To a user, a transaction is a single change event that either happens or does not happen To the system implementers, a transaction is a programming style that enables them to code modules that can participate in distributed computations Ex: transferring money from a checking to a savings bank account Sounds easy but in a distributed environment need transaction control Java Transaction Service Transaction manager – keeps track of the progress of a transaction Commits or rolls back the ENTIRE transactions which can be updates to multiple database tables in multiple databases...

26 What is a Naming Service? A naming system provides a natural, understandable way of identifying and associating names with data Enable humans to interact with complex computer addressing systems by associating data and objects with simple names Independent from computer systems that use them Can serve any system that can connect to them and understands their protocol

27 Java Naming & Directory Interface (JNDI)

28 Enterprise Java Beans “Written in the Java programming language, an enterprise bean is a server-side component that encapsulates the business logic of an application. The business logic is the code that fulfills the purpose of the application” (Sun, 2006).Sun, 2006 For example, in a university student services application, this logic would include the registration of students, but not the underlying networking code allowing registration via a web browser. An enterprise bean typically contains business logic that operates on the enterprise’s data An enterprise bean’s instances are created and managed at runtime by a container An enterprise bean can be customized at deployment time by editing its environment entries. Various service information, such as transaction and security attributes, are separate from the enterprise bean class and can be configured without changes to the software

Basic Enterprise Java Bean Architecture

30 EJB Server EJB server provides an organized framework or execution environment in which EJB containers can run. Makes available system services for multiprocessing, load balancing, and device access for EJB containers. EJB server also makes EJB containers running within them visible to the outside world. It may also provide vendor-specific features like an optimized data access interface, additional CORBA Services, SSL support, a JNDI-accessible naming service, and transaction management services.

31 The Home Interface and Home Object Contains Factory methods for locating, creating and removing instances of EJBs EJB developer defines the Home Interface for his bean Home Object is generated by tools provided by the Container vendor Home Object is the implementation of the Home Interface

32 The Remote Interface and the EJB Object Remote Interface lists the business methods present in the EJB class Remote Interface is defined by the EJB developer EJB Object which is the concrete class for the Remote Interface is generated by tools provided by the container vendor EJB Clients use the methods present in the Remote Interface to invoke business methods of the EJB

33 EJB Containers An EJB container acts as the interface between an enterprise bean and low-level, platform-specific functionality that supports the bean. Container vendor is also free to provide additional services implemented at either the container or the server level. EJB client never accesses a bean directly. Any bean access is done through the methods of the container- generated classes, which, in turn, invoke the bean's methods. Having the container interpose on all bean invocations allows the container to manage transactions, load bean instances, if necessary, and, in general, to do all the wonderful things EJBs do. Two types of containers exist: session containers that may contain transient, nonpersistent EJBs whose states are not saved entity containers that contain persistent EJBs whose states are saved between invocations.

34 The Enterprise JavaBean Real enterprise bean itself is contained within an EJB container and is never directly accessed by anyone but the container EJB container mediates all EJBs Does not implement the remote interface within the bean itself – uses skeleton

The Enterprise JavaBean

36 Two Types of EJBs we will discuss in this class... Session BeanEntity Bean The data members of the session bean contain conversational state. The data members of the entity bean represent actual data in the domain model. A session bean may handle database access for a single client. Entity beans share database access for multiple clients. Because session beans are about a conversation with a single client, session beans are allowed to store per-client state information.. Because entity beans are shared between multiple clients, they do not allow storage of per-client state information. The relationship between a session bean and its client is one-to-one. The relationship between an entity bean and a row in the domain model is one-to-one. The life of the session bean is limited to the life of its client. An entity bean persists as long as the data exists in the database. Session beans can be transaction aware. Entity beans are transactional. Session beans do not survive server crashes. Entity beans survive server crashes.

37 The EJB Client Finds EJB containers using JNDI Uses EJB containers to invoke EJB methods EJB Client only gets a reference to an EJB Object instance – not actual bean Uses the Home Object to locate, create or destroy an EJB class Uses the EJB Object instance to invoke business methods of the EJB instance

38 The EJB Lifecycle – Roles in EJB EJB Server Provider – creates EJB Servers EJB Container Provider – creates EJB container and tools EJB Developer – creates EJBs EJB Deployer – deploys the EJBs on a Server Application Assembler – uses the EJBs

Major Components of the EJB Architecture

40 Developing EJBs Define your Home Interface Define your Remote Interface Develop your Entity or Session Bean In the case of Entity Beans, define a Primary Key class Write your Deployment Descriptor Compile your classes and generate the Container code using the tools provided Set up your Data Source to the Database Develop the client code Startup your Server & execute your client

41 The Contents of an Enterprise Bean To develop an enterprise bean, you must provide the following files: Deployment descriptor: An XML file that specifies information about the bean such as its persistence type and transaction attributes. The deploy tool utility creates the deployment descriptor when you step through the New Enterprise Bean wizard. Enterprise bean class: Implements the methods defined in the following interfaces. Interfaces: The remote and home interfaces are required for remote access. For local access, the local and local home interfaces are required. For access by web service clients, the web service endpoint interface is required. (Please note that these interfaces are not used by Helper classes: Other classes needed by the enterprise bean class, such as exception and utility classes.

42 The Contents of an Enterprise Bean

43 Naming Conventions for Enterprise Beans

44 The Life Cycles of Enterprise Beans An enterprise bean goes through various stages during its lifetime, or life cycle. Each type of enterprise bean—session, entity, or message-driven—has a different life cycle.

45 The Life Cycle of an Entity Bean

46 End of Lecture