Spring Framework Overview Ppt


Published on


Published in: Education
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Spring Framework Overview Ppt

  1. 1. Spring Application Framework Overview Praveen Manvi 21-Nov-2007
  2. 2. Agenda • History • Spring Goals • Dependency Injection • Spring Popular extensions • Road ahead
  3. 3. History Spring HISTORY
  4. 4. Rod Johnson – Father of Spring
  5. 5. History • Starting goal of Spring (from 2002) was to help to reduce the complexity of J2EE development & to simplify without sacrificing power • It grew from practical experience of Rod Johnson & his ilk as they found J2EE has become extremely complex to use. • As the leading full-stack Java/Java EE application framework, Spring delivers significant benefits for many projects, reducing development effort and costs while improving test coverage and quality. • It is a non-harvesting framework (as told by Martin Fowler) & delivers best
  6. 6. Continued… • Spring makes developing J2EE application easier, Introduced by Rod Johnson in “J2EE Design & Development” • Rod Johnson started developing framework for web application in 2000 while working as independent consultant in the financial industry in London • This project (as Spring) was started by Rod Johnson in 2002 but the first official release was made in March 2004 • The first version was written by Rod Johnson, who first released it with the publication of his book Expert One-on-One Java EE Design and Development (Wrox Press, October 2002). He also wrote a book J2EE without EJB in 2003
  7. 7. Continued… • Now spring is officially developed & maintained by interface21 company http://www.interface21.com/ • Spring has crossed 1 million downloads as of 22/09/2006 We can believe that, • “Spring framework” of the developers, by the developers & for the developers shall not perish from java world
  8. 8. Goals SPRING – GOALS & Architecture
  9. 9. Goals (Outlined by Rod Johnson) • J2EE should be easier to use currently Over-engineering is endemic in J2EE • It's best to program to interfaces, rather than classes. Spring reduces the complexity cost of using interfaces to zero. • POJO offer a great way of configuring applications & it should be utilized • OO design is more important than any implementation technology, such as J2EE. • Checked exceptions are overused in Java. A framework shouldn't force you to catch exceptions you're unlikely to be able to recover from. • J2EE can be made simpler without sacrificing power & facilitate best practices
  10. 10. Continued… • Testability is essential, and a framework such as Spring should help make your code easier to test. • Spring should be a pleasure to use • Application code should not depend on Spring APIs • Spring should not compete with good existing solutions, but should foster integration. (For example, JDO and Hibernate are great O/R mapping solutions. We don't need to develop another one.) • Enable applications to use POJO’s & allow enterprise services to be applied to those POJOs in a declarative, non-invasive way
  11. 11. Continued… • addresses overall application architecture & can become internal structure of an application • focuses on consistent programming model & decouples from concrete runtime environment hence boosting testing • It intends support any kind of Java application (Spring has even extensions to SWING) but with special support for J2EE environments
  12. 12. Spring Architecture
  13. 13. J2EE Architectural benefits & their shortcomings • Declarative Transactions o Good, but not always appropriate • Remoting/Distrubution o Best choice, there are equally good alternatives & also can be a made "On Demad" o Flexibility • Clustering/Scalability/Availability o Entity and SFSB have weak implementations. Session replication works well only in theory. o Scaling is more important at the web layer… Ex: eBay, Yahoo!, Google
  14. 14. Continued… • Resource Management o Not tied container (Heavy weight one) • Security o Security requirements tend to be more complex in practice • Business Object Management o Use of JNDI unnecessarily complex with very less value addition • Distributed transaction with multiple data sources o EJB - still the best choice Co-location of state & behavior is the lynch-pin of scalable performance So move as little as possible as rarely as possible. "Transparency is valuable, but while many things can be made transparent in distrubted objects, performance isn't usually one of them" - Martin Fowler Errant Architectures
  15. 15. Continued… • Thread Management o Multi-threaded services without read/write instance variables are scaling well (i.e. Servlets). • Instance Pooling o Is over-valued theory with modern garbage collectors. • Google, Yahoo*, eBay & Amazon are scaling well because of stateless architecture
  16. 16. Spring is Non-Invasive What does that mean? • You are not forced to import or extend any Spring APIs • An invasive API takes over your code. Introduces noise & boilerplate code • Anti-patterns: (Sample Invasive framework) o EJB forces you to use JNDI o Struts forces you to extend Action, ActionForm Invasive frameworks are inherently difficult to test (especially unit testing). You have to stub the runtime that is supplied by the application server
  17. 17. Spring core aspects At it’s core, Spring provides: • An Inversion of Control Container o Also known as Dependency Injection (Fowler’s term) • An AOP Framework o Spring provides a proxy-based AOP framework o You can alternatively integrate with AspectJ or AspectWerkz • A Service Abstraction Layer o Consistent integration with various standard and 3rd party APIs These together enable you to write powerful, scalable applications using POJOs.
  18. 18. IoC & Dependency Injection IoC or Dependency Injection
  19. 19. IoC or Dependency Injection Inversion of Control (IoC) is all about Object dependencies. Traditional "Pull" approach: • Direct instantiation (Ex: new Person()) • Asking a Factory for an implementation (PersonFactory.getPerson()) • Looking up a service via JNDI (Naming.lookup()) "Push" approach: • Something outside of the Object "pushes" its dependencies into it. • This is usually done through XML configuration or Java annotations This “Push” approach is called “Dependency Injection”
  20. 20. IOC - Definitions • Dependency Injection is the act of injecting dependencies into an Object. • Inversion of Control is the general style of using Dependency Injection to wire together application layers. • A way of sorting out dependencies between objects and automatically “injecting” references to collaborating objects on demand • Spring is an Inversion of Control container. That is, it is a container that handles Dependency Injection for you. Powerful bean configuration management (IOC) is the most important feature provided by Spring
  21. 21. Why Dependency Injection? • Loose Coupling & High Cohesion o It is loosely Coupled because you don't hard-code dependencies between layers and modules. Instead you configure them outside of the code. This makes it easy to swap in a new implementation of a service, or break off a module and reuse it elsewhere, although they are loosely coupled it is easy to wire them o It reduces coupling between implementation objects and encourages interface based design o Promotes OO design, allows pluggability, hot swapping & reuse • Testability o Testability is improved because your Objects don't know or care what environment they're in as long as someone injects their dependencies. Hence you can deploy Objects into a test environment and inject Mock Objects for their dependencies with ease.
  22. 22. Continued • Martin Fowler came up with this idea of dependency injection o http://martinfowler.com/articles/injection.html
  23. 23. Popular Extensions Spring Popular Extensions
  24. 24. Popular Extensions • Follows the DRY (Don’t Repeat Yourself) principle • Probably the most important feature of Spring, the main driving factor for large adoptation • Show cases the philosophy & techniques of Spring • Don’t compete with best • Provides abstraction & fully-factored API wrappers over these technologies  JDBC  Hibernate  JPA  TopLink  iBatis  JDO  Struts/Tapestry/Webwork  Quartz/Timer  Remote calls and Web Services (Axis)  EJB/JMS  AOP (AspectJ) & declarative transaction support
  25. 25. Spring modules
  26. 26. Spring Related Add-Ons • ACEGI Security - Full fledged security services for the Spring Framework http://www.acegisecurity.org/ • Spring IDE - IDE (Eclipse plug in) the configuration files used by the Spring Framework http://www.springide.org • Spring BeanDoc - tool that facilitates documentation and graphing of Spring bean factories and application context files http://opensource.atlassian.com/confluence/spring/display/BDOC/Home?showAttachme nts=true&showChildren=true • XDoclet Spring Tags - support for generating Spring XML config files from annotations in Java classes (JDK1.5 annotations can be used to achieve this) http://xdoclet.sourceforge.net/xdoclet/tags/spring-tags.html • AppFuse is Matt Raible's project to start your web projects. It uses Spring at it's core. http://www.appfuse.org
  27. 27. Road Ahead – Final thoughts Spring in 2008 – Road Ahead
  28. 28. On brighter side • Weblogic full fledged support – Good news, official vendor support will always help • Enormous # of Spring developers (Struts became popular for this reason, so popularity may not be always because of technical excellence) & hence lot of Spring jobs • Committed & highly intelligent Spring core team • Spring Webflow has good support for continuations • Good support for JSF/OSGI
  29. 29. Darker side • Spring metadata or XML hell • EJB 3 which is lightweight & has come up with same value proposition backed by strong vendors • Seam, RIFE & Ruby on Rails – Competing frameworks, also by highly credible set of people • Java EE & adaptation by Strong vendors like Oracle, IBM, JBoss, Sun • Vista & .NET innovation, Support for AJAX, Scripting langauages • Guice framework (Dependency Injection) from Google
  30. 30. Resources • http://en.wikipedia.org/wiki/Spring_Framework_%28Java% 29 • www.springframework.org • http://www.interface21.com/ • http://www.theserverside.com/tt/articles/article.tss?l=Sprin gFramework Finally Spring reference manual http://www.springframework.org/docs/reference/
  31. 31. Spring Books • Spring in Action - by Craig Walls and Ryan Breidenbach • Pro Spring - by Rob Harrop and Jan Machacek • J2EE Without EJB - by Rod Johnson and Juergen Holler • Expert One-on-One J2EE Design and Development - by Rod Johnson • Spring Developers Notebook - by Bruce Tate and Justin Gehtland • Spring Live - by Matt Raible • Professional Java Development with the Spring Framework - Rod Johnson & others
  32. 32. Credits • Much of the content in this presentation is influenced by presentation from Rod,books and links (see reference) • Coming up? o Scheduling Jobs with Spring and Quartz? o Working with LDAP & Spring? o Working with JMX & Spring o Sending Email with Spring & velocity? o Working with JDBC using Spring? o Working with Hibernate using Spring? o Working with iBatis using spring Spring? o Working with Hibernate using Spring? o Working with EJB using Spring? o Accessing Web Services Via Spring? o Exposing a Web Service with Spring? o Integrating Spring with JSF/Struts/Webwork/Tapestry? o Working with Swing (RCP) & Spring? Questions? Suggestions? Please mail me praveen.manvi@yahoo.com