2012-03-29

STEP back

Recently I was asked to do a small demo of the STEP Framework.
I picked the last version I worked on: STEP Tough, instrumented for performance monitoring.

1. I checked out the source code from SourceForge:

svn co https://stepframework.svn.sourceforge.net/svnroot/stepframework/branches/1_4_toughstep_maintenance toughstep

2. I installed stepcat 1.4-6.0.14, meaning that it contains the libraries for STEP 1.4 and runs Apache Tomcat 6.0.14

Here is stepcat's readme:
"

*********************
*** Tomcat for STEP ***
*********************

This file summarizes the installation procedure and describes the
configuration changes made to prepare the package.

The package version number refers to the supported STEP Framework version and
to the Apache Tomcat version.

Please refer to webapps/ROOT/index.html for the listing of other included and
recommended software versions.

--

Installation guide:

1 - Install recommended JDK

2 - Install recommended database

3 - Unzip package

4 - Define environment variables

JAVA_HOME C:\java\jdk\1.6.0_18
CATALINA_HOME C:\temp\stepcat-1.x-6.0.14
ANT_HOME C:\temp\stepcat-1.x-6.0.14\apache-ant
STEP_HOME C:\temp\stepcat-1.x-6.0.14

5 - Extend PATH environment variable to include:
%JAVA_HOME%\bin;%ANT_HOME%\bin;%CATALINA_HOME%\bin;

6 - Open new console and test command line tools:

java -version
javac -version
wsimport -version
xjc -version

ant -version
catalina version

7 - The server comes configured to run in C:\temp\stepcat-1.x-6.0.14.
To change configuration to a different location
execute 'ant -f bin\relocate.xml' in the new location.

8 - Start server

catalina start
browse http://localhost:8080

--

This is a replicable server version.

To change the server ports, replace all occurrences of the following numbers:
8080 - HTTP Port
8005 - Admin Port
8443 - HTTPS Port

The most important changes to make are in the conf folder.

These changes can be automated using Ant.
Refer to 'bin\replicate-server.xml' for more information.


--

Package preparation steps:

Unzipped apache-tomcat-6.0.14.zip to stepcat-1.x-6.0.14

Unzipped apache-ant-1.7.1.zip to stepcat-1.x-6.0.14/apache-ant

Copied tail.exe (win32 binary) to stepcat-1.x-6.0.14/bin

Copied servlet-api.jar and jsp-api.jar to STEP lib

Copied all stepframework/lib jar files to stepcat-1.x-6.0.14/lib

stepframework/src/lib/stepframework.jar is NOT included.
(Applications will have to include this JAR themselves.
The rationale is to give developers more visibility of the framework's source code
and to allow easier modification and experimentation.)

Copied junit-4.5 to stepcat-1.x-6.0.14/apache-ant/lib/junit.jar and
to stepcat-1.x-6.0.14/lib/junit.jar

Deleted all stepcat-1.x-6.0.14/webapps except ROOT and manager.

Renamed stepcat-1.x-6.0.14/webapps/ROOT/index.html to
stepcat-1.x-6.0.14/webapps/ROOT/index-tomcat.html
Added new index.html to stepcat-1.x-6.0.14/webapps/ROOT
(added STEP logo, quick link to manager)

Added new user with the role manager to
stepcat-1.x-6.0.14/conf/tomcat-users.xml:



Documentations were moved to stepcat-1.x-6.0.14_docs
Added index.html to stepcat-1.x-6.0.14_docs.

created Eclipse User Library named 'STEP dependencies' including all
STEP framework dependency libraries, but not STEP itself.

Saved user library export file in 'eclipse/stepdeps.userlibraries'.

--

Acknowledgements:

Apache Software Foundation and
all other authors of used open-source software packages.

--

"

3. Next I installed/started MySQL 5.1

I created the databases 'flight' and 'mediator' and the user 'step' without password.
I then granted all rights for these databases to the user.


4. Next I compiled and deployed the Trip Planner demo application

I did everything except the test.

Here is stepframework\src readme:
"

STEP Framework Demo: Trip Planner

Table of contents
==============================

1. Introduction
2. Structure
3. Compiling
4. Installing
5. Deploying
6. Running
7. Testing
8. Extensions


1. Introduction
==============================

The Trip Planner is a system for selling trip packages via a web interface.
It is composed by several distributed systems, which act together through a
mediator that interacts with the clients.

This demonstration version of the Trip Planner supports booking a flight
and uses 3 demonstration Framework Extensions:
- hello - just says hi when it intercepts the services or web services
- trace - prints tracing data
- errors - allows creating test errors

Extensions enable the programmer to add code around the services layer
and around the Web Services layer, orthogonally to the application code.
Each extension can be enabled or disabled simply by editing the
extensions.properties configuration file.



2. Structure
==============================

The Trip Planner system is composed by 2 separate domains: flight and
mediator. The flight domain manages flight reservations. The mediator domain
mediates the interaction between client and the other reservation domains
(only the flight in this demonstration).

Conceptually, each application consists of 4 layers:

+--------------+
| Presentation |
+--------------+
| Services |
+--------------+
| Domain model |
+--------------+
| Data access |
+--------------+

These layers are developed in sub-sub-projects of the flight and the mediator
sub-projects. The entire project' structure is as follows:

.
|-- flight
| |-- core
| `-- view
`-- mediator
|-- core
|-- view
`-- web

Both 'core' sub-sub-projects implement all the layers from the bottom up to
the services layer. The 'view' sub-sub-projects implement the classes that
can be returned from the services to the presentation layer; this also
includes any exceptions that can be thrown. The 'web' sub-sub-project
implements the presentation layer of the mediator. There are no presentation
layers implemented for the flight domain.


3. Compiling
==============================

The project uses Apache Ant and the ImportAnt library. At each level there is
a build file that takes care of building the project at that specific level.
Thus, the entire project can be built simply by invoking at the top level:

$ ant

Note that Ant and JWSDP should be properly installed for this command to work.


4. Installing
==============================

Two databases must be configured before running the distributed applications.
By default these are:

- For flight:

database.host=localhost
database.name=flight
database.username=step
database.password=

- For mediator:

database.host=localhost
database.name=mediator
database.username=step
database.password=

Therefore, either:

- create the default databases on the localhost's mysql server with the
configured username and password access, or;

- change in the hibernate.cfg.xml and dbunit.properties files the database information
(flight-ws/src/hibernate.cfg.xml, flight-ws/tests/dbunit.properties, and
mediator-web/src/hibernate.cfg.xml, mediator-web/src/dbunit.properties).

Note: after making changes to the configuration propertied you should rebuild
you applications to ensure that the new values have been correctly propagated
to the packed jars. ("ant clean build" at the top level ensures that)

After the database locations are configured, we need to create the databases.

To create the tables execute at the top level:

$ ant hibernatetool

When executing creating the tables for the first time, some errors like the
following may appear:

"[hibernatetool] Error #1: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table mediator.Client' doesn't exist"

They should all be ignored.

Then check that the tables have been correctly created in each database.


5. Deploying
==============================

It is now possible to deploy the flight and mediator applications. Each
application can be deployed by its own build.xml file, but for convenience
there is a top level ant target to do that. Execute:

$ ant deploy

If any of these application is already deployed use the corresponding
"redeploy" target instead.


6. Running
==============================

Point your favourite web browser to http://localhost:8080/mediator-web to start
using the application. Try booking a flight from Lisbon to New York!



7. Testing
==============================

Running tests in a distributed system requires all the tables to be stored
in the same database.
This is necessary because of the way that DBUnit populates data before each
test method.

The data populated for the tests can then be used for user testing the application.

To run tests for the distributed application, edit flight-ws/tests/dbunit.properties and
mediator-web/tests/dbunit.properties and set the same database in both.

Then, at the top level rebuild the applications and create the tables.

$ ant clean build hibernatetool

Then, redeploy the flight web service and mediator web application

$ ant redeploy


To run tests for one domain at a time:

$ ant run-tests-flight
$ ant run-tests-mediator

To run all tests:

$ ant run-tests


8. Extensions
==============================

To see output from the extension engine and from the extensions themselves,
look at the application server's log file.

Feel free to experiment with the extensions configuration files and source code.

The flight extensions configuration is located in flight-ws/src.
The mediator extensions configuration is located in mediator-web/src.

The logging produced by the extensions engine can be adjusted in the
log4j.properties files, for each component and application.

"

5. I used flight-perf's DomainDataGenerator to populate the database


6. Then I tested the application.

http://localhost:8080/mediator-web/

Before:

After:

--

It had been a long time since I had seen these screens.
There a lot of loose ends in the code and documentation, but they are mostly small things.
Most of all, I think you can still learn a lot from the source code.

Who knows what the future holds for the STEP Framework? :)

No comments: