RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from...

40
IBM Rational Software Development Conference 2006 © 2006 IBM Corporation ® RAD Plug RAD Plug - - in for Migrating from in for Migrating from STRUTS to SPRING STRUTS to SPRING By Sourav Sengupta Sourav Sengupta L&T Infotech –“Building relationships globally

Transcript of RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from...

Page 1: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational SoftwareDevelopment Conference 2006

© 2006 IBM Corporation

®

RAD PlugRAD Plug--in for Migrating from in for Migrating from STRUTS to SPRINGSTRUTS to SPRING

By Sourav SenguptaSourav Sengupta

L&T Infotech – “Building relationships globally”

Page 2: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Presenters

Devendra RajputSr. Software Engineer,

L&T Infotech

Makarand HiralikarDeputy Head – Technology Solutions,

L&T Infotech

Page 3: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

���������������� ����������������

�� ���������� ���������������

���� ���� ��� �����

�� ���������� ��������������

�� ��������������

Agenda

���� ��� � ���

Page 4: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Technology Accelerators @ L&T Infotech

MarketAnalysis

Technology Solutions

Strategy

DomainCompetency

Delivery Engine

Industry Bodies

Technology Leaders

ConsultingOrganizations

Leading Analysts

Consulting

Alliances

Affiliations

Interaction

Page 5: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Technology Accelerators @ L&T Infotech

Code MigrationCode Migration

Technology AcceleratorsTechnology Accelerators

SDLC HelpersSDLC Helpers

Industry Solution FrameworksIndustry Solution Frameworks

Cobol to JavaCobol to Java

Struts to Spring (vice versa)Struts to Spring (vice versa)

Page 6: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

�� ��������������

Page 7: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

! ��� "�������

� Framework• Basic architecture for designing a complex application

• Helps in reducing the complexities

• Enhances the concept of reusability along with the basic principles of design pattern

� MVC ( Model View Controller) Framework • Design paradigm, originated in the Smalltalk community

• Separates Business logic/state (the Model) from User Interface (the View) and program progression/flow (the Control)

• Model: Represents the data in the system

• View: How data is represented to the user

• Controller: Responsible for controlling the flow of the program

Framework Overview -

Page 8: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

�������������#"

� Struts Framework� Based on MVC architecture

� Model – Business Services

� Transfer Objects Business Services populate and return Transfer Objects

� View – JSPs, ActionForms

� JSP queries ActionForm for form data

� Controller – ActionServlet, Actions

� ActionServlet delegates control to Action class instances

� Spring Framework � DispatcherServlet - Spring’s Front Controller implementation

� Encapsulates navigation logic & delegates to the service objects for business logic

� View- JSP’s

� ModelAndView - Created by the Controller

� Stores the Model data & associates a View to the request

� Can be a physical View implementation or a logical View name

� ViewResolver - Maps logical View names to actual View implementations

� HandlerMapping-Strategy interface used by DispatcherServlet for mapping incoming requests to individual Controllers

Framework Overview -

Page 9: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

����� ������� ��������������������������������������� ����� ���� ����������������

����� �� �� � �������������!�����"�� ���������������#�������������$������ ����� ���� �

����������� �������

%����� �

�����������������������#� ��� �������������������������$ &��'��������#� ���� ����� '�� ���$���( �' ����)����'���

�����������������������!���* (��� ��������� ��������( �' �������

���� '�

�+ �,�����������������'�-��'��.�,, ���� $/������.�'�"�' $�!���* (��� ������ ����� ���*��� ��

�"�� ��������"�� ����"�� ��.�,, ����"�� �����$��'��"�� ��0������"�� ��������/������.��������!���* (��� ������ ����� ���*��� ��

.�����,�����

$%&�'($�&)�$

Comparison – STRUTS & SPRING

Page 10: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

�*���$������$��������'���,��

�.����(��������( �������� ����������������������

��(������� ����� ���� ��

�/ � '� ��� �������������

� �����(����'�,� ����� �� ����(1���

� 0������������,,����� ������ ���,� ���

� + �� �����������

� ������ ������ �������

���2�

�3�������(�����1������������(�� �����(1����

�3 ��(� ��� ����� '�� �����'���������'� ��

���� (����,, ����������������������1����4/*�,�������

�#� �'�������,�����,� ������� �����������������$��� ����� ����� �������� ������� ��

�0����������"5����'�������,� ���������� ��$(�� �

����$������$��������'���,��

���,,���'�(������������

�6��'��,���� �������������

���2�

$%&�'($�&)�$

Comparison Contd…

Page 11: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

�� ���������� ��������������

Page 12: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Framework Migration Methodology� A simple struts application can be divided into 6 categories

� JSP * (ex- login.jsp)� Action Classes (ex- LoginAction.java)� Form Beans (ex- LoginForm.java) � TagLibs (ex- struts-html. tld)

� Config Files (ex – Web.xml, struts-config. xml)� Library Files (ex- struts.jar)

� Step 1: Face Lift ( JSP’s )� Any struts specific tag is to be converted to it’s corresponding simple HTML tag

� Step 2: Organ Transplant ( Form beans) � change the existing Form beans to Command Classes

� Step 3: Heart Transplant (Action Classes)� Change the existing Action Classes to Controller Classes

� Step 4: Brain Transplant (XML’s)� Change the struts specific config files to spring specific config files

� Step 5: Blood Transfusion� Add spring specific jars in lib folder of the application

������������������

Page 13: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� Step 1: Face Lift ( JSP’s ) : Changing Struts specific tags to simple HTML Tags in JSP

� JSP’s in a Struts application can contain Struts specific tags where as JSP’s in a Spring application contains simple HTML tags.

��� &��� ����*� ����*� "�������

$���������� ��

7����8����,��,���9:������: ;

7 �,�����,9:���:�����9:������:� ;

7����8,���$��'��,��,���9:,���$��': ;

7 �,�����,9:,���$��':���9:,���$��': ;

7����8��(� � ; 7 �,�����,9:��(� �:� ;

7����8�������� ��9: ��� �:; 7���� ��� ��9: 7�,,� ��� ��<����������; ��� �����: ;

+$��� �� /�� ������ ��(��������$����

���+$%� ��

/�� ������ ��(��������$����

Five Step Methodology

Page 14: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� Step 2: Organ Transplant : Changing Struts Form Beans to Spring Command Classes � Struts provide FormBeans as interface between the JSP and the controller servlet.

In Spring these are replaced by POJO (Plain Old Java Objects) Command Classes.

� Form beans extend the ActionForm class of struts framework. POJO Command Classes do not extend any class

��$����� ��$�����

,�(� ��������*�� ����� ���'��"�� �������=>���?

,�(� ��������*�� �������'=�>���?

Five Step Methodology

Page 15: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� Step 3: Heart Transplant: Changing Struts Action classes to Spring Controller classes

� Struts provide ActionServlet by default as the controller where as in Spring the default controller is DispatcherServlet

� Spring has different controllers which handle individual modules. These can be seen as replacement for Action Classes

$������������� ����*���,����� ��� ����*�

���'��"�� �� ���'��� �,��������������

3��8���������������(�� �,����������������������������������������������������������������� ��(��

,�(� ��"�� �����$��'�����"�� ��.�,, ����,, ���"�� ������������-��,�����/)����)����-��,�����/�,�����,�����

=�

,�����'�.�'�"�' $����(� ��-��,�����/)����)�����-��,�����/�,�����,����5(1�����'�# �'0��,� ���,��

����$��0��,� ���=

@������ ������� 9��@������������A @��������'�����'B�9��@��������'����'A

B3��8������' ��������������������� �A� ��$ ����,����

C�������D $��������'�� ���� ��1����� �

��������,, ���� �'���$��'�:������ :�A �������$�.�'�"�' $��������� $���A

��������,, ���� �'���$��'�:�� ���:�A �������$�.�'�"�' $������� $���A

Five Step Methodology

Page 16: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� Step 4: Brain Transplant : Changing Struts Configuration files to Spring Configuration files

� Struts use web.xml & struts-config.xml to direct the flow of the application

$�����-������.*�� ��*���,����� ��� ����*�

7������<���� �;��7 ������<���� �;� 7(���;�7 (���;

<forward name="sucess" path="/form/yyy.jsp" />

<property name="successView"><value>yyy</value>

</property>

<forward name="failure" path="/form/zzz.jsp" />

<property name=" formView"><value>zzz</value>

</property>

&��� �� ���� ���

"�� �� 7�����<���;action/0�������1� ��2 @���� � � ������������������<����������

3��8�%�������'��,�����������C���D �����<����������(��C��� ��D�����

Action 7�����<��,, ��;

7�����<���;action/0�������1� ��27���<,�����;*.do/0���1� �����2

7 �����<��,, ��;

���

*.do B����

Five Step Methodology

Page 17: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� Step 5: Blood Transfusion : Replacing Struts jar files with Spring jar files

� Removing the struts specific jars (struts.jar, struts-legacy.jar etc)

� Adding Spring specific jars (standard.jar, spring.jar etc) into lib folder of the

application.

� All *.tld remain same

� Updating classpath entry

Five Step Methodology

Page 18: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

�� ���������� ���������������

Page 19: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

File Locator

Checks

Ip/op framework

Ip project folder files

MappingJSP Parser

Other Parser(e.g. .property)

Config

WEB

XML Parser

Form

Action

JAVA ParserFile Converter

Checks

File types

Calls parsersCreatorWriter

Struts

project

Spring

project

Denotes Plug-able component

Framework Migrator Architecture

Highlights

�Foundation for more conversions

�2-way conversion possible

�Mappings are flexible, outside code

�Pluggable parcels

�Folder structure defined in mapping DB

Page 20: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Architecture details

� File Locator

� Checks the input project folder is struts or spring

� Checks the input project folder structure & files

� Stores Input & Output project folder path in mapping database

� File Converter

� Checks file types

� Calls appropriate File parsers

� File Parsers

� Individual parsers for individual file types

� Converts struts related tags, codes etc to spring equivalent

� File Creator

� Creates Spring project folders structure

� Copies converted files to appropriate folders

Page 21: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

���� ���� ��� �����

Page 22: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

J2EE Framework Migrator

� A Plug-in (MIGRATOR) which is compatible with Eclipse

� It can convert an application from Struts to Spring

� Easy to install & enhance

Features

� This plug-in reduces certain overheads :

� Creating new Folder Structure according to

the migrated framework.

� Installing related Jars of migrated framework

� Converting Configuration files from one framework to other.

� Converting one Framework specific tags to other framework specific tags

� Converting Framework specific code

Operational Features

Page 23: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Plug-in Development Environment

� Eclipse has provided an API for plug-in development (PDE) for RAD, which is used to develop MIGRATOR Plug-in.

� This helps it to plug in various different IDE’s like Rational Application Developer (RAD), WebsphereApplication Developer (WSAD), Netbeans, and Eclipse 3.0.

What does this plug-in do?� Creates framework specific Folder structure

� Places all framework specific jars in lib folder

� Converts framework specific code of JSP’s, Form beans, Action Classes

� Creates/Converts framework specific configuration XML’s

� Places all the converted files in appropriate folder

Page 24: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� Migrator can be installed on any eclipse based IDE or NetBeans IDE using the Installer provided.

� There are two ways to start Migrator

Installing Migrator Plug-in

Page 25: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� Phase-wise capability in terms of effectiveness of migrating a simple application from Struts to Spring

Phase in Migration Plug in Capability

Face Lift 50%

Organ Transplant 90%

Heart Transplant 30%

Brain Transplant 20%

Blood Transfusion 90%

� Overall the MIGRATOR Plug-in is capable to reduce 70% (approx) of the manual efforts in migrating a simple Struts application to Spring. Further enhancements may increase the level of automation.

Migrator Plug-in Capability

Page 26: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

���� ��� � ���

Page 27: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Creator Classes

Page 28: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

File Converter and Locator Classes

Page 29: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

File Parsers

Page 30: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Mapping Database

Page 31: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Mapping Database

Page 32: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Demo

Page 33: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Migrator UI

Page 34: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

JSP with Struts tags (Before migration)

Page 35: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Spring JSP (After migration)

Page 36: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Migration Summary

Page 37: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� Presently MIGRATOR plug-in is capable of migrating simple applications in

Struts to Spring, for more complex applications

� It can be enhanced to migrate areas such as

� Struts tld library

� Logic tags

� Validation framework

� Error handling

� Database Mapping

� Other Controllers of Spring

Further Enhancements

Page 38: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

� It only handles SimpleCommandController

� findForward("sucess") , “success” is user defined tag which cannot be pre assumed for

success or failure views. So after conversion both the statements of Success & Failure are inserted in comment , the programmer can choose the statement according to the view required

� Some closing tags are missed out or not in proper place , the programmer must ensure it before executing

� Programmer has to handle logical flow of the application as migrator handles only

framework specific code

Known Issues

Page 39: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

Questions

Page 40: RAD Plug-in for Migrating from STRUTS to SPRING · PDF fileRAD Plug-in for Migrating from STRUTS to SPRING By ... Framework • Basic architecture for designing a complex application

IBM Rational Software Development Conference 2006

AM13

[email protected]@[email protected]

Thank You