• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Spring 2.0
 

Spring 2.0

on

  • 2,418 views

 

Statistics

Views

Total Views
2,418
Views on SlideShare
2,415
Embed Views
3

Actions

Likes
3
Downloads
0
Comments
0

1 Embed 3

http://www.slideshare.net 3

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Spring 2.0 Spring 2.0 Presentation Transcript

    • 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