This documentation is not maintained. Please refer to doc.castsoftware.com/technologies to find the latest updates.

Summary: this page provides an explanation of Spring Frameworks.

What is Spring?

Spring is essentially a technology dedicated to enabling you to build applications using POJOs (Plain Old Java Object). This desirable goal requires a sophisticated framework, which conceals much complexity from the developer.
In short, Spring provides a lot of functionalities:

  • Inversion of control container
  • JDBC abstraction and data access exception hierarchy
  • O/R mapping integration
  • AOP (Aspect-oriented programming)
  • MVC web framework similar to Struts
  • Ease EJB implementation
  • Ease testing

For more information refer to: Introduction to Spring Framework. Note that CAST manages only the IoC part of Spring:

  • For Spring 1.2.x, Spring beans and links between Spring beans are created.
  • For Spring 2.x and above, only Spring beans are created. Annotations and XML configuration is taken into account.

Analysis setup

Among the other tasks that you need to perform for a normal JEE analysis, here are the specifics for Spring:

Environment Profile

In order to analyze Spring applications, you must select the appropriate Environment Profiles in your Application or Analysis Unit:

Check for each environment that your application uses the same version, otherwise duplicate the Environment Profile to preserve parametrization, change its name and select the right version of the archive.

XML files

In the Application or Analysis Unit configuration, you need to select an XML directory that contains Spring Configuration files. The selection of the Spring Environment Profile will automatically find Spring XML files and manage them. In Spring 1.2.x, Spring XML files refer to the Spring DTD (all Spring files must refer to it):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
[...]
</beans>
In Spring 2.x, Spring XML files refer to the Spring namespace:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
...
<beans>

Annotations

The Spring annotations are automatically taken into account when you select the Spring Framework Environment Profile.

Restitution Sample for Spring

  • The main method reference the Spring Bean createCreditCard through AbstractApplicationContext.getBean() call
  • The Spring Bean reference its implementation class
  • The Spring Bean reference other Spring Beans (only available for Spring 1.2.x)