SlideShare a Scribd company logo
Spring 2.0 GouthamV Sr.Software Engineer InfoGroup
  Spring 2.0 Simplified, extensible XML schema based configuration. New JSP form tags. Powerful new Spring AOP features and AspectJ 5 integration, also leveraging new XML configuration. Asynchronous JMS facilities enabling message driven POJOs. JPA (Java Persistence API) Integration. Spring Portlet MVC. Full backwards compatibility.
Spring 2.0 : XSD-driven Configuration Spring 1.2.x: <! DOCTYPE  beans  PUBLIC  &quot;-//SPRING//DTD BEAN//EN&quot;  &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot; > or <! DOCTYPE  beans  PUBLIC  &quot;-//SPRING//DTD BEAN//EN&quot;  &quot;http://www.springframework.org/dtd/spring-beans-2.0.dtd&quot; > Spring 2.0: < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot;   xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot;   xsi:schemaLocation =  &quot;http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd ” >
Spring 2.0 : XSD-driven Configuration XML schema based configuration file makes Spring XML  configuration easier. Namespaces M ore concise configuration. Better validation and code-completion in IDE. Extensible for higher level domain-specific configurations. Out-of-the-box namespaces:   Special namespace- property (“p”) Utils (“util”) Java EE(“jee”) AOP(“aop”) Transactions management(“tx”) Dynamic Languages(“lang”)
Spring 2.0 : Namespace examples-property(“p”) <beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot;   xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot;   xmlns:p = &quot;http://www.springframework.org/schema/p&quot; xsi:schemaLocation =  “ http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; > Spring 1.2  < bean  id = &quot;salesRepController&quot;  class = &quot;isis.oe.web.controllers.logon.SalesRepController&quot; > < property  name = &quot;formView&quot; >< value > login_repnum_entry </ value ></ property > < property  name = &quot;successView&quot; >< value > redirect:search.html </ value ></ property > </ bean > Spring 2 .0 < bean  id = &quot;salesRepController&quot;  class = &quot;isis.oe.web.controllers.logon.SalesRepController&quot;  p:formView = &quot;login_repnum_entry&quot;  p:successView = &quot;redirect:search.html&quot;  />
Spring 2.0 : Namespace examples-property(“p”) Spring 1.2  < bean  id = &quot;searchController&quot;  class = &quot;isis.oe.web.controllers.search.SearchController&quot; > < property  name = &quot;validator&quot; >< ref  bean = &quot;searchParamsValidator&quot; /></ property > < property  name = &quot;formView&quot; >< value > search </ value ></ property > </ bean > < bean  id = &quot;searchParamsValidator&quot;  class = &quot;isis.oe.web.validator.SearchParamsValidator&quot; /> Spring 2 .0 < bean  id = &quot;searchController&quot;  class = &quot;isis.oe.web.controllers.search.SearchController&quot;  p:validator-ref = &quot;searchParamsValidator&quot;  p:formView = &quot;search&quot;  /> < bean  id = &quot;searchParamsValidator&quot;  class = &quot;isis.oe.web.validator.SearchParamsValidator&quot; />
Spring 2.0 : Namespace examples-JNDI(“jee”) < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot;   xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot;   xmlns:jee = &quot;http://www.springframework.org/schema/jee&quot;   xsi:schemaLocation =  &quot;http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee  http://www.springframework.org/schema/jee/spring-jee-2.0.xsd&quot; > Spring 1.2  < bean  id = &quot;jaznDataSource&quot;  class = &quot;org.springframework.jndi.JndiObjectFactoryBean&quot; > < property  name = &quot;jndiName&quot;  value = &quot;java:comp/env/jdbc/useradmin&quot; /> < property  name = &quot;resourceRef&quot; >< value > false </ value ></ property > </ bean > ( JndiObjectFactoryBean is Spring internal implementation class which is unnecessary for end user) Spring 2 .0 < jee:jndi-lookup  id = &quot;jaznDataSource&quot;  jndi-name = &quot;java:comp/env/jdbc/useradmin&quot;  resource-ref = &quot;false&quot;  />
Spring 2.0 : Namespace examples-JNDI(“jee”) Spring 1.2  < bean  id  =  &quot;simple&quot;  class = &quot;org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean&quot; > < property  name = &quot;jndiName&quot;  value = &quot;ejb/RentalServiceBean&quot; /> < property  name = &quot;businessInterface&quot;  value = &quot;com.foo.service.RentalService&quot; /> </ bean > ( LocalStatelessSessionProxyFactoryBean is Spring internal implementation class which is unnecessary for end user) Spring 2 .0 < jee:local-slsb  id = &quot;simpleSlsb&quot;  jndi-name  =  &quot;ejb/RentalServiceBean&quot;  business-   interface = &quot;com.foo.service.RentalService&quot; />
Spring 2.0 : Namespace examples- util - Properties < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot;   xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:util = &quot;http://www.springframework.org/schema/util&quot;   xsi:schemaLocation =  &quot;http://www.springframework.org/schema/beans      http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util  http://www.springframework.org/schema/util/spring-util-2.0.xsd&quot; > Spring 1.2  < bean  id = &quot;loadProperties&quot;  class = &quot;org.springframework.beans.factory.config.PropertiesFactoryBean&quot; > < property  name = &quot;location&quot;  value = &quot;classpath:message.properties&quot; /> </ bean > Spring 2 .0 < util:properties  id = &quot;loadProperties&quot;  location = &quot;classpath: message.properties&quot; />
Spring 2.0 : Namespace examples- util - Constant Spring 1.2  < bean  id = “constant&quot;  class = “com.iusa.util.UtilTest&quot; > < property  name = &quot;isolation&quot; > < bean  id = &quot;java.sql.Connection.TRANSACTION_REPEATABLE_READ&quot;  class = &quot;org.springframework.beans.factory.config.FieldRetrievingFactoryBean&quot;  /> </ property > </ bean > Spring 2 .0 < bean  id = &quot; constant &quot;  class = &quot; com.iusa.util.UtilTest&quot; > < property  name = &quot;isolation&quot; > < util:constant  static-field = &quot;java.sql.Connection.TRANSACTION_SERIALIZABLE&quot; /> </ property > </ bean >
Spring 2.0 : Namespace examples- util - List Spring 1.2  < bean  id = &quot;emailList&quot;  class = &quot;org.springframework.beans.factory.config.ListFactoryBean&quot; > < property  name = &quot;sourceList&quot; > < list >   < value > gautamr@ infousa.com </ value >   < value > [email_address] </ value > </ list > </ property > </ bean > Spring 2.0 < util:list  id = &quot; emailList &quot; > < value >  gautamr @ gautamr. com  </ value > < value >  abc@def.com  </ value > </ util:list >
Spring 2.0 : Namespace examples- util - Map Spring 1.2  < bean  id = &quot;emailMap&quot;  class = &quot;org.springframework.beans.factory.config.MapFactoryBean&quot; > < property  name = &quot;sourceMap&quot; > < map > < entry  key = &quot; gautamr &quot;  value = &quot; gautamr@ infousa.com &quot; /> < entry  key = &quot;  abc &quot;  value = “ [email_address] &quot; /> </ map > </ property > </ bean > Spring 2.0 < util:map  id = &quot;emailMap&quot; > < entry  key = &quot; gautamr &quot;  value = &quot; gautamr@ infousa.com &quot; /> < entry  key = &quot;  abc &quot;  value = “ [email_address] &quot; /> </ util: map  >
Spring 2.0 : Scopes Spring 1.2 Singleton & Prototype Ex: <!-- spring-beans-2.0.dtd --> < bean  id = &quot;id&quot;  class = &quot;com.foo.TestScope&quot;  scope = &quot;singleton&quot; /> <!-- spring-beans.dtd --> < bean  id = &quot;id&quot;  class = &quot;com.foo.TestScope&quot;  singleton = &quot;true&quot; />   Spring 2.0 Singleton, Prototype, Request, Session, GlobalSession,  UserDefined scope Ex: < bean  id = &quot;id&quot;  class = &quot;com.foo.TestScope&quot;  scope = “request&quot; />
Spring 2.0 : Scopes Scopes a single bean definition to the lifecycle of a HTTP Session. Only valid in the context of a web-aware  Spring ApplicationContext. session Scopes a single bean definition to the lifecycle of a single HTTP request; i.e. each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext. request Scopes a single bean definition to any number of object instances. prototype Scopes a single bean definition to a single object instance per Spring IoC container. singleton Description Scope
Spring 2.0 : Scopes Scopes a single bean definition to the lifecycle of a global HTTP  Session . Typically only valid when used in a  portlet context . Only valid in the context of a web-aware Spring  ApplicationContext . Global Session
Spring 2.0 : Scopes – request & session Minor initial configuration is required before you can set about defining definitions request and session If you are using a Servlet 2.4+ web container, add the following  ContextListener  to the XML declarations in your web application's  'web.xml'  file. < web-app > < listener > < listener-class > org.springframework.web.context.request.RequestContextListener. </ listener-class > </ listener > </ web-app > If you are using an older web container (before Servlet 2.4), add the following to ‘web.xml’ < filter > < filter-name > requestContextFilter </ filter-name > < filter-class > org.springframework.web.filter.RequestContextFilter </ filter-class > </ filter > < filter-mapping > < filter-name > requestContextFilter </ filter-name > < url-pattern > /* </ url-pattern > </ filter-mapping >
Spring 2.0 : Scopes – Custom scope As of Spring 2.0, the bean scoping mechanism in Spring is extensible, that is you can define your own scopes. Steps to create your own custom scope Implement  org.springframework.beans.factory.config.Scope  interface Make the Spring container aware of your new scope(s). Scope myScope = new MyScope(); beanFactory.registerScope(“ scopename &quot;, myScope); You can then create bean definitions that adhere to the scoping rules of your custom  Scope <bean id=&quot;...&quot; class=&quot;...&quot;  scope=&quot;scopename&quot; />
Spring 2.0 : Form tag As of version 2.0, Spring provides a comprehensive set of data binding-aware tags for handling form elements when using JSP and Spring Web MVC Similar to the Struts <html:xxxx> tags. Spring's form tag library is integrated with Spring Web MVC, giving the tags access to the command object and reference data your controller deals with . To use the tags from this library, add the following directive to the top of your JSP page: <%@ taglib prefix=&quot;form&quot; uri=&quot;http://www.springframework.org/tags/form&quot; %> List of form tags: <form:checkbox />, <form:errors />, <form:form />,  <form:hidden />, <form:input />, <form:label />  <form:option />, <form:options />, <form:password />, <form:radiobutton />, <form:select />, <form:textarea />,
Spring 2.0 : Other features - Namespaces Dynamic Language support(“lang”) AOP(“aop”) Transactions management(“tx”) Ex: < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:aop = &quot;http://www.springframework.org/schema/aop&quot; xmlns:tx = &quot;http://www.springframework.org/schema/tx&quot; xmlns:lang = &quot;http://www.springframework.org/schema/lang&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd&quot; >
Spring 2.0 : Other features - Dynamic Language support(“lang”) Spring 2.0 introduces comprehensive support for using classes and objects  that have been defined using a dynamic language The dynamic languages currently supported are: JRuby Groovy BeanShell Ex: <!-- this is the bean definition for the Groovy-backed Messenger implementation --> < lang:groovy  id = &quot;messenger&quot;  script-source = &quot;classpath:Messenger.groovy&quot; > < lang:property  name = &quot;message&quot;  value = “Hello Groovy&quot;  /> </ lang:groovy >
Spring 2.0 : Other features Powerful new Spring AOP features and AspectJ 5 integration, also leveraging new XML configuration Asynchronous JMS facilities enabling Message Driven POJOs(MDP) Prior to Spring 2.0, Spring's JMS offering was limited to sending messages and the  synchronous  receiving of messages. Spring 2.0 now ships with full support for the reception of messages in an asynchronous fashion using MDP JPA (Java Persistence API) Integration Spring Portlet MVC
Spring 2.0 : Deprecated classes and methods Previously were marked as  @deprecated  classed and methods   have been removed from the Spring 2.0 codebase. The following classes/interfaces have been removed from the Spring 2.0 codebase: •  ResultReader  : Use the  RowMapper  interface instead. •  BeanFactoryBootstrap  : Consider using a  BeanFactoryLocator
Spring 2.0 : 1.2 to 2.0 migration steps Download latest spring.jar from  http://www.springframework.org/download ( Spring Framework 2.0.2 is the current production release ) Note: Jar packaging: The packaging of the Spring Framework jars has changed quite substantially between the 1.2.x and 2.0 releases. In particular,  there are now dedicated jars for  the JDO, Hibernate 2/3, TopLink ORM integration classes: they are no longer  bundled in the core  'spring.jar'   file anymore.
Spring 2.0 : Resources http://static.springframework.org/spring/docs/2.0.x/reference/index.html http://www.infoq.com/articles/spring-2-intro  by Rod Johnson (Creater of spring) http://www.infoq.com/articles/Simplifying-Enterprise-Apps

More Related Content

PPT
Spring 2.0
PPT
merb.intro
ODP
Developing and testing ajax components
PPT
What's new in Rails 2?
PPT
Boston Computing Review - Ruby on Rails
PPT
Getting More Traffic From Search Advanced Seo For Developers Presentation
PPT
Advanced SEO for Web Developers
PDF
Front End on Rails
Spring 2.0
merb.intro
Developing and testing ajax components
What's new in Rails 2?
Boston Computing Review - Ruby on Rails
Getting More Traffic From Search Advanced Seo For Developers Presentation
Advanced SEO for Web Developers
Front End on Rails

What's hot (20)

PPT
JSP Custom Tags
PPT
Evolution of API With Blogging
PPT
Widgets Tools Keynote
PPT
Changing Template Engine
PPT
Apache Camel - WJax 2008
PPTX
JSP custom tags
PPT
Web APIs & Google APIs
PPT
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
PPT
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
PPTX
DevDays09 Internet Explorer 8
PPTX
E Pi Server Easy Search Technical Overview
PPT
Django
PPT
New Browsers
ODP
Beautiful Java EE - PrettyFaces
PPTX
Meetup django common_problems(1)
PDF
Rails and security
PDF
Finding things on the web with BOSS
PPT
Week7
 
PPT
Fast Loading JavaScript
PDF
fast prototyping with sinatra sequel w2tags
JSP Custom Tags
Evolution of API With Blogging
Widgets Tools Keynote
Changing Template Engine
Apache Camel - WJax 2008
JSP custom tags
Web APIs & Google APIs
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
DevDays09 Internet Explorer 8
E Pi Server Easy Search Technical Overview
Django
New Browsers
Beautiful Java EE - PrettyFaces
Meetup django common_problems(1)
Rails and security
Finding things on the web with BOSS
Week7
 
Fast Loading JavaScript
fast prototyping with sinatra sequel w2tags
Ad

Viewers also liked (7)

PPT
Booa8 Slide 04
PPT
Project management slide - Introduction
PPTX
Law of diminishing marginal utility
PPTX
Diminishing marginal utility
PPT
ISO 14000
DOCX
Plan de asignatura de tecnología e informática de 1-11 2017
PDF
Beyond the Gig Economy
Booa8 Slide 04
Project management slide - Introduction
Law of diminishing marginal utility
Diminishing marginal utility
ISO 14000
Plan de asignatura de tecnología e informática de 1-11 2017
Beyond the Gig Economy
Ad

Similar to Spring 2.0 (20)

ZIP
GTAC: AtomPub, testing your server implementation
PPT
Struts2
PDF
Seam Glassfish Slidecast
PPTX
Using Forms in Share
PPT
Ajax ons2
PPTX
Alfresco Search Internals
PPTX
สปริงเฟรมเวิร์ค4.1
ODP
Разработка приложений для Android Honeycomb: ActionBar & Fragments
ODP
2. wiring beans
PPT
KMUTNB - Internet Programming 3/7
PPT
Spring overview
PPT
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
PPT
PDF
Building Web Interface On Rails
PPT
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
PPT
Krazykoder struts2 data_tags
PPT
Grddl In A Nutshell V1
ODP
Introduction into Struts2 jQuery Grid Tags
PPT
Facebook Development with Zend Framework
GTAC: AtomPub, testing your server implementation
Struts2
Seam Glassfish Slidecast
Using Forms in Share
Ajax ons2
Alfresco Search Internals
สปริงเฟรมเวิร์ค4.1
Разработка приложений для Android Honeycomb: ActionBar & Fragments
2. wiring beans
KMUTNB - Internet Programming 3/7
Spring overview
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
Building Web Interface On Rails
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Krazykoder struts2 data_tags
Grddl In A Nutshell V1
Introduction into Struts2 jQuery Grid Tags
Facebook Development with Zend Framework

Recently uploaded (20)

PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
August Patch Tuesday
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Getting Started with Data Integration: FME Form 101
PDF
Encapsulation theory and applications.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Mushroom cultivation and it's methods.pdf
DP Operators-handbook-extract for the Mautical Institute
Unlocking AI with Model Context Protocol (MCP)
Zenith AI: Advanced Artificial Intelligence
August Patch Tuesday
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
cloud_computing_Infrastucture_as_cloud_p
WOOl fibre morphology and structure.pdf for textiles
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
OMC Textile Division Presentation 2021.pptx
Hindi spoken digit analysis for native and non-native speakers
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Getting Started with Data Integration: FME Form 101
Encapsulation theory and applications.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Mushroom cultivation and it's methods.pdf

Spring 2.0

  • 1. Spring 2.0 GouthamV Sr.Software Engineer InfoGroup
  • 2. Spring 2.0 Simplified, extensible XML schema based configuration. New JSP form tags. Powerful new Spring AOP features and AspectJ 5 integration, also leveraging new XML configuration. Asynchronous JMS facilities enabling message driven POJOs. JPA (Java Persistence API) Integration. Spring Portlet MVC. Full backwards compatibility.
  • 3. Spring 2.0 : XSD-driven Configuration Spring 1.2.x: <! DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot; > or <! DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans-2.0.dtd&quot; > Spring 2.0: < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd ” >
  • 4. Spring 2.0 : XSD-driven Configuration XML schema based configuration file makes Spring XML configuration easier. Namespaces M ore concise configuration. Better validation and code-completion in IDE. Extensible for higher level domain-specific configurations. Out-of-the-box namespaces: Special namespace- property (“p”) Utils (“util”) Java EE(“jee”) AOP(“aop”) Transactions management(“tx”) Dynamic Languages(“lang”)
  • 5. Spring 2.0 : Namespace examples-property(“p”) <beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:p = &quot;http://www.springframework.org/schema/p&quot; xsi:schemaLocation = “ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; > Spring 1.2 < bean id = &quot;salesRepController&quot; class = &quot;isis.oe.web.controllers.logon.SalesRepController&quot; > < property name = &quot;formView&quot; >< value > login_repnum_entry </ value ></ property > < property name = &quot;successView&quot; >< value > redirect:search.html </ value ></ property > </ bean > Spring 2 .0 < bean id = &quot;salesRepController&quot; class = &quot;isis.oe.web.controllers.logon.SalesRepController&quot; p:formView = &quot;login_repnum_entry&quot; p:successView = &quot;redirect:search.html&quot; />
  • 6. Spring 2.0 : Namespace examples-property(“p”) Spring 1.2 < bean id = &quot;searchController&quot; class = &quot;isis.oe.web.controllers.search.SearchController&quot; > < property name = &quot;validator&quot; >< ref bean = &quot;searchParamsValidator&quot; /></ property > < property name = &quot;formView&quot; >< value > search </ value ></ property > </ bean > < bean id = &quot;searchParamsValidator&quot; class = &quot;isis.oe.web.validator.SearchParamsValidator&quot; /> Spring 2 .0 < bean id = &quot;searchController&quot; class = &quot;isis.oe.web.controllers.search.SearchController&quot; p:validator-ref = &quot;searchParamsValidator&quot; p:formView = &quot;search&quot; /> < bean id = &quot;searchParamsValidator&quot; class = &quot;isis.oe.web.validator.SearchParamsValidator&quot; />
  • 7. Spring 2.0 : Namespace examples-JNDI(“jee”) < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:jee = &quot;http://www.springframework.org/schema/jee&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd&quot; > Spring 1.2 < bean id = &quot;jaznDataSource&quot; class = &quot;org.springframework.jndi.JndiObjectFactoryBean&quot; > < property name = &quot;jndiName&quot; value = &quot;java:comp/env/jdbc/useradmin&quot; /> < property name = &quot;resourceRef&quot; >< value > false </ value ></ property > </ bean > ( JndiObjectFactoryBean is Spring internal implementation class which is unnecessary for end user) Spring 2 .0 < jee:jndi-lookup id = &quot;jaznDataSource&quot; jndi-name = &quot;java:comp/env/jdbc/useradmin&quot; resource-ref = &quot;false&quot; />
  • 8. Spring 2.0 : Namespace examples-JNDI(“jee”) Spring 1.2 < bean id = &quot;simple&quot; class = &quot;org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean&quot; > < property name = &quot;jndiName&quot; value = &quot;ejb/RentalServiceBean&quot; /> < property name = &quot;businessInterface&quot; value = &quot;com.foo.service.RentalService&quot; /> </ bean > ( LocalStatelessSessionProxyFactoryBean is Spring internal implementation class which is unnecessary for end user) Spring 2 .0 < jee:local-slsb id = &quot;simpleSlsb&quot; jndi-name = &quot;ejb/RentalServiceBean&quot; business- interface = &quot;com.foo.service.RentalService&quot; />
  • 9. Spring 2.0 : Namespace examples- util - Properties < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:util = &quot;http://www.springframework.org/schema/util&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd&quot; > Spring 1.2 < bean id = &quot;loadProperties&quot; class = &quot;org.springframework.beans.factory.config.PropertiesFactoryBean&quot; > < property name = &quot;location&quot; value = &quot;classpath:message.properties&quot; /> </ bean > Spring 2 .0 < util:properties id = &quot;loadProperties&quot; location = &quot;classpath: message.properties&quot; />
  • 10. Spring 2.0 : Namespace examples- util - Constant Spring 1.2 < bean id = “constant&quot; class = “com.iusa.util.UtilTest&quot; > < property name = &quot;isolation&quot; > < bean id = &quot;java.sql.Connection.TRANSACTION_REPEATABLE_READ&quot; class = &quot;org.springframework.beans.factory.config.FieldRetrievingFactoryBean&quot; /> </ property > </ bean > Spring 2 .0 < bean id = &quot; constant &quot; class = &quot; com.iusa.util.UtilTest&quot; > < property name = &quot;isolation&quot; > < util:constant static-field = &quot;java.sql.Connection.TRANSACTION_SERIALIZABLE&quot; /> </ property > </ bean >
  • 11. Spring 2.0 : Namespace examples- util - List Spring 1.2 < bean id = &quot;emailList&quot; class = &quot;org.springframework.beans.factory.config.ListFactoryBean&quot; > < property name = &quot;sourceList&quot; > < list > < value > gautamr@ infousa.com </ value > < value > [email_address] </ value > </ list > </ property > </ bean > Spring 2.0 < util:list id = &quot; emailList &quot; > < value > gautamr @ gautamr. com </ value > < value > abc@def.com </ value > </ util:list >
  • 12. Spring 2.0 : Namespace examples- util - Map Spring 1.2 < bean id = &quot;emailMap&quot; class = &quot;org.springframework.beans.factory.config.MapFactoryBean&quot; > < property name = &quot;sourceMap&quot; > < map > < entry key = &quot; gautamr &quot; value = &quot; gautamr@ infousa.com &quot; /> < entry key = &quot; abc &quot; value = “ [email_address] &quot; /> </ map > </ property > </ bean > Spring 2.0 < util:map id = &quot;emailMap&quot; > < entry key = &quot; gautamr &quot; value = &quot; gautamr@ infousa.com &quot; /> < entry key = &quot; abc &quot; value = “ [email_address] &quot; /> </ util: map >
  • 13. Spring 2.0 : Scopes Spring 1.2 Singleton & Prototype Ex: <!-- spring-beans-2.0.dtd --> < bean id = &quot;id&quot; class = &quot;com.foo.TestScope&quot; scope = &quot;singleton&quot; /> <!-- spring-beans.dtd --> < bean id = &quot;id&quot; class = &quot;com.foo.TestScope&quot; singleton = &quot;true&quot; /> Spring 2.0 Singleton, Prototype, Request, Session, GlobalSession, UserDefined scope Ex: < bean id = &quot;id&quot; class = &quot;com.foo.TestScope&quot; scope = “request&quot; />
  • 14. Spring 2.0 : Scopes Scopes a single bean definition to the lifecycle of a HTTP Session. Only valid in the context of a web-aware Spring ApplicationContext. session Scopes a single bean definition to the lifecycle of a single HTTP request; i.e. each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext. request Scopes a single bean definition to any number of object instances. prototype Scopes a single bean definition to a single object instance per Spring IoC container. singleton Description Scope
  • 15. Spring 2.0 : Scopes Scopes a single bean definition to the lifecycle of a global HTTP Session . Typically only valid when used in a portlet context . Only valid in the context of a web-aware Spring ApplicationContext . Global Session
  • 16. Spring 2.0 : Scopes – request & session Minor initial configuration is required before you can set about defining definitions request and session If you are using a Servlet 2.4+ web container, add the following ContextListener to the XML declarations in your web application's 'web.xml' file. < web-app > < listener > < listener-class > org.springframework.web.context.request.RequestContextListener. </ listener-class > </ listener > </ web-app > If you are using an older web container (before Servlet 2.4), add the following to ‘web.xml’ < filter > < filter-name > requestContextFilter </ filter-name > < filter-class > org.springframework.web.filter.RequestContextFilter </ filter-class > </ filter > < filter-mapping > < filter-name > requestContextFilter </ filter-name > < url-pattern > /* </ url-pattern > </ filter-mapping >
  • 17. Spring 2.0 : Scopes – Custom scope As of Spring 2.0, the bean scoping mechanism in Spring is extensible, that is you can define your own scopes. Steps to create your own custom scope Implement org.springframework.beans.factory.config.Scope interface Make the Spring container aware of your new scope(s). Scope myScope = new MyScope(); beanFactory.registerScope(“ scopename &quot;, myScope); You can then create bean definitions that adhere to the scoping rules of your custom Scope <bean id=&quot;...&quot; class=&quot;...&quot; scope=&quot;scopename&quot; />
  • 18. Spring 2.0 : Form tag As of version 2.0, Spring provides a comprehensive set of data binding-aware tags for handling form elements when using JSP and Spring Web MVC Similar to the Struts <html:xxxx> tags. Spring's form tag library is integrated with Spring Web MVC, giving the tags access to the command object and reference data your controller deals with . To use the tags from this library, add the following directive to the top of your JSP page: <%@ taglib prefix=&quot;form&quot; uri=&quot;http://www.springframework.org/tags/form&quot; %> List of form tags: <form:checkbox />, <form:errors />, <form:form />, <form:hidden />, <form:input />, <form:label /> <form:option />, <form:options />, <form:password />, <form:radiobutton />, <form:select />, <form:textarea />,
  • 19. Spring 2.0 : Other features - Namespaces Dynamic Language support(“lang”) AOP(“aop”) Transactions management(“tx”) Ex: < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:aop = &quot;http://www.springframework.org/schema/aop&quot; xmlns:tx = &quot;http://www.springframework.org/schema/tx&quot; xmlns:lang = &quot;http://www.springframework.org/schema/lang&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd&quot; >
  • 20. Spring 2.0 : Other features - Dynamic Language support(“lang”) Spring 2.0 introduces comprehensive support for using classes and objects that have been defined using a dynamic language The dynamic languages currently supported are: JRuby Groovy BeanShell Ex: <!-- this is the bean definition for the Groovy-backed Messenger implementation --> < lang:groovy id = &quot;messenger&quot; script-source = &quot;classpath:Messenger.groovy&quot; > < lang:property name = &quot;message&quot; value = “Hello Groovy&quot; /> </ lang:groovy >
  • 21. Spring 2.0 : Other features Powerful new Spring AOP features and AspectJ 5 integration, also leveraging new XML configuration Asynchronous JMS facilities enabling Message Driven POJOs(MDP) Prior to Spring 2.0, Spring's JMS offering was limited to sending messages and the synchronous receiving of messages. Spring 2.0 now ships with full support for the reception of messages in an asynchronous fashion using MDP JPA (Java Persistence API) Integration Spring Portlet MVC
  • 22. Spring 2.0 : Deprecated classes and methods Previously were marked as @deprecated classed and methods have been removed from the Spring 2.0 codebase. The following classes/interfaces have been removed from the Spring 2.0 codebase: • ResultReader : Use the RowMapper interface instead. • BeanFactoryBootstrap : Consider using a BeanFactoryLocator
  • 23. Spring 2.0 : 1.2 to 2.0 migration steps Download latest spring.jar from http://www.springframework.org/download ( Spring Framework 2.0.2 is the current production release ) Note: Jar packaging: The packaging of the Spring Framework jars has changed quite substantially between the 1.2.x and 2.0 releases. In particular, there are now dedicated jars for the JDO, Hibernate 2/3, TopLink ORM integration classes: they are no longer bundled in the core 'spring.jar' file anymore.
  • 24. Spring 2.0 : Resources http://static.springframework.org/spring/docs/2.0.x/reference/index.html http://www.infoq.com/articles/spring-2-intro by Rod Johnson (Creater of spring) http://www.infoq.com/articles/Simplifying-Enterprise-Apps