First step, I think adopt Middle Tier Data Access using JdbcTemplate should be easy way.
JdbcTemplate
Let me work on the products table.
1. Domain -- create Product domain class with get/setter methods.
2. DAO -- create ProductDao interface with CRUD methods.
3. JDBC DAO implementation -- public class JdbcProductDao extends SimpleJdbcDaoSupport implements ProductDao
4. ProductManager -- create ProductManager interface so you could group the product related methods together.
5. SimpleProductManager -- implementation of ProductManager interface.
6. Config applicationContext.xml -- specify dataSource, productDao, productManager bean.
7. Jsp pages get the productManager bean --
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(application);
ProductManager productManager = (ProductManager)ctx.getBean("productManager");
That's it. only 7 steps to Refactory that.
No comments:
Post a Comment