Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.

Slides:



Advertisements
Similar presentations
Introduction to the Spring Framework
Advertisements

Apache Struts Technology
Spring, Hibernate and Web Services 13 th September 2014.
Introduction to the Spring Framework University of Kansas January 2009 This presentation and example application are available at
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Next Generation Node (NGN) Technical Overview April 2007.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
1 November 21st 2009 Shaun Abram An Introduction to Spring.
The Spring Framework: A brief introduction to Inversion of Control James Brundege
Last Update: 5/15/061 Spring J2EE Framework Ram A. Rao May 15 th ‘05.
Intro to Spring CJUG - January What is Spring? “The Spring framework provides central transaction control of various objects.” This means that any.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Using Third-Party Frameworks in Building Blocks™ David Ashman Principal Architect, Product Development.
An Introduction to Hibernate Matt Secoske
The Spring Framework A quick overview. The Spring Framework 1. Spring principles: IoC 2. Spring principles: AOP 3. A handful of services 4. A MVC framework.
Spring Framework Adam Waldal Senior Consultant. About me..  OPI is a leader in J2EE consulting with Relationships with BEA, IBM, Tibco, and many other.
UNIT-V The MVC architecture and Struts Framework.
Spring Framework. Spring Overview Spring is an open source layered Java/JavaEE application framework Created by Rod Johnson Based on book “Expert one-on-one.
NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Introduction to the Spring Framework By: Nigusse A. Duguma Kansas State university Department of Computer Science Nov 20, 2007.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
Spring. Spring Overview Spring Container Concepts Spring and AOP Spring and Data Access Managing Transactions and Resources Remoting and Accessing Enterprise.
The Spring Framework Training Get to know Spring Framework Rohit Prabhakar
Introduction to the Spring Framework Rajesh. Spring Mission Statement J2EE should be easier to use OO design is more important than any implementation.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Dependency Injection in Action Jan Västernäs. CADEC2006, DI, Slide 2 Copyright 2006, Callista Enterprise AB Agenda (DI=Dependency Injection) Background.
JBoss at Work JAW Motors Application Chapter 1-3 Jeff Schmitt October 9, 2006.
Text 16 de mayo de 2009 Spring Framework Part I. Dependency Injection Buenos Aires, May 2009.
PicoContainer Presented by: Jim O’Hara Ed Kausmeyer Jingming Zhang.
Opus College - overview. OpusCollege - background First project: ICT Capacity Building Mozambican Higher Education Institutions Partners: RUG Groningen,
Spring Data Access By, Srinivas Reddy.S
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework,
Introduction to Web Dimitar Nenchev Ivan Nakov
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
Spring Framework. About spring Spring is the most popular application development framework for enterprise Java. Millions of developers around the world.
Apache Struts. J2EE Web Application using MVC design pattern Why MVC? Separate components = easier maintenance – Model component holds object data – View.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
1 Spring Framework April, 2012 Lam Ho Lam To. © 2010 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 2 1.Spring Overview 2.Framework.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Enterprise JavaBeans 3.0. What is EJB 3.0 -Reusable server-side component framework-technology -Designed to support building demanding enterprise – level.
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Spring Framework BT Team 25/02/ Spring A lightweight framework that addresses each tier in a Web application. Presentation layer – An MVC framework.
Introduction – ORM, Helloworld Application
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions and Spring MVC Buenos Aires, June 2009.
Apache Struts Technology A MVC Framework for Java Web Applications.
Introduction to Inversion Of Control (IOC). IOC Definition (based on Wikipedia)  Consider the way in which an object obtains references to its dependencies.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework.
CS520 Web Programming Spring – Inversion of Control Chengyu Sun California State University, Los Angeles.
Training What’s Spring? The leading full-stack Java/JEE application framework.
J2EE Platform Overview (Application Architecture)
J2EE Lecture 6: Spring – IoC and Dependency Injection
CS520 Web Programming Spring – Inversion of Control
Introduction to J2EE Architecture
Unit 6-Chapter 2 Struts.
By Ru Shen Department of Computer Science UAlbany, 2008
Intro to Spring CJUG - January 2013.
Testing a persistence layer
Tuesday Brown Bag Inversion of Control with Howard Abrams
Developing and testing enterprise Java applications
Presentation transcript:

Spring Framework

Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one J2EE Design and Development” (October, 2002) Current version (released on ) The Spring Framework is licensed under the terms of the Apache License, Version 2.0 and can be downloaded at: Philosophy: J2EE should be easier to use, “Lightweight Container” concept A software framework is a re-usable design for a software system.

What are Lightweight Frameworks? Non-intrusive No container requirements Simplify application development Remove re-occurring pattern code Productivity friendly Unit test friendly Very pluggable Usually open source Examples: Spring, Pico, Hivemind Hibernate, IBatis, Castor WebWork Quartz Sitemesh

Spring Mission Statement J2EE should be easier to use It's best to program to interfaces, rather than classes. Spring reduces the complexity cost of using interfaces to zero. JavaBeans offer a great way of configuring applications 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. Testability is essential, and a framework such as Spring should help make your code easier to test 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 and Hibernate are great O/R mapping solutions. Don't need to develop another one).

Modules of the Spring Framework The Spring Framework can be considered as a collection of frameworks-in-the-framework: Core - Inversion of Control (IoC) and Dependency Injection AOP - Aspect-oriented programming DAO - Data Access Object support, transaction management, JDBC-abstraction ORM - Object Relational Mapping data access, integration layers for JPA, JDO, Hibernate, and iBatis MVC - Model-View-Controller implementation for web- applications Remote Access, Authentication and Authorization, Remote Management, Messaging Framework, Web Services, , Testing, …

Overview of the Spring Framework Very loosely coupled, components widely reusable and separately packaged.

Spring Details Spring allows to decouple software layers by injecting a component’s dependencies at runtime rather than having them declared at compile time via importing and instantiating classes. Spring provides integration for J2EE services such as EJB, JDBC, JNDI, JMS, JTA. It also integrates several popular ORM toolkits such as Hibernate and JDO and assorted other services as well. One of the highly touted features is declarative transactions, which allows the developer to write transaction-unaware code and configure transactions in Spring config files. Spring is built on the principle of unchecked exception handling. This also reduces code dependencies between layers. Spring provides a granular exception hierarchy for data access operations and maps JDBC, EJB, and ORM exceptions to Spring exceptions so that applications can get better information about the error condition. With highly decoupled software layers and programming to interfaces, each layer is easier to test. Mock objects is a testing pattern that is very useful in this regard.

Advantages of Spring Architecture Enable you to write powerful, scalable applications using POJOs Lifecycle – responsible for managing all your application components, particularly those in the middle tier container sees components through well-defined lifecycle: init(), destroy() Dependencies - Spring handles injecting dependent components without a component knowing where they came from (IoC) Configuration information - Spring provides one consistent way of configuring everything, separate configuration from application logic, varying configuration In J2EE (e.g. EJB) it is easy to become dependent on container and deployment environment, proliferation of pointless classes (locators/delegates); Spring eliminates them Cross-cutting behavior (resource management is cross-cutting concern, easy to copy-and-paste everywhere) Portable (can use server-side in web/ejb app, client-side in swing app, business logic is completely portable)

Spring Solutions Solutions address major J2EE problem areas: Web application development (MVC) Enterprise Java Beans (EJB, JNDI) Database access (JDBC, iBatis, ORM) Transaction management (JTA, Hibernate, JDBC) Remote access (Web Services, RMI) Each solution builds on the core architecture Solutions foster integration, they do not re-invent the wheel

How to Start Using Spring Download Spring from e.g. spring-framework with-dependencies.zip Unzip to some location, e.g. C:\tools\spring-framework Folder C:\tools\spring-framework-2.0.6\dist contains Spring distribution jar files Add libraries to your application classpath and start programming with Spring

Inversion of Control (IoC) Central in the Spring is its Inversion of Control container Based on “Inversion of Control Containers and the Dependency Injection pattern” (Martin Fowler) Provides centralized, automated configuration, managing and wiring of application Java objects Container responsibilities: creating objects, configuring objects, calling initialization methods passing objects to registered callback objects etc All together form the object lifecycle which is one of the most important features Java objects that are managed by the Spring IoC container are referred to as beans

Dependency Injection – Non-IoC public class MainBookmarkProcessor implements BookmarkProcessor{ private PageDownloader pageDownloader; private RssParser rssParser; public List loadBookmarks() { // direct initialization pageDownloader = new ApachePageDownloader(); rssParser = new JenaRssParser(); // or factory initialization // pageDownloader = PageDownloaderFactory.getPageDownloader(); // rssParser = RssParserFactory.getRssParser(); // use initialized objects pageDownloader.downloadPage(url); rssParser.extractBookmarks(fileName, resourceName); //... }

Dependency Injection - IoC Beans define their dependencies through constructor arguments or properties Container resolves (injects) dependencies of components by setting implementation object during runtime BeanFactory interface - the core that loads bean definitions and manages beans Most commonly used implementation is the XmlBeanFactory class Allows to express the objects that compose application, and the interdependencies between such objects, in terms of XML The XmlBeanFactory takes this XML configuration metadata and uses it to create a fully configured system

Non-IoC versus IoC Non Inversion of Control approach Inversion of Control approach

IoC Basics Basic JavaBean pattern: include a “getter” and “setter” method for each field: Rather than locating needed resources, application components provide setters through which resources are passed in during initialization In Spring Framework, this pattern is used extensively, and initialization is usually done through configuration file rather than application code class MyBean { private int counter; public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; } }

IoC Java Bean public class MainBookmarkProcessor implements BookmarkProcessor{ private PageDownloader pageDownloader; private RssParser rssParser; public List loadBookmarks() { pageDownloader.downloadPage(url); rssParser.extractBookmarks(fileName, resourceName); //... } public void setPageDownloader(PageDownloader pageDownloader){ this.pageDownloader = pageDownloader; } public void setRssParser(RssParser rssParser){ this.rssParser = rssParser; }

References Spring Home: Inversion of Control Containers and the Dependency Injection pattern Spring IoC Container: e/beans.html Introduction to the Spring Framework by Rod Johnson gFramework