The Modeling Zone
UML
UML is an industry standard
language used to describe
and communicate requirements,
architectures and designs.
UML can be leveraged to visually develop Java Enterprise
components and Web services applications.
UML's
Origins
"The development of UML began in late
1994 when Grady Booch
and Jim Rumbaugh of Rational Software Corporation began their
work on unifying the Booch and OMT (Object Modeling Technique)
methods. In the Fall of 1995, Ivar Jacobson and his Objectory
company joined Rational and this unification effort, merging in
the OOSE (Object-Oriented Software Engineering) method"
-History of UML
IBM Acquires Rational
We learned earlier in the course that IBM acquired Rational
and subsequently undertook a major revision of their Enterprise
authoring systems based on Rational's body of knowledge.
The Rational
Universal Process
The following is a snapshot of Rational's latest thinking.
RUP uses takes process descriptions and progressively
refines them into more detailed process descriptions.
The Rational Unified Process combines six best practices
into a "cohesive and well documented process description:"
RUP Six Best Practices
- Develop iteratively
- Manage requirements
- Use component architectures
- Model visually
- Continuously verify quality
- Manage change
Visual Editing
Visual editing allows the development to proceed without
explicitly typing code into a text editor. Components, such
as Java classes are dragged and dropped from a palette
onto a diagram. Further editing can proceed by adding
methods and attributes or defining relations between them.
RAD 7 supports the following types of UML visual diagrams:
RAD 7 UML Visual Diagrams
- Class diagrams
- show some or all application elements
- visually represent and develop
- structures & relationships
- for Java classes and interfaces
- develop Java elements directly from class diagrams
- Browse
diagrams
- temporary diagrams to explore application
- detail, elements and relationships.
- specify a context element to view
- can be converted to
- a UML class diagram or
- save it in an image file
- Topic diagrams
- non-editable
- a quick show of existing relationships
- made by querying the current application state
- queries can be customized
- open multiple copies
- Sequence
diagrams
- show object interactions
- focused on sequence
- timing of message exchange
- Static method
sequence diagrams
- non-editable
- explore the chronological sequence
- of messages between Java instances
- more detailed method interplay
The tools are not Java specific and can work with
XML in creating Web Services.
// see pdf for diagram of a typical
work space setup
Unified Modeling Language
RUP is largely based on models.
"A model - is a
description of a system from a particular
perspective, omitting irrelevant details so that the
characteristics of interest are seen more clearly."
Models are useful for
- understanding problems
- communicating with interested parties
- preparing documentation
- designing applications
Modeling promotes
- better understanding of requirements
- cleaner designs
- more maintainable applications.
UML is a standardized language for modeling different
aspects of an application.
UML can be used to:
- visualize
- specify
- construct
- document the artifacts of an application.
//
a UML favorite word, 'artifact' -'anything made
// by human work or art' - webster's dictionary
The language uses three kinds of building blocks:
- Things
- Relationships
- Diagrams
Things
Things are the basic elements of a model.
The UML defines four kinds of things:
- Structural
things // static elements
- the nouns of a model
- interfaces
- classes
- components
- uses cases
- Behavioral
things //
dynamic parts
- the verbs of the model
- messages exchanged between objects
- Grouping
things
- used to organize a model.
- group semantically related things together
- to a certain context.
- The only UML defined grouping thing
- Annotational
things
- further explanations
- comments in the UML
Relationships
UML defines five kinds of relationships describing
how element are related:
- Dependency
- a semantic relationship where a change
- to one class might affect another class.
- example
- a Bank class depends on an Account class
- because it is used as parameter for an operation.
- Association
- a structural relationship
- describes a connection between objects
- maps to class member declaration
- For example
- a Customer class with a single association
- to an Account class, each Account instance
- is owned by one Customer instance.
- The extends
relationship
- one thing is a specialization of another more general thing.
- maps to the 'extends' keyword in Java.
- For example
- SavingsAccount extends an Account class
- The
implements relationship
- maps to the implements keyword in Java.
- a class that 'realizes' operations defined by an interface.
- The owned
element association
- classes that are owned by a package.
- //
a construct for implementation reasons
- and for hiding information
Diagrams
"A diagram -is a graphical presentation of a set of
elements, most often rendered as a connected graph
of things and their relationships."
UML provides thirteen types of diagrams allowing
capturing, communicating and documenting all aspects
of an application in a standard graphical notation.
The diagrams are categorized into three groups:
- Structural
diagrams
- show the building blocks of an application
- characteristics that do not change over time
- objects, attributes, operations, and relationships.
- Examples
- component diagrams
- class diagrams and
- deployment diagrams.
- Dynamic
behavior diagrams
- how applications responds to requests
- or otherwise evolves over time
- by showing collaborations among objects
- and changes to the internal states of objects.
- Examples
- use case diagrams and
- activity diagrams.
- Interaction
diagrams
- a subset of behavior diagrams
- focused on the exchange of messages
- within a collaboration
- // a
group of cooperating objects
- Examples
Rational's Products are Costly
The modeling software that Rational provided before
joining IBM and now after having integrated fully with
the Eclipse platformed, value added Rational Development
Environment has always been expensive.
One seat at a coorporation, for RAD 7 purportedly costs
~$5000 for a year. // last time it was checked at least
Open
Source Alternatives
The Open Source movement is hotly pursuing the
provisioning of Modeling software. Although they have
a ways to go before catching up with Rational, the pace
of development is quick.
Modeling in Open Source with Eclipse
// detour to Annotations
Annotations,
New in JDK1.5
A trend was developing in Java where the Javadoc comment
section was being used to send extra information about the
source code to differerent development and deployment tools.
This extra information, really what is called metadata is also
referred to as annotations.
Just as in JavaBeans archictecture, where naming patterns
were used for getting and setting properties, in Enterprise
JavaBeans, stylistic patterns have allowed methods to be
marked as those of the remote or the home interfaces.
Additional informations is supplied regarding persistence
and transactions.
Custom tools use metadata in the creation of auxillary files
needed in the system being developed. An example is the
creation, by a stub generator, of remote procedure call stubs
based on signals provided as annotations.
Because this system of supplying metadata is growing, and
threatens to become vague and 'ad hoc' in it's use, JSR 175
promotes a standardization of the technique, where attribute
information can be associated with classes, interfaces,
methods and fields in a predictable fashion.
This new Java feature is introduced here, to provide a
background to the use of annotations in the Eclipse Modeling
Framework.
EMF Overview
A definitive reference for the Eclipse Modeling Framework
is supplied below.
Eclipse Modeling
Framework (Addison Wesley, 2003)
http://www.awprofessional.com/titles/0131425420
"EMF is a Java framework and code generation facility for
building tools
and other applications based on a structured
model."
EMF helps
you rapidly turn models into efficient, correct,
and easily
customizable Java code. While, modeling systems
are usually very expensive, EMF is intended to provide the
same benefits at a low cost of entry.
What
is Modeling?
When we think of modeling we generally think of UML or
Unified Modeling Language, the de facto standard for
modelling, with it's different Class, Collaboration, State
and other sorts of diagrams. Essentially each aspect of
an object or data oriented system is represented pictorally
by a diagram. A translator program can then translate this
diagram into corresponding code.
The EMF model achieves it's modest cost by only developing
a small subset of the things that
can be modeled in UML.
EMF is focused on modeling only class definitions with their
attributes and relations. This makes full-scale graphical modeling
tools
unnecessary.
XMI, XML Metadata Interchange
While EMF uses XMI or XML Metadata Interchange as its
primary form to create model
definitions. Models can be
translated into that form in different ways.
XMI Form Changing
- Create the XMI document directly, in an XML/Ttext editor
- Export the XMI document from a modeling tool such as Rational Rose
- Annotate Java interfaces with model properties
- Use XML Schema to describe the form of a serialization of the
model
Creating XMI or XML Schema, will appeal only to XML specialists
familiar with XMI and XML Schema. Exporting from a Rational
product is an option, perhaps as a way of sharing the product of a
few seats at a corporation that have Rational, with a larger body
working on Eclipse.
Annotations Strike Again
Providing annotating Java interfaces is a practical option for Java
programmers.
But in the general sense, this is about translation. The real promise
of EMF is to provide a modeling method that can be used to generate
code.
Getting Back to the Model
Given an EMF model, an EMF generator can generate a corresponding
set of Java implementation classes. Editing the
generated classes will,
in the general case, cause a regeneration in the corresponding
model.
Primary Benefit of building an application
Using EMF
While EMF, is a modeling tool that will grow in sophistication, it
most
important utility, may be that it provides a
foundation for interoperability
with other EMF-based tools and
applications.
EMF Fundamental Frameworks
- EMF // generation and runtime support
- EMF.Edit // undoable model editing
Tutorial: Generating an
EMF Model
http://help.eclipse.org/ganymede/topic/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html
EMF & OMG's MOF //
Ecore
The OMG Object Management Group
have a modeling
system called MOF or Meta Object Facility. EMF started
out as an implementation of the MOF specification.
EMF has since evolved into a highly efficient Java
implementation of a core subset of the MOF API.
To avoid confusion, the MOF-like core meta model
in EMF is
called Ecore.
// MOF 2.0, proposes a similar
subset called EMOF or Essential MOF
// with small differences between
Ecore and EMOF. EMF can transparently
// read
and
write serializations of EMOF.
Defining an EMF Model
In IBM's "Eclipse tutorial, a model is started on a single
class.
Class Diagram
Book
title:String
pages:int =100
category:BookCategory
|
It's Easy in UML
You draw the class diagram as shown above, press a button
and the code is generated for you!
XMI
Following is how the above definition is defined in XMI.
Definitely not as much fun.
XMI Representation of the Book
Class
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
name="library "nsURI="http:///library.ecore" nsPrefix="library">
<!-- below you see the the class def and the two attributes -->
<eClassifiers xsi:type="ecore:EClass" name="Book">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="title"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="pages"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
</ecore:EPackage>
Annotated Java
Our third option
as Java programmers, is to provide a Java
interface with model annotations that can be used by the
EMF generator. The Eclipse Tutorial supplies the following
code.
Partial Java Code
//
from the Eclipse Documentation
/**
* @model
*/
public interface Book
{
/**
* @model
*/
String getTitle();
/**
* @model
*/
int getPages();
}
The @model
tag may be followed by with. additional details.
To make the page read-only where a set method is not
created, the following would be added to the
annotation.
Example
//
from the Eclipse Documentation
/**
* @model changeable="false"
*/
int getPages();
XML Schema
Recall EMF supplies three native forms. Following
is the XML schema equivalent of the above forms.
In XML schema the class is represented as a complex
type with, a sequence of attributes.
Schema Example
// from the Eclipse Documentation
<xsd:schema targetNamespace="http:///library.ecore"
xmlns="http:///library.ecore" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Book">
<xsd:sequence>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="pages" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
The Generated Java
Following is the generated EMF example and in this case
the result is heart-warmingly familiar.
EMF Output
public interface Book extends EObject
{
String getTitle();
void setTitle(String value);
int getPages();
void setPages(int value);
}
A point to note, the extension is of EObject. This is the
EMF equivalent of java.lang.Object and is the base of
every EMF class.
The implementation class that is created is reminiscent
of the output of the CORBA and RMI generators.
Following is the generated implementation, (some parts
left out presumably for clarity, in the Eclipse Documenation.)
Implementation Class
// from the Eclipse Documentation
public class BookImpl extends EObjectImpl implements Book
{
...
protected static final int PAGES_EDEFAULT = 0;
protected int pages = PAGES_EDEFAULT;
public int getPages()
{
return pages;
}
public void setPages(int newPages)
{
int oldPages = pages;
pages = newPages;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ..., oldPages, pages));
}
...
}
EMF Practical
We can detour to the IBM site to trace through a practical
tutorial that is listed there.
EMF Tutorial Site
// Eclipse site
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.emf.doc/tutorials/slibmod/slibmod.html
Saying
Goodbye to EMF for Now
From here the explanation of how EMF deals with different sorts
of modeling associations, different types and inheritance gets
complicated. Refer to the documentation for more information.
Hopefully, this is sufficient to characterize EMF and to point out
that it promises to provide an excellent modeling framework for
future use.
Conclusions
Following is the packaging
map for an enterprise applications.
We can use it to reflect on different aspects of the course. The
Java project was a straight ahead aspect of the course with which
we had no problemsn. The web components were also easy to
develop in Eclipse as was the database component. The
Connection Project below represents the database component.
I had some difficulty with the Enterprise JavaBeans and personally
think that EJBs remain a part of Enterprise Java that needs more
work and standardization.
Project Mapping To Module Types
Enterprise
Application
Project |
→ → → |
→ |
Enterprise
Application
Resource |
EAR
File |
|
|
|
|
|
|
|______
|
|
Connector
Project |
→ |
Resource
Adapter Archive |
RAR
File |
|______
| |
Utility
JAR Project |
→ |
Utility
Java Library |
JAR
File |
|______
| |
Web
Project |
→ |
Web
Application Resource |
WAR
File |
|______
| |
Java
Project |
→ |
Standard
Java Archive |
JAR
File |
|______
| |
EJB
Project |
→ |
EJB
Resource |
JAR
File |
|______
|
Application
Client Project |
→ |
Application
Client Resource |
JAR
File |
To Do
Other parts of the Enterprise Edition that call for investigation
are as follows.
Enterprise Topics Still To Do
- Java Messaging Service
- Concurrent Versioning System
- Web Services
If we had one more lecture, it would have been good to take
the following MVC models we introduced earlier and provided
a implementation.
I hope our students recognize that we were close to doing
complete implementations of these models in our exercises.
Diagram of Model II
Architecture
Browser
--request--> Controller Servlet
|
( instantiates bean)
|
v
Bean
Controller <--data access--> DataSource/EIS
|
v
Browser
<--response--- JSP
View
Variation of a Model II JSP
Architecture
// different component
accesses data source. Bean is more a 'result carrier' then a controller.
Browser --request--> Servlet/JSP
<-->
DataSource
|
v
Result Bean
|
v
Browser <--response--- JSP View
Exam
First and Last Lecture won't be on the final test.
The test will have multiple choice, True False and
a few fill in the blanks. Good Luck!