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.

Slides:



Advertisements
Similar presentations
A plataforma J2EE.
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.
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.
Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB.
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.
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.
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.
Brad Rippe Fullerton College. What you need to get started? JDK 1.3 standard for compilation J2EE - SDK1.2.1 App Server - An EJB Container/Web Container.
J2EE Part 2: Enterprise JavaBeans CSCI 4300 Images and code samples from jGuru EJB tutorial,
Enterprise Java Beans - (EJB)
Seminar: Enterprise JavaBeans. Agenda Agenda Java™ 2 Platform Java™ 2 Platform Java™ 2 Platform,Enterprise Edition(J2EE) Java™ 2 Platform,Enterprise Edition(J2EE)
Entity Beans BMP Celsina Bignoli
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
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.
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.
Middleware Technology (J2EE/EJB) Stateful Session Bean.
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.
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.
第十四章 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.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
© jGuru.com Enterprise JavaBeans Fundamentals.
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.
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.
Enterprise Java Bean Technology Briefing Markus Hebach.
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.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
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.
©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.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
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.
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
Java Servlets By: Tejashri Udavant..
Introduction to J2EE Architecture
Structure of Enterprise Java Beans
J2EE Application Development
Understanding and Designing with EJB
Luca Simone Software Engineering 2 a.a. 2001/2002
Objectives In this lesson, you will learn to:
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Component-based Applications
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Knowledge Byte In this section, you will learn about:
Presentation transcript:

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

2 Concepts Session bean is a non-persistent object that implements some business logic running on the server. A session bean represents a transient conversation with a client A stateless session bean does not maintain a conversational state for its client A stateful session bean maintains a conversational state for its client throughout the session. The state is retained for the duration of the client- bean session and the state is discarded when the client removes the bean or terminates

3 Constitution of a session bean Remote interface: defines the business methods of the bean. Home interface: defines the lifecycle methods of the bean (like creating or removing a bean) Note: The remote and home interfaces provide the client's view of the bean. Enterprise Bean class: provides the implementation for the business methods. Deployment Descriptor: This configuration document defines the bean's runtime attributes, such as its transaction or security attributes Helper classes

4 Remote Interface Must derive from javax.ejb.EJBObject EJB remote interface must conform to RMI rules Any method must throw RemoteException Parameters passing to method and return data type must be RMI valid types, such as primitives, serializable objects or remote objects public interface Register extends EJBObject { public int signup(Customer cust) throws RemoteException; public int newAccount(Account acc) throws RemoteException; }

5 Home Interface Define methods for creating and destroy EJB object Container need Home interface to generate Home object- part of container Client invokes method on Home interface to ask for instantiate and remove EJB object Stateless session bean has only one create() method with no argument Stateful session bean may have multi create() method with different arguments to initiate its state – argument type must be RMI valid types

6 Home Interface

7 Must extends EJBHome interface Must define at least one create() method that return the remote interface type of the enterprise bean. (But an ejbCreate method returns void.) All create() methods must throw RemoteException and CreateException public interface TransactionHome extends EJBHome { public Transaction create(int accNo) throws RemoteException, CreateException; }

8 Enterprise Bean class implements the SessionBean interface. The SessionBean interface extends the EnterpriseBean interface, which in turn extends the Serializable interfaceSessionBeanEnterpriseBean The class is defined as public, cannot be defined as abstract or final. implements one or more ejbCreate methods with the following requirements The access control modifier must be public. The return type must be void Every create method in the home interface corresponds to an ejbCreate method in the bean class

9 Enterprise Bean class implements the business methods The method name must not conflict with one defined by the EJB architecture the arguments and return types must be legal types for the Java RMI API. contains a public constructor with no parameters. must not define the finalize method

10 Enterprise Bean class

11 Enterprise Bean class Container call setSessionContext() to associate a SessionContext with a bean ejbPassivate() should release any holding resources ejbActivate() should acquire any needed resources Passivation & activation do not apply to stateless session bean (pool & reuse do not apply to stateful session bean)

12 Deployment Descriptor Used by container for runtime setup of EJB: middle-ware services provided according to deployment descriptor Specify Bean management & life-cycle requirements Name of class, stateless/ful, transaction manage Persistence requirement (entity bean only) Transaction requirement Security requirements Resource references/ mapping Error/Exception mapping

13 Client side Client can exist in any scenario Stand-alone application Java-based applet Jsp page, servlet Other enterprise bean Client code typically follow these steps: Look up home object by JNDI name Use the home object to create EJBObject Call business method on EJB object Remove EJB object For remote client of j2ee server, need to install j2sdkee on client machine actualy necessary is j2ee.jar and properties file)

14 Web Client The classes needed by the client are declared with a JSP page directive ) Because locating the home interface and creating the enterprise bean are performed only once, this code appears in a JSP declaration enclosed within the characters that contains the initialization method, jspInit(), of the JSP page

15 Deployment on J2EE server Start up application server -EJB Container (J2EE server) Using deploytool to generate deployment descriptor, verify and deploy your enterprise application Because EJB client code use home and remote interface, you must deploy these classes in client enviroment (but not bean class) Modify.properties file for port setting and database setting resource.properties, orb.properties, web.properties, ejb.properties setenv.bat