Diapositive 1

Download Report

Transcript Diapositive 1

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.)
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
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…)
Experience return from BnF:
BCWeb Curator Tool (2/4)
Architectural overview schema
Tomcat 5.5 or 6.0
Web application
BCWeb
Database
(PostgreSQL)
Berkeley DB
(Transfer)
NetArchive Suite
Database
(PostgreSQL)
Open LDAP
Active Directory
Legend : data streams
Data input and visulaization, administration
Data transfers to NetArchive Suite
Authentication
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.
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
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.
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?
Q&A


Questions?
Code samples from BCWeb if anyone
interested and there is time left :)