Step-by-Step Legacy Migration with Aranea Jevgeni Kabanov R&D lead, Aranea project lead Webmedia, Ltd.

Slides:



Advertisements
Similar presentations
Web Server Programming
Advertisements

 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
MSc. Publishing on WWW JavaScript. What is JavaScript? A scripting language devised by Netscape Adds functionality to web pages by: Embedding code into.
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
Struts Basics SSE USTC Qing Ding. Agenda What is and Why Struts? Struts architecture – Controller: Focus of this presentation – Model – View Struts tag.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
DT228/3 Web Development JSP: Directives and Scripting elements.
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Web programming for project students Dr Jim Briggs.
Session-01. Layers Struts 2 Framework The struts 2 framework is used to develop MVC-based web application. Struts 1.0 was released in June The.
C++ fundamentals.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Apache Jakarta Tomcat Suh, Junho. Road Map Tomcat Overview Tomcat Overview History History What is Tomcat? What is Tomcat? Servlet Container.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
JSP Java Server Pages Softsmith Infotech.
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
1 Dr Alexiei Dingli Web Science Stream Introducing Rails.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Fall CIS 764 Database Systems Design L8. Web ….
Struts: An Insiders View October Abstract Struts is the de facto standard framework for Java web applications, but where did it come from, and where.
Peter Laird. | 1 Building Dynamic Google Gadgets in Java Peter Laird Managing Architect WebLogic Portal BEA Systems.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Struts Framework Anna Paščenko. What is Struts?  An open source framework for building Java web applications.
CS-4220 Dr. Mark L. Hornick 1 Java Server Pages. HTML/JSPs are intended to be used as the views in an MVC- based web application Model – represents an.
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
©SoftMoore ConsultingSlide 1 Filters. Filters can be used in a web application to intercept, examine, and possibly transform requests or responses associated.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
RESTful Web Services What is RESTful?
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Java Server Pages. 2 Servlets The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
Enterprise Java v050228MVC1 Model, View, Controller Web Architecture.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
Java Servlets By: Tejashri Udavant..
Aranea – Java Web Framework Construction and Integration Kit
Web Software Model CS 4640 Programming Languages for Web Applications
Haritha Dasari Josue Balandrano Coronel -
Introduction to Servlets
RESTful Web Services.
Presentation transcript:

Step-by-Step Legacy Migration with Aranea Jevgeni Kabanov R&D lead, Aranea project lead Webmedia, Ltd.

Motivating scenario “Stakeholders have a large web application written in Struts. They consider Struts legacy and want to continue development in JSF. However rewriting all of the code would take too much time, effort and money and would halt the ongoing development.“

Our solution 1.Use Aranea web integration layer to run different technologies side-by-side 2.Refactor the application into independent coarse-grained components 3.Start new development immediately and change old code only when requirements change – step-by-step migration

Goal Get rid of legacy and custom web frameworks in your application

Aranea Aranea began as an Object-Oriented MVC Web Framework From the onset we had plans to build web integration on the same platform Aranea Integration has been released to public yesterday :)

Disclaimer Aranea MVC is stable and used in production Aranea Integration is beta and used in pilot migration projects Everything is Open-Source with documentation and support available for free from araneaframework.org Commercial support/training/consulting is provided at araneaframework.com

Organization Aranea Component Model Widgets Flow navigation Aranea Integration Layer Struts, JSF, GWT Step-by-step migration Principles Case study

Aranea Component Model Every component is a first-class object Objects are created by the programmer No (XML) mappings State is in the object (no scopes) Components, pages and flows are represented by first-class widgets

Hello World! NameWidget name.jsp Reads the name from requests and passes it to HelloWidget HelloWidget hello.jsp Renders the “Hello ${name}!” greeting, where name is given by the caller.

NameWidget public class NameWidget extends BaseUIWidget { //Called on “hello” event public void handleEventHello() { String name = //reads “name” from request parameters (String) getScopedData().get("name"); getFlowCtx().replace(new HelloWidget(name)); } Insert your name: name.jsp:

HelloWidget public class HelloWidget extends BaseUIWidget { private String name; //Widget state is in its fields public HelloWidget(String name) { this.name = name; //We could pass any Java object here } public String getName() { return this.name; } public void handleEventBack() { getFlowCtx().replace(new NameWidget()); } Hello ${widget.name}! hello.jsp:

web.xml... araneaServlet AraneaSpringDispatcherServlet araneaApplicationStart example.NameWidget 1 araneaServlet /main/*...

Flows Currently we use replace() which means: A new instance is created every time We know where to return Flow1

Flows What we would want is to preserve the instance and nest the new flow Flow1 Flow2

Flows start() and finish() do exactly that: public class NameWidget extends BaseUIWidget {... public void handleEventHello() {... getFlowCtx().start(new HelloWidget(name)); } public class HelloWidget extends BaseUIWidget {... public void handleEventBack() { getFlowCtx().finish(null); }

Including widgets Widgets can be included, let’s try to use HelloWidget inside NameWidget like this handleEventHello() HelloWidget We assume that the “back” button was removed from HelloWidget

Including widgets First let’s modify the HelloWidget: public class HelloWidget extends BaseUIWidget { private String name; public HelloWidget(String name) { this.name = name; } public String getName() { return this.name; } public void setName(String name) { this.name = name; }

Including widgets Now let’s add a HelloWidget instance public class NameWidget extends BaseUIWidget { private HelloWidget helloWidget; protected void init() { helloWidget = new HelloWidget("Stranger"); addWidget("hello", helloWidget); } public void handleEventHello() { String name = (String) getScopedData().get("name"); helloWidget.setName(name); }

Including widgets Insert your name: And finally we include the widget in the JSP

Including widgets So this is what we get: helloWidget.setName(“Jevgeni”) HelloWidget, helloWidget

Widgets are objects We can include several widgets of same class on one page public class RootWidget extends BaseUIWidget { protected void init() { addWidget("hello1", new NameWidget()); addWidget("hello2", new NameWidget()); addWidget("hello3", new NameWidget()); }

Flows are objects public class RootWidget extends BaseUIWidget { protected void init() { addWidget("flowContainer1", new StandardFlowContainerWidget(new NameWidget())); addWidget("flowContainer2", new StandardFlowContainerWidget(new NameWidget())); addWidget("flowContainer3", new StandardFlowContainerWidget(new NameWidget())); } We can also include several flow containers on one page

Goal Get rid of legacy and custom web frameworks in your application

Our Solution 1.Use Aranea web integration layer to run different technologies side-by-side 2.Refactor the application into coarse-grained integration components 3.Start new development immediately and change old code only when requirements change – step-by-step migration

Requirements We want to implement widgets using any framework/technology available This can mean running a whole application in one widget and another application in its sibling Without any changes to the technology In fact we want to do that retroactively, reusing existing applications

Aranea Integration Layer Integration Layer API is based around widgets: StrutsWidget, JsfWidget, GwtWidget Widgets receive the URI of the starting point of the subapplication E.g. new StrutsWidget(“/Welcome.do”); AraneaUtil gives access to all of the Aranea API from embedded applications

Struts Integration Problems 1.Session and request attributes share the same namespace and can clash 2.Request parameter names will clash already during form submission 3.Struts navigates between pages by changing the actual URL 4.HTML limits usage of some tags

Problem 1: Attributes We can make request attributes local, by wrapping HttpServletRequest and saving them in a local map Since HttpSession can only be accessed via HttpServletRequest we can do the same thing to session attributes

Problem 2: Parameters Since parameter names clash already during the submission of request we need to solve the problem in HTML We can do it by introducing prefixes to each field name referring to the containing widget The request wrapper restores the original names

Problem 3: Navigation We put a filter over the Struts servlet that will include the Aranea servlet While Aranea renders the particular StrutsWidget, it will include the according action Therefore it will render in correct place as will everything else

Problem 3: Navigation However we need to include some information that is used to render Aranea Servlet path Window id Current widget id We do that by overriding encodeURL() in request wrapper

Problem 4: HTML There are two main things we need to change in Struts HTML output: Forms cannot be nested and must be escaped Field names must be prefixed These are easy to change using a lexer (not even a parser) on the output stream To escape forms we construct a JavaScript object with the same properties/methods

name.jsp & hello.jsp <form method="get" action=" "> Hello ${param.name}! ">Back

HelloNameWidget & RootWidget public class HelloNameWidget extends StrutsWidget { public HelloNameWidget() { super("/name.jsp"); } public class RootWidget extends BaseUIWidget { protected void init() { addWidget("hello1", new HelloNameWidget()); setViewSelector("root"); } <input type="submit" onclick=“new Aranea.Struts.Form(…).submit()" value="Say hello!"> Output:

What will happen? public class RootWidget extends BaseUIWidget { protected void init() { addWidget("hello1", new HelloNameWidget()); addWidget("hello2", new HelloNameWidget()); addWidget("hello3", new HelloNameWidget()); setViewSelector("root"); }

DEMO

Generalizing Integration The approach taken with Struts can be easily extended to any action-based framework Including custom ones In fact most of it is applicable to component- based frameworks as well However component-based frameworks will usually allow us to solve these problems simpler

JSF Integration We use the same approach to encapsulate request and session attributes Form fields can be prefixed by overriding the naming container (form) Navigation can be solved by overridding the view handler No postprocessing necessary!

DEMO

GWT Integration Essentially the simplest, as almost everything happens on the client side Two problems Using RPC to call widget methods Restoring client-side state after a full request Not solved yet!

Our Vision

Goal Get rid of legacy and custom web frameworks in your application

Our Solution 1.Use Aranea web integration layer to run different technologies side-by-side 2.Refactor the application into coarse-grained integration components 3.Start new development immediately and change old code only when requirements change – step-by-step migration

Refactoring 1.Enable Aranea Integration and sanitize HTML (produces working application) 2.Extract layout, menu and login 3.Split application into coarse-grained components

Case Study Estonian Tax Inspection application module Connected with Forestry and European Union directives Part of a large application family based on common architecture that manage all tax and customs needs

Technologies MVC web framework is Struts Presentation done using Velocity and Tiles A lot of custom extensions to all of them SSO using Weblogic API

Step 1: Integration & HTML Application started running after initial configuration HTML tags were used in some places, which means encodeURL() was not applied Some scripts accessed form fields by name Added a widget prefix before the name

Step 2: Layout, menu and login Since login was done using SSO we left it be We extended the Aranea MenuWidget to implement the menu from scratch, reusing all the old privileges After lifting header, footer and menu to the RootWidget turned out that Tiles were not doing anything useful anymore and could be eliminated

Step 3: How to split? First we extract the widgets pointing to the relevant parts of the application Next we change all navigation/inclusion between those parts to use Aranea API: Sending events to the hosting widget AraneaUtil.getFlowCtx(), AraneaUtil.addWidget(), used from the embedded applications

Step 3: Analyze and split After some research we decided that the best way to split the application would be vertically – by functionality We ended up with five different functionality types and about ten different widgets (some widgets were multipurpose)

Step 3: Analyze and split Some widgets were used only as flows while others were included as components By extracting and abstracting several included widgets we eliminated a lot of copy-paste While we could further refine our components it was good enough for starting migration

Results Five main functionality parts which could be rewritten one by one without affecting the others No more Tiles Less copy-paste If we needed to add a sixth functionality part we could start using JSF immediately

Goal Get rid of legacy and custom web frameworks in your application

Our solution 1.Use Aranea web integration layer to run different technologies side-by-side 2.Refactor the application into coarse-grained integration components 3.Start new development immediately and change old code only when requirements change – step-by-step migration

Step-by-step migration After refactoring every component is a Java class with a particular interface/contract The rest of the components can only interact with it via that contract Therefore we can just rewrite it using any other implementation as long as the contract is preserved

Case study: migration In the case study we wanted to use Aranea, so there was no need for further migration Eventually we would like to lift the whole Tax and Customs application to Aranea using other framework features when needed However we also have clients who prefer JSF and Tapestry, so in those cases we would continue

The Next Step Aranea Integration solves the problem of mashing up Java web applications A lot of legacy applications are written in Perl, PHP, Oracle Forms, etc You’d also want to integrate with.NET web applications Aranea Remote Integration will support that!

Webmedia Webmedia ( is a Baltic company employing over 300 people that sponsors Aranea developmentwww.webmedia.eu Webmedia offers complete commercial support for Aranea MVC & Integration In fact we now also offer support for migrating your legacy web applications to a platform of your choice :)

Final Words Using Aranea Integration is easy Problems might come up requiring better understanding of Integration works Migration is not completely painless, but it is cheap next to the alternative Migrated Struts Mailreader application in the distribution is a good starting point

Questions