You are on page 1of 26

|  

 
  
i
 
   

O Spring is a Lightweight | 


Framework
O ihere Struts, iebiork and others can be
considered i Jrameworks, Spring
addresses all tiers oJ an application
O Spring provides the plumbing so that you
don¶t have to!
   

O Started 2002/2003 by Rod Johnson


and Juergen Holler
O Started as a Jramework developed
around Rod Johnson¶s book Expert
One-on-One J2EE Design and
Development
O Spring 1.0 Released March 2004
O 2004/2005 Spring is emerging as a
leading Jull-stack Java/J2EE
application Jramework
 |      

O Spring is NOT a J2EE application server


O Spring can integrate nicely with J2EE
application servers (or any Java
environment)
O Spring can, in many cases, elegantly replace
services traditionally provided by J2EE
application servers
×  ×   

O ·eJore Struts, everyone wrote their own Jront


controllers (or YIKES! put their controller logic in JSP)
O AJter Struts, the custom Jront controllers could be
thrown out
± Developers Jocus on solving business problems
± Productivity Gain!
O ·ut with Struts (and most oJ the other web
Jrameworks) you still have to write your own
business delegates or service layers«
   

O Spring brings a consistent structure to your entire


application
O Spring provides a consistent way to glue your whole
application together
O Spring provides elegant integration points with
standard and deJacto-standard interJaces: Hibernate,
JDO, TopLink, EJ·, RMI, JNDI, JMS, ieb Services,
Struts, etc.
O Just as Struts did on the web tier, we can realize
huge productivity gains by not having to write the
common integration points across your application
  !      
"   #

$

   
%
O Spring should be a pleasure to use
O Your application code should  depend on Spring
APIs
O Spring should not compete with good existing
solutions, but should Joster integration. (For
example, JDO and Hibernate are great O/R mapping
solutions. ie don't need to develop another one.)
 &  

Jrom    '

( % Spring distribution comes as one big jar Jile and alternatively as a series oJ smaller
jars broken out along the above lines (so you can include only what you need)
·ut really, what ? Spring?

At it¶s core, Spring provides:


O An Inversion oJ Control Container
± Also known as Dependency Injection (Fowler¶s term)
O An AOP Framework
± Spring provides a proxy-based AOP Jramework
± You can alternatively integrate with AspectJ or Aspectierkz
O A Service Abstraction Layer
± Consistent integration with various standard and 3rd party APIs

These together enable you to write powerJul, scalable


applications using POJOs.
Seriously though, what ? Spring?

O Spring at it¶s core, is a Jramework Jor


wiring up your entire application

O ·   are the heart oJ Spring


·   

O A ·   is typically conJigured in an


XML Jile with the root element: <beans>
O The XML contains one or more <bean>
elements
± id (or name) attribute to identiJy the bean
± class attribute to speciJy the Jully qualiJied class
·   

O ·y deJault, beans are treated as singletons


O Can also be prototypes
Here is an example: r 

r    
 
â 
â 
  

    
â 

â 
â  
â   
â 
ü ) ·   

O Strings and Numbers


â 
â!"â â  
â 
â#â â  

O Arrays and Collections


â 
 
â 
â$%  â 
â$%& â 
â  
â  
ü ) ·   
"   #

The real magic comes in when you can set


a property on a bean that reJers to another
bean in the conJiguration:
â 
  
    '
â 
  &()
â 

â  
â 
      
! "    "

 
 "
r  
 


 
 
º   *  
"     #

O Complicated sounding terms Jor a Jairly


simple concept
O The ³Hollywood Principle´: Don¶t call
me, I¶ll call you
O Dependencies used Jrom within a bean
aren¶t asked Jor outwardly, but are
injected into the bean by the container
º   *  
"     #

O Eliminates lookup code Jrom within your


application
O Allows Jor pluggablity and hot swapping
O Promotes good OO design
O Enables reuse oJ existing code
O Makes your application extremely testable
|)   ·  %

|      +

O An |      + is a ·  ,
but adds ³Jramework´ Jeatures such as:
± i18n messages
± Event notiJications
O This is what you will probably most oJten use
in your Spring applications
  |,  × 

Spring provides abstraction Jor:


O Transaction Management
± JTA, JD·C, others
O Data Access
± JD·C, Hibernate, JDO, TopLink, i·atis
O Email
O Remoting
± EJ·, ieb Services, RMI, Hessian/·urlap
  |,  × 

·eneJits:
O No implicit contracts with JNDI, etc.
O Insulates you Jrom the underlying APIs
O Greater reusability
O Spring abstractions always consist oJ interJaces
O This makes testing simpler
O For data access, Spring uses a generic transaction
inJrastructure and DAO exception hierarchy that is
common across all supported platJorms
  
i ,$ 

O Spring integrates nicely with Struts,


iebiork, JSF, Tapestry, Velocity and other
web Jrameworks
O Spring also provides it¶s own web Jramework,
Spring ieb MVC
  
i ,$ -  !)

O The Spring MVC Framework oJJers a simple


interJace based inJrastructure Jor handing
web MVC architectures
O Spring MVC components are treated as Jirst-
class Spring beans
± Other Spring beans can easily be injected into
Spring MVC components
± Spring MVC components are easy to test
& 
 +  .

( See http://www.zabada.com/technology/iiki.jsp?page=SpringRecipes )
 /  $ |0& 
O ACEGI Security - comprehensive security services Jor the Spring
Framework
O Spring IDE - graphical user interJace Jor the conJiguration Jiles used by
the Spring Framework
O Spring ·eanDoc - tool that Jacilitates documentation and graphing oJ
Spring bean Jactories and application context Jiles
O XDoclet Spring Tags - support Jor generating Spring XML conJig Jiles
Jrom annotations in Java classes (you could also use JDK1.5
annotations to achieve this)
O Spring ieb Flow - Jor web applications with demanding page Jlow
requirements
O AppFuse Not really a tool or add-on, but AppFuse is Matt Raible's
project to jumpstart your Java web projects. It uses Spring at it's core
and studying it is a great way to learn about Spring.
O Spring Framework .NET ± Spring Clone Jor the Dark Side
  1  /  
/    

$
&    /    ! 
http://www.springJramework.org/docs/reJerence/
     ,/

http://www.theserverside.com/articles/article.tss?l=SpringFramework
  |  by Craig ialls and Ryan ·reidenbach
ü   by Rob Harrop and Jan Machacek
i 
· by Rod Johnson and Juergen Holler
+ & 0 0& º    º     by Rod Johnson
 º   ( , by ·ruce Tate and Justin Gehtland
·  2 2× 
  by ·ruce Tate and Justin Gehtland
 ×  by Matt Raible
ü   º     

   
by many oJ the core Spring developers:   334
i 5

O ëuestions/Comments?
± Feedback is appreciated!
± Email me: roblambert@zabada.com

O ie¶re Hiring For A Few Positions


± Senior Java Developer
± Mid-level Java Developer
± Spring/Hibernate and other relevant Java technologies
± Let me know iJ you¶re interested: rlambert@schawk.com
  

O Thanks to the Spring Framework Team. See


— 
  
O Much oJ the content in this presentation was
inspired by presentations by Rod Johnson
and Craig ialls

You might also like