Chapter 2. Expresso Overview

Table of Contents

Introduction
Using Expresso
Services
Expresso's Struts Integration
Benefits of Struts Integration
History of Integration
Struts Users Getting Started with Expresso
Expresso/Struts Webapp Example
Taking Advantage of Struts
Views
Flow of Control
Struts Tag Libraries
Other Open Source Project Integration
Conclusion
Contributors

Note

If you find this EDG documentation helpful please consider DONATING! to keep the doc alive and current.

 Maintainer:David Lloyd

Expresso is the most popular architectural framework which has the largest userbase. It has an emphasis on building robust, secure, feature-rich and reliable web applications quickly and easily. As an extensible, vendor-independent application framework, it benefits your development by significantly increasing quality and productivity through code reuse which greatly lowers cost and shortens time-to-market.

Introduction

Every Enterprise Java project has the same basic plumbing. Most enterprise applications have a great deal in common - no matter what the application does or who uses it. Every enterprise application requires services such as security, logging, configuration support, monitoring, automated testing, persistence, data exchange, and so on. In most projects, each service is either developed "from scratch", or pieced together from different vendor offerings. This process is repeated project after project, with little or no reuse even though the same basic needs do not change between applications. Clearly by pulling these common services into a core framework that could be tested once and reused across many projects, it would be a huge benefit to nearly every enterprise web application project. By embracing this premise, you can cut project costs and improve software quality in one swoop. Choosing an extensible, vendor-neutral solution with source code makes it all the more valuable. This is the what Expresso provides.

Using Expresso

To use Expresso's capabilities to their best advantage your application should be written using Expresso as it's application framework. This involves using Expresso's initialization mechanism, configuration and cache management, database objects and security systems, and it's MVC Controller and State objects with the presentation mechanism of your choice (such as JSP (with the full Struts tag library available), Webmacro, and several others).

Using Expresso is this way still leaves plenty of room for integration of other development toolkits, frameworks, and component libraries. Expresso is designed to provide extraordinary extensibility, and can integrate with many other tools easily.

While it is quite possible to use Expresso's components without using all of Expresso, the system also makes the entire construction of web applications easier when used as a whole. Expresso imposes a minimum of constraints on the applications built with it. It does not tie you in to any particular navigation method or style, or even any particular architecture. Web applications build using Expresso as their framework can use JSP's, ordinary Servlets, even Applets or stand-alone Applications as their User Interface.

In the chapters that follow, we will mostly be discussing Expresso's use as an application framework, but the individual sections that describe components like Database Objects, Controllers, Jobs, and so forth can easily be applied to their use as individual components as well.

Expresso is highly dependent on at least one relational database being available for it's operation, and is best suited to those applications in which a database is an essential part of the application.

Expresso is a web application framework. While it provides many services that facilitate application development, servlet development, and enterprise development, it does not service web requests itself. Web requests can be forwarded to it to be handled. This is a common separation of labor. In order to handle web requests, Expresso needs to be installed into a Servlet Container. Common examples of Servlet Containers are Tomcat, Resin, WebLogic, and many others. Expresso has been tested with the most common of these and is known to work well with them. Please refer to the documentation for more information on application server compatibility and configuration.

Services

Expresso provides a number of services that assist in building web applications. We will explore these areas in the order that the developer of an Expresso application is likely to need them. Your experience of course may vary from this order.

Expresso's Struts Integration

This section describes how this integration functions, and how to make maximum use of the Struts capabilities in Expresso, including URL mapping and JSP tag libraries. Struts contains a methodology for web page mapping and flow control that is an excellent addition to Expresso - specifically in the area of using controllers in a web application. Struts also contains a robust tag library that is also be a welcome addition to the current Expresso tag library. The Expresso 5.5 release is integrated with Struts 1.1.

Struts is a thin MVC light weight framework and Expresso a full application development framework which complements Struts with additional components for developing database-driven web applications. Developers will be interested in Expresso if they need to communicate with databases more often than not, don't want to write their own security for servlets and actions, and need a lot of the grunt work taken out of writing object to relational table mapping. Expresso is about speeding time to market. And if and when the client's project scales to J2EE the components are generally pluggable.

Benefits of Struts Integration

What does Struts supply? It is open source framework for building web applications in Java Servlets and JavaServer Pages. Struts implements a Model 2, JSP web application architecture. This approach is characterised by using a Servlet as a command request dispatcher. Struts unifies a Java Bean and JSP through the using custom action tag libraries. It is particular strong in coupling business logic and views without excessive cohesive. There is a clear separation of business logic and presentation with the library if the edicts are followed. The rich custom action tag libraries, use of XML technology, and for some people whose natural language is not English, built-in in support for internationalisation, means that Struts is clear popular winner across the world.

Advantages to Expresso applications:

  • URL mapping capabilities: Struts provides a robust and flexible mechanism to "map" specified URL's to the appropriate Action (or in Expresso's case, Controller) object. This results in much more readable URL's, and allows great flexibility in configuring the system for different URL patterns.

  • View handling: Struts also provides a mechanism for mapping from logical view names (such as "error" for example) to specific URL paths to process that view, (such as /expresso/jsp/showerror.jsp for example). This allows a complete de-coupling of Controllers and their associated views, and provides the ability for views to be "snapped in" to applications very easily, allowing complete customizability of the visual portion of an application without changing the underlying code at all.

  • Tag Library: Struts provides a powerful and flexible tag library, in addition to the tag library already available in Expresso, to make building sophisticated JSP views very straightforward, and eliminating the need for any code in the JSP page itself. This promotes a richer user interface while keeping a clean separation between View and Controller and Model.

  • Performance: Due to the way Struts instantiates Controllers, and the work done to make Controller objects thread-safe, the new integration uses substantially less memory and creates fewer objects in a running system, improving overall web application performance.

  • Single point of Configuration: All of the configuration of views and mappings is done now in one place: the struts-config.xml file. This simplifies the administration of the web application and provides a single point of reference for all mapping and configuration issues of this nature.

History of Integration

With Release 4.0, Expresso was an early adopter of integrating with the Apache Jakarta Struts framework. as an integral component of Expresso.

With Expresso 5.0 the Struts integration has been extended with integration with Tiles, ActionForms, Radio Input types, Combobox tag, and an Expresso-aware html:link tag that will work with Transitions.

With 5.5, the Struts integration has been extended to bring Struts 1.1 features available to Expresso applications. These include:

  • Better XML configuration

  • Plug-ins

  • Request Processor

  • Global Exceptions

  • Dynamic Form Beans and Dyna Beans

  • Struts Validation

  • Commons Beans Utils Introspection

  • Action Messages

  • Modules

  • As well as the Struts Action and Action Form, among others.

Struts Users Getting Started with Expresso

Commonly asked questions and answers for users starting with Expresso from a Struts application:

  • Do I use Expresso standalone, or do I use it in conjunction with Struts? : Expresso incorporates struts. the main difference is that you use it indirectly.. almost without knowing struts is there.

  • Do I have to use all of Expresso or select components?: You don't have to use Expresso from the ground up. For example, you can use only DBObjects for your data access, and then straight Struts actions. This allows you to add Expresso components to your applicatin on an as need basis.

  • What's the learning curve like for Expresso? Is it comparable to Struts? : If you master struts, Expresso won't be a big deal to learn, since it shares several concepts. There are many utility classes that you learn easily with the JavaDocs, and the DBObjects are quite similar to EJBs. Personally, I spent a week to get started with the EDG, and some articles (there are two written by Peter Pilgrim, and published in theserverside.com), and in two weeks I was already developing with it. In addition, if you can afford it, the commercial support will help you a lot. Anyway, when working in a team, the learning curve is much lower than working alone (my case).

  • People often ask, how long does it take to learn Expresso?: Maybe less than a day to get it up, and another day or so to get the initial customization pointing to your own verbiage and images. For this investment of a day, you will be shocked to see what you get, especially if you compare it to writing your own infrastructure, or even worse, writing your site in pure servlets, without a supporting infrastructure. In all newbies find it takes about 2 weeks to get fully up to speed. Here is what one newbie had to say,

    • " Let me say that I think to understand expresso so that I can work with it, is very easy. I start to learn java, by using expresso last year. The normal user has only 2 things to do: Write DB Objects and handle the logic in a controller. Again a big step to future is to write a controller that's logic is driven by a XML file, may be it can be helpful to we write a DBObject too, that's driven by a xml file. The Next step is to write a drag and drop xml editor and than every child can create high performance web applications in java with expresso. ;- )"

  • Do I have to recode my hard-working Actions into Controllers?: To reduce memory consumption, Controller must now be thread-safe. They are no longer stored in each session. There are a couple of changes that must be factored into your code now.

    • (a) All necessary functionality that would be normally put in the Controller itself has been moved to parameters ControllerRequest and ControllerResponse. This includes parameter retrieval, formCache, and other commonly used controller services.

    • (b) Your controller must not use instance variables. Any instance variables must be moved manually to the Session.

  • My client wants to build an EJB-based Web application that can produce output for various devices, such as HTML and WAP. Would Expresso be a good fit for my client? : It depends on the needs of your client. At a first sight, it seems to be a good option, since it's lightweight, stable and scalable, and it can work with the EJBs. For example you can use entity EJBs to map your data, Use expresso's SecuredDBObjects to access them from inside Expresso, and use a session façade as an enter point who will delegate to expresso's controllers. Need to explain the philosophy of getting traditional Struts objects like and ActionForm instances. These are objects that Struts will be interested in getting if they are to use Expresso!!!)

  • I have written my own custom Struts Login. How do I integrate it? Or how do I use yours? I have written a lot of ActionForms? How are they used in Expresso? Can I still use them? In relation to ActionForms how to copy out fields from my LoginForm (action form) bean to an Expresso DBObject? : This will mean convenient functions / methods. Maybe PropertyUtils will have to be extended to support DBObjects. You cant expect Struts to simply hand code `DBObject.setField("UserName", loginForm.getUserName() )'.

  • How do I take advantage of Expresso? Is there an documentation for Struts users? : There sure is, see the following section to help you get started.

Expresso/Struts Webapp Example

One way of helping Struts developers find their our own way with Expresso would be reimplement the Struts Example webapp. in Expresso Framework, the Struts Example is mock up of a mail reader application. The Registration Page link in a specific example of DBObject with the Default View thing. The Login page is an example of DBController. Maybe you can use the com.expresso.jcorporate.services.controller.Login there already. The EditSubscription page could be an example of Subscription DBObject. One thing that is clear is that you cannot really mix the same coding styles. A Struts user might automatically look for ActionMapping class to do request dispatching `findForward("success")'. It is pretty what is going on in pure Struts code. You just have to look at the struts-config.xml to work just what an action. However, looking at the new Expresso (Struts) enabled Login controller above I could find no such equivalent. The Expresso best practice is different to say the least. The other part is the style of handling errors. Every Struts Action can have an ActionErrors instance. It is sort of similar to Expresso ErrorCollection. Briefly looking at it, the style is similar.

Taking Advantage of Struts

This document describes how this integration functions, and how to make maximum use of the Struts capabilities now included in Expresso, including URL mapping and JSP tag libraries. The areas involved in the Struts / Expresso integration are:

  • Views

  • Flow of Control

  • Tag Libraries

Views

Every State of every Controller produces at least one Input, Output, Transition or Block. These elements are handled by a "view", which can be one of (currently)the following types:

  • Default View

  • XML View

  • JSP View

  • JSF View

  • Velocity View

  • Webmacro View

Which view is used for which Controller/State depends on the configuration of that Controller in the Action Mapping section of struts-config.xml.

Flow of Control

Struts handles the mapping of a URL issued by the user to the execution of the appropriate Controller object by Expresso. Expresso Controller is now a directly subclass of org.apache.struts.action.Action. Therefore any type of Expresso Controller com.jcorporate.expresso.core.controller.Controller can be integrated into Struts. The integration has abstracted away the HTTP specific input and output to and from an Expresso Controller. To handle input to a controller there is a new object class ControllerRequest and to handle an output there is a new object class ControllerResponse.

Struts Tag Libraries

Expresso applications can take advantage of all of the standard Struts tag libraries. See the Tag Libraries Chapter for detailed documentation on each tag.

Other Open Source Project Integration

Struts is not the only Apache project woven into Expresso - Log4j, Junit, Regexp, Xalan, Xerces and others.

This is what makes Expresso better. Expresso's design, as an architectural framework, builds on and integrates best of breed open source components. We don't aim to recreate wheels but rather focus on what we do best. Jcorporate is the first vendor to offer an application infrastructure solution that's based on a software foundation but also unifying an enormous collection of disparate, non-integrated products and technologies. Expresso is based on a single, integrated software architecture that's designed to provide unparalleled ease-of-use, reliability and stability.

The following open source projects are integrated into Expresso. We work with these projects to ensure that the latest technological advancements are incorporated into Expresso.

From the Apache Jakarta team:

Table 2.1. Apache

AntA build system that we use for the Expresso development. The ANT jars are not included by default with the Expresso Framework.
CactusA server side unit testing extension to JUnit that allows for Servlet (and thus Controller) testing.
Commons-BeanUtilsA set of utility classes and methods for easing development with JavaBeans
Commons-CollectionsA library of various data structures that extend the data structures commonly included in Expresso.
Commons-DigesterA library that makes it easy to build XML-based configuration files
Commons-LoggingA logging system facade that makes an attempt to wrap various logging systems such as log4j, JDK 1.4 logger, etc. For your own apps, we still recommend the direct use of log4j.
Log4JA fast and fully configurable logging system that we use and recommend for all Expresso-based apps. Expresso has been integrated with Log4J for multi-tiered configurable logging. With log4j it is possible to enable logging at runtime without modifying the application binary. The log4j package is designed so that these statements can remain in shipped code without incurring a heavy performance cost. Logging behavior can be controlled by editing a configuration file, without touching the application binary.
OROA robust and feature rich Regular Expression Mapping framework
StrutsThe MVC framework upon with Expresso's Controller System is based. Struts encourages application architectures based on the Model-View-Controller (MVC) design paradigm. The goal of the Struts project is to provide an open source framework useful in building web applications with Java Servlet and JavaServer Pages (JSP) technology.
TilesThe servlet container bundled with the expresso-complete distribution, as well as the container used for the development environment.
Tomcat Servlet ContainerThe servlet container bundled with the expresso-complete distribution, as well as the container used for the development environment.
XalanUsed for XML transformations. The Xalan XSL Translator is an implementation of the XML Stylesheet Langauge (XSL). XSL provides tranlation capabilities for XML documents, provided much of the rich functionality of XML. Among other things, XSL allows developers to separate business logic from presentation logic, adding to the modularity of applications. Furthermore, XSL allows developers to maintain a single copy of data, translating the data for whatever purposes are necessary for the data. This simplifies maintenance of data, while also minimizing the likelyhood that different uses for data will result in separate versions will be out of sync.
XercesOne of the leading XML parsers. Expresso has been integrated with Xerces' XML parser and Xalan XSL transformation tool. The Xerces XML Parser provides an implementation of the Simple API for XML (SAX) and Document Object Model (DOM) for the eXtensible Markup Language (XML). Aside from providing a variety of three leter acronyms (TLA), XML allows for the simple creation of application-specific data languages. XML does so by providing markup for data in a consistent and easy-to-use manner. XML is used throughout Jcorporate's software development, from configuration files to dynamic web portal content, from themeable GUIs to message passing protocols.

Other projects which have been integrated include:

Table 2.2. Other Projects Integrated

BouncycastleExpresso has been integrated with Bouncy Castle Crypto APIs for portable and international strong encryption and security. The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms, it was developed by the Legion of the Bouncy Castle. Cryptix products are free, both for commercial and non-commercial use and are being used by developers all over the world. The lightweight API works with everything from the J2ME to the JDK 1.3.
HSQL Database EngineA 100% Pure Java relational database system that is included in the Expresso-Complete download bundle.
JUnitConsidered the premiere unit testing framework for the Java language. Expresso has been integrated with Junit for integrated unit testing and support of the Extreme Programming paradigm. JUnit provides a framework for building rich unit test suites for Java programs. At the heart of the XP methodology is the construction of test suites for projects before the project development is begun. This aides in the construction of software that meets specifications, and allows projects to be continually expanded without adversely affecting the functionality of existing components. To learn more about XP, visit XProgramming.com.
Oswego-ConcurrentDoug Lea's infamous threading library. Provides many useful primitives for working with multi-threaded applications.

Conclusion

Developing web applications is metaphorically speaking likecomparing different boxing weight divisions. You can choose to code from the beginning the raw JSP and Java Servlets API in the featherweight division. ou might choose a weightier framework like, Jakarta Struts, this is the flyweight division; Expresso is well within the medium weight division; WebSphere / Oracle AS / JBoss / Enhydra / BEA are all heavy weight because they guarantee Enterprise level features. If you require transaction integrity, load balancing servers, distributed session management, naming directory services, replication, failsafe, database access with guaranteed transaction monitoring then you are looking at one of the heavy weight guys. (With these application server prize-guys, you can usually start with a raw standard "J2EE Server" then buy extras like a personalisation server or front-end portal server.) The increase of scale goes up (ie the weight) with what the framework can do. You can have high level of security, transaction integrity, and business confidence if you choose one of J2EE application server with the supplementary portal product. As the "to J2EE or not J2EE" question is often a concern - allowing the ability to develop a project "non-j2ee", then scale up to J2EE without any major re-writing is a benefit. What we've been doing is working on a way to deploy our "Controller" objects (basically a collection of Action objects) as a session bean, and our "DBObjects" (the object/relational mapping classes in Expresso) as entity beans. You could then write your application using DBObjects and Controllers and Struts, then deploy it in one case with only a servlet/jsp engine, and in a more usage-intensive case in a full J2EE/clustered environment - without recoding anything. Given the capabilities to crank out the logic & UI that are so strong in Struts, it seemed to me that it would be a perfect fit with this effort in Expresso - that's one of the reasons we started in on integrating Struts in the first place. Struts is lightweight it is at the level of "intermediate web application development". It is easy to get into. It is popular, because there are already two Wrox books with dedicated chapters about it. Best of all it is an MVC framework that works and is established in the marketplace. Combined with Expresso makes a very winning combination because Expresso complements Struts with additional components for developing database-driven web application. Expresso is also established in the marketplace with a large number of downloads and a very large listserv. The market acceptance and utilization of these tools is important in the corporate environment because our project leads needs to be able to justify that development ideas are sound.

Contributors

The following persons have contributed their time to this chapter:

Note

Was this EDG documentation helpful? Do you wish to express your appreciation for the time expended over years developing the EDG doc? We now accept and appreciate monetary donations. Your support will keep the EDG doc alive and current. Please click the Donate button and enter ANY amount you think the EDG doc is worth. In appreciation of a $35+ donation, we'll give you a subscription service by emailing you notifications of doc updates; and donations $75+ will also receive an Expresso T-shirt. All online donation forms are SSL secured and payment can be made via Credit Card or your Paypal account. Thank you in advance.

Copyright © 2001-2004 Jcorporate Ltd. All rights reserved.