Life Cycle of All Beans

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

The Lifecycles of Enterprise Beans - The Java EE 6 Tutorial https://docs.oracle.com/javaee/6/tutorial/doc/giplj.

html

Document Information

Preface

Part I Introduction
1. Overview
2. Using the Tutorial Examples
The Java EE 6
Part II The Web Tier
3. Getting Started with Web Applications
Tutorial
4. JavaServer Faces Technology
5. Introduction to Facelets Home | Download | PDF | FAQ | Feedback
6. Expression Language
7. Using JavaServer Faces Technology in Web
Pages
8. Using Converters, Listeners, and Validators
9. Developing with JavaServer Faces
Technology
The Lifecycles of Enterprise Beans
10. JavaServer Faces Technology: Advanced An enterprise bean goes through various stages during its lifetime, or lifecycle.
Concepts
Each type of enterprise bean (stateful session, stateless session, singleton
11. Using Ajax with JavaServer Faces
session, or message-driven) has a different lifecycle.
Technology
12. Composite Components: Advanced Topics The descriptions that follow refer to methods that are explained along with the
and Example
code examples in the next two chapters. If you are new to enterprise beans, you
13. Creating Custom UI Components and
Other Custom Objects
should skip this section and run the code examples first.
14. Configuring JavaServer Faces Applications
15. Java Servlet Technology
The Lifecycle of a Stateful Session Bean
16. Uploading Files with Java Servlet
Figure 22-3 illustrates the stages that a session bean passes through during its
Technology lifetime. The client initiates the lifecycle by obtaining a reference to a stateful
17. Internationalizing and Localizing Web session bean. The container performs any dependency injection and then invokes
Applications the method annotated with @PostConstruct, if any. The bean is now ready to
have its business methods invoked by the client.
Part III Web Services
18. Introduction to Web Services Figure 22-3 Lifecycle of a Stateful Session Bean
19. Building Web Services with JAX-WS
20. Building RESTful Web Services with JAX-
RS
21. JAX-RS: Advanced Topics and Example

Part IV Enterprise Beans


22. Enterprise Beans
What Is an Enterprise Bean?
Benefits of Enterprise Beans
When to Use Enterprise Beans
Types of Enterprise Beans

What Is a Session Bean?


Types of Session Beans
Stateful Session Beans
Stateless Session Beans
Singleton Session Beans

When to Use Session Beans While in the ready stage, the EJB container may decide to deactivate, or
passivate, the bean by moving it from memory to secondary storage. (Typically,
What Is a Message-Driven Bean?
the EJB container uses a least-recently-used algorithm to select a bean for
What Makes Message-Driven Beans passivation.) The EJB container invokes the method annotated @PrePassivate,
Different from Session Beans?
if any, immediately before passivating it. If a client invokes a business method on
When to Use Message-Driven Beans
the bean while it is in the passive stage, the EJB container activates the bean,
Accessing Enterprise Beans calls the method annotated @PostActivate, if any, and then moves it to the
Using Enterprise Beans in Clients ready stage.
Portable JNDI Syntax
At the end of the lifecycle, the client invokes a method annotated @Remove, and
Deciding on Remote or Local Access the EJB container calls the method annotated @PreDestroy, if any. The bean’s
Local Clients instance is then ready for garbage collection.
Accessing Local Enterprise Beans
Using the No-Interface View Your code controls the invocation of only one lifecycle method: the method
Accessing Local Enterprise Beans annotated @Remove. All other methods in Figure 22-3 are invoked by the EJB
That Implement Business container. See Chapter 45, Resources and Resource Adapters for more
Downloads Ch17.pptx
Interfaces 1504860721SE-MOD19-…
information. 100% Clear

1 of 3 8/18/2023, 7:24 PM
The Lifecycles of Enterprise Beans - The Java EE 6 Tutorial https://docs.oracle.com/javaee/6/tutorial/doc/giplj.html

Remote Clients The Lifecycle of a Stateless Session Bean


Web Service Clients Because a stateless session bean is never passivated, its lifecycle has only two
Method Parameters and Access stages: nonexistent and ready for the invocation of business methods. Figure 22-4
Isolation illustrates the stages of a stateless session bean.
Granularity of Accessed Data
Figure 22-4 Lifecycle of a Stateless Session Bean
The Contents of an Enterprise Bean
Packaging Enterprise Beans in EJB
JAR Modules
Packaging Enterprise Beans in WAR
Modules

Naming Conventions for Enterprise Beans

The Lifecycles of Enterprise Beans


The Lifecycle of a Stateful Session
Bean The EJB container typically creates and maintains a pool of stateless session
The Lifecycle of a Stateless beans, beginning the stateless session bean’s lifecycle. The container performs
Session Bean any dependency injection and then invokes the method annotated
The Lifecycle of a Singleton @PostConstruct, if it exists. The bean is now ready to have its business
Session Bean methods invoked by a client.
The Lifecycle of a Message-Driven
Bean At the end of the lifecycle, the EJB container calls the method annotated
@PreDestroy, if it exists. The bean’s instance is then ready for garbage
Further Information about Enterprise collection.
Beans

23. Getting Started with Enterprise Beans The Lifecycle of a Singleton Session Bean
24. Running the Enterprise Bean Examples Like a stateless session bean, a singleton session bean is never passivated and
25. A Message-Driven Bean Example has only two stages, nonexistent and ready for the invocation of business
26. Using the Embedded Enterprise Bean methods, as shown in Figure 22-5.
Container
27. Using Asynchronous Method Invocation in Figure 22-5 Lifecycle of a Singleton Session Bean
Session Beans

Part V Contexts and Dependency Injection for the


Java EE Platform
28. Introduction to Contexts and Dependency
Injection for the Java EE Platform
29. Running the Basic Contexts and
Dependency Injection Examples
30. Contexts and Dependency Injection for the
Java EE Platform: Advanced Topics
The EJB container initiates the singleton session bean lifecycle by creating the
31. Running the Advanced Contexts and
Dependency Injection Examples
singleton instance. This occurs upon application deployment if the singleton is
annotated with the @Startup annotation The container performs any
Part VI Persistence dependency injection and then invokes the method annotated @PostConstruct,
32. Introduction to the Java Persistence API if it exists. The singleton session bean is now ready to have its business methods
33. Running the Persistence Examples invoked by the client.
34. The Java Persistence Query Language
35. Using the Criteria API to Create Queries
At the end of the lifecycle, the EJB container calls the method annotated
@PreDestroy, if it exists. The singleton session bean is now ready for garbage
36. Creating and Using String-Based Criteria
Queries collection.
37. Controlling Concurrent Access to Entity
Data with Locking The Lifecycle of a Message-Driven Bean
38. Using a Second-Level Cache with Java Figure 22-6 illustrates the stages in the lifecycle of a message-driven bean.
Persistence API Applications
Figure 22-6 Lifecycle of a Message-Driven Bean
Part VII Security
39. Introduction to Security in the Java EE
Platform
40. Getting Started Securing Web Applications
41. Getting Started Securing Enterprise
Applications
42. Java EE Security: Advanced Topics

Part VIII Java EE Supporting Technologies


43. Introduction to Java EE Supporting
Technologies
44. Transactions
45. Resources and Resource Adapters
46. The Resource
Downloads Adapter Example
Ch17.pptx 1504860721SE-MOD19-… 100% Clear

2 of 3 8/18/2023, 7:24 PM
The Lifecycles of Enterprise Beans - The Java EE 6 Tutorial https://docs.oracle.com/javaee/6/tutorial/doc/giplj.html

47. Java Message Service Concepts The EJB container usually creates a pool of message-driven bean instances. For
48. Java Message Service Examples each instance, the EJB container performs these tasks.
49. Bean Validation: Advanced Topics
50. Using Java EE Interceptors
1. If the message-driven bean uses dependency injection, the container injects
these references before instantiating the instance.
Part IX Case Studies
51. Duke's Bookstore Case Study Example 2. The container calls the method annotated @PostConstruct, if any.
52. Duke's Tutoring Case Study Example
Like a stateless session bean, a message-driven bean is never passivated and
53. Duke's Forest Case Study Example
has only two states: nonexistent and ready to receive messages.
Index
At the end of the lifecycle, the container calls the method annotated
@PreDestroy, if any. The bean’s instance is then ready for garbage collection.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices

Downloads Ch17.pptx 1504860721SE-MOD19-… 100% Clear

3 of 3 8/18/2023, 7:24 PM

You might also like