. A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate. ...

39
Presentation

Transcript of . A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate. ...

Page 1: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Presentation

Page 2: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Recap A multi layer architecture powered by Spring

Framework, ExtJS, Spring Security and Hibernate. Taken advantage of Spring’s multi layer injection

and loose coupled approach of having an MVC architecture.

Rich UI achieved using ExtJS 4.0 Framework at UI layer.

Communication achieved using AJAX calls (XMLHttpRequest) from Client to Server using JSON objects.

Page 3: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Recap

Architectural view of ECMS

Page 4: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.
Page 5: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Design Use Case #1 (UI Layer)Maintain Air Freight Job Records

Page 6: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

: OperationStaff : OperationStaff : MaintainAirFreightJobRecordUIView : MaintainAirFreightJobRecordUIView : MaintainAirFreightJobRecordUIButton : MaintainAirFreightJobRecordUIButton : MaintainAirFreightJobRecordUIController

: MaintainAirFreightJobRecordUIController

: MaintainAirFreightJobRecordUIStore

: MaintainAirFreightJobRecordUIStore

: Proxy : Proxy : Service : Service

1: clickButton( )

2: handler( )

3: create( )

4: renderView( )

5: delegateAsyncRequest( )

6: delegateAsyncRequest( )

7: handleRequest( )

Service class becomes the actor for backend functions

Page 7: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Design Use Case #1 (Service Layer)Maintain Air Freight Job Records (ADD)

Page 8: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

: Service : Service : AirJobController : AirJobController

: AirJobService : AirJobService : HibernateT...

: HibernateT...

: JSON Array : JSON Array : JSON Object : JSON Object : AirJobDAO : AirJobDAO

: AirJob : AirJob

2: addJob( ) 3: getListAirJobFromJSON ( ):List<AirJob>

4: fromObject(Object):JSON Array

5: toCollection(JSON Array, AirJob)

8: getAirJobFromJSON ( ):AirJob

13: saveAirJob(AirJob)

14: saveAirJob( )

1: addJob( )

9: fromObject(Object):JSON Object

10: toBean(JSON Object, AirJob)

6: AirJob( )

7: setAttributes( )

11: AirJob( )

12: setAttributes( )

Page 9: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Design Use Case #1 (Service Layer) Maintain Air Freight Job Records

(Update)

Page 10: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

: Service : Service : AirJobController : AirJobController : AirJobService : AirJobService : JSON Array : JSON Array : JSON Object : JSON Object : AirJobDAO : AirJobDAO

: AirJob : AirJob :

HibernateT... :

HibernateT...

1: updateJob( )

2: updateJob( )

3: getListAirJobFromJSON( ):List<AirJob>

4: fromObject(Object):JSON Array

5: toCollection(JSON Array, AirJob)

8: getAirJobFromJSON( ):AirJob

9: fromObject(Object):JSON Object

10: toBean(JSON Object, AirJob)

7: setAttributes( )

12: setAttributes( )

13: saveAirJob(AirJob)

14: saveAirJob( )

6: AirJob( )

11: AirJob( )

Page 11: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Design Use Case #1 (Service Layer) Maintain Air Freight Job Records

(Remove)

Page 12: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

: Service : Service : AirJobController : AirJobController : AirJobService : AirJobService : JSON Array : JSON Array : AirJobDAO : AirJobDAO

: AirJob : AirJob

: HibernateT...

: HibernateT...

1: deleteJob( )

2: deleteJob( )

3: getListIdFromJSON(Object):List<Integer>

5: toCollection(JSON Array, AirJob)

4: fromObject(Object):JSON Array

8: deleteAirJob(AirJob)9: loadAirJob(AirJob, Integer)

10: deleteAirJob( )

6: AirJob( )

7: setAttributes( )

Page 13: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Design Use Case #1 (Service Layer) Maintain Air Freight Job Records (List)

Page 14: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

: Service : Service : AirJobController : AirJobController : AirJobService : AirJobService : AirJobDAO : AirJobDAO :

HibernateT... :

HibernateT... : HashMap : HashMap

1: listJob ( ):list<AirJob>

2: getJobList( ):list<AirJob>

3: getAllAirJobs( ):list<AirJob>

4: findAirJobList( ):list<AirJob>

5: getMap(list<AirJob>):HashMap(key,value)

6: put(String, Long)

7: put(String, list<AirJob> )

Page 15: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Development

Page 16: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Development Approach

A reference model developed for an important use case (Air Job) including UI widgets, controllers, services and DAOs.

After full requirement analysis Entities and DAO layer interfaces are finalized, and implemented.

Individual was assigned use cases to construct both UI components and Service components.

Page 17: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Flow of Development Activities

RequirementGathering and

Analysis

Reference application

development

Design andDevelopmentOf Use Cases

Entity and DAO

Implementation

Improvement And updates in Reference App

ContinuousIntegration and

Test

Page 18: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Development ActivitiesRequirement Analysis

Experimental Development of Reference Application

Entity Model & DAO Construction

Design, Development & testing of Use Cases

Improvement and Add-On

Continuous Integration and Testing

Page 19: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Important Features

Page 20: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Hibernate (DAO Layer)

Page 21: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Grid View Search (Filter Approach)

All use cases has their entry point at Grid Panels, all Form panels are reached by selecting grid data record and by pressing “Show Details” Button on the grid.

Grid Panels are build much powerful to provide functionalities such aso Filter/Search Records ( Including advanced search) o Refresh the Grid without navigating away from the

page.o Pagination.o Add, Remove and Update records, all in one request

to server (which enhance usability and makes less server calls)

Page 22: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Filter/Search Records

: Service : Service : AirJobController : AirJobController : AirJobService : AirJobService : AirJobDAO : AirJobDAO : FilterCallBackImpl : FilterCallBackImpl : HibernateTemplate : HibernateTemplate

1: searchJobs( )

2: createFilterMap( )

3: getJobList(FilterMap)

4: getAirJobs(FilterMap)

5: FilterCallBackImpl( )

6: execute(FilterCallBackImpl, FilterMap)

7: doInHibernate( )

8: listRecords( )

Page 23: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Transaction Management and Concurrency Control

Optimistic Concurrency control mechanism is used.

This is achieved by version checking against session and retrieved objects, upon any update and delete.

Page 24: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Versioning to control Concurrent updates

RequestContextHolder

Request

Session

Version

Version

DAO

ECMS DB

Page 25: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Spring Security• Plug and play way of apply security to the web

application.• More configuration less of coding to maintain the

security aspects of the application.• Aspect Oriented Programming model (AOP)• Spring Security 3.0 release is experimented and

successfully plugged into Spring Framework 3.x.• Secure and extremely secure folders are created to

secure static and dynamic contents of server.• Access level of such folders are described in security

configuration xml.• Cryptography is used to protect password from

exposure.

Page 26: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Security Context

Security Context

Authentication Object

WebAuthenticationDetails

ObjectUser

Authority

Page 27: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Security Schema

User

-user_name-password-enabled

Authority

-user_name-authority

*1

Page 28: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Event Based UI programming model

Following important events are used to make server calls upon events trigger when User interacts with the system.o beforeShow (to assemble different forms and their data

before it shown to the user.)o afterRequest (to fetch the records to sync UI store with

database asynchronously and avoid any race conditions)

o beforeRequest (to set parameters to the request)o beforeDestroy (to avoid destroying the pop-up

windows and forms to enhance the performance of the system)

o expand (upon expanding the accordion layout’s panels)o Collapse( upon colapsing the accordion layout’s panels)

Page 29: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Race Conditions During the coding, many race conditions

are discovered, because of asynchronous nature of the requests.

Among such scenarios the most encountered one is, when a code segment is in under UPDATE or CREATE operation, during this time sending a SELECT request for the same record within the same session is found to be a race condition.

Above race condition identified, and resolved by using afterRequest event handle the SELECT request to update the UI Store.

Page 30: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Race Conditions-Problem

UIController DespatcherServlet UserCaseController UserCaseService DAO

1 : updateRecord()2 : delegate update request()

3 : getRecord()4 : delegate select request()

5 : marshal and update to database()6 : saveOrUpdate()7 : getRecord()

8 : getRecord()

9 : result()

10 : execute update()

11 : return()

Race condition hereResult with no updates

Page 31: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Race Conditions-SolutionUIController DespatcherServlet UserCaseController UserCaseService DAO

1 : updateRecord()2 : delegate update request()

3 : marshal and update to database()

4 : saveOrUpdate()

5 : execute update()

6 : return()7 : fire afterRequest event()

8 : getRecord()9 : delegate select request()

10 : getRecord()11 : getRecord()

12 : result()

After request event fired

Page 32: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Example of the code

Page 33: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Technical Challenges Novelty of technology at UI layer.

o ExtJS documentation studied and referenced.o Wiki pages were used to share the knowledge within the

team.• www.code.google.com/p/iss2011s7/w/list

JSON Parser couldn't able to parse if object properties contains null.o Work around

• Null values are replaced with empty string before it transmitted from server to UI layer.

o Long term fix strategy• JSON Parser to be fixed.

Page 34: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Technical Challenges Handling complex objects at UI Layer (ExtJS)

o mapping between objects Lazy Fetching

o Lazy fetching was not able to achieve because of JSON Parser limitation of unable to handle null values.

Page 35: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Future aspects and improvements

Refreshing the stale records by estimating user’s operation Rest Time.o UI layer can be enhanced to have capability to refresh

the data grids by estimating user’s rest time, and if it reaches a particular threshold value, the system would refresh the data grid by using beforeActivate event of the RowEditor.

o Above would avoid user to get into a situation of updating a stale record on grid.

Page 36: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Future aspects and improvements

UI Update for Mobility in worko Proposing client for an update of UI version for

Tablets and Smart Phones. o ExtTouch( A mobile javascript framework)

shall be used to built tablet and smart phone applications.

o HTML 5 standards.o Only User Interface shall required to update

and service shall remain as it is. This is to have an advantage of mobility

and instant access to the application with greater performance.

Page 37: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Future aspects and improvements

Integration Requiremento Understand from client that operations are not

integrated to the Accounts system.o Proposal for an integration between both of the systems

can be consider.

Page 38: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Future aspects and improvements

Concurrent updates acknowledgement-o Grid Panel records can be highlighted in red color of

text to notify users that the local copy of the record is stale or no more fresh, and any updates to the stale data will not be persist in database.

o The above can be achieve by Observer Design Pattern and Push model of communication from server.

Page 39: .  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.

Doing It Again After getting full understanding of the

domain (cargo management), we would like to go for more generalized and multi-tenancy approach of building this application.

Metadata entity model can be used instead of rigid domain model, by which we can achieve customization requirements of data grids, forms and any other view panels for different customer.

Spring’s web service framework can be used to expose server side operation as web services, if necessary.

Releasing it as a software as a service (SaaS).