10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Naming Conventions for Enterprise Beans<br />

Because enterprise beans are composed of multiple parts, it’s useful to follow a naming<br />

convention for your applications. Table 20–2 summarizes the conventions for the example<br />

beans in this tutorial.<br />

TABLE 20–2 Naming Conventions for Enterprise Beans<br />

Item Syntax Example<br />

Enterprise bean name nameBean AccountBean<br />

Enterprise bean class nameBean AccountBean<br />

Business interface name Account<br />

<strong>The</strong> Life Cycles of Enterprise Beans<br />

An enterprise bean goes through various stages during its lifetime, or life cycle. Each type of<br />

enterprise bean (stateful session, stateless session, or message-driven) has a different life cycle.<br />

<strong>The</strong> descriptions that follow refer to methods that are explained along with the code examples<br />

in the next two chapters. If you are new to enterprise beans, you should skip this section and run<br />

the code examples first.<br />

<strong>The</strong> Life Cycle of a Stateful Session Bean<br />

<strong>The</strong> Life Cycles of Enterprise Beans<br />

Figure 20–3 illustrates the stages that a session bean passes through during its lifetime. <strong>The</strong><br />

client initiates the life cycle by obtaining a reference to a stateful session bean. <strong>The</strong> container<br />

performs any dependency injection and then invokes the method annotated with<br />

@PostConstruct, if any. <strong>The</strong> bean is now ready to have its business methods invoked by the<br />

client.<br />

Chapter 20 • Enterprise Beans 639

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!