Java Reference
In-Depth Information
5.1.1. Basics of EJB context
As you can see in the following listing, the EJBContext interface allows direct program-
matic access to services such as transaction, security, and timers, which are typically speci-
fied through configuration and managed completely by the container.
Listing 5.1. javax.ejb.EJBContext interface
Let's look briefly at what each of these methods does ( table 5.1 ) . We'll save a detailed ana-
lysis for later, when we discuss the services that each of the methods is related to. For now,
you should note the array of services offered through the EJB context, as well as the meth-
od patterns.
Table 5.1. You can use javax.ejb.EJBContext to access runtime services
Methods
Description
These methods are useful when using bean-managed security. We discuss these
two methods further in chapter 6 when we discuss programmatic security.
getCallerPrincipal isCallerInRole
These methods are used to obtain the bean's “remote home” and “local home”
interfaces respectively. Both are optional for EJB 3 containers and are hardly
used beyond legacy EJB 2.1 beans. We won't discuss these methods beyond
this basic introduction. They're mainly provided for backward compatibility.
getEJBHome getEJBLocalHome
These methods are used for EJB transaction management in the case of
container-managed transactions. We discuss container-managed transactions in
greater detail in chapter 6 .
getRollbackOnly setRollbackOnly
 
Search WWH ::




Custom Search