spring framework

15
Spring Framework Spring Framework Presented by Preetam Palwe Aftek Limited

Upload: preetam-palwe

Post on 01-Nov-2014

15 views

Category:

Technology


0 download

DESCRIPTION

A presentation given my me on Spring in Aftek.

TRANSCRIPT

Page 1: Spring Framework

Spring FrameworkSpring FrameworkPresented by Preetam PalweAftek Limited

Page 2: Spring Framework

IntroductionIntroductionSpring is a open source application

framework for Java (and .NET)Replacement or addition to EJBNo “Reinventing the wheels” rather

integrating with proven frameworksConfigurable using XML (or

annotations) metadataFirst version in 2002 by Rod Johnson

(released with his book “Expert One-on-One J2EE Design and Development”)

VMware acquired SpringSource in 2009

Page 3: Spring Framework

Modules (Features)Modules (Features)Inversion of Control (IoC)

◦Managed objects◦Dependency injection

Data access◦OR mapping integration◦JDBC templates◦Transaction management

Aspect Oriented Programming (AOP)

Testing MVC (and many more…)

Page 4: Spring Framework

Inversion of Control (IoC)Inversion of Control (IoC)IoC container manages object’s

lifecycle Managed objects are called as

beans!Dependency injection via

constructors, properties, factory methods

Page 5: Spring Framework

Data accessData accessIntegration with many data access

frameworks JDBC, Hibernate, JPA etc ◦Resource management like connections

etc◦Uniform exception handling (using

exception hierarchy) ◦Transaction management

JDBC transactions OR mapping (Unit of Work) transactions JTA transactions Integration with messaging and caching

systems

Page 6: Spring Framework

Data access (cont)Data access (cont)Template classes

◦Based on Template Method pattern◦JDBC templates helps eliminate

boilerplate code in DAOs ◦JMS templates ◦Templates for OR mapper

technologies

Page 7: Spring Framework

Aspect Oriented Aspect Oriented Programming (AOP)Programming (AOP)Separation of cross-cutting concernsIncrease in modularityOwn interception based AOP

frameworkConfigured at runtime (no

compilation step needed)Same nomenclature as that of

AspectJ (aspect, advice, pointcut etc)

Integration with AspectJUsed for transaction management,

security, JMX etc

Page 8: Spring Framework

TestingTestingEasy to unit test since everything is

POJO◦IoC helps (Spring bean factories, contexts

can be setup outside the container)◦No dependency on application server

services like JNDITest framework like

org.springframework.test package ◦Reuse business layer XML configuration◦Cache container configuration like JDBC

connection or Hibernate session factories◦Test methods can have transactions

(helpful for testing DAOs)

Page 9: Spring Framework

MVCMVCSpring has its own MVC

framework similar to struts◦Strategy interfaces based design◦IoC helps easier unit testing

Integration with strutsIntegration with Flex BlazeDS

Page 10: Spring Framework

AdvantagesAdvantagesEffectively organize your middle tier objects

(with/without EJB) (no need of service locators!)Promotes programming to interfaces, rather

than classes (helps to perform mock-object testing!)

Eliminate the proliferation of Singletons Minimum or zero dependency on Spring APIsEasy to unit test (no need of deployment for

testing!)Declarative transaction management using AOP

(no need of heavy EJB container!)Build applications using POJOs!

Page 11: Spring Framework

Case study: SomeProjectCase study: SomeProjectIoC

◦IoC container manage object lifecycle and dependency injection

◦IoC managed singletonsProgramming for interfaces

◦Mock object injection of business layer classes enable unit testing of presentation tier delegate classes

◦Course grain business services exposed to client objects

Page 12: Spring Framework

Case study: SomeProject Case study: SomeProject (cont)(cont)Integration with JPA

◦JPA hides OR mapping framework like Hibernate

◦DI of PersistenceContext in beansAOP

◦Declarative transaction management for service layer objects

Ease of unit testing ◦Unit testing of business layer POJOs

using Spring TestContext framework◦No need of application deployment for

unit testing

Page 13: Spring Framework

Case study: SomeProject Case study: SomeProject (cont)(cont)Business logic portability

◦Zero dependency on Spring API◦Zero dependency on Hibernate /

TopLink API (JPA helps!)◦JTA not needed and even heavy

application server not needed (deployment in tomcat!)

Page 14: Spring Framework

ReferencesReferences http://en.wikipedia.org/wiki/Spring_Framework

http://www.springsource.org

Page 15: Spring Framework

Thank you!Thank you!