Appendix B.  State and Sequence Diagrams

This appendix contains state and sequence diagrams for all the bean types discussed in this book: container-managed and bean-managed entity beans, stateless and stateful session beans, and message-driven beans. Although standard Unified Modeling Language (UML) is used in these diagrams, some extensions were required to model EJB runtime characteristics. In the state diagrams, for example, callback methods and class instantiation operations are shown as part of the transition event.

In the sequence diagrams, container-provided classes such as the container itself, the EJB object, and the EJB home are shown as separate classes but are also boxed together. Messages sent from classes in the container system box are considered to be sent from the container system as a whole, not necessarily from the specific container-provided class. This generalization is necessary because the container’s interaction with the bean is characterized by these classes but differs from one vendor’s implementation to the next. The exact source of the message is immaterial, as long as you realize that the container system sent it.

Entity Beans

Life Cycle State Diagram of the Entity Bean

Life-cycle state diagram of the entity bean

Figure B-1. Life-cycle state diagram of the entity bean

Sequence Diagrams for Container-Managed Persistence

Creation and removal in container-managed persistence

Figure B-2. Creation and removal in container-managed persistence

Activation and synchronization in container-managed persistence

Figure B-3. Activation and synchronization in container-managed persistence

Sequence Diagrams for Bean-Managed Persistence

Creation and removal in bean-managed persistence

Figure B-4. Creation and removal in bean-managed persistence

Activation and synchronization in bean-managed persistence

Figure B-5. Activation and synchronization in bean-managed persistence

Table B-1 summarizes the operations an entity bean is allowed to perform in various stages of its life cycle. The allowed operations are the same for EJB 2.0 and 1.1, except for the EntityContext methods getEJBLocalHome() and getEJBLocalObject() and the operations allowed for ejbHome() methods, which are specific to EJB 2.0.

Table B-1. Allowed operations for entity beans

Method

Allowed operations

setEntityContext()

unsetEntityContext()

EntityContext methods:

getEJBHome()

getEJBLocalHome()

JNDI ENC contexts:

Properties: java:comp/env

ejbCreate()

ejbFind()

ejbHome()

EntityContext methods:

getEJBHome()

getEJBLocalHome()

getCallerPrincipal()

isCallerInRole()

getRollbackOnly()

setRollbackOnly()

JNDI ENC contexts:

Properties: java:comp/env

Resource managers: java:comp/env/jdbc

EJB references: java:comp/env/ejb

ejbPostCreate()

ejbLoad()

ejbStore()

ejbRemove()

Business methods

EntityContext methods:

getEJBHome()

getEJBLocalHome()

getCallerPrincipal()

isCallerInRole() getRollbackOnly()

setRollbackOnly()

getEJBObject()

getEJBLocalObject()

getPrimaryKey()

JNDI ENC contexts:

Properties: java:comp/env

Resource managers: java:comp/env/jdbc

EJB references: java:comp/env/ejb

ejbActivate()

ejbPassivate()

EntityContext methods:

getEJBHome()

getEJBLocalHome()

getEJBObject()

getEJBLocalObject()

getPrimaryKey()

JNDI ENC contexts:

Properties: java:comp/env

Note that entity beans can never access the EJBContext.getUserTransaction() method, because entity beans are not allowed to manage their own transactions. Only session beans can access this method.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset