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:
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.
The information center provides more information on these topics:
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.
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.
UML EJB tutorial
in this
example)The EJB project is created along with several supporting projects, as shown in the Project Explorer view of the J2EE perspective:
UML EJB tutorialEAR
in Enterprise
ApplicationsUML EJB tutorial
in EJB ProjectsUML EJB tutorialClient
in Other
ProjectsIn the Project Explorer view, expand Enterprise Applications and explore the UML EJB
tutorialEAR
project. Within the EAR directory you will see
Deployment Descriptor
directory that contains three subdirectories.
The Deployment Descriptor directory is also a link to the application.xml file
in the META-INF directory.Modules
directory containing EJB UML_EJB_tutorial.jar
.
This is the primary JAR file for the enterprise beans. It is associated with the
EJB project.Project Utility JARs
directory containing UML_EJB_tutorialClient.jar
.
This JAR file contains the code needed by an EJB client. It is
associated with the EJB client project.Utility JARs
directory. This directory can hold other
classes that are used by the EJB components. META-INF
directory, containing the application.xml deployment descriptor.
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
() 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.
Close the deployment descriptor editor by clicking the X on the title bar.
In the Project Explorer view, collapse all open projects (). Expand EJB Projects, then UML
EJB tutorial. You will find these resources:
Deployment Descriptor
directory, that contains four subdirectories. The Deployment
Descriptor directory is also a link to the ejb-jar.xml file in the ejbModule > META-INF
directory.Session Beans
directory that will list session beans associated with the EJB project.
Entity Beans
directory that will list entity beans associated with the EJB project.
Message-Driven Beans
directory that will list message-driven beans associated with the EJB project.
Maps
directory that will list mapping relationships between the enterprise beans and the
relational database tables.
ejbModule
directory that contains the META-INF
directory. The META-INF
directory contains the ejb-jar.xml deployment descriptor.
WebSphere v6.0 Runtime
directory, containing code libraries
shipped with WebSphere Application Server v6.0.Java Runtime Environment (JRE) System Library [WebSphere v6 JRE]
directory, which are the Java libraries
shipped with WebSphere Application Server v6.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.
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.
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.
In the Project Explorer view, collapse the expanded projects again ().
Expand Other Projects, then UML EJB tutorialClient. You will find these resources:
ejbModule
directory, which will contain the local and local home classes.
gen/src
directory, where generated code is placed. For instance,
if you generate a session facade bean, the code is placed here, as well as the gen/src
directory in the EJB project.
WebSphere v6.0 Runtime
directory, the same as in the EJB
project.JRE System Library [WebSphere v6 JRE]
directory, the same as in the EJB
project.bin
directory, which will eventually contain compiled Java classes.
Notice that there is no deployment descriptor for this type of project.
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:
UML EJB tutorial
.diagrams
.Now, create an empty UML class diagram by following these steps:
EJB Sample
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.
Now you are ready to begin Exercise 1.3: Adding entity beans to class diagrams.