The EJB visual editing tools included in Rational Application Developer for WebSphere software, Version 6.0, (hereafter referred to as Application Developer) enable users to graphically visualize and edit EJB code and data objects using industry-standard UML notation. This helps developers -- even those unfamiliar with UML -- to better understand and manage complex code. The EJB Visual Editor provides graphical editors, such as UML class diagrams, for adding EJB components directly into an EJB project that automatically generates the corresponding code. Subsequestly, you can edit the code either directly, or from within the UML class diagrams. Being dynamic in nature, the EJB Visual Editor is always synchronized with the underlying code.
The class diagram editor can be used to visualize data objects, create new EJB components, create and edit relationships betwen beans, or explore and discover existing relationships involving beans, classes, and interfaces. It is a very simple approach for creating complex Enterprise JavaBeans™, and is highly recommended for developers new to EJB concepts. Seasoned EJB developers can still benefit from the higher level of abstraction and the rich set of features that visual editing offers. The diagram editors can help you to identify and highlight relationships within code and data objects that are not easily recognizable with other editors, and can help you better communicate with software architects and other members of the develpment team.
Figure 1 shows a typical class diagram with multiple beans that have relationships between them. This diagram is derived from the Auction example included in the Samples Gallery of Application Developer.
Figure 1. Typical class diagram showing beans and relationships
The first version of the EJB Visual Editor was introduced in WebSphere Studio Application Developer Version 5.1.1. The latest release of EJB Visual Editor in Rational Application Developer Version 6.0 has many new features, in addition to the already robust existing functionality. This article will cover:
- Conceptual changes made in the mapping of EJB elements with UML elements.
- Walkthrough of some new features that will be instrumental in developing complex Enterprise JavaBeans.
- Tighter integration with J2EE™ tools and the Deployment Descriptor editor.
- Security management visualization.
For illustration purposes, this article uses the widely-used Library example in Application Developer throughout.
Enterprise JavaBeans to UML 2.0 mapping
In the first release of the EJB Visual Editor, Enterprise JavaBeans were mapped to a UML Class. The client view of the EJB component was shown as a list of local and remote methods within the Operation compartment, and the persistant attributes were shown within the Attribute compartment. Figure 2 shows a visual representation of a typical bean as visualized in WebSphere Studio Application Developer Version 5.1.
Figure 2. Visual representation of Book in WebSphere Studio Application Developer Version 5.1
Feedback we received from customers suggested ordering these methods according to the interfaces to which they belong. This made sense, since showing the methods (local and remote) from the interface's prespective tells what interface the method belongs to.
In the new release of EJB Visual Editor, Enterprise JavaBeans are mapped to UML components, a subtype of UML class. A component defines its behavior in terms of provided and required interfaces:
- Provided interfaces for an Enterprise JavaBean are those which it exposes to its clients, like Home interface and Remote interface.
- Required interfaces are those which the Enterprise JavaBean needs to be able to offer its full set of provided functionalities.
Simple! The Bean class realizes the behavior of the Enterprise JavaBean. Figure 3 shows an example of a typical visual representation of an Enterprise JavaBean in Rational Application Developer Version 6.0.
Figure 3. Visual representation of Book in Rational Application Developer Version 6.0
Notice how we have a Provided Interface compartment and an Attribute compartment visible by default. If the Enterprise JavaBean has both the local and remote clients, the Provided Interface compartment will show four interfaces with collapsable methods listed beneath each interface. If you want to view the Required Interface compartment, or any other compartments, right click on the bean shape, select Filters => Show/Hide Compartment and select the desired compartment to show.
In class diagrams, UML notation is used to represent Enterprise JavaBeans-related elements. EJB profiles are defined to extend standard stereotypes. It is basically an extension mechanism that broadens the vocabulary of the UML and provides more specific meaning. Table 1 shows how EJB elements are mapped to UML elements, along with the stereotypes and icons used in UML class diagrams.
Table 1. EJB to UML mapping
|EJB JAR||Artifact||EJB JAR|
|CMP 1.x entity bean||Component||Entity bean|
|CMP 2.x entity bean||Component||Entity bean|
|BMP entity bean||Component||Entity bean|
|Message driven bean||Component||Message driven bean|
|Session bean||Component||Session bean|
|Session bean facade||Component||Session bean facade|
|Bean class||Class||Bean class|
|Remote interface||Interface||Remote interface|
|Local interface||Interface||Local interface|
|Home interface||Interface||Home interface|
|Local home interface||Interface||Local home interface|
|Primary key class||Class||EJB primary key class|
|Primary key field||Attribute||EJB primary key field|
|CMP field||Attribute||CMP field|
|Local home method||Operation||Local home|
|WebSphere Application Server extension for Inheritance relationship||Inheritance||WebSphere Application Server inheritance||N/A|
|CMP relationships||Association||CMP relationship||N/A|
|Relationship between an EJB and its home, remote (local-home, local) interfaces||Implementation||EJB implementation||N/A|
|Relationship between EJB JAR and its contained EJBs||Manifestation||EJB manifestation||N/A|
|Relationship between EJB and its bean class||Realization||EJB realization||N/A|
|Local reference between EJBs||Usage||Local reference||N/A|
|Remote reference between EJBs||Usage||Remote reference||N/A|
|Facade relationship between CMP and Session facade bean||Usage||Facade||N/A|
|Mapping between EJB and ratabase||Usage||map||N/A|
|Method permission||Class||Method permission|
|Exclude list||Class||Exclude list|
|Security role name||Actor||Security role name|
|Security role||Usage||Security role||N/A|
|Security role reference name||Actor||Role name reference|
|Security role reference||Usage||Security role reference||N/A|
|Relationship between Security role reference name and Security role||Usage||Role link||N/A|
|Relationship between Enterprise bean and Method permission||Usage||Permission||N/A|
|Relationship between Enterprise bean and Exclude list||Usage||Exclude||N/A|
|Method element||Operation||Method element|
Usability improvements and new features
One of the main drivers in this release of EJB Visual Editior has been the user experience. Most of the enhancements described below originated from customer feedback.
EJB palette improvements
The "cluttered" EJB palette on a Class Diagram in WebSphere Studio Application Developer 5.1 has been modified in the new release with the use of stackable palette items, as shown in Figure 4.
Figure 4. New look of the EJB palette
The most widely used CMP relationship types are stacked into one palette entry, and can be accessed by selecting the CMP relationship palette entry. Depending on the project version, CMP 1.x and 2.x bean types are also stacked as shown above.
Show Related Elements and Show/Hide Relationships
Given a selection, this feature searches for related elements based on the criteria selected by the user. The new look for the Show Related Elements and Show/Hide Relationships is shown in Figures 5 and 6.
Figure 5. New look of Show Related Elements dialog
The options available are shown in platform-specific terminology, as well as UML terminology (in brackets). Some popular presets that have been introduced as well. Another new feature enables the creation of custom queries that you can save for later use.
Figure 6. New look of Show/Hide Relationships dialog
Relationships are also shown in terms of platform-specific terminology and UML terminology (in brackets).
Direct editing of multiplicity in CMP relationship
In WebSphere Studio Application Developer, the types of 1.x CMP relationships between two 1.x CMP beans that could be created using the Deployment Descriptor editor were more than what could be visually created from the Class Diagram. The way around this was to edit the multipliclity of an existing 1.x CMP relationship to get to the desired multiplicity, or use the Deployment Descriptor editor to create them. For example, the user could not create a directed 1..1 : 0..* relationship which could be created from the Deployment Descriptor editor. The workaround was to first create some arbitarary 1.x CMP relationship, and then directly edit the multiplicity type to the desired multiplicity value. The possibility of making an error while typing the multiplicity in the correct format was huge. This has been addressed in the new release.
Figure 7 shows a case where the user wants to create a 1..1 : 0..* directed relationship between a Customer and a BankAccount CMP beans. The user could first create a 0..1 : 0..* directed relationship and then directly edit the multiplicity by choosing one of the available options in the drop down combo box.
Figure 7. Direct editing of multiplicity
Editing existing elements
In addition to many inline direct editing features, EJB Visual Editor exposes editing using wizards similar to those in the Deployment Descriptor editor. For example, one can edit an existing CMP Attribute as follows:
- Select an existing CMP attribute.
- Right click on it and select Edit => Edit. The CMP Attribute dialog (Figure 8) will display.
Figure 8. Edit CMP attribute using wizard
- Modify values as neceesary, then select OK. The Class diagram will reflect the changes.
With this feature, the user can edit visual elements such as CMP Relationships, Method Permission, Exclude List, and Role Link.
Cross Model Reference decoration
Another improvement from the previous version of the EJB Visual Editor is the introduction of Cross Model Reference decorations in UML shapes. For example, if an Enterprise JavaBean belonging to an EJB project is being visualized on a Class diagram that is contained in a different EJB project, there will be a decoration on the top left of the bean component shape dipicting that it belongs to a separate project. Figure 9 shows such a decoration.
Figure 9. Cross Model Reference decoration
Connector handler and action bars
Another great feature is in-coming and out-going connector handlers that show up on the sides of the bean shape when you hover over it, or when you select the element and press the space bar. This usability feature provides an alternate user gesture to expand related shapes and create new relationships. When hovering over a shape, connector handles appear around the shape. Performing a certain user gesture on a particular connector handle will enable the user to expand a certain type of relationships to/from this shape, or create a relationship to a different shape. This feature can really increase productivity.
Figure 10. Action bars and Connector handler
The connectors appear at the same time that a tool tip would appear on the shape. When you hover over one of the connector handles, a tool tip appears containing a brief description of the user gestures possible from this connector handle. The connector handles disappear after a certain amount of time has passed.
One handle is used for gestures involving out-going connectors, and the other handle is used for gestures involving in-coming connectors. If the shape does not support any of the use cases for a particular handle (out-going or in-coming), then that handle does not appear.
Available options with connector handles:
- Create Relationship from Source to Target with Outgoing Connector Handle
- Create Relationship from Target to Source with Incoming Connector Handle
- Create Relationship from Source to Unspecified Target with Outgoing Connector Handle
- Create Relationship from Target to Unspecified Source with Incoming Connector Handle
- Create Relationship from Source to Unspecified Target with a Palette Connector Tool
- Show Related Elements with Outgoing Connector Handle
- Show Related Elements with Incoming Connector Handle
We will describe only option 3, but the others are fairly similar and easy to pick up. Depending on the selection (Source in this case), the number of options available changes on the menu that pops up when the user drops the cursor on the Diagram surface. Figure 11 shows a case when we have selected a 2.0 CMP bean, dragged the out-going connector handler, and dropped it on the digram surface.
Figure 11. Creating Relationship from Source to Unspecified Target with Outgoing Connector Handle
Let's create an EJB reference (local) between Book bean and the existing Author bean:
- When you select the Existing Element option, a bean selection dialog will display (Figure 12). (At this time, you could have also created the reference to a new Enterprise JavaBean by selecting other options. This would have resulted in opening an Enterprise JavaBean creation wizard instead of a Bean Selection Dialog.)
Figure 12. Bean selection dialog
- When you select OK, appropriate changes will be made and the Author bean, along with the EJB local reference connector, will be shown on the diagram surface (Figure 13).
Figure 13. EJB Local reference
The other thing that you see is what are called Action Bars, which are just a quick alternative to the available context menus, and is very similar the tool bar concept.
Opening source editors from Enterprise JavaBean shape
This feature enables you to open various editors from the Bean shape on a class diagram (Figure 14).
Figure 14. Opening source editors
Ability to add and remove client views from the bean shape
You can now add or remove client views (Local or Remote) after the bean has been created and visualized on a class diagram. To add a client view, right click on the bean shape and select Edit => Add Client View. The Add Client Dialog will display (Figure 15).
Figure 15. Add Client View
To remove a client view, right click on an interface, and select Edit => Remove Client View. The changes will be reflected on the bean shape.
Figure 16. Remove Client View
Advanced view properties
The Advanced tab in the Properties view now shows properties of the selection on the class diagram in read-only format. These properties are the same ones as you will see in the Deployment Descriptor editor. Figure 17 shows typical properties when a bean shape is selected on the class diagram.
Figure 17. Advanced Properties
Integration with J2EE tools
Much work has been done to acheive tighter integration between J2EE tools and EJB Visual Editor tools.
A new Visualization section is now available in the Deployment Descriptor editor's Overview tab, enabling easy navigation to (and creation of) class diagrams.
Figure 18. Visualization section in Deployment Descriptor editor
UML Visualization page in J2EE wizards
To make the UML Visual Editor more visible, a few wizards have been extended with a new Class Diagram Selection page at the end (Figure 19), enabling you to select a Class Diagram where the newly created Enterprise JavaBean or database Table will be visualized. You can invoke the Class Diagram creation wizard from this page as well. A global preference under Modeling => EJB controls this behavior.
Figure 19. Class Diagram selection page
Additionally, many new action items have been exposed on the Enterprise JavaBean shape, including creating Session Bean Facades, generating EJB-RDB maps, and Run/Debug/Profile on Server. Creating Session Bean Facades and visualizing them on a class diagram can now be done in a single step. Figure 20 shows the Session Bean Facade in relation to its CMP 2.x bean.
Figure 20. CMP 2.x with it Session Bean Facade
Security management visualization
This release introduces Security Management Visualization. Security Roles, Security Role Reference, Security Identity, Method Permissions, and Exclude lists can now be created visually and manipulated using the EJB Visual Editor.
An application assembler typically defines one or more security roles for an application composed of one or more enterprise beans. Defining the security roles in the Deployment Descriptor is optional for the application assembler, meaning that the Application Assembler would choose not to pass any security deployment related instructions to the deployer in the Deployment Descriptor. If the application assembler defines the security-role elements in the Deployment Descriptor, he is also responsible for linking all the Security Role References declared in the security-role-ref elements to the security roles defined in the security-role elements. The Bean Provider is responsible for declaring all the security role names used in the enterprise bean code. Declaring the Security Roles References in the code allows the application assembler to link the names of the security roles used in the code to the security roles defined for an assembled application through the security-role elements. The EJB Visual Editor now enables the application assembler to visually create security roles and link the Security Role Reference to the security roles. It also enables the Bean Provider to visually create Security Role References, as well. Figure 21 shows four security roles defined for an application that consists of multiple Enterprise JavaBeans.
Figure 21. Security roles
Figure 22 shows the Security Role Reference being linked to the appropriate security role. This can either be done while creating the security role reference (if the Bean Provider is the same as the application assembler) or can be perfomed later by the application assembler, once it has the knowledge of the Security Role Reference.
Figure 22. Security Role Reference linked to Security Role
The application assembler can specify in the Deployment Descriptor whether the caller's Security Identity or a Run-As Security Identity should be used for the execution of the beans methods. This can now be done visually using the EJB Visual Editor.
Another aspect of Security Management that can now be visually created and manipulated is Method Permission. An application assembler that defines security roles for the Enterprise JavaBeans can also specify the methods of the Home and Component interfaces that each security role is allowed to invoke. Method permissions are defined in the Deployment Descriptor as a binary relation from the set of security roles to the set of methods of the Home, Component interface of the Session, and Entity beans, including all their super interfaces (including the methods of EJBHome and EJBObject interfaces, and/or EJBLocalHome and EJBLocalObject interface). EJB Visual Editor now enables visual creation of new Method Permissions and manipulation of existing Method Permissions. To create a new Method Permission:
- Right-click on an Enterprise JavaBean shape on the class Diagram and select Add EJB => Method Permission.
- Select the appropriate security roles, as shown in Figure 23, then Next.
Figure 23. Add Method Permission
- Select methods from the Home and Component interfaces that each selected security role is allowed to invoke (Figure 24), then Finish.
Figure 24. Method Elements
Figure 25 shows a visual matrix of Method Permissions on the bean Book.
Figure 25. Visual Matrix of Method Permission with Security Roles
This article highlighted new features of the EJB Visual Editor, included in IBM's Rational Application Developer for WebSphere software Version 6.0, showing how EJB Visual Editor provides a more productive and intuitive way for bean providers and application assemblers to develop EJB applications. EJB Visual Editor not only hides the complexities of the EJB specification, but can actually make development an enjoyble experience!
- EJB development made easy using the UML Visualizer in WebSphere Studio shows how to create a simple EJB Application using the UML Visual Editor in WebSphere Studio V5.1.2.
- To learn more, visit the developerWorks WebSphere Studio zone. You'll find technical documentation, how-to articles, education, downloads, product information, technical support resources, and more.
- Browse for books on these and other technical topics.
- WebSphere forums. Product-specific forums where you can ask questions and share your opinions with other WebSphere users.
- developerWorks blogs. Ongoing, free-form columns by software experts, with space for you to add your comments.
Dig deeper into WebSphere on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Keep up with the best and latest technical info to help you tackle your development challenges.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.