180 likes | 643 Views
Migrating Web Frameworks Using Water Transformations. Ahmed E. Hassan Richard C. Holt School of Computer Science University Of Waterloo. Web Applications. A software system whose functionality is delivered through the web Web browser is used as the client
E N D
Migrating Web FrameworksUsing Water Transformations Ahmed E. Hassan Richard C. Holt School of Computer Science University Of Waterloo
Web 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
Introduction to Active Pages Simple html file: (foo.html) <html> Welcome to CNN.COM </html> AP file: (foo.ap) <html> Welcome to <% Write(“CNN.COM”) %> </html>
Introduction to Active Pages Interesting AP file: (foo2.ap) <html> Welcome to <% Write(Server.name) %> </html>
Introduction to Active Pages file.ap Web Server Pre-processor file.html COM/ CORBA Objects Data Tables Data Flow
Structure of an Active Page Active Page HTML Server Scripts Client Scripts VBScript Perl JavaScript JavaScript VBScript
Web 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
Migrating from ASP to NSP • Language Transformation: • ASP uses VBScript • NSP uses JavaScript • Object Model Transformation: • Different set of built-in objects
ASP Example 1: <HTML> 2: <TITLE>Main Page</TITLE> 3: <% if Session("loggedIn") Then ‘ User already logged in%> 4: Welcome <%Response.Write(Session("username"))%> to your account, 5: To display balance <A HREF="balance.asp">click here</A> 6: <% Else ‘ User needs to login %> 7: Please Login first, <A HREF="login.asp">click here</A> 8: <% End If %> 9: </HTML>
Island 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
Water 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
Migration Overview rmHTML (in Perl) VBScript code rmComment (in Perl) ASP file Lang Trans. (in TXL) Object Model Trans. (TXL) addHTML (in Perl) JavaScript code addComment (in Perl) NSP file
1: <HTML> 2: <TITLE>Main Page</TITLE> 3: <% if Session("loggedIn") Then ‘ User already logged in%> 4: Welcome <%Response.Write(Session("username"))%> to your account, 5: To display balance <a HREF="balance.asp">click here</A> 6: <% Else ‘ User needs to login %> 7: Please Login first, <a HREF="login.asp">click here</A> 8: <% End If %> 9: </HTML> 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
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 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
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 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.
Conclusion • 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