BOF-2368 Restructuring a Web Application, Using Spring and Hibernate   Gustavo de Paula  |   [email_address] Devendra Tewa...
Motivation <ul><li>C.E.S.A.R was hired to build a phonebook synchronization for a CDMA carrier in Brazil (July 2004) – VPB...
Agenda <ul><li>Synchronization solution </li></ul><ul><ul><li>Project requirements </li></ul></ul><ul><ul><li>Main problem...
About C.E.S.A.R <ul><li>Recife Center for Advanced Studies and Systems </li></ul><ul><li>Most important innovation company...
About the Speaker <ul><li>Speaker in conferences in Brazil, US and Europe </li></ul><ul><li>8 years of experience in Softw...
VPBook 1.0
VPBook 1.0 - Synchronization solution Phone Client 1 Phone Client 2 Phone Client n Virtual  Phonebook Web Server ... HTTP ...
VPBook 1.0 – Server Requirements <ul><li>Two actors: cell phone client and the web user </li></ul><ul><li>From the cell ph...
VPBook 1.0 – Client Navigational Model
VPBook 1.0 – Server Navigational Model
VPBook 1.0 – Server Navigational Model
VPBook 1.0 – High Level Sequence Diagram Cell Phone VPBook Sync Database Login Send Modified Contacts Identify what was  c...
VPBook 1.0 System Architecture Sync module Contact  Manager DB Interface DB Layer DB Carrier Integration BREW App Web GUI ...
Components <ul><li>Carrier Integration </li></ul><ul><ul><li>The user can login in the carrier portal </li></ul></ul><ul><...
Components <ul><li>DB Layer </li></ul><ul><ul><li>All implemented using JDBC </li></ul></ul><ul><ul><li>A single class wit...
Main Issues in the VPBook 1.0 System Architecture <ul><li>Performance </li></ul><ul><ul><li>JBDC solution was not good </l...
Main Issues in the VPBook 1.0 System Architecture <ul><li>The system facade was not well defined.  </li></ul><ul><ul><li>B...
VPBook 2.0
New requirements <ul><li>New carriers support </li></ul><ul><li>New handsets support </li></ul><ul><ul><li>BREW and J2ME <...
Solution – Spring <ul><li>Based in IoC pattern </li></ul><ul><li>Code uses the interfaces </li></ul><ul><li>All implementa...
Spring Main Modules Spring live. Figure 1.1
Spring Main Modules <ul><li>Spring Core </li></ul><ul><ul><li>Has all basic services. Implements the IoC and manage the ja...
Spring Main Modules <ul><li>Spring DAO </li></ul><ul><ul><li>JDBC Abstraction layer and transaction management </li></ul><...
Spring – how we use it Spring live. Figure 1.2
VPBook 2.0 System Architecture VPBook Core Sync Client Web Client Admin Client VPBook DB Layer Struts Struts Struts Spring...
VPBook 2.0 System Architecture <ul><li>Use struts in the sync part instead of servlets </li></ul><ul><li>Use Tomcat sessio...
VPBook 2.0 System Architecture Advantages <ul><li>Well Defined facade </li></ul><ul><ul><li>Simpler sync client and web cl...
Comparison metrics *Not end-to-end 69% smaller 858 2477 DB access NCSS  30x faster 1 sec. 30 secs. DB Performance Full Syn...
Conclusion <ul><li>Don’t implement a project like this is two months   </li></ul><ul><li>Spring helped in </li></ul><ul><...
 
Upcoming SlideShare
Loading in …5
×

Restructuring a Web Application, Using Spring and Hibernate

1,374 views
1,302 views

Published on

javaone 2006 presentation

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,374
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
29
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Restructuring a Web Application, Using Spring and Hibernate

  1. 1. BOF-2368 Restructuring a Web Application, Using Spring and Hibernate Gustavo de Paula | [email_address] Devendra Tewari | [email_address]
  2. 2. Motivation <ul><li>C.E.S.A.R was hired to build a phonebook synchronization for a CDMA carrier in Brazil (July 2004) – VPBook1.0 </li></ul><ul><li>The client side should be developed in BREW </li></ul><ul><li>Initially target two different handset models </li></ul><ul><ul><li>Motorola V710 and Motorola C357 </li></ul></ul><ul><li>Very tight schedule </li></ul><ul><ul><li>From carrier requirements to deployment in 2 months! </li></ul></ul><ul><li>After first release, there were new requirements </li></ul><ul><li>We developed a VPBook 2.0 solution </li></ul>
  3. 3. Agenda <ul><li>Synchronization solution </li></ul><ul><ul><li>Project requirements </li></ul></ul><ul><ul><li>Main problems </li></ul></ul><ul><li>New requirements </li></ul><ul><li>Problems to solve </li></ul><ul><li>VPBook 2.0 - New solution </li></ul><ul><li>Comparison metrics </li></ul><ul><li>Conclusion </li></ul><ul><li>Q&A </li></ul>
  4. 4. About C.E.S.A.R <ul><li>Recife Center for Advanced Studies and Systems </li></ul><ul><li>Most important innovation company in Brazil </li></ul><ul><li>600 employees </li></ul><ul><li>Main clients are telecom companies (carriers and handset manufactures) </li></ul><ul><ul><li>Samsung </li></ul></ul><ul><ul><li>LG </li></ul></ul><ul><ul><li>Motorola </li></ul></ul><ul><ul><li>TIM </li></ul></ul><ul><ul><li>Bell South </li></ul></ul><ul><ul><li>Vivo </li></ul></ul>
  5. 5. About the Speaker <ul><li>Speaker in conferences in Brazil, US and Europe </li></ul><ul><li>8 years of experience in Software development </li></ul><ul><li>6 years of experience in Mobile Application Development </li></ul><ul><li>Holds and M.Sc. in Computer Science </li></ul>
  6. 6. VPBook 1.0
  7. 7. VPBook 1.0 - Synchronization solution Phone Client 1 Phone Client 2 Phone Client n Virtual Phonebook Web Server ... HTTP Requests/Responses WEB Related to mobile devices. ... Related to browsing interaction. User 1 User 2 User n Mobile Web Browsing Data Carrier Portal
  8. 8. VPBook 1.0 – Server Requirements <ul><li>Two actors: cell phone client and the web user </li></ul><ul><li>From the cell phone the user can: </li></ul><ul><ul><li>Synchronize its phonebook </li></ul></ul><ul><li>From the web the user can: </li></ul><ul><ul><li>Insert contacts </li></ul></ul><ul><ul><li>Delete contacts </li></ul></ul><ul><ul><li>Edit contacts </li></ul></ul><ul><ul><li>Restore contacts from recycled bin </li></ul></ul><ul><ul><li>Change his password </li></ul></ul><ul><ul><li>Import other user’s phonebook </li></ul></ul><ul><li>Two way synchronization </li></ul>
  9. 9. VPBook 1.0 – Client Navigational Model
  10. 10. VPBook 1.0 – Server Navigational Model
  11. 11. VPBook 1.0 – Server Navigational Model
  12. 12. VPBook 1.0 – High Level Sequence Diagram Cell Phone VPBook Sync Database Login Send Modified Contacts Identify what was changed in the server Apply Changes PhoneBook Changes Apply Changes Solve Conflicts Read Contacts Logout Commit Changes Check user
  13. 13. VPBook 1.0 System Architecture Sync module Contact Manager DB Interface DB Layer DB Carrier Integration BREW App Web GUI Carrier Portal
  14. 14. Components <ul><li>Carrier Integration </li></ul><ul><ul><li>The user can login in the carrier portal </li></ul></ul><ul><ul><li>If the user has the phonebook synchronization service a link is presented to him </li></ul></ul><ul><ul><li>When the user click that link it will call this component with the user’s MIN </li></ul></ul><ul><li>Sync module </li></ul><ul><ul><li>Servlets that receive requests from the BREW Application (Login, logout, sync, etc.)’ </li></ul></ul><ul><li>Contact Manager </li></ul><ul><ul><li>Has all the services to manage the contacts from the Web (insert, delete, edit). The Web GUI is implemented using Struts </li></ul></ul>
  15. 15. Components <ul><li>DB Layer </li></ul><ul><ul><li>All implemented using JDBC </li></ul></ul><ul><ul><li>A single class with 45 KLOC </li></ul></ul><ul><ul><li>Several operations to sync contacts </li></ul></ul><ul><li>DataBase </li></ul><ul><ul><li>The DB used is PostgreSQL </li></ul></ul>
  16. 16. Main Issues in the VPBook 1.0 System Architecture <ul><li>Performance </li></ul><ul><ul><li>JBDC solution was not good </li></ul></ul><ul><ul><li>JBDC was not optimized in the first releases </li></ul></ul><ul><li>Synchronization rollback </li></ul><ul><ul><li>Several problems to handle transactions </li></ul></ul><ul><ul><li>Some handset loose connection while synchronizing (session handling control implemented in the application) </li></ul></ul><ul><li>New handsets support </li></ul><ul><ul><li>The solution was not scalable to new handsets </li></ul></ul><ul><ul><li>Each new handset has a different phonebook format </li></ul></ul><ul><ul><li>The web GUI does not adapt to each handset </li></ul></ul>
  17. 17. Main Issues in the VPBook 1.0 System Architecture <ul><li>The system facade was not well defined. </li></ul><ul><ul><li>Bussiness logic both in the contact manager and in the sync module and in DB Layer </li></ul></ul><ul><li>Hard to include new functions </li></ul><ul><ul><li>Due to the tight schedule, the solution focus the two initial handsets and the initial requirements </li></ul></ul><ul><ul><li>It was hard to adapt the solution to new requirements </li></ul></ul>
  18. 18. VPBook 2.0
  19. 19. New requirements <ul><li>New carriers support </li></ul><ul><li>New handsets support </li></ul><ul><ul><li>BREW and J2ME </li></ul></ul><ul><li>Generic Solution </li></ul><ul><ul><li>Sync client (not associate with an specific carrier) </li></ul></ul><ul><ul><li>Web client (not associate with an specific carrier) </li></ul></ul><ul><li>Include the concept of handset profile </li></ul><ul><li>Adapt Web GUI according to the handset profile </li></ul><ul><li>Transfer phonebook from different profiles </li></ul><ul><li>Include Administration Support </li></ul><ul><li>Solve performance problems </li></ul>
  20. 20. Solution – Spring <ul><li>Based in IoC pattern </li></ul><ul><li>Code uses the interfaces </li></ul><ul><li>All implementation classes defined in XMLs </li></ul>Spring is a layered J2EE application framework based on code published in Expert One-on-One J2EE Design and Development by Rod Johnson
  21. 21. Spring Main Modules Spring live. Figure 1.1
  22. 22. Spring Main Modules <ul><li>Spring Core </li></ul><ul><ul><li>Has all basic services. Implements the IoC and manage the javabeans lifecycles </li></ul></ul><ul><li>Spring Web </li></ul><ul><ul><li>Web oriented integration (multipart support, web context and servlet listeners) </li></ul></ul><ul><li>Spring AOP (Aspect Oriented Programming) </li></ul><ul><ul><li>AOP Alliance compliant implementation. </li></ul></ul><ul><li>Spring ORM (Object/Relationship Mapping) </li></ul><ul><ul><li>Integration layers to ORM APIS (such as hibernate and JDO) </li></ul></ul>
  23. 23. Spring Main Modules <ul><li>Spring DAO </li></ul><ul><ul><li>JDBC Abstraction layer and transaction management </li></ul></ul><ul><li>Spring Context </li></ul><ul><ul><li>Provides a way to access the beans in a framework-like manner </li></ul></ul><ul><li>Spring MVC </li></ul><ul><ul><li>Full MVC framework implementation for web applications </li></ul></ul>
  24. 24. Spring – how we use it Spring live. Figure 1.2
  25. 25. VPBook 2.0 System Architecture VPBook Core Sync Client Web Client Admin Client VPBook DB Layer Struts Struts Struts Spring Hibernate
  26. 26. VPBook 2.0 System Architecture <ul><li>Use struts in the sync part instead of servlets </li></ul><ul><li>Use Tomcat session manager </li></ul><ul><ul><li>Handles login / sync / logout process </li></ul></ul><ul><li>Has a well defined facade with all the services that the clients will use </li></ul><ul><li>Each carrier can define its own web client </li></ul><ul><li>Spring is used to </li></ul><ul><ul><li>Declarative transactions </li></ul></ul><ul><ul><li>Dependencies bindings between the components </li></ul></ul><ul><ul><li>Persistence support with hibernate </li></ul></ul><ul><li>All DB layer is implemented in Hibernate </li></ul>
  27. 27. VPBook 2.0 System Architecture Advantages <ul><li>Well Defined facade </li></ul><ul><ul><li>Simpler sync client and web client </li></ul></ul><ul><li>Struts in the Sync Client </li></ul><ul><ul><li>Simply server side </li></ul></ul><ul><li>Use of Spring </li></ul><ul><ul><li>Simply the transaction control. Original version control the transaction in the code </li></ul></ul><ul><ul><li>Made it possible to plug different implementations according to the carrier </li></ul></ul><ul><li>Hibernate </li></ul><ul><ul><li>Simplify the database implementation </li></ul></ul><ul><ul><li>Significant performance improvements </li></ul></ul>
  28. 28. Comparison metrics *Not end-to-end 69% smaller 858 2477 DB access NCSS 30x faster 1 sec. 30 secs. DB Performance Full Sync (Before JDBC improvements) * 2x faster 1 sec. 2 secs. DB Performance Full Sync (After JDBC improvements) * 61% bigger 12089 7502 Full project NCSS 462% bigger 16 MB 3.463 MB Deployment Pack 250% increase 45 18 Number of UCs New solution Rate Old solution
  29. 29. Conclusion <ul><li>Don’t implement a project like this is two months  </li></ul><ul><li>Spring helped in </li></ul><ul><ul><li>Use of a well defined facade </li></ul></ul><ul><ul><li>Remove dependencies between the layers </li></ul></ul><ul><ul><li>Declarative transactions </li></ul></ul><ul><li>Hibernate helped in </li></ul><ul><ul><li>Relational database independence </li></ul></ul><ul><ul><li>Lazy loading </li></ul></ul>

×