The goal is to remove business logic and entities from the struts action classes and their associated JSP's.
Note: rather than refactoring legacy Struts Action classes, the approach is being taken to simply replace Action classes and JSPs with SpringMVC/Webflow and Freemarker pages.
The approach is to first push down all business logic and knowlege of business entities into a service facade that is responsible for two things:
It shields the presentation layer from any business knowlege
It shields the domain layer from any knowlege of presentation data.
Steps to achieving this
Find the Struts action integration test that verifies the action class you are refactoring. Run this(in eclipse) before starting any refactoring and run it again and again after changes to pick up on any possible problems
Consider inline refactoring private methods in action class where possible. This helps identify cases where unnessecary queries are repeated or data is put into session.
There are typcially two types of refactoring which are:
Data Retrieval and Display
Inspect the JSP file and identify places where 'xyzBO's are being used and create DTO with data that matches the data being used from the 'xyzBO'.
Create your service facade method that is responsible for returning the DTO to be used by the JSP. * All business related code in action class gets 'pushed down' into this method. i.e. 'xyzPersistence.xxxx', 'xyzService.xxxx'
Define the service facade interfaces and DTOs in the serviceInterfaces module (so they can be accessed by new UI code in userInterface module-- see SystemInformationServiceFacade as an example).
Create or Update of Business Entities
Create your service facade method that is responsible for delegating to correct 'xyzService' for creation or updates.
You should consider creation of DTOs that represent the data required for either creation or update.
You may need to look at 'pulling out' persistence behaviour from the business object or just defer from using it and use the DAO pattern instead.