OOHDMJava2 Report PDF
OOHDMJava2 Report PDF
Applications
Mark Douglas Jacyntho (*), Daniel Schwabe (*)§, Gustavo Rossi (**)
(*) Departamento de Informática. PUC-Rio, Rio de Janeiro, Brazil
E-mail: [email protected] , [email protected]
(**) LIFIA - Facultad de Informática. UNLP, La Plata, Argentina
E-mail: [email protected]
Abstract
In this paper we present an architecture for building families of rich Web
applications. We first characterize current trends in Web applications, from read-only
Web sites to sophisticated applications where complex distributed transactions must be
supported. We next some design principles for building Web applications, and give the
rationale for separating application behavior from navigation and interface issues. We
briefly argue the need for developing a product line architecture for simplifying the
systematic construction of different families of applications. We next describe the main
components of our architecture explaining how we manage to decouple application
specific aspects from technological aspects (such as dynamic page generation and
persistence) that can be eventually solved by reusing of-the-shelf components. We
show how to build application frameworks using this architecture using a concrete
example of an electronic CD store.
1 Introduction
Building complex Web applications such as E-commerce applications is difficult,
since these applications often act as integrators of distributed data or behavior
repositories, and usually support different user profiles. Web applications combine
challenging technological issues such as allowing access from mobile devices, or
balancing support for current html/xml releases, with more conceptual ones such as
implementing new business models - internet-based business may be quite different
from traditional ones.
We need to understand the underlying application domain: objects, behaviors,
business rules, etc., and come up with flexible and evolvable software architectures in
that domain. To make matters worse these applications evolve continuously and, at the
same time, they should be deployed quickly and with zero defects. Systematic
engineering and reuse-centric approaches are certainly a must.
In the last 6 years we have been using the Object-Oriented Hypermedia Design
Model (OOHDM) [Schwabe 98] for designing complex Web applications. We have also
explored reuse in Web applications. We have mined architectural and navigation
patterns in these genres of applications [Rossi99], and also discovered patterns in
specific application domains such as E-commerce [Rossi00].
Although micro-architectural reuse such as afforded by applying design patterns
may help to build high-quality Web applications, we need more powerful approaches in
§
Daniel Schwabe was partially supported by a grant from Conselho Nacional de Pesquisa Científica –
CNPq, Brazil
1
order to deal with complexity, evolution and short development and maintenance times,
in particular in the context of families of Web Applications (e.g. virtual museums,
electronic stores, etc). We have introduced Web frameworks as a way to introduce
domain knowledge in the application’s design architecture [Schwabe 01]. Unfortunately,
however, when these patterns and frameworks are mapped onto current
implementation settings, we can loose most reuse opportunities if we don’t use an
architectural-centric approach [Bass 98].
In this paper we present a component-based architecture and an implementation
framework for building complex Web applications. We first present our view of Web
applications as views on Object Models; we next justify the need for improving current
Web implementation architectures (such as J2EE) with components that simplify the
development of new applications; we next describe OOHDM-Java2, an architecture that
allows decoupling design decisions related with the domain model from those related
with the navigation and interface architecture. We show how using this architecture we
can implement application frameworks for different families of Web applications. We
next give an example in the field of E-commerce. Finally we discuss further issues and
draw some conclusions.
2
• The inability of methodologists for providing non-proprietary solutions to the
aforementioned “mapping” dilemma.
In this paper we present a software architecture together with an
implementation framework that allows improving the process of mapping a design
schema onto a running Web application. The architecture supports and encourages the
use of a set of design principles provided by most methodologies, and implements them
in the context of the J2EE architecture, thereby improving existing approaches for using
J2EE. The salient principles are:
• Applications should be built using layers in which different concerns are taken into
account; in particular, application data should be separated from the page’s contents
(navigation nodes) and these contents, in turn, should be clearly separated from the
interface look-and-feel (pages). In Figure 1 we illustrate a three-layer design
architecture following this principle. When we clearly decouple interface from
navigation and from application behavior we have better opportunities for reuse
• Nodes should represent logical views on domain objects, thereby allowing the
construction of customized applications according to the user profile simply by
changing views instead of changing domain objects. This principle refines the
previous one by identifying nodes as first-class abstractions that should not be
subsumed in interaction code. For example, in an electronic store, the manager view
of a product will be different from the customer view, and for each we may have
different look and feel depending on the interface device (as shown in Figure 1).
......
....…… ...... ......
...... ...... ............
.
. ............ ............
............ Interface objects
contain the look and feel
of navigation objects
3
to the other without backtracking to the index. Since the same CD may also appear
in other sets, such as today’s recommendations, navigation controls should depend
on the set and not only on the node. At the same time, complementary context-
related information should ideally be provided; for example for each recommended
CD we should explain why we recommend it - and this information would not
appear when the CD is accessed within the former set. A different example not
involving sets occurs if we want to restrict navigation or other operations in some
context: e.g. when we navigate from the shopping cart to a CD we may want to
prevent the user from adding the CD again to the cart.
In OOHDM for example, a design model comprises a conceptual, a navigational
and an interface model. The conceptual model is described using a variant of UML (with
use cases, class diagrams, etc). The navigational model is specified with two schemas,
the navigational schema showing nodes and links (as views of conceptual objects) and
a context schema that shows indexes and contexts in the application.
As an implementation environment, the J2EE (Java 2 Enterprise Edition) [Sun]
which has become popular in the market, is a platform for implementation of distributed
multi-tier applications
To illustrate how the use of a software architecture improves the implementation
of complex applications we can use as an example the J2EE platform. J2EE consists
mainly in three tiers: client, middle and EIS (Enterprise Information System). In the
client tier we may have a stand-alone application or a Web browser; the EIS tier usually
handles persistence, while the middle tier is itself divided in sub-tiers, which use
components deployed into containers. There are two containers: the EJB container and
the Web container. In the Web container we deploy JSP pages and servlets, whereas in
the EJB container we deploy enterprise java beans (EJB) components that implement
business rules in a software applications. EJB components may be entity beans,
representing entities stored in some persistence mechanism; session beans,
representing a client on the J2EE server, i.e., a logical extension of the client on the
server; and Message Driven Beans, which permit J2EE applications to process messages
asynchronously.
Using J2EE may be extremely difficult, since a programmer may be led to
incorrectly distribute software responsibilities. However if we use a software
architecture to reason about the construction of Web applications using J2EE, we can
simplify the process. For example, using the Model View Controller (MVC) [Krasner 88]
architecture we are not condemned to leave most architectural design decisions to the
programmer’s wisdom or ability.
4
Simply encapsulating business rules in application objects and invoking them from
interface pages does not solve the problem, since there still is a strong coupling among
interface and business-specific behavior.
The evolution of software platforms for building Web applications shows a
perceivable trend towards modular architectures, i.e. those in which program
components and their interactions follow established software engineering practices,
such as separation of concerns, good support for evolution, etc.
For example, we can consider that the use of the Model View Controller (MVC)
[Krasner 88] architecture for improving the development of J2EE-based applications
enhances earlier proposals in which most architectural design decisions were left to the
programmer’s savvy or ability. The MVC architecture, summarized in Figure 2, has been
extensively used for decoupling the user interface from application data and from its
functionality. Different programming environments provide large class libraries that
allow the programmer to reuse standard widgets and interaction styles by plugging
corresponding classes into his “model”.
B MODEL
R View Selection (EJBs)
O Change Notification ! Encapsulates application data
W ! Encapsulates application functionality
S ! Provides an interface for state queries
E ! Provides an interface for functionality
R ! Notifies view of changes (push)
Data
Source
VIEW
http response (JSPs)
! Renders the model data
! Requests updates from model (pull) State Query
! Allows controller to select the view
Application Server
5
handle user interaction, the controller, (or, more generally, interaction with other
systems or user) provides better decoupling between the application behavior and the
way in which this behavior is triggered.
Moving to a software architectural approach has many benefits, which will be
evident throughout the paper; to mention only some of them (see [Bass 98]) we can:
• Improve communication among stakeholders; as the architecture
represents a common high-level abstraction of a system that most
stakeholders can use as a basis for creating mutual understanding and
forming consensus.
• Represent early design decisions; because architecture represents the
manifestation of the earliest and most important decisions with respect to
the entire system development cycle.
• Promote large-scale reuse in our applications; because we can apply the
same architectural styles to many similar systems regardless to their in-
the-small concerns.
These advantages become even more tangible when we can refine our software
architecture into a set of smaller-grained architectures for particular families of domain-
specific Web applications, such as e-commerce or interactive learning applications. We
can build a product-line architecture [Bass 98] and different application frameworks for
each domain. The development of a new application will then involve just instantiating
and connecting framework components, instead of building everything from scratch
each time.
In the following section we introduce the OOHDM-Java2 architecture, explaining
its components and the interactions among them, and show an example of use of the
architecture.
6
unmanageable. The same problem occurs if we use different JSP pages for different
contexts, duplicating code.
An alternative approach is having one JSP page that generates the information
common to all contexts ("basic node"), and one JSP page for each "node in context"
that dynamically inserts that common JSP page, adding the context sensitive
information. This is still unsatisfactory, since this case, the "basic node" layout becomes
fixed and we have lost flexibility.
Summarizing, the main problem is that the navigational logic (node and context
management) is dealt with in the JSP page, which mixes it with the interface layout. To
solve this problem, we propose the creation of a navigational layer encapsulating all
navigational logic. While the JSP is responsible for the page layout structure, the
navigational layer manages the node contents and deals with context-specific
information.
7
Controller
Client
1) Http
Request
Http Request
Translator
6) Http
Response
2) Business
Extended View Event
3) Application Model
Funcionality
JSP (layout) Invocation
Executor Business
Objects
Navigational
Navigational Node
Node
(contents,
(contents, model
model 5) Selected
view)
view) View View
Selector 4) Queries on
Model State
Component Description
8
from some business objects and other navigational
sub-components such as indexes, anchors, etc.
This component has the contents to be shown by
the response interface (JSP).
JSP (Extended View) This component generates the look-and-feel that
the client component receives as a response to its
request. To achieve this, it instantiates the
corresponding navigational node component and
adds the layout to the node’s contents. Notice that
the JSP component does not interact directly with
model objects. In this way we can have different
layouts for the same navigational node.
3. The Executor component is then customized. For each business event object, the
designer must indicate the execution logic of this event, i.e. how model objects are
invoked to implement the business event.
4. After the execution of the business event it is necessary to send a response to the
client. The designer must specialize the View Selector component adding the
application’s specific logic to select the response interface. In some cases this logic
is a simple mapping between the http request and the response interface; in other
cases it may be necessary to query the model state to select the response interface.
9
6. Once the contexts have been defined, we have to define the structure of nodes in
the application, which are usually specified as part of a navigational model in
existing methods. This is achieved by refining the Navigational Node component,
adding the attributes that must be made perceivable to the client.
7. Finally the designer must specify the JSP pages in the application defining the
layout for the corresponding navigational node structure. These pages obtain their
contents from the navigational nodes defined in step 6.
It should be noted that steps 5-6 can be automatically generated from an XML
specification of the design in a DTD such as OOHDM ML [Medeiros 01], since all the
information is known at design time.
In Figure 4 we summarize the mapping of an OOHDM design model into the
OOHDM-Java2 framework.
10
Design OOHDM-Java2
Model Framework
EJBs
Use Cases
And State Objects
Scenarios
Web Objects
Event
Conceptual
(Business) Request
Model Handlers
Event
Handlers
Navigational
Model
Node
Nodes Creators
Contexts Navigational
Contexts
Indexes
Index
Creators
Interface
Model JSP
Pages
The following description is based in a 3-tier scenario (web tier, EJB tier, and
persistence tier). Nevertheless, it is perfectly possible to use this architecture in a 2-tier
scenario (web tier, and persistence tier). In the 2-tier scenario the model is composed
of simple Java Objects in place of the EJBs, and the EJB Controller core functionality is
merged into the Web Controller. The OOHDM-Java2 a architecture implementation has
11
a configuration parameter that must be used to indicate whether is a 3-tier or a 2-tier
application. The client tier (the client browser) was omitted for the sake of simplicity.
Answer
Controller JSP 9) Calls the
Navigational 6) Access
Manager to and update
8) Answer
assemble the the
Interface interface
Front
selected. contents of database.
Manager
Servlet the
navigational
2) Calls the Navigational node.
Request Manager, Manager
passing the http
request that will be
Request 5) Executes the
Manager
translated in an
event. event calling
methods on DBMS
business
3) Sends the (conceptual)
event to the objetcs.
Web 10) Calls the Web Controller to
Controller. access the state of business
(conceptual) objects.
Web
Controller EJB
(proxy) Controller
4) Redirects the event to
the EJB Controller.
12
Controller invokes the appropriate business objects, and notifies the Web Controller of
the resulting changes to be reflected in the observer objects.
The EJB Controller invokes the Event Handler, which has the specific logic for
executing the events, i.e. knows which conceptual objects (EJBs) to invoke, when and
how. For each business event there is a corresponding Event Handler and this
correspondence is defined using an XML configuration file.
At this stage we need to send a response back to the client. The Front Servlet
invokes a black-box component, the Interface Manager, which selects the response
interface. When the mapping between the http request and the response interface is
not direct, the Interface Manager invokes the Interface Handler, containing the logic for
selecting the interface based on the request and on the state of conceptual objects. The
mapping between the http request and the response interface (and if necessary the
Interface Handler) are also specified using an XML file.
In OOHDM-Java2 an interface template is a JSP page containing place holders,
known as template parameters. There are two genres of template parameters: those
whose value is a text to be inserted directly, and those whose value is another JSP page
whose contents are inserted dynamically. Template pages are defined using the custom
tag parameters containing an attribute defining the parameter name or place holder of
the template. A template plus its parameter’s values define an interface. Application
interfaces are also defined using XML files.
When the response interface contains a JSP page that exhibits a navigational
node or an index, it is necessary to instantiate them using components Navigational
Node or Index. This JSP invokes the Navigational Manager component using the custom
tag crate_node or create_index. The Navigational Manager invokes the corresponding
factory object (Node Creator or Index Creator) containing the specific logic for creating
the node or index. These objects access appropriate conceptual objects through the
Navigation View interface, which is responsible for implementing the view over the
conceptual object.
The Navigational View interface declares three methods: getContextNodeIDs,
getObjectList, and getObject. The first method returns the node identifiers (NodeIDs) of
a navigational context. The second return the list of objects that contains the data used
to create each index entry of an index. The last method returns a state object
encapsulating the actual data used to create the navigational node in a context.
Another important component (not shown in Figure 4 for the sake of simplicity)
is the Navigational Context, which represents the set of nodes the user is currently
navigating. This component interacts with the Navigation View component to access the
conceptual objects corresponding to the nodes in the current context. The Navigational
Manager interacts with the Navigational Context to provide adequate contextual
information for a Node Creator or Index Creator to instantiate the node or index. This
information includes ID of the next and previous nodes, number of elements in the
context, the URL(s) where the node in context is exhibited, etc. In other words, when
the node is created, the linking information is retrieved and inserted into the node by
the Node Creator.
13
The definition of contexts and the correspondence between contexts and the
corresponding Navigational Context and Node Creator are specified using XML
configuration files.
Finally, if the http request does not have an associated business event, i.e. it is
only a navigational request, the process is fairly simple; the interface response must be
defined, the corresponding node (in context) must be created and the JSP must
generate the layout. In this case, the Front Servlet invokes the Interface Manager and
processing follows from that point.
5 Instantiating an application
In this section we explain how a designer instantiates our framework for creating
a specific application, illustrating each step using the example of an online CD store.
Although we show a step-by-step explanation, the process is usually incremental.
We assume that the designer has built design models (for example using
OOHDM), and thus he has partitioned the design space into three different models:
conceptual, navigational and interface. For the sake of conciseness we do not describe
persistence issues in this explanation. We also give a simplified presentation of the
application layer because it is straightforward, e.g. mapping design classes into EJBs
(entity beans, session beans, state objects, data access objects, etc), or into Java
classes.
In figure 6 we present a simplified version of the OOHDM conceptual model of
the CD store.
Client Artist
name: string name: string
password: string description: string
... ...
1 1..*
makes participates
0..* 0..*
Order CD
title: string
number: integer description: text
shipAddress: string 0..* includes 1..* kind: [Rock, Jazz, etc]
/total_price: real ...
prazo_entrega: real
...
createOrder() Item
addItem(cd: CD, quantity: integer
quantity: integer) ...
...
14
! Catalog – A stateless session bean that provides information about CDs and
artists. It is stateless since it is independent of the session or the user.
! Cart – The shopping cart (current order) of the application. It is a stateful
session bean, if we assume the shopping cart is not kept in between
navigation sessions.
! Account – An entity bean that represents the client account. It is an entity
bean since it is persistent.
! Order – An entity bean that represents the client order. It is an entity bean
since it is persistent
Once the application model is ready, we must map our navigation objects -
nodes, indexes, contexts - into the architecture. The first step is to implement the
Navigational View interface for those objects (EJBs, State Objects or Web Objects) that
must provide information for the creation of nodes and indexes. To implement this
interface we must analyse the navigational model to obtain the necessary information.
The figure 7 and 8 ilustrate part of the navigational model.
CD
Artist {from c: CD}
{from a: Artist} name: string
name: string description: text
description: text 1..* participates 0..* genre: [Rock, Jazz,etc]
... ...
cds: Index CDs by Artist (self) artists: Index Artists by CD (self)
1
is
Order 0..*
{from o: Order}
Item
name: cl:Client, cl.name where cl makes o
e-mail: cl:Client, cl.e -mail where cl ma kes o cd_name: c:CD, o: Order, c.name where Item (c, o)
number: integer order_num: c: CD, o: Order, o.number where Item (c, o)
... 1 contains 1..* quantity: integer
ship_address: string
...
updateItemQuantity (c:CD, quantity: integer): c:CD,
cds: Index CDs by Order (self)
o:Order, o.updateItemQuantity where item(c,o)
CD
Main By Genre
Menu Genre
Figure 8 – Part of the OOHDM context diagram (the Genres index and the
“CDs By Genre” navigational context)
In our example application, there are several objects that implement the
Navigational View. For instance, the catalog bean implements this interface to supply
conceptual information to all contexts and indexes involving CD or Artist.
To illustrate this step, we show a fragment of code of the Catalog EJB that is
responsible for implementing the Navigational View interface to return data about CDs
and Artists. For instance, the Catalog EJB queries the database and returns the list of
15
node objects that encapsulate the necessary data for Index Creator to assemble the
Kinds index. The query is made according to the selection criteria specified in the
corresponding index spcecification card.
}
. . .
/**
* Implementation of the Navigational View Interface. Used by Index
Creator components.
*/
public ArrayList getObjectList(String indexID,
HashMap parameters)
throws UnknownIDException
{
. . .
16
if (indexID.trim().equals(IndexIDs.KIND_ALPHA_ID))
{
return (ArrayList) this.getAllKinds();
}
else if (indexID.equals(IndexIDs.CD_BY_KIND_ID))
{
String genreID = parameters == null ?
null :(String)
parameters.get(HttpParameterNames.KINDID);
}
}
. . .
/**
* Implementation of the Navigational View Interface. Used by Node
Creator components.
*/
public StateObject getObject(String conceptualObjectName,
PrimaryKey objectID)
throws UnknownIDException
{
. . .
if(conceptualObjectName.trim().
equals(ConceptualObjectNames.ARTIST))
{
return this.getFullArtist((ID)objectID);
}
else if (conceptualObjectName.trim().
equals(ConceptualObjectNames.CD))
{
return this.getFullCD((ID)objectID);
}
else
{
throw new UnknownIDException("The conceptualObjectName \""
+ conceptualObjectName
+ "\" is unknown!");
}
}
. . .
}
There are several events in a CD store, corresponding to the business logic. For
instance, analysing the sequence of actions and operations in the use case “Select CDs
by genre to buy” we may have the event “add CD to shopping cart” or in the use case
“Confirm order”, the event “create a new order”.
17
For each business event we define the structure of corresponding event object
(from Event component). We must identify the business objects affected by the event
because the event structure must contain all data needed for its processing by the
corresponding Event Handler, which is captured from the http request by the associated
Request Handler.
For example, the following code defines the event AddItemEvent for the CD
store. This event adds a CD into the stateful session bean Cart.
. . .
/**
* AddItemEvent.
*/
public class AddItemEvent implements Event
{
//Item
private CartItem item = null;
//constructor
public AddItemEvent(String cdID, int quantity)
{
this.item = new CartItem(new ID(cdID), quantity);
}
public CartItem getItem()
{
return this.item;
}
}
The navigational layer is straightforward. Before showing more details, it should
be stressed that most of this code can be derived automatically from an XML
representation of the design in a DTD such as OOHDM ML [Medeiros 01].
For each context in the application we must create the corresponding
Navigational Context object. The implementation of these objects consists in getting
context parameters from the http request, accessing the Navigational View to retrieve
the identifiers of the Nodes in Context and returning these identifiers. For each index,
we define the corresponding Index Creator, implemented in an analogous manner.
In the former figure 8we present one of the navigational contexts of the CD store
application: “CDs By Kind”. The specialization of the Navigational Context component is
shown in the following code.
. . .
public class CDByKindContext extends NavigationalContext
{
. . .
/**
* Implementation of the load method of the superclass.
*/
protected ArrayList load(HttpServletRequest request,
WebController webController)
throws ContextException
{
. . .
return this.getNodeIDs(request, parameters,
CatalogJNDINames.CATALOG_EJBHOME);
}
}
18
In the code above the getNodeIDs (implemented in superclass) method invokes,
transparently, the Web Controller to get the Navigational View whose ID is
CatalogJNDINames.CATALOG_EJBHOME, that is, the Catalog EJB. The Catalog EJB is
invoked to obtain the list of node identifiers of the context.
Finally we must create nodes for each context (component Navigational node).
For each node present in the navigational class diagram (base node) and node in
context type we define the corresponding Node creator.
The implementation of a Node Creator for a base node consists in obtaining the
ID of the node corresponding to the http request, accessing the Navigational View to
obtain the corresponding (State) object containing the node’s information: attributes,
anchors and indexes. The Navigational Manager is accessed to obtain context-related
information about the node. The code illustrating the creation of a CD base node is
shown in the appendix.
The following code shows the Node Creator that instantiates the CD node in the “CD by
Kind” context.
. . .
/**
* CD Node in CDByKind context
*/
public class CDByKindNodeCreator extends CDNodeCreator
{
// default constructor
public CDByKindNodeCreator()
{ super(); }
/** Implementation of createNode method of the Node Creator. */
public NavigationalNode createNode(HttpServletRequest request,
WebController webController)
throws NodeCreatorException
{
//base node
/* Invoke the createNode of the superclass to obtain the base node */
NavigationalNode node = super.createNode(request, webController);
...
//add anchor next and previous in current context
//access the Navigational Manager to obtain the context info
try
{/*access the Navigational Manager to obtain the context info */
ContextInformation infoCDByKind =
this.navManager.getContextInformation(request,
ContextIDs.CD_BY_KIND_ID,
new NodeID(new ID(cdID)));
if (infoCDByKind.getNextNode() != null)
{
Anchor anchor = new Anchor(AnchorIDs.NEXT);
anchor.setText("next");
anchor.setURL(infoCDByKind.getSimpleContextURL());
anchor.addParameter(HttpParameterNames.CDID,
infoCDByKind.getNextNode().toString());
anchor.addParameter(HttpParameterNames.KINDID, genreID);
node.addComponent(anchor);
}
if (infoCDByKind.getPreviousNode() != null)
{
19
... /* similar to NEXT above */
}
}
catch(ContextException ex)
{ throw new NodeCreatorException("Error on creating the context "
+" node of context: " + ContextIDs.CD_BY_KIND_ID
+ " Cause: "+ex.getMessage());
}. . .
return node;
}
}
Note that in the code above the class CdbyKindNodeCreator is a subclass of
CDNodeCreator, and the first step in the createNode method is to invoke the
createNode of the superclass to obtain the base node.
Once we have defined the navigational nodes and indexes, it is necessary to
create the interface objects, that is, the JSP pages that will establish the layout of the
nodes and indexes. In the JSP page, the first step we must do is to use the appropriate
custom tag (create_node or create_index) to instantiate the node or index. Then we
access the node or index to create its “look and feel” for its information.
The following JSP page excerpt presents the CD node in the “CDs by Kind”
context in the CD store application.
<%@page contentType="text/html"%>
20
<% Anchor addCartAnchor = (Anchor)
node.getComponent(AnchorIDs.ADD_ITEM_CART_ID);
%>
<br><br><br><br>
<a href="<%= addCartAnchor.getDestination() %>">
<%= addCartAnchor.getText() %>
</a>
. . .<br><br>
<%
Anchor nextAnchor =
(Anchor) node.getComponent(AnchorIDs.NEXT);
Anchor previousAnchor =
(Anchor) node.getComponent(AnchorIDs.PREVIOUS);
%>
<%
if (previousAnchor != null)
{
%>
<a href="<%= previousAnchor.getDestination() %>">
<%= previousAnchor.getText() %>
</a>
. . .
In addition, we must create the templates and other general JSP pages of the
application (responses to events, form pages, error pages, etc).
Finally we must configure the whole application defining corresponding XML files,
as follows:
! urlmappings.xml - Maps the request URL into the answer interface and, if
necessary, into the Request Handler and/or Interface Handler..
! interfaces.xml - Defines each interface of the application, that is, for each
interface (present in the urlmappings.xml or exceptionmappings.xml) it
defines the template and the values of template parameters.
! eventmappings.xml - Maps each event to respective Event Handler.
! exceptionmappings.xml - Maps each event exception to respective Exception
Handler or answer interface.
! contextsmappings.xml - Defines all contexts of the application (navigation
type, Node Creator, Navigational Context, URL(s)). Each URL present here
must have a correspondent entry in the urlmappigns.xml file.
! indexmappings.xml - Defines all indexes of the application (Index Creator,
URL). Each URL present here must have a correspondent entry in the
urlmappings.xml file.
21
The generic conceptual model is similar to an object-oriented application
framework [Fayad 99]; it contains generic classes (Product, Order, Invoice, Customer,
etc) and corresponding behaviors (e.g. check-out). Building one e-store may imply
adding new sub-classes (types of products), refining some behaviors such as different
pricing strategies or check-out processes, to adapt the generic model to the specificities
of the application.
A generic navigational model meanwhile implies specifying a generic navigational
and context schema that abstracts most common navigational topologies in the
application domain. For example we may have generic nodes such as Product and
Shopping Cart and generic contexts such as “product by <class property>”.
The OOHDM-Java2 architecture allows mapping such reusable application models
into a domain-specific architecture in which these generic design artifacts are
implemented using the base framework components. For example, generic navigation
schema and indexes can be implemented defining objects that implement the
Navigational View interface in a generic manner, and then refined by specializing these
generic objects adding the application specific behavior (for example, adding a new
context or customizing a state object). In addition, we may define generic Node
Creators and Index Creators to assemble generic contents and then specialize them
adding specific attributes of the application.
7 Concluding Remarks
In this paper we have presented the OOHDM-Java2 architecture and its
associated component framework. We have described the overall structure of the
architecture and the process of building a new application.
The architecture implements an extension of the MVC model and provides the
following features:
• It supports a clear separation between application and presentation logic
• Further separation between navigation logic and interface aspects
• Support for navigational contexts and set-based navigation
• Decoupling between JSP pages and business events
• Centralized control of http requests (in particular of the translation of http
requests into business events)
• Centralized control of business events execution
• Centralized control on the selection of response interfaces
• Single entry points (Façades) to business objects, both in the Web and EJB
layers.
• Single entry point for serializing requests of the same user
• Centralized mapping of business events into corresponding execution logic
• Centralized control of navigation logic
Many of the above features impact positively in the evolution and maintenance of
applications built on top of OOHDM-Java2. In particular:
• We can easily alter the interface response
• Changes in the navigational structure do not impact on the business logic
• Similarly, changes in the business logic are transparent to the navigational
layer.
22
• We can easily implement indexes and contexts without writing complex code
structures
As applications are configured declaratively using XML files, we get further
benefits:
• Each XML file constitutes a point of control
• The navigational and interface application behavior can be altered just by
altering or adding XML attributes
• Each XML file provides a map of some specific application functionality,
easing its maintenance
• The definition and modification of Contexts and Indexes can be done easily.
There is an evident trade-off between these benefits above and the complexity
of the architecture, in particular the learning curve for instantiating an application. We
have designed it in order to optimize this compromise. For example, for simple read-
only applications, a designer must only use a minimal sub-set of the previously
described constructs (see Section 4.3), and a large part of it may be automatically
generated from XML specifications using the OOHDM-ML DTD. For complex,
transactional applications, we consider that the learning endeavor is similar to the need
to use the J2EE platform. From the point of view of design complexity, the overload
caused by of OOHDM-Java2 components is then balanced by the benefits mentioned
above.
Our current research includes defining frameworks for particular domains such as
e-stores catalogs; implementing the translation between OOHDM ML specifications and
OOHDM Java 2 implementation of navigational nodes, indexes and contexts; creating
custom tags that encapsulate the data retrieval from the node in the JSP page; and
exploring extensions to integrate web services defined using WSDL.
8 References
23
Hypermedia Applicatons in the Web”, MSc Thesis, Dept. of
Informatics, PUC-Rio, 2001 (in Portuguese).
[Rossi99] G. Rossi, D. Schwabe, F. Lyardet: “Improving Web Information
Systems with Navigational Patterns”, Proceedings of the 8th.
International Conference on the World Wide Web, Elsevier 1999, pp
589-600.
[Schwabe98] D. Schwabe, G. Rossi: “An object-oriented approach to web-based
application design”. Theory and Practice of Object Systems
(TAPOS), Special Issue on the Internet, v. 4#4, pp.207-225,
October, 1998.
[Schwabe 99] Schwabe, D.; Pontes, R. A.; Moura, I.; “OOHDM-Web: An
Environment for Implementation of Hypermedia Applications in the
WWW”, SigWEB Newsletter, Vol. 8, #2, June 1999.
[Schwabe01] D. Schwabe, G. Rossi, L. Esmeraldo, F. Lyardet: “Engineering Web
Applications for reuse”. To appear, IEEE Multimedia, Spring 2001.
[SUN] SUN Microsystems, Java 2 Enterprise Edition (J2EE) Official site,
http://java.sun.com/j2ee/
9 Appendix
For the sake of completeness, we include here additional examples of Java code
and XML specifications, mentioned in the main text of the paper.
<%@page contentType="text/html"%>
<%@ taglib uri="/WEB-INF/taglib.tld" prefix="oohdmjava2" %>
<html>
<head>
<title> <oohdmjava2:parameter name="TitleContents"/>
</title>
</head>
<body>
********************** OOHDM-Java2 ***************************
<br>
<a href="main">Home</a>
<br><br>
<table border="1" height="85%" width="100%" cellspacing="0" border="0">
<tr>
<td valign="top"><oohdmjava2:parameter name="BodyContents"/>
</td>
</tr>
<tr>
<td valign="bottom"> <oohdmjava2:parameter name="FooterContents"/>
</td>
</tr>
</table>
<br><br>
<a href="main">Home</a>
<br>
********************** OOHDM-Java2 ***************************
<br><br>
</body>
24
</html>
//performers
List performersList = new List(ListIDs.PERFORMERS_ID);
for (int i=1; i <= cd.getTotalPerformers(); i++)
{
ListEntry listEntry = new ListEntry();
Performer performer = cd.getPerformer(i);
25
listEntry.addAttribute(
new Attribute(AttributeIDs.PERFORMER_NAME_ID,
performer.getName()));
performersList.addListEntry(listEntry);
}
node.addComponent(performersList);
//songs
csList = new List(ListIDs.SONG_ID);
}
catch(IndexException ex)
{ ... }
//anchor to add to shopping cart
Anchor anchor = new Anchor(AnchorIDs.ADD_ITEM_CART_ID);
anchor.setText("Add to Shopping Cart");
anchor.setURL(URLs.ADD_ITEM_CART);
anchor.addParameter(HttpParameterNames.CDID, cd.getCDID().toString());
node.addComponent(anchor);
return node;
}
}
Urlmappings.xml:
<?xml version='1.0'?>
<!DOCTYPE url_mappings
SYSTEM "http://localhost:8000/cdstore/dtds/urlmappings.dtd">
<url_mappings>
<!-- Main Page -->
<url_mapping path = "/main" interface = "MAIN"/>
. . .
<!-- CDs By Kind-->
<url_mapping path = "/cdbygenrecontext" interface = "CD_BY_KIND_CONTEXT"/>
...
<!-- *********** Indexes ***-->
26
. . .
<!-- hierarchical index Kind:CD -->
<url_mapping path = "/genrecdhierarchicalindex" interface =
"KIND_CD_HIERARCHICAL_INDEX"/>
interfaces.xml:
<?xml version='1.0'?>
<!DOCTYPE interfaces
SYSTEM "http://localhost:8000/cdstore/dtds/interfaces.dtd">
<interfaces>
<interface name="MAIN" template="/main.html"/>
27
value="New User Form." as_is="yes"/>
<parameter name="BodyContents"
value="/enterUserData.jsp" as_is="no"/>
<parameter name="FooterContents"
value="OOHDM-JAVA2 CD Store - New User Form." as_is="yes"/>
</interface>
. . .
/interfaces>
eventmappings.xml:
<?xml version='1.0'?>
<!DOCTYPE event_mappings
SYSTEM "http://localhost:8000/cdstore/dtds/eventmappings.dtd">
<event_mappings>
<!-- ********Cart - Stateful Session Bean * -->
<!-- AddItemEvent -->
<event_mapping
event_class="pucrio.inf.oohdmjava2.cdstore.event.cart.AddItemEvent"
handler_class=
"pucrio.inf.oohdmjava2.cdstore.ejb.eventHandlers.cart.AddItemEventHandler"/>
. . .
<!-- ********** Order - Entity Bean ********* -->
<!-- NewOrderEvent-->
<event_mapping event_class=
"pucrio.inf.oohdmjava2.cdstore.event.client.order.NewOrderEvent"
handler_class=
"pucrio.inf.oohdmjava2.cdstore.ejb.eventHandlers.client.order.
NewOrderEventHandler"/>
</event_mappings>
contextmappings.xml:
<?xml version='1.0'?>
<!DOCTYPE context_mappings
SYSTEM "http://localhost:8000/cdstore/dtds/contextmappings.dtd">
<context_mappings>
. . .
<!-- Context: CD by Kind -->
<context_mapping context_id = "cdByKindContext" navigation_type = "SI"
context_class="pucrio.inf.oohdmjava2.cdstore.web.navigational.cd.contexts
.bygenre.CDByKindContext">
<simple url_path = "/cdbygenrecontext"
node_creator_class="pucrio.inf.oohdmjava2.cdstore.web.navigational.cd.
contexts.bygenre.CDByKindNodeCreator"/>
</context_mapping>
. . .
</context_mappings>
28