Exercise 1.2: Preparing the workspace

Before you begin, you might want to review the concepts in Exercise 1.1: Introduction to the technologies.

Exercise 1.2 gives an overview of the workbench layout and EJB-related projects. In this exercise, you will do these tasks:

Workbench layout

All work done in the workbench must be associated with a project. Projects provide an organized view of the work files and directories, optimized with functions based on the type of project.

The layout of the workbench consists of perspectives and views. Views are panes in the workbench providing different ways of looking at the data. For instance, projects are displayed in a Project Explorer view. The structure of a class or XML file would be displayed in an Outline view. The workbench has many different views, specialized for each type of data. In a given area of the workbench, views may be stacked, so that they appear as tabbed pages for easy access.

A perspective manages the overall layout of the workbench, and comprises a set of views and an editor area. Perspectives come with a set of predefined or default views, laid out in a specific arrangement. However, the perspectives are highly customizable. Different views can be added or removed from a given perspective. The location of a view can be changed.

The J2EE perspective is optimized for EJB development.

J2EE perspective

The information center provides more information on these topics:

Setting up the projects

In the workbench, all files must reside in a project, so before you create the UML class diagram, you need to create a project to put it in. Since you are creating an EJB, you will create an EJB project. When you create an EJB project, other supporting projects are automatically created.

Creating an EJB project

Creation of an EJB project requires that a Target server be defined. Make sure that you included the WebSphere Application Server 6.0 Integrated Test Environment during installation of this product.

  1. From the File menu, select New > Other. The New wizard opens.
  2. Select the Show All Wizards check box.
  3. Expand EJB.
  4. Select EJB Project.
  5. Click Next.
  6. If the Confirm Enablement dialog box opens, click OK.
  7. When the New EJB Project wizard opens, give the project a name (UML EJB tutorial in this example)
  8. Leave the project location as it is.
  9. If the Advanced options are displayed, there is no Target server defined. If this occurs, you need to do one of these steps:
  10. Click Finish.
  11. If the Confirm Perspective Switch dialog box opens, answer Yes. This switches you to the J2EE perspective.

The EJB project is created along with several supporting projects, as shown in the Project Explorer view of the J2EE perspective:

EJB related projects

The Enterprise Application (EAR) project

In the Project Explorer view, expand Enterprise Applications and explore the UML EJB tutorialEAR project. Within the EAR directory you will see

expanded view of EAR project

If you double-click the deployment descriptor (either the link or the actual file), the application.xml file opens in the Application Deployment Descriptor editor. Contents of the application deployment descriptor are shown on several different pages and can be navigated by clicking the tabs at the bottom of the editor area. You can double-click the title bar (title bar) of the Application Deployment Descriptor editor to expand it to use the entire workbench frame. Double-click the title bar again when you want to restore the window to its normal size.

Notice on the Overview page, under the General Information heading, the Display name is UML EJB tutorialEAR, which is the same as the EAR project name. This name is derived from your EJB project name. Display name is the value seen when installing and configuring an EAR file in the WebSphere Application Server Administrative console. Of course, you can choose your own names when creating the EJB project, or rename them after creation.

Also note, under the Modules heading, EJB UML_EJB_tutorial.jar. On the Module tab, in addition to this EJB JAR file, you will see the Project Utility JAR file, UML_EJB_tutorialClient.jar listed.

Application Deployment Descriptor editor

Close the deployment descriptor editor by clicking the X on the title bar.

The EJB project

In the Project Explorer view, collapse all open projects (Collapse All icon). Expand EJB Projects, then UML EJB tutorial. You will find these resources:

expanded view of EJB project

If you double-click the deployment descriptor (either the link or the actual file), the ejb-jar.xml file opens in the EJB Deployment Descriptor editor. Contents of the EJB deployment descriptor are shown on several different pages and can be navigated by clicking the tabs at the bottom of the editor area.

Notice on the Overview page, under the General Information heading, the Display name is UML EJB tutorial. This is the same as your EJB project name. Under the Usage heading, you will see the UML EJB tutorialEAR, indicating the EAR file that uses this JAR file. Under the EJB Client Jar heading, you will see the UML_EJB_tutorialClient.jar listed.

EJB Deployment Descriptor editor

Click on the Source tab of the deployment descriptor. This view shows the actual XML data that is displayed on the other pages of the deployment descriptor editor. When changes are made to the enterprise application, via the deployment descriptor editor or via the UML class diagram, the changes are made to the XML data, then shown in the deployment descriptor editor and the class diagram.

source page of EJB deployment descriptor editor

There are many other tabs for the EJB deployment descriptor editor, but these details are beyond the scope of this tutorial. See the EJB deployment descriptor editor section of the information center for more information.

Close the deployment descriptor editor by clicking the X on the title bar.

The EJB Client project

In the Project Explorer view, collapse the expanded projects again (Collapse All icon).

Expand Other Projects, then UML EJB tutorialClient. You will find these resources:

Notice that there is no deployment descriptor for this type of project.

expanded view of EJB client project

Creating the UML class diagram

Now that you have your projects defined, you will create a UML class diagram. You will create a folder to contain the class diagram, to keep it separate from the actual code.

In the Project Explorer view, do these steps:

  1. Highlight the EJB project UML EJB tutorial.
  2. Right-click, select New > Other.
  3. Expand Simple.
  4. Select Folder.
  5. Click Next.
  6. Verify that the parent folder name is UML EJB tutorial.
  7. Provide the folder name diagrams.
  8. Click Finish.

Now, create an empty UML class diagram by following these steps:

  1. Highlight the EJB project UML EJB tutorial.
  2. Right-click and select New > Class Diagram. The New Class Diagram wizard opens.
  3. Expand UML EJB tutorial.
  4. Select the diagrams folder.
  5. Change the class diagram file name to EJB Sample
  6. Click Finish.

This creates an empty class diagram and opens the empty file in the UML visual editor. Notice the palette on the right side of the class diagram. The palette contains items that can be created, visualized, and edited on the class diagram. In general, click on any palette object to highlight it, then click anywhere in the class diagram to drop the item onto the class diagram. The object will appear on the class diagram after any underlying code to support that object is created in your project. If creation of the object involves a wizard, the wizard is automatically launched.

Notice the EJB drawer in the palette. Since our class diagram is inside an EJB project, the EJB drawer is automatically included on the palette.

UML class diagram editor

Now you are ready to begin Exercise 1.3: Adding entity beans to class diagrams.

Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.