Java Reference
In-Depth Information
1.1.1. EJB as a component model
In this topic, EJBs refer to server-side components that you can use to build the business
component layer of your application. Some developers associate the term component with
developing complex and heavyweight CORBA or Microsoft COM+ code. In the brave new
world of EJB 3, a component is what it ought to be—nothing more than a POJO with some
special powers. More importantly, these powers stay invisible until they're needed and
don't distract from the real purpose of the component. You'll see this firsthand throughout
this topic, especially starting in chapter 2 .
To use EJB services, your component must be declared to be a recognized EJB component
type. EJB recognizes two specific types of components: session beans and message-driven
beans. Session beans are further subdivided into stateless session beans, stateful session
beans, and singletons. Each component type has a specialized purpose, scope, state, life-
cycle, and usage pattern in the business logic tier. We'll discuss these component types
throughout the rest of the topic, particularly in part 2 . For data CRUD (create, read, update,
delete) operations in the persistence tier, we'll talk about JPA entities and their relationship
with EJBs in detail in part 3 . As of EJB 3.1, all EJBs are managed beans. Managed beans
are basically any generic Java object in a Java EE environment. Contexts and Dependency
Injection (CDI) allows you to use dependency injection with all managed beans, including
EJBs. We'll explore CDI and managed beans further in part 3 .
1.1.2. EJB component services
As we mentioned, the canned services are the most valuable part of EJB. Some of the ser-
vices are automatically attached to recognize components because they make a lot of sense
for business logic-tier components. These services include dependency injection, transac-
tions, thread safety, and pooling. To use most services, you must declare you want them us-
ing annotations/XML or by accessing programmatic EJB APIs. Examples of such services
include security, scheduling, asynchronous processing, remoting, and web services. Most
of this topic will be spent explaining how you can exploit EJB services. We can't explain
the details of each service in this chapter, but we'll briefly list the major ones in table 1.1
and explain what they mean to you.
Search WWH ::




Custom Search