Home

 

Creating, editing, and viewing EJBs in UML class diagrams

Class diagrams also allow developers to visually represent and develop Enterprise JavaBeans (EJBs) in EJB applications. Developers can create class diagrams and populate them with existing EJBs to allow the business tier architecture to be documented and understood. Class diagrams can also be used to develop new EJBs, including EJB relationships such as inheritance and association, and to configure the security aspects of bean access such as security roles and method permissions.

Rational Application Developer v7.5 now supports EJB 3.0, and class diagrams can be drawn showing EJB 3.0 beans. The support for drawing class diagrams showing EJB 2.1 and earlier beans is still supported, but we do not discuss it here.

To use the EJB class diagram capabilities, a class diagram must be created within the context of an EJB project. The palette can then be used to create and edit as before, but now with the addition of EJBs. Alternatively, you can create the EJBs in the Enterprise Explorer and place them on a diagram later.

Figure | -8 shows the graphical representation of an EJB 3.0 session bean.

Figure 7-8 Visualization of an EJB 3.0 session bean

To visualize an EJB, simply drag it from the Enterprise Explorer to the class diagram editor. EJBs are rendered as a class that is stereotyped as <<Java Class>> with appropriate stereotype for the type of bean. In this case, the other stereotype is <<Stateless>> because we have an EJB 3.0 stateless session bean. An EJB exposes its functionality to clients through either a remote interface, a local interface or less commonly both. The session bean shown in Figure | -8 provides only a local interface. The interface is shown on the class diagram as a class stereotyped as <<Java Interface>> and <<Local>>.

EJBs in an EJB 3.0 project usually employ Java Persistence API (JPA) entities to provide data persistence rather than EJB 2.1 entity beans. Figure | -9 shows an EJB 3.0 session bean and a JPA entity. Note that the JPA entity is shown in the diagram as a class with appropriate stereotypes.

(

Figure 7-9 Class diagram showing an EJB 3.0 session bean and a JPA entity

ibm.com/redbooks