Download presentation
Presentation is loading. Please wait.
Published byOswald Hunt Modified over 9 years ago
1
Enterprise Java Bean Matt
2
2 J2EE
3
3 J2EE Overview
4
4 J2EE 1.4 API
5
5 Distributable Components Components should provide services to clients running locally or remotely SelfContained Components Components should only contain the code necessary to implement their services Infrastructure services should be injected by the execution environment Standard infrastructure services include Directory Services Distributed transaction management Security management Concurrent access management Persistence management Resource pooling (e.g. DB connections) Administration interface Load Balancing Fault tolerance An application server provides the infrastructure and services to run components/applications
6
6 Object Pooling An application server may create a pool of bare objects that may be used as EJBs when requests are made
7
7 Container A Container provides the environment in which a bean executes generates Home Object generates EJB Object manages individual bean instances
8
8 EJB
9
9 Enterprise Java Bean 包括了 Session Bean: Session beans are essentially service providers Stateless Stateful Entity Bean: Entity beans are used to represent data in a database. BMP CMP Message-Driven Bean: Message driven beans are capable of responding to JMS messages
10
10 EJB Overview EJB simplified distributed development Develop EJB implementation logic Define Home/Local Remote/Local interfaces Container delegates client calls Container manages resources/lifecycle/callbacks
11
11 EJB
12
12 EJB Design Approaches Remote interface Home interface Bean class
13
13 EJB Architecture
14
14 EJB Flow Chart
15
15 Client View of EJB
16
16 EJB EJB clients utilizes the Java Naming and Directory Interface (JNDI) to look up for the references to home interfaces use home and remote EJB interfaces to utilize all EJB-based functionality EJB Home interface create EJBs remove EJBs find handles to EJB remote interface objects EJB remote interfaces provide business-specific functionality of an EJB are similar to RMI Remote interface EJB implementation (Bean Class) business method invocation database loading logic passivation, database storage Session Context The Container has already reference to the bean The bean interacts with the Container through SessionContext and retrieves home interfaces gets and sets transactions attributes obtains security attribute The setSessionContext method is used to inform the bean about the session context
17
17 Steps to Develop an EJB
18
18 Hello World Object Model using RMI
19
19 Session Bean
20
20 Session EJBs View Stateless Stateful
21
21 Life Cycle of Stateless Session Bean
22
22 Life Cycle of Stateful Session Bean
23
23 Stateful vs Stateless Stateful Bean A stateful bean contains a conversational state that is retained across method calls and transactions. The create method takes arguments e.g. create(String id), create(int I, String id) There can be one or more arguments in a create method e.g An EJB that unzips 100 bytes of data An EJB that checks to see if a stock symbol is valid Stateless Bean A stateless bean does not have any state between calls to its methods The create method does not take arguments e.g create() There can be no arguments in a create method e.g An EJB that books a flight and rents a car at a travel agent’s web site.
24
24
25
25 Entity Bean
26
26
27
27 Message-Driven Bean
28
28
29
29
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.