PageBox for Java: Web application deployment using Java PageBox

for
 PageBox for Java 
 API 
 Demo 
 Background 
Presentation Download User guide Implementation Epimetheus euroLCC Prometheus

euroLCC

Objective

This document explains how to use the euroLCC Web archive and presents the euroLCC implementation.

Assumptions

In this document we assume that you have installed:

  • Java JDK 1.4

  • Java Web Services Developer pack (WSDP) 1.2, which includes Tomcat 5

  • PageBox for Java version 0.0.9ter or above

  • MySql. Pandora was tested with version MySql 3.23.53. It should be easy to adapt to other databases.

See the PageBox installation guide for more information about the PageBox installation.

Overview

euroLCC is a Web application that helps finding Low Cost Carrier (LCC) flights between origin and destination airports. euroLCC illustrates the use of the generic installation class. Starting with version 0.0.2 euroLCC is misnamed. The initialization files of euroLCC describe European, Australian, American and other countries airports and some LCCs and LCC routes.

For background information about Air Transport industry and specifically about Low Cost Carriers you may read our presentation of the Air Transport industry. European market of Low Cost carriers is especially interesting to study because:

  • European LCCs have just started their consolidation phase. We list 16 European carriers but there are probably more European LCCs.

  • Main airports are congested and there is no more space for airports close to cities. European LCCs tend to operate flights from airports far from cities (like Stansted or Beauvais). We only consider connections in the same airport.

  • Distances are short. Flights tend to be one hour long. In some cases it can make sense to go in the opposite direction to get a connection to the destination. It would make sense to also consider bus and rail services.

For comparison we added two American LCCs (South West and Jet Blue) and two LCCs from Australia / New Zealand (Freedom Air and Virgin Blue). Though we took a rather close definition of LCC in our selection if you analyze the route.csv file with a spreadsheet you may find that we compare oranges and apples. There seems to be at least three kinds of LCCs:

  1. Pure LCCs like South West, Ryan Air and EasyJet that challenge network carriers with simpler procedures and lower operating cost, much in the same way as Laker used to do

  2. LCCs created by network airlines to compete with pure LCCs

  3. Some German LCCs seem to offer a sort of charter flights to leisure locations

To test euroLCC you need:

  1. To setup a PageBox

  2. To subscribe the PageBox to a Repository

  3. To publish the euroLCC archive on the Repository

PageBox

The PageBox must be configured:

  • To run the installation class of euroLCC.war (the generic Install class)

  • With a JDBC connection

You can use the same PageBox as for Pandora distributed.war and central.war. For more details about the database and the rules.xml setting you can look at the Pandora user guide. You can also use this document to understand how to subscribe your PageBox and publish euroLCC.

Installation verification

If you configured properly the PageBox, euroLCC.war should be properly installed.

You can check that the database tables were properly setup. For instance to check the euroLCC database run the mysql command.

use pagebox_eurolcc;

mysql> select * from airport;

+------+---------------------------------------+

| code | name |

+------+---------------------------------------+

| AAR | Aarhus Tirstrup |

| ABZ | Aberdeen Dyce |

| ADB | Izmir Adnan Menderes |

...

| ZAD | Zadar |

| ZRH | Zurich Kloten |

+------+---------------------------------------+

166 rows in set (0.00 sec)

mysql> select * from route;

+------+---------------------------------------+

| origin | destination | url |

+------+---------------------------------------+

...

| BGY | LBA | http://www.jet2.co.uk/ |

| NCE | LBA | http://www.jet2.co.uk/ |

| PMI | LBA | http://www.jet2.co.uk/ |

+--------+-------------+---------------------------------------------+

1177 rows in set (0.02 sec)

The database is created by the PageBox and its name is made of the PageBox directory and of the archive name. Its name may be different in your case. In the case of euroLCC the generic installer creates two tables:

  • An airport table with 166 rows

  • A route table with 1177 rows

Use

euroLCC includes three forms

  • airline to display the airlines defined in the euroLCC tables

  • airportcode to display the airport code using the airport name

  • route to display possible flights between an origin and a destination

airline

Start your browser. If your PageBox is configured with the rules.xml listed in the Pandora user guide:

<rules>

<subscriber>

<name>subscriber</name>

<password>subscriber</password>

</subscriber>

<publishers>

<publisher>

<name>publisher</name>

<allow>install</allow>

</publisher>

</publishers>

<repositories>

<repository>

<name>http://localhost:8080/Repository/jaxrpc/RepoQueryIF</name>

<allow>install</allow>

</repository>

<default>

<allow>none</allow>

</default>

</repositories>

<target>E:\java\PageBox1</target>

<root-path>/PageBox1</root-path>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost/pandora</url>

</rules>

You can display the Airline list of euroLCC for an WSDP running locally on default port (8080) with http://localhost:8080/PageBox1/euroLCC/airline. You should get this:

This list contains the URLs of the sites of the European Low Cost Carriers considered in euroLCC.

airportcode

You can click on the Airport codes link on the top right of the Airline list or go to http://localhost:8080/PageBox1/euroLCC/airportcode. You should get this:

Select an airport name on the drop down list and click the Get code button. Then the airport code is displayed.

route

You can click on the Routes link on the top right of the Airline list or go to http://localhost:8080/PageBox1/euroLCC/route. You should get this:


Select an origin airport on the Origin drop down list and a destination airport on the Destination drop down list. Then click on the Get route button. You should get a list like this.

The first displayed route is a direct flight. Other routes have a connection. For instance you can go from Nice to Barcelona using a Virgin Express flight to Geneva followed by an Easy Jet flight from Geneva to Barcelona.

Notes:

  • euroLCC doesn’t check if the connection is convenient

  • euroLCC only considers routes with at most one connection

  • Some professional applications emulate a browser and parse the Low Cost Carrier responses to display the cost and allow booking. This model has some drawbacks. First the Low Cost Carrier brand is hidden to some extent. Second this parsing is a time-consuming task: each time a Low Cost Carrier changes its site you may need to change the parsing. Third the payment implies getting the passenger name, credit card number, etc and forwarding them to the involved carriers.

Implementation

Design choices

  1. Model View Controller (MVC) architecture

  2. Data stored in a RDBMS and accessed using JDBC

  3. Use of the generic Installation class

euroLCC is made of the following components:

Name

Function

euroLCC/AirlineBean.java

Airline model. Displays the Airline list.

airline.jsp

Airline view. Displays the Airline frame.

euroLCC/Airline.java

Airline controller. Servlet handling user requests.

euroLCC/AirportCodeBean.java

Airport code model. Displays the Airport list.

airportcode.jsp

Airport code view. Displays the Airport code frame.

euroLCC/AirportCode.java

Airport code controller. Servlet handling user requests.

euroLCC/RouteBean.java

Route model. Displays the Airport lists and the Route list.

euroLCC/Segment.java

Describes a flight (origin, destination and URL of the carrier)

route.jsp

Route view. Displays the Route frame.

euroLCC/Route.java

Route controller. Servlet handling user requests.

Install.java

Generic Installation class

Install

Use

The generic Installation class:

  • Populates the archive database with data found in an sqlinstall directory

  • Updates the archive web.xml file

The sqlinstall directory must be a subdirectory of the installation directory of the archive.

The sqlinstall directory must contain Comma Separated Value (.csv) files with the same number of fields on each line, in the following format:

sqlinstall

Database

File Name without extension

Table name

First line

Column names

Second line

Column definitions

Next lines

Data of a row to insert in the table

Here is the beginning of the euroLCC’s route.csv:

origin,destination,url

char(3) not null,char(3) not null,varchar(128) not null

AMS,BCN,http://www.easyjet.com/

AMS,BFS,http://www.easyjet.com/

...

Here is the beginning of the euroLCC’s airport.csv:

code,name

char(3) not null,varchar(64) not null

AAR,Aarhus Tirstrup

ABZ,Aberdeen Dyce

The generic installation class replaces the first <!--Install_wordir--> place holder in web.xml by the installation directory of the archive.

Implementation

The generic Install class implements the InstallIF interface and is called by the PageBox once the archive has been installed on the target Application server and before the archive is dynamically deployed on the Application server. For more information about the Installation interface see the developer guide and the installation guide.

install

The install method is a method of the InstallIF interface called by PageBox to perform a post installation. The install method enumerates the files in the sqlinstall directory and for each file found calls a create method.

Then the install method calls an updateWebXml method to replace the first <!--Install_wordir--> place holder in web.xml by the installation directory of the archive.

create

The create method processes the creation and the population of a table described in a sqlinstall file. The create method first calls a readFile method to read and parse the file.

If the file describes a table but doesn’t contain data the file has only two lines. In this case and in case of archive update create does nothing in order to preserve the existing table content. Otherwise create drops and creates a table with the same name as the file (without extension) and calls a createData method to populate the table.

readFile

The readFile method reads and parses a csv file. readFile returns the number of lines in the file and setup the following variables:

Name

Function

name

Table name

names

Array of column names

types

Array of column

rows

ArrayList containing an array of field values for each row to add

createData

For each array found in the rows ArrayList createData inserts a new row in the table.

uninstall

The uninstall method is a method of the InstallIF interface. The uninstall method is called by PageBox to perform a de-installation. In case of de-installation for update uninstall does nothing. Otherwise the uninstall method enumerates the files in the sqlinstall directory and for each file found drops the table with the same name as the file (without extension).

updateWebXml

updateWebXml updates the archive web.xml. The web.xml is expected to contain a workdir context parameter with an update placeholder:

<context-param>

<param-name>workdir</param-name>

<param-value><!--Install_wordir--></param-value>

</context-param>

updateWebXml replaces <!--Install_wordir--> by the archive directory.

Here is how it works. updateWebXml

  1. Checks that web.xml exists at the expected location archive_directory/WEB-INF/web.xml

  2. Creates a new configuration file web2.xml

  3. Reads web.xml and looks for <!--Install_wordir-->

  4. Rewrites on web2.xml but when it finds <!--Install_wordir-->. In that case updateWebXml writes the path of the archive directory

  5. Renames web2.xml into web.xml

Use in euroLCC

In case of euroLCC sqlinstall contains two files, route.csv and airport.csv. therefore the generic installation class creates two tables:

  • route that contains (origin airport code, destination airport code, LCC URL) uples

  • airport that contains (airport code, airport name) uples

AirlineBean

The AirlineBean class handles a TreeSet containing the carriers’ URLs.

The getAirlines method of AirlineBean is called by airline.jsp to format the carriers’ URLs in HTML table rows.

Airline

The Airline servlet has two main methods, initialize called in its doGet method and doGet called when the user queries the airline URL.

  • initialize instantiates an AirlineBean object, retrieves the carriers’ URLs from the route table and populates the TreeSet of the AirlineBean object

  • doGet adds the AirlineBean object to the request attributes and forwards the request to airline.jsp

AirportCodeBean

The AirportCodeBean class handles a TreeMap whose keys are airport names and values airport codes and the currently selected airport name.

The getNames method of AirportCodeBean is called by airportcode.jsp to format the airport names in HTML select options.

AirportCode

The AirportCode servlet has three main methods, initialize called in its doGet and doPost method, doGet called when the user queries the airline URL and doPost called when the user clicks on the Get code button.

  • initialize instantiates an AirportCodeBean object, retrieves the airport names and codes from the airport table and populates the TreeMap of the AirportCodeBean object

  • doGet adds the AirportCodeBean object to the request attributes and forwards the request to airportcode.jsp

  • doPost retrieves the airport name selected by the user, adds the corresponding airport code and the AirportCodeBean object to the request attributes and forwards the request to airportcode.jsp

RouteBean

The RouteBean class handles one origin AirportCodeBean, one destination AirportCodeBean and an ArrayList of the routes found between the selected origin and destination. A route can be made of one or two Segment objects. A Segment describes a flight origin, flight destination and carrier URL.

The getAirlines method of RouteBean is called by route.jsp to format the flight origins, flight destinations and carrier URLs in HTML table rows. getAirlines enumerates the route ArrayList and for each route the route Segments.

Route

The Route servlet has four main methods, initialize called in its doGet and doPost method, doGet called when the user queries the airline URL, doPost called when the user clicks on the Get route button and findRoutes called by doPost to find routes.

  • initialize instantiates a RouteBean object, retrieves the airport names and codes from the airport table to populate the embedded origin and destination AirportCodeBeans

  • doGet adds the RouteBean object to the request attributes and forwards the request to route.jsp

  • doPost retrieves the origin and destination selected by the user, calls findRoutes, adds the RouteBean object to the request attributes and forwards the request to route.jsp

  • findRoutes first retrieves direct flights with a SQL request SELECT url FROM route WHERE origin="origin" AND destination="destination". To find routes with one connection findRoutes first lists flights whose destination is the requested destination. Then for each found origin findRoutes retrieves flights whose origin is the requested origin and destination is the found origin.

Contact:support@pagebox.net
2002-2004 Alexis Grandemange. Last modified .