IBM WebSphere Developer Technical Journal: Using the new EJB Visual Editor in Rational Application Developer for WebSphere software

The EJB™ Visual Editor development tool in IBM's Rational® Application Developer for WebSphere® software Version 6.0 has matured considerably from its predecessor in WebSphere Studio Application Developer Version 5.1. This article highlights important new features to prepare you for using this enhanced and more intuitive version of this popular tool.

Manish Bhargava (manishb@us.ibm.com), Software Engineer, IBM, Aurora Platform/Visualizer Core Services

Manish Bhargava is a software engineer at IBM Research Triangle Park Lab. He works on the Aurora Platform/Visualizer Core Services team. His expertise includes UML Visual Modeling, and he has a MS degree in Engineering from OSU.



01 December 2004

Introduction

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
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
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
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

ElementUML elementStereotypeIcons
EJB JARArtifactEJB JARUML icon for EJB JAR
CMP 1.x entity beanComponentEntity beanUML icon for CMP 1.x entity bean
CMP 2.x entity beanComponentEntity beanUML icon for CMP 2.x entity bean
BMP entity beanComponentEntity beanUML icon for BMP entity bean
Message driven beanComponentMessage driven beanUML icon for Message driven bean
Session beanComponentSession beanUML icon for Session bean
Session bean facadeComponentSession bean facadeUML icon for Session bean facade
Bean classClassBean classUML icon for Bean class
Remote interfaceInterfaceRemote interfaceUML icon for Remote interface
Local interfaceInterfaceLocal interfaceUML icon for Local interface
Home interfaceInterfaceHome interfaceUML icon for Home interface
Local home interfaceInterfaceLocal home interfaceUML icon for Local home interface
Primary key classClassEJB primary key classUML icon for Primary key class
Primary key fieldAttributeEJB primary key fieldUML icon for Primary key field
CMP fieldAttributeCMP fieldUML icon for CMP field
Local methodOperationLocalUML icon for Local method
Remote methodOperationRemoteUML icon for Remote method
Local home methodOperationLocal homeUML icon for Local home method
Home methodOperationHomeUML icon for Home method
WebSphere Application Server extension for Inheritance relationshipInheritanceWebSphere Application Server inheritanceN/A
CMP relationshipsAssociationCMP relationshipN/A
Relationship between an EJB and its home, remote (local-home, local) interfacesImplementationEJB implementationN/A
Relationship between EJB JAR and its contained EJBsManifestationEJB manifestationN/A
Relationship between EJB and its bean classRealizationEJB realizationN/A
Local reference between EJBsUsageLocal referenceN/A
Remote reference between EJBsUsageRemote referenceN/A
Facade relationship between CMP and Session facade beanUsageFacadeN/A
Mapping between EJB and ratabaseUsagemapN/A
Method permissionClassMethod permissionUML icon for Method permission
Exclude listClassExclude listUML icon for Exclude list
Security role nameActorSecurity role nameUML icon for Security role name
Security roleUsageSecurity roleN/A
Security role reference nameActorRole name referenceUML icon for Security role reference name
Security role referenceUsageSecurity role referenceN/A
Relationship between Security role reference name and Security roleUsageRole linkN/A
Relationship between Enterprise bean and Method permissionUsagePermissionN/A
Relationship between Enterprise bean and Exclude listUsageExcludeN/A
Method elementOperationMethod elementUML icon for 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
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
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
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
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:

  1. Select an existing CMP attribute.
  2. Right click on it and select Edit => Edit. The CMP Attribute dialog (Figure 8) will display.
    Figure 8. Edit CMP attribute using wizard
    Figure 8. Edit CMP attribute using wizard
  3. 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
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
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:

  1. Create Relationship from Source to Target with Outgoing Connector Handle
  2. Create Relationship from Target to Source with Incoming Connector Handle
  3. Create Relationship from Source to Unspecified Target with Outgoing Connector Handle
  4. Create Relationship from Target to Unspecified Source with Incoming Connector Handle
  5. Create Relationship from Source to Unspecified Target with a Palette Connector Tool
  6. Show Related Elements with Outgoing Connector Handle
  7. 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
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:

  1. 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
    Figure 12. Bean selection dialog
  2. 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
    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
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
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
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
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.

Visualization section

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
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
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
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 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
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:

  1. Right-click on an Enterprise JavaBean shape on the class Diagram and select Add EJB => Method Permission.
  2. Select the appropriate security roles, as shown in Figure 23, then Next.
    Figure 23. Add Method Permission
    Figure 23. Add Method Permission
  3. 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 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
Figure 25. Visual Matrix of Method Permission with Security Roles

Conclusion

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!

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=87365
ArticleTitle=IBM WebSphere Developer Technical Journal: Using the new EJB Visual Editor in Rational Application Developer for WebSphere software
publish-date=12012004