Title: Migrating Web Frameworks Using Water Transformations
1Migrating Web FrameworksUsing Water
Transformations
Ahmed E. Hassan Richard C. Holt School of
Computer Science University Of Waterloo
2Web Applications
- A software system whose functionality is
delivered through the web - Web browser is used as the client
- HTTP state-less protocol is used as the
communication protocol - Many development frameworks have been proposed
JSP, NSP, ASP, ASP, CF - Active pages are their building blocks
3Introduction to Active Pages
- Simple html file (foo.html)
- lthtmlgt
- Welcome to CNN.COM
- lt/htmlgt
- AP file (foo.ap)
- lthtmlgt
- Welcome to lt Write(CNN.COM) gt
- lt/htmlgt
4Introduction to Active Pages
- Interesting AP file (foo2.ap)
- lthtmlgt
- Welcome to lt Write(Server.name) gt
- lt/htmlgt
5Introduction to Active Pages
file.ap
file.html
Web Server Pre-processor
COM/ CORBA Objects
Data Tables
Data Flow
6Structure of an Active Page
Active Page
Client Scripts
Server Scripts
HTML
JavaScript
Perl
VBScript
VBScript
JavaScript
7Web Application Development Frameworks
- Abstract details of developing an application
- access control
- client state maintenance
- relational database access
- file manipulations on the server
- Each framework
- uses its own programming language
- Each framework provides a set of built-in objects
8Migrating from ASP to NSP
- Language Transformation
- ASP uses VBScript
- NSP uses JavaScript
- Object Model Transformation
- Different set of built-in objects
9ASP vs NSP built-in objects
10ASP Example
1 ltHTMLgt 2 ltTITLEgtMain Pagelt/TITLEgt 3 lt if
Session("loggedIn") Then User already logged
ingt 4 Welcome ltResponse.Write(Session("username
"))gt to your account, 5 To display balance ltA
HREF"balance.asp"gtclick herelt/Agt 6 lt Else
User needs to login gt 7 Please Login first, ltA
HREF"login.asp"gtclick herelt/Agt 8 lt End If
gt 9 lt/HTMLgt
11Island Grammars
- Used for robust parsing and extraction
- Recover from errors and handle ill defined
grammars - Island
- Tokens of interest (VBScript Code)
- Parsed and expanded
- Water
- Un-interesting tokens (HTML/Comments)
- Skipped
12Water Transformations
- Extends the idea of Island Grammars for code
transformations - Converts Water to special Islands
- Performs code transformation on Islands using
traditional approaches - Convert back the special post-transform. Islands
to Water
13Migration Overview
rmComment (in Perl)
rmHTML (in Perl)
VBScript code
ASP file
Lang Trans. (in TXL)
Object Model Trans. (TXL)
addComment (in Perl)
addHTML (in Perl)
JavaScript code
NSP file
141 ltHTMLgt 2 ltTITLEgtMain Pagelt/TITLEgt 3 lt if
Session("loggedIn") Then User already logged
ingt 4 Welcome ltResponse.Write(Session("username
"))gt to your account, 5 To display balance lta
HREF"balance.asp"gtclick herelt/Agt 6 lt Else
User needs to login gt 7 Please Login first, lta
HREF"login.asp"gtclick herelt/Agt 8 lt End If
gt 9 lt/HTMLgt
Input ASP file
1 HTMLCALL() 2 if Session("loggedIn") Then
User already logged in 3 HTMLCALL() 4
Response.Write(Session("username")) 5
HTMLCALL() 6 Else User needs to login 7
HTMLCALL() 8 End If 9 HTMLCALL()
After rmHTML
151 HTMLCALL() 2 if Session("loggedIn") Then
User already logged in 3 HTMLCALL() 4
Response.Write(Session("username")) 5
HTMLCALL() 6 Else User needs to login 7
HTMLCALL() 8 End If 9 HTMLCALL()
After rmHTML
1 HTMLCALL() 2 if Session("loggedIn") Then
3 COMMENTCALL() 4 HTMLCALL() 5
Response.Write(Session("username")) 6
HTMLCALL() 7 Else 8 COMMENTCALL() 9
HTMLCALL() 10 End If 11 HTMLCALL()
After rmCmt
161 HTMLCALL() 2 if Session("loggedIn") Then
3 COMMENTCALL() 4 HTMLCALL() 5
Response.Write(Session("username")) 6
HTMLCALL() 7 Else 8 COMMENTCALL() 9
HTMLCALL() 10 End If 11 HTMLCALL()
After rmCmt
1 HTMLCALL() 2 if (Client.loggedIn)) 3
COMMENTCALL() 4 HTMLCALL() 5
write(Client.username)) 6 HTMLCALL() 7
else 8 COMMENTCALL() 9
HTMLCALL() 10 11 HTMLCALL()
After TXL Trans.
17Conclusion
- An approach to migrate ASP to NSP is presented
- Language Transformation
- Object Model Transformation
- Pre/Post processing steps are used to massage the
input and transform it to a traditional program - The approach preserves the location of the
comments and HTML compared to the source code to
ease future maintenance