1、外文原文 In Chapters 35, we scratched the surface of EJB with an introduction to session bean programming. Now that youve seen the bare-bones examples, lets put a bit more meat on our beans. In this chapter, youll see the following: _ How to query the container with EJB contexts _ How to use environment
2、 properties to customize your beans, and access those environment properties at runtime_ How to use the EJB security model _ How to use EJB object handles _How to call beans from other beans _ A non-trivial example illustrating each of these concepts, using both stateless and stateful session beans
3、Lets begin with a look at EJB contexts. EJB Contexts: Your Gateway to the Container As youll see once you begin your EJB development, non-trivial enterprise beans need to determine information about their current status at runtime. This can include the following: _ Information about the beans home o
4、bject or EJB object. _ Information about any transaction the bean is currently involved in. For example, if the current transaction is going to fail, the bean can skip unnecessary computation steps. Adding Functionality to Your Beans134 M A S T E R I N G E N T E R P R I S E J A V A B E A N S Go back
5、 to the first page for a quick link to buy this book online! _ Security information for client authorization. A bean can query its environment to determine if a client has the required security access level to perform a desired operation. _ Environment properties that the bean was deployed with. The
6、 container houses all of this information in one object, called an EJB context object. An EJB context object is your gateway to the container. EJB contexts are physical parts containers, and can be accessed from within your beans. Thus, a context represents a way for beans to perform callbacks to the container. These callbacks help beans both ascertain their current status and modify their current status. The motivation behind a context is to encapsulate the beans domain in one