Tool Mentor: Modeling the Design of a J2EE Application in Rational Rose
This tool mentor describes how to use Rational Rose to model the design of a J2EE Application.
Tool: Rational Rose
Relationships
Related Elements
Main Description

Purpose

You will also design J2EE components within the J2EE framework, representing them in Rose as classes and collaborations of classes. 

In general, a J2EE application uses the services of a relational database. You design a Data Model for the database, representing it in Rose using the Rose Data Modeler. 

To model a J2EE application in Rose, perform the following steps:

For more information on J2EE, see Concept: Java 2 Platform Enterprise Edition (J2EE) Overview

For an overview of component-based development using the J2EE platform, see Concept: Developing Component Solutions .

See also:

Set up Rational Rose for the J2EE Project

Set up Rational Rose as described in the Tool Mentor: Setting Up Rational Rose for a Project.

In addition, you will need to enable the Rose Java add-in and configure project-specific settings.

For detailed information about configuring Rose Java, see helpbook icon Rose Java > How to > Set Project Properties in the Rational Rose online Help.

Organize the Design Model

Create Packages and Layers in the Design Model

The Tool Mentor: Managing the Design Model Using Rational Rose describes how to create packages and layers in the Artifact: Design Model, starting with the RUP model template that is provided with Rose.  This template provides a skeleton of the design model, including placeholders for the types of packages, subsystems and diagrams that should be created during design activities (Task: Use-Case Design, Task: Class Design, and Task: Subsystem Design).   

See also:

Note that the package structure in your Artifact: Design Model does not have to match the package structure in your Artifact: Implementation Model. When you forward engineer your Java classes, it is the package structure in the Implementation Model that determines the package structure of the generated Java classes.

helpbook icon  For more information about packages, refer to the Package topic in the Rational Rose online Help.

Add the Java Language Packages

You must add the Java language packages for Java and J2EE, to provide the services of the J2EE platform, called the ?system layer?. These packages are used when you create your own classes in the model; for example, if your class defines an operation that returns the Java type String, then the Java language package java.lang that contains the class String must be present in your model.

 For details, see the Rational Rose online Help topics:

  • helpbook icon Rose Java > Concepts > Using Java Frameworks

  • helpbook icon  Rose Java > How to > Load Java class libraries in a model

Add the Schemas Package

The Schemas package contains the design of the database tables in the application.  See Tool Mentor: Designing and Modeling Databases Using Rational Rose Data Modeler for more information.

Model Java Beans and Java Classes

This section does not cover how you model EJBs (see Model EJBs) or how you model the presentation classes, such as HTML and JSP pages (see Model the Presentation Layer).

It does provide information on how to model the remaining Java beans and Java classes (such as utility classes) as you would for any Java application. For details, see:

Model EJBs

For more information on EJBs, see and Guideline: Enterprise JavaBean (EJB).

The following is a summary of the steps you perform to model an EJB in Rose:

Create a Design Subsystem for the EJB

In general, EJBs are grouped in design subsystems. 

Design subsystems are used to encapsulate behavior inside of a "package", which provides explicit and formal interfaces, and which (by convention) does not expose any of its internal contents. 

See Tool Mentor: Managing Subsystems Using Rational Rose for detailed information on how to create design subsystems.

Determine the Type of the EJB, and its Persistence Mechanism

Before you can create the EJB in Rose, you must decide on what type of EJB it will be-entity bean, session bean, or message-driven bean. For an entity bean, you must choose between container-managed-persistence and bean-managed-persistence. For a session bean you must choose whether the bean is to be stateful or stateless.

See Guideline: Enterprise JavaBean (EJB).

Use Rose Java to Create EJB Classes

Rose Java provides a set of dialogs for creating and maintaining EJB classes in Rose.

  helpbook icon  For more information, refer to the Rose Java > How to > Work with EJBs and servlets topic in the Rational Rose online help. 

You use Rose Java to:

  • create a new EJB from the very beginning

  • convert an existing class in the model to an EJB-Rose Java converts the existing class into the EJB remote interface, and creates new classes for the home interface and bean class 

  • add finder methods to the EJB

  • update the home interface with any lifecycle or finder methods defined in the bean implementation class

  • update the EJB's class properties (such as the name of the home interface), persistence properties (like whether it is bean-managed or container-managed) and deployment descriptor properties (such as container-managed fields or environment entries).

An entity or session bean created using Rose Java consists of the following:

  • the home interface class

  • the remote interface class

  • the bean class

  • properties that define the generic EJB deployment descriptor ejb-jar.xml, stored as properties of the EJB?s bean class

  • operations and attributes required by the EJB specification (such as callback methods) will have been created in the home interface, remote interface, and bean class

Those classes created by the Rose Java EJB utility are modeled according to the mapping defined in the Sun standard JSR-000026 UML/EJB Mapping Specificationhelpbook icon For more information, refer to the Rose Java > Concepts > About Support for the Java 2 Platform, Enterprise Edition (J2EE) topic in the Rational Rose online Help. 

For more information on the EJB 1.1 or 2.0 specifications, visit http://java.sun.com/ and follow the links to Docs & Training > Java 2 Platform, Enterprise Edition > Enterprise JavaBeans Specification.

Define Operations and Attributes

After you have created the EJB classes, you can add operations (such as business methods) and attributes as you choose.

Rose Java provides a set of dialogs for creating and maintaining EJB classes in Rose.

  helpbook icon  Refer to the Rose Java > How to > Work with EJBs and servlets > Adding methods to a bean class topic in the Rational Rose online help.

For more information on defining operations and attributes, see:

Model the Classes:  Relationships

You create class diagrams as part of the Task: Class Design, on which you model the relationships (such as associations, dependencies, and inheritance relationships) between classes.

The Rational Unified Process Rose model template, provided with Rose, gives an outline as a starting point for the class diagrams you should create.

See Task: Class Design for more information on modeling the relationships between classes.

Model the Classes:  Interactions

As part of the Task: Use-Case Design you create messages on sequence diagrams, which you then use to describe the interactions between design objects. Create a set of sequence diagrams to describe the main and alternative flows of events for each Use-Case Realization in your Design Model. 

As an EJB designer, you use a sequence diagram to:

  • determine the operations and operation arguments of the classes involved in the interaction

  • document the operations that will be called by a class during an interaction

  • document what an object does when it receives a message, for example, by attaching a script to the message. helpbook icon  For more information, refer to the Rational Rose > How to > Create and work in a model > Using scripts on sequence diagrams help topic.

See also:

Model EJB Persistence

An Entity EJB represents an object-oriented view of the application?s persistent data.  Modeling an EJB class as an entity and flagging the class as Persistent indicates that the Role: Database Designer will need to map the EJB object onto the Data Model during the Task: Database Design.

The Role: Database Designer creates the application?s data model as part of the Task: Database Design.

Rose provides support for database design with the Rational Rose Data Modeler tool, which allows you to transform persistent classes in your object model into a data model, and vice versa.

The mapping of classes in the object model onto tables in the data model is documented in the Mapped From field of data model table?s Rose specification.

See also Artifact: Data Model and Guideline: Data Model

For detailed information on the Rose Data Modeler, see Tool Mentor: Designing and Modeling Databases Using Rational Rose Data Modeler.

Modeling considerations for Session EJBs

Session beans can read or write persistent data-see Guideline: Designing Enterprise JavaBeans (EJBs)- Direct Access vs. Entity EJBs.  

In such a situation you should use data access object (DAO) classes to isolate the details of the EJB?s database connection and access using the javax.sql interface. 

Modeling considerations for bean-managed Entity EJBs

Bean-managed entity beans read and write database tables using the JDBC API. Use DAO classes to isolate the details of the EJB?s database connection and access using the javax.sql interface. 

Modeling considerations for container-managed Entity EJBs

You do not need to design DAO classes for a container-managed Entity EJB, since its persistence is managed by the EJB container.

Model Transactions

Transactions define a set of atomic operation invocations-they are either all performed or none of them are performed. In the context of persistence, a transaction defines a set of changes to a set of objects that again are either all performed or none are performed. Transactions provide consistency, ensuring that sets of objects move from one consistent state to another.

See Concept: Java 2 Platform Enterprise Edition (J2EE) Overview - Transaction Management for an overview of transaction management.

Model EJB transactions as described in Task: Use-Case Design - Modeling Transactions.  At implementation time you decide, based on your design model, whether to demarcate the transactions declaratively-in the deployment descriptor, by defining the transaction attribute of an EJB method as one of Required, RequiresNew, NotSupported, Supports, Mandatory, or Never or programmatically using the Java Transaction API.

Model Security

As part of the design, determine whether application security can be handled declaratively, using security roles and method permissions in the EJB deployment descriptor or programmatically using J2EE security APIs.

Use sequence diagrams to consider security scenarios. If necessary, annotate the sequence diagrams to document the security requirements.

See Concept: Java 2 Platform Enterprise Edition (J2EE) Overview - Security Management for an overview of security management.

Forward Engineer EJB Components

You generate an EJB's Java classes by forward engineering using Rose Java, as described in Tool Mentor: Generating Elements from a Model Using Rational Rose. The EJB deployment descriptor ejb-jar.xml will be generated automatically as a result of forward engineering the EJB's bean class.

Reverse Engineer EJBs

You can reverse engineer an existing EJB using Rose Java, as described in the Tool Mentor: Reverse-Engineering Code Using Rational Rose. You must reverse engineer a .jar file that contains the EJB classes and the deployment descriptor, so that Rose Java can determine the relationships between the classes (for example, which class is the home interface) being reverse engineered. 

Model the User Interface Layer

Model the User Interface layer of a J2EE application as you would any Web application. In general, analysis classes stereotyped <<boundary>> are candidates for classes and collaborations of classes in the User Interface layer. Boundary classes can be implemented as, for example, JSP pages, servlets, HTML pages or standalone Java clients, depending on the design.

For more information, see: 

Related activities:

See also:

Forward and Reverse Engineering of Presentation Classes

You can forward and reverse engineer presentation classes. Rose Java supports:

  • Reverse engineering of a Web application (.war). helpbook icon For more information, refer to the Rose Java > How to > Reverse Engineer from  Java Source to Rose  topic in the Rational Rose online Help.

  • Creating a new servlet class complete with appropriate methods. helpbook icon For more information, refer to the Rose Java > How to > Work with EJBs and servlets topic in the Rational Rose online Help.