Sunteți pe pagina 1din 40

IBM Rational Software

Development Conference 2006

RAD Plug-in for Migrating from


STRUTS to SPRING
By

Sourav Sengupta

L&T Infotech Building relationships globally

2006 IBM Corporation

IBM Rational Software Development Conference 2006

Presenters

Makarand Hiralikar

Devendra Rajput

Deputy Head Technology Solutions,

Sr. Software Engineer,

L&T Infotech

L&T Infotech

AM13

IBM Rational Software Development Conference 2006

Agenda

AM13

IBM Rational Software Development Conference 2006

Technology Accelerators @ L&T Infotech


Consulting

Consulting
Organizations

Technology
Leaders
Technology
Solutions

Strategy

Alliances

Delivery
Engine
Interaction

Market
Analysis
Leading
Analysts

Domain
Competency

Affiliations

Industry
Bodies

AM13

IBM Rational Software Development Conference 2006

Technology Accelerators @ L&T Infotech


Technology Accelerators
Code
Code Migration
Migration
Cobol
Cobol to
to Java
Java
Struts
Struts to
to Spring
Spring (vice
(vice versa)
versa)

SDLC
SDLC Helpers
Helpers
Industry
Industry Solution
Solution Frameworks
Frameworks

AM13

IBM Rational Software Development Conference 2006

AM13

IBM Rational Software Development Conference 2006

Framework Overview -

"

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

AM13

IBM Rational Software Development Conference 2006

Framework Overview -

#"

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 - Springs Front Controller implementation
Encapsulates navigation logic & delegates to the service objects for business
logic
View- JSPs
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

AM13

IBM Rational Software Development Conference 2006

Comparison STRUTS & SPRING


$ &) $

$%& '(
.

"
"
"
"
"
"
/
!

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

. ,,
$ '
0
.
*(

'
! *(
( '

#
$& '
#
'
)
'

( '

%
!
"
#
$

AM13

IBM Rational Software Development Conference 2006

Comparison Contd
$ &) $

$%& '(
2

$
$
,
,,
'(
6 ' ,
'

3
(
3

(
(1

'

'

'
(

,,
1

,
# '

4/*

$
0
,

"5

'
$ (

2
/ '
(

',
(1

0
+

*
'
.

$
,
(

$
(

,,
,
(

AM13

IBM Rational Software Development Conference 2006

AM13

IBM Rational Software Development Conference 2006

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 ( JSPs )


Any struts specific tag is to be converted to its 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 (XMLs)
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
AM13

IBM Rational Software Development Conference 2006

Five Step Methodology


Step 1: Face Lift ( JSPs ) : Changing Struts specific tags to simple HTML Tags in
JSP
JSPs in a Struts application can contain Struts specific tags where as JSPs in a
Spring application contains simple HTML tags.
&
$

7
8
, ,
9:

*
7 ,
;

: ;

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

7 ,

7 ,

9:

:;

, 9:

+$%

9:

, 9:, $ ':
9:, $ ': ;
, 9:

7
;

+$

"

: ;

9: 7 ,,
:;

<

/
(

/
(

AM13

IBM Rational Software Development Conference 2006

Five Step Methodology


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

,(
=> ?

' "

,(
=> ?

'

AM13

IBM Rational Software Development Conference 2006

Five Step Methodology


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

,
(

,( "
$ '
"
. ,,
,,
"
- ,
/)
)
- ,
/ ,
,
=
@

9 @

'. ' " ' $


(
- ,
/)
)
- ,
/ ,
,
5(1
'
# '0 ,
,
$ 0 ,
=

@
B3
C

,,

'

$ ':

,,

'

$ ':

: A
: A

'
8

'B 9 @

'

'A

'

D $

'

$. ' " '

$. ' " '

1
$

AM13

IBM Rational Software Development Conference 2006

Five Step Methodology


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>

&
"

;action/0

<

<

3
<
Action
*.do

7
7
7

<
<
<,
7

,, ;
;action/0
;*.do/0
1
<
,, ;

1
2

8%
C

' ,
( C

AM13

IBM Rational Software Development Conference 2006

Five Step Methodology


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

AM13

IBM Rational Software Development Conference 2006

AM13

IBM Rational Software Development Conference 2006

Framework Migrator Architecture


Mapping
JSP Parser

WEB

Struts
project

Spring

Config

Checks

Checks

Ip/op framework

File types

Ip project folder files

Calls parsers

project

XML Parser

Writer

Creator

Action
Form

File Locator

File Converter

JAVA Parser

Highlights
Other Parser
(e.g. .property)

Denotes Plug-able component

Foundation for more conversions


2-way conversion possible
Mappings are flexible, outside code
Pluggable parcels
Folder structure defined in mapping DB
AM13

IBM Rational Software Development Conference 2006

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

AM13

IBM Rational Software Development Conference 2006

AM13

IBM Rational Software Development Conference 2006

Operational Features
J2EE Framework Migrator
A Plug-in (MIGRATOR)
compatible with Eclipse

which

is

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
AM13

IBM Rational Software Development Conference 2006

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 IDEs like
Rational Application Developer (RAD), Websphere
Application 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 JSPs, Form beans, Action Classes
Creates/Converts framework specific configuration XMLs
Places all the converted files in appropriate folder

AM13

IBM Rational Software Development Conference 2006

Installing Migrator Plug-in


Migrator can be installed on any eclipse based IDE or NetBeans IDE
using the Installer provided.
There are two ways to start Migrator

AM13

IBM Rational Software Development Conference 2006

Migrator Plug-in Capability


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.

AM13

IBM Rational Software Development Conference 2006

AM13

IBM Rational Software Development Conference 2006

Creator Classes

AM13

IBM Rational Software Development Conference 2006

File Converter and Locator Classes

AM13

IBM Rational Software Development Conference 2006

File Parsers

AM13

IBM Rational Software Development Conference 2006

Mapping Database

AM13

IBM Rational Software Development Conference 2006

Mapping Database

AM13

IBM Rational Software Development Conference 2006

Demo
AM13

IBM Rational Software Development Conference 2006

Migrator UI

AM13

IBM Rational Software Development Conference 2006

JSP with Struts tags (Before migration)

AM13

IBM Rational Software Development Conference 2006

Spring JSP (After migration)

AM13

IBM Rational Software Development Conference 2006

Migration Summary

AM13

IBM Rational Software Development Conference 2006

Further Enhancements
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

AM13

IBM Rational Software Development Conference 2006

Known Issues
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

AM13

IBM Rational Software Development Conference 2006

Questions
AM13

IBM Rational Software Development Conference 2006

Thank You
Makarand.Hiralikar@Lntinfotech.com
Sourav.Sengupta@Lntinfotech.com
Devendra.Rajput@Lntinfotech.com

AM13

S-ar putea să vă placă și