netarchive suite workshop 2011 technical track - code refactoring with the spring framework

10
NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Upload: caroline-west

Post on 26-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

NetArchive Suite Workshop 2011

Technical Track-

Code refactoring with the Spring Framework

Page 2: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Introduction

The Spring framework has grown as a major, if not unavoidable, framework set

for developing enterprise Java applications.

It offers a wide range of technologies to address both fundamental and

transverse aspects of application programming.

Here are a few quotes about how Spring developpers envision coding with

Spring:

•Spring should be a pleasure to use

•Your application code should not depend on Spring APIs

•Spring should not compete with good existing solutions, but should foster integration. (For example, JDO,

Toplink, and Hibernate are great O/R mapping solutions. We don't need to develop another one.)

Page 3: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

An overview of Spring Core technologies

(from SpringSource website)

Spring is a layered Java/J2EE application platform, based on code published in Expert One-on-One J2EE Design and Development by Rod Johnson. Spring includes:

• a complete lightweight container • a common abstraction layer for transaction management • a JDBC abstraction layer that offers a meaningful exception hierarchy, simplifies error handling, and greatly reduces the amount of code you'll need to write. Integration with Toplink, Hibernate, JDO, and iBATIS SQL Maps •AOP functionality, fully integrated into Spring configuration management •A flexible MVC web application framework, built on core Spring functionality

Page 4: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Experience return from BnF:BCWeb Curator Tool (1/4)

The development of BnF’s new curator tool (BCWeb) is making extensive use of the Spring Core 3.0 framework.

The application first version is aimed at BnF curators and external institutional collaborators, and aims at the following main functionalities :

• Shared selection of web sites to be harvested, related to disciplines, projects and events. • Organizing these websites as coherent documentary collections and sharing responsibilities between collection departments.• Providing a documentary and technical descriptions of websites• Daily management tasks of web sites (e.g. adding new sites, updating informations relative to a website, removing a website from harvests, changing harvest frequency…)

Page 5: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Experience return from BnF:BCWeb Curator Tool (2/4)

BCWebDatabase

(PostgreSQL)

(PostgreSQL)

Tomcat 5.5 or 6.0

Web application

Berkeley DB(Transfer)

Active Directory

Open LDAP

Data input and visulaization, administration

AuthenticationData transfers to NetArchive Suite

Legend : data streams

NetArchive SuiteDatabase

Architectural overview schema

Page 6: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Experience return from BnF:BCWeb Curator Tool (3/4)

Spring 3.0 is the backbone of the application code:– Definition of components (scoping and lifecycle) is

done through the lightweight container, using annotations: @Component, @Repository, etc… and package scanning

– DAO layer uses NamedParameterJDBCTemplate (we chose not to use Hibernate which felt a bit overkill for our needs)

– The web tier uses Spring MVC + JSTL + jQuery.

Page 7: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Experience return from BnF:BCWeb Curator Tool (4/4)

Initial learning phase not too long DAO framework is very easy to use Annotation-based wiring of components is cool :) Hardest part to master proved to be test-related

APIs, we still have a long way to go! Ultimately there is no turning back once you start

using Spring, benefits are obvious. But at the same time you become dependent on a very large set of frameworks... the decision can be tough to make.

Page 8: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Areas in NAS where Spring could help (1/2)

Wiring and lifecycle management of objects, would imply rewriting the settings management and deployer code. But it could help a lot to make configuration more readable. We would need to use the declarative and not annotations.

DAO code would benefit a lot of a Spring rewrite : transaction and datasource management are made much easier. Hibernate could also be considered, as one of its interesting features is the ability to configure lazy loading, which could improve performance when the data grows big.

Page 9: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Areas in NAS where Spring could help (2/2)

The web UI of course would benefit from a major upgrade, Spring MVC seems the right choice.

Spring offers easy integration of JMX for objects managed by the lightweight container, could this be an alternative to JMS communication?

Page 10: NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework

Q&A

Questions? Code samples from BCWeb if anyone

interested and there is time left :)