- Java 5 Support - The core API of Spring 3.0 framework is using Java 5, so Java5 or above is required to run Spring 3.0 based applications. Java 5 features such as generics and annotations and varargs can be used in Spring 3.0 Framework based applications. The Spring 3.0 is fully compatible with the JEE1.4 and JEE5.
- Spring Expression Language (SpEL) - Spring 3.0 introduces Spring Expression Language (SpEL), a powerful expression language that supports querying and manipulating an object graph at runtime. With SpEL, Spring applications can overcome the limitation of using only fixed values in configuration files. It can be used for bean definitions in both XML- and annotation-based configurations.
- IoC enhancements/Java based bean metadata are introduced - Some of the Spring JavaConfig capabilities have been migrated into the core framework, such as @Configuration, @Bean, @Primary, @DependsOn, @Lazy, @Import and @Value.
- Declarative model validation using constraint annotations - JSR 303 (Bean Validation) annotations support has been added and validation rules can now be added to beans using annotations such as @NotNull and @Max(23).
- Comprehensive REST support in Spring MVC - Support for building RESTful servers and clients has been added.
- Java EE 6 support - Many of the Java EE 6 features such as JPA 2.0 and JSF 2.0 are supported and they work on non-EE 6 containers like Tomcat and J2EE 1.4 app servers.
- Annotation-based formatting - Bean fields can be automatically formatted and converted using annotations such as @DateFimeFormat(iso=ISO.DATE) and @NumberFormat(style=Style.CURRENCY).
- Support for embedded databases -Support for embedded Java database engines provides by the org.springframework.jdbc.datasource.embedded package (HSQL, H2, and Derby).
- Object to XML Mapping(OXM)- The Object-to-XML (OXM) mapping functionality from the Spring Web Services project has been moved into the Core Spring Framework (org.springframework.oxm).
- Support for Hibernate 4.x (Spring 3.1): org.springframework.orm.hibernate4 package.
- Support for Servlet 3 based asynchronous request processing (Spring3.1): The Spring MVC programming model now provides explicit Servlet 3 async support. @RequestMapping methods can return one of:
- java.util.concurrent.Callable to complete processing in a separate thread managed by a task executor within Spring MVC.
- org.springframework.web.context.request.async.DeferredResult to complete processing at a later time from a thread not known to Spring MVC — for example, in response to some external event (JMS, AMQP, etc.)
- org.springframework.web.context.request.async.AsyncTask to wrap a Callable and customize the timeout value or the task executor to use.
- Spring MVC Test framework (Spring 3.1): First-class support for testing Spring MVC applications with a fluent API and without a Servlet container. Server-side tests involve use of the DispatcherServlet while client-side REST tests rely on the RestTemplate.
- Refined Java SE 7 / OpenJDK 7 support (Spring 3.2): Spring Framework 3.2 comes with refined Java 7 support within the framework as well as through upgraded third-party dependencies: specifically, CGLIB 3.0, ASM 4.0
Sunday, February 2, 2014
New Features in Spring Framework 3.x
New Features in Spring Framework 3.x:
New Features in Spring Framework 2.5:
New Features in Spring Framework 2.5:
- Annotation-driven configuration: Annotation-driven dependency injection through @Autowired annotation and fine-grained auto wiring control with@Qualifier.
Support for JSR-250 annotations including @Resource for dependency injection of a named resource, as well as @PostConstruct and @PreDestroy for life-cycle methods.
- Autodetecting components in the classpath: Spring 2.5 introduces support component scanning: autodetecting annotated components in the classpath. Typically, such component classes will be annotated with stereotypes such as @Component, @Repository, @Service, @Controller.
- Portlet framework: Spring 2.0 ships with a Portlet framework that is conceptually similar to the Spring MVC framework.
- Enhanced testing support: Spring 2.5 introduces the Spring TestContext Framework which provides annotation-driven unit and integration testing. A new integration test framework that is based on JUnit 4 and Annotations.
- Java 5 (Tiger) support: Java 5 support in Spring 2.0 and 2.5.
- Dynamic language support: Spring 2.5 refines the dynamic languages support with autowiring and support for the recently released JRuby 1.0.
- Java EE 5 support: including JTA 1.1, JavaMail 1.4 and JAX-WS2.0 etc.
- Support for AspectJ load-time weaving: Spring 2.5 introduces explicit support AspectJ load-time weaving, as alternative to the proxy-based AOP framework. The new context:load-time-weaver configuration element automatically activates AspectJ aspects as defined in AspectJ's META-INF/aop.xml descriptor, applying them to the current application context through registering a transformer with the underlying ClassLoader.
- Easier XML configuration: New XML configuration namespaces, including context namespace for configuring application context details and a jms namespace for configuring message-driven beans.
Step by Step to develop Spring4.0 Application
Step1: Create Java Project
The first step is to create a simple Java Project using Eclipse IDE. Follow the option File -> New -> Project and finally select Java Project wizard from the wizard list. Now name your project as HelloWorld.
Step 2 - Add Required Libraries:
Add Spring Framework and common logging API libraries in HelloWorld project. To do this, right click on your project name HelloWorld and then follow the following option available in context menu: Build Path -> Configure Build Path to display the Java Build Path.
Now use Add External JARs button available under Libraries tab to add the following core JARs from Spring Framework and Common Logging installation directories:
Windows:
SPRING4_HOME=E:\ranga\MyFiles\Spring\Software\spring-framework-4.0.0.RELEASE
SPRING4_HOME=E:\ranga\MyFiles\Spring\Software\spring-framework-4.0.0.RELEASE
Linux:
SPRING4_HOME=/home/ranga/MyFiles/Spring/Software/spring-framework-4.0.0.RELEASE
SPRING4_HOME=/home/ranga/MyFiles/Spring/Software/spring-framework-4.0.0.RELEASE
%SPRING4_HOME%/libs/spring-core-4.0.0.RELEASE.jar
%SPRING4_HOME%/libs/spring-beans-4.0.0.RELEASE.jar
commons-logging-1.1.3.jar
Step 3 - Create HelloMessage Interface (HelloMessage.java) :
package com.ranga;
public interface HelloMessage {
public void sayHello();
}
Step 4 - Create HelloMessageImpl Class (HelloMessageImpl.java) :
package com.ranga;
public class HelloMessageImpl implements HelloMessage{
@Override
public void sayHello() {
System.out.println("Hello Ranga!");
}
}
Step 5 - Create Bean Configuration file (beans.xml):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<bean id="helloMessage" class="com.ranga.HelloMessageImpl"></bean>
</beans>
Step 6 - Create Client Application (Application.java):
package com.ranga;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
public class Application {
public static void main(String[] args) {
Resource resource = new ClassPathResource("beans.xml");
BeanFactory beanFactory = new XmlBeanFactory(resource);
HelloMessage helloMessage = (HelloMessage) beanFactory.getBean("helloMessage");
helloMessage.sayHello();
}
}
Step 7 - Run the Application (Application.java):
Feb 2, 2014 11:31:26 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [beans.xml]
Hello Ranga!Next Program We can see by using Annotations and Java Configuration
.............
Coming soon......
Difference between Spring and Struts framework:
The major differences between Spring framework and Struts framework are :
Spring | Struts |
Spring is an application framework in which Spring MVC is one of the modules of Spring framework. | Struts is a web framework which can be used to develop web applications. |
Spring implements IOC Design Pattern. | Struts implement MVC Design Pattern. |
It provides abstraction layer on multiple Java/J2EE technologies including Servlet, JSPs. Also provides abstraction on other framework software. | It provides abstraction layer only on Servlet, JSP technology. |
Spring is a Layered Architecture. | Struts is a not a Layered Architecture. |
Spring Framework is said to be a non-invasive means it doesn’t force a programmer to extend or implement their class from any predefined class or interface given by Spring API. | Struts is said to be invasive. In Struts we used to extend Action Class. It forces the programmer that, the programmer class must extend from the base class provided by Struts API. |
Spring provides easy integration with ORM, JDBC technologies. | In Struts, integrating with ORM, JDBC technology, we need to do manually coding. |
Gives built-in middleware services like transaction, logging, connection pooling etc. | Doesn’t give built-in middleware services. |
Spring is Lightweight framework. | Struts is Heavyweight framework. |
Spring is loosely coupled. | Struts is tightly coupled. |
It is not easy to integrate with other client side technologies. | It is easy to integrate with other client side technologies. |
Spring MVC just provides tags for basic HTML form tags. | Struts 2 provides many out-of-box JSF styled complex and composite tags Such as: Ajax DOJO tags |
For View component, Spring allows JSP, Velocity, Freemarker, Excel and PDF | For View component Struts allows only JSP. |
Spring MVC provides more handler mappings. | Struts doesn’t have specific handler mappings but uses Action mappings. |
Spring clear module division between Model, View and Controller. | Struts mixes Controller and Model. |
Advantages of Spring Framework:
| Advantages of Struts Framework:
|
Saturday, February 1, 2014
Migrating to Spring Framework 4.0
Hi friends to migrate from 3.x to 4.x the documentation is available in git hub. Click here to see.
or
Git Hub URL: https://github.com/spring-projects/spring-framework/wiki/Migrating-from-earlier-versions-of-the-spring-framework
or
Git Hub URL: https://github.com/spring-projects/spring-framework/wiki/Migrating-from-earlier-versions-of-the-spring-framework