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

Slides:



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

J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
19 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Developing Web Services.
21 Copyright © 2005, Oracle. All rights reserved. Oracle Application Server 10g Transaction Support.
12 Copyright © 2005, Oracle. All rights reserved. Implementing Business Tasks with Session EJBs.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
3 Copyright © 2005, Oracle. All rights reserved. Designing J2EE Applications.
15 Copyright © 2005, Oracle. All rights reserved. Container-Managed Relationships (CMRs)
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
J2EE Overview.
Enterprise Java and Data Services Designing for Broadly Available Grid Data Access Services.
Executional Architecture
Approaches to EJB Replication. Overview J2EE architecture –EJB, components, services Replication –Clustering, container, application Conclusions –Advantages.
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.
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.
EJB Design. Server-side components Perform –complex algorithms –high volume transactions Run in –highly available environment (365 days/year) –fault tolerant.
Enterprise Java Beans Welcome to the world of “Distributed System” Presented By: Sameer Nanda Date: 12/17/03.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
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.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
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.
EJB.
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. 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.
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
Session Beans -) stateless -) stateful. Session Beans A session bean represents a single client inside the J2EE server. To access an application that.
Collaborate Lesson 4C / Slide 1 of 22 Collaborate Knowledge Byte In this section, you will learn about: The EJB timer service Message linking in EJB 2.1.
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
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
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.
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.
©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.
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.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
EJB (Enterprise Java Beans)
Introduction to J2EE Architecture
Introduction to Enterprise JavaBean
Understanding and Designing with EJB
Luca Simone Software Engineering 2 a.a. 2001/2002
Understanding and Designing with EJB
Component-based Applications
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Understanding and Designing with EJB
Enterprise Java Beans.
Objectives In this lesson, you will learn about:
Presentation transcript:

J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Introduction to EJB

J0 2 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento What is an EJB ? An enterprise java bean is a server-side component that encapsulates the business logic of an application. By invoking the exposed methods, remote clients can access the services provided by the application.

J0 3 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Architectural view

J0 4 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Simplify the development of large distributed apps The EJB container provides system-level services to enterprise beans. EASIER DEVELOPMENT => The EJB container--not the bean developer--is responsible for services such as transaction management and security authorization.

J0 5 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Simplify the development of large distributed apps Separation of responsability among tiers: EASIER DEVELOPMENT => the bean developer can concentrate on solving business problems. EASIER DEVELOPMENT => the client developer can focus on the presentation of the client business rules or access databases. BETTER PRODUCTS => The clients are thinner, a benefit that is particularly important for clients that run on small devices.

J0 6 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Simplify the development of large distributed apps Enterprise beans are portable components: REUSABILITY => application assembler can build new applications from existing beans. PORTABILITY => These applications can run on any compliant J2EE server.

J0 7 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Architectural view 1 - Write the beans 2 -Write the descriptor 3- Write the client

J0 8 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento EJB ingredients Interfaces: The remote and home interfaces are required for remote access. For local access, the local and local home interfaces are required. Enterprise bean class: Implements the methods defined in the interfaces. Helper classes: Other classes needed by the enterprise bean class, such as exception and utility classes.

J0 9 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento EJB ingredients Deployment descriptor: An XML file that specifies information about the bean such as its persistence type and transaction attributes. You package the files in the preceding list into an EJB JAR file, the module that stores the enterprise bean. To assemble a J2EE application, you package one or more modules--such as EJB JAR files-- into an EAR file, the archive file that holds the application.

J0 10 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento When to use EJB ? The application must be scalable. To accommodate a growing number of users, you may need to transparently distribute an application's components across multiple machines. Transactions are required to ensure data integrity. Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects. The application will have a variety of clients. With just a few lines of code, remote clients can easily locate enterprise beans. These clients can be thin, various, and numerous.

J0 11 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Types of EJB Enterprise Bean Type Purpose SessionPerforms a task for a client EntityRepresents a business entity object that exists in persistent storage Message-DrivenActs as a listener for the Java Message Service API, processing messages asynchronously

J0 12 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Entity Beans An entity bean represents a business object in a persistent storage mechanism. Some examples of business objects are customers, orders, and products. The bean represents a business entity, not a procedure. For example, CreditCardEJB would be an entity bean, but CreditCardVerifierEJB would be a session bean. The bean's state must be persistent. If the bean instance terminates or if the J2EE server is shut down or crashes, the bean's state still exists in persistent storage (a database).

J0 13 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Session Beans A session bean represents a single client inside the J2EE server. To access an application that is deployed on the server, the client invokes the session bean's methods. The session bean performs work for its client, shielding the client from complexity by executing business tasks inside the server. At any given time, only one client has access to the bean instance. The state (i.e. the values of the instance variables) of the bean is not persistent, existing only for a short period of time. A session bean can be stateful or stateless.

J0 14 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Stateful session Beans In a stateful session bean, the instance variables represent the state of a unique client-bean session. This state is often called the conversational state. The state is retained for the duration of the client-bean session. If the client removes the bean or terminates, the session ends and the state disappears.

J0 15 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Stateless session Beans A stateless session bean does not maintain a conversational state for a particular client. When a client invokes the method of a stateless bean, the bean's instance variables may contain a state, but only for the duration of the invocation. When the method is finished, the state is no longer retained.

J0 16 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Stateless vs. stateful session Beans All instances of a stateless bean are equivalent, allowing the EJB container to assign an instance to any client. => Stateless session beans can support multiple clients, and offer better scalability for applications that require large numbers of clients. Typically, an application requires fewer stateless session beans than stateful session beans to support the same number of clients.

J0 17 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Stateless vs. stateful session Beans The EJB container can write a stateful session bean to secondary storage. However, stateless session beans are never written to secondary storage. Therefore, stateless beans may offer better performance than stateful beans.

J0 18 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Stateful session Beans – examples of use The bean needs to hold information about the client across method invocations. The bean mediates between the client and the other components of the application, presenting a simplified view to the client. Behind the scenes, the bean manages the work flow of several enterprise beans.

J0 19 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Stateless session Beans – examples of use In a single method invocation, the bean performs a generic task for all clients. For example, you might use a stateless session bean to send an that confirms an online order. The bean fetches from a database a set of read-only data that is often used by clients.

J0 20 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Message Driven Beans A message-driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously. It acts as a JMS message listener, which is similar to an event listener except that it receives messages instead of events. The messages may be sent by any J2EE component--an application client, another enterprise bean, or a Web component--or by a JMS application or system that does not use J2EE technology.

J0 21 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento Message Driven Beans A message-driven bean's instances retain no data or conversational state for a specific client. All instances of a message-driven bean are equivalent, allowing the EJB container to assign a message to any message-driven bean instance. The container can pool these instances to allow streams of messages to be processed concurrently. A single message-driven bean can process messages from multiple clients.

J0 22 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento A more detailed architectural view Image taken from Mastering EJ2B DB CMP JDBC

J0 23 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento More on Entity Beans: PERSISTENCE Persistence means that the entity bean's state exists beyond the lifetime of the application or the J2EE server process. There are two types of persistence for entity beans: bean-managed and container-managed. With bean-managed persistence (BMP), the entity bean code that you write contains the calls that access the database. If your bean has container-managed persistence (CMP), the EJB container automatically generates the necessary database access calls. The code that you write for the entity bean does not include these calls.

J0 24 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento More on Entity Beans: SHARED ACCESS Entity beans may be shared by multiple clients. Because the clients might want to change the same data, it's important that entity beans work within transactions. Typically, the EJB container provides transaction management. In this case, you specify the transaction attributes in the bean's deployment descriptor. You do not have to code the transaction boundaries in the bean--the container marks the boundaries for you.

J0 25 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento More on Entity Beans: DB-like features Like in a relational database: Each entity bean has a unique object identifier; An entity bean may be related to other entity beans. The unique identifier, or primary key, enables the client to locate a particular entity bean. You implement relationships differently for entity beans with BMP and those with CMP: BMP: the code that you write implements the relationships. CMP: the EJB container takes care of the relationships for you. (container-managed relationships).

J0 26 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento More on Entity Beans: SHARED ACCESS Entity beans may be shared by multiple clients. Because the clients might want to change the same data, it's important that entity beans work within transactions. Typically, the EJB container provides transaction management. In this case, you specify the transaction attributes in the bean's deployment descriptor. You do not have to code the transaction boundaries in the bean--the container marks the boundaries for you.

J0 27 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento KEY CONCEPTS Entity beans: synchronous, shared access, concurrency-safe -CMP -BMP Session Beans: synchronous -Statefulsingle access, conversational state -Stateless sharable, no state Message-Drive Beans: asynchronous, sharable, no state