I'm proud to announce the first official release of Acceleo module generator for "Spring Framework". It is available with the latest version of Acceleo 2.2.

The "JEE / Spring" Acceleo module uses UML2 models with stereotypes in order to generate applications based on the Spring Framework.

It generates applications with multi-tiers architecture with the following layers:

  • User Interface layer
  • Data Transfert Objects layer
  • Business Services layer
  • Data Acces Objects layer


Presentation of the target technology:

Spring is a lightweight container, which provides similar infrastructure than the Java EE platform. It provides the ability to create / instanciate objects and manage their dependencies. The major advantage of this approach is the possibility to exclusively use POJO (Plain Old Java Objects, objects without any reference of specifics Java interfaces). It also offers the ability to realize loosely coupled between all application layers by using together the dependency injection and the programming with interface. Several features such as security or transactions can be declaratively specified in the XML configuration file, ... Even with the new features of the version 2 of Spring, the major drawback of this framework is the usage of XML files in order to specify dependencies. These files, seems sometimes to be complex to write and maintain.

Hibernate Hibernate is a framework used with the Java EE platform to manage object / relational mapping. This paradigm defines how to persist objects in a relational database.



Modeling :


The JavaEE-Spring generator allows to use UML 2.1 models with specifics stereotypes in order to identify artefacts of the different application layers. You must use a modeler supporting by this standard. Topcased is this kind of this tool and The Acceleo website provides a bundle containing Acceleo and Topcased.

Simplified Architecture

SpringModule

The figure above shows the stereotypes that would specify a semantic on UML elements. According to the Java EE architecture, various stereotypes are provided:

  • The <<Entity>> stereotype applies on business domain classes;
  • The <<Dao>> stereotype applies on data access classes and, it provides read and write methods for business entities;
  • The <<Service>> stereotype applies on business service classes;
  • The <<Transactional>> stereotype applies on operations of business services in order to specify transactional aspect. Both properties: "isolation" and "propagation" can be use to define the transaction strategy;
  • The <<Remote>> stereotype applies on business services operations in order to publish as Web Service;
  • The <<Dto>> stereotype applies on data transfert objects classes, often used as return parameter operation of business service.


Features generator


In service layer:
  • Generate all Spring configuration files
  • Easy to use data transfert object in order to provide mediation layer
  • Transaction Management with aspect-oriented programming
  • Lazy loading support for all objects in the same transaction (design pattern "ThreadLocal Session")
  • Can publish operation of business service as a Web service using XFire
  • JUnit tests
In persistence layer:

The generator applies Hibernate best practices to provide a better productivity and great performance.

Easy browsing on business objects

  • Subclassing
  • 1-1, 1-*, *-* associations
  • Unidirectional and bidirectional navigability
  • Optimisations
  • Usage of POJOs

Relational Mapping

  • Cache handling on persisted data
  • 3NF SQL
  • Integrity constraints
  • Concurrent accesses
  • Technical identifier

Date access layer

  • No dependency between DTOs and Hibernate
  • Advanced search methods
  • Transaction handling
  • JUnit tests


Demonstration :

The installation of generator is detailed on the pages installation of modules.

Install the demonstration project using the menu "Project ..", then select "JEE-Spring Demo" from the menu "Examples / Acceleo

demo-1

The wizard creates a new project "org.acceleo.sample.demo.spring" in your workspace.

  • The directory src contains the generated sources;
  • The directory resources contains spring and hibernate configurations files;
  • The directory tests contains unit tests;
  • The directory lib contains required libraries;
  • The directory model contains :
    • The files conception.uml and conception.umldi are the application model;
    • The files profile.uml and profile.umldi are UML profile used to extend UML and handle the generation process;
  • The file spring.chain used to launch generation process;
  • The file spring.properties used to specify generation properties;

demo-2

The conception.umldi model described below:

  • The <<Entity>> Product defines the concept of products, it contains the properties name and color,
  • The <<Dao>> ProductsDao is responsible for reading and updating of product objects. The DAOs systematically implements CRUD (Create-Read-Update-Delete) methods. Thus you should not model these methods. However, it is possible to add operations such asfindProductByColor;
  • The <<Service>> ProductsServices contains the following operations:
    • getListOfProducts : returns the list of all products;
    • getProduct : returns one product from given identifier. As this method is <<Remote>> and will be published as a Web service;
    • addProduct : addes given product. This method is <<Transactional>>, if an error occured the database will not be updated and will be therefore incorporates;
    • updateProduct : updates a given product;
    • removeProduct : deletes a given product;

The Dependencies modelled means:

  • From <<Service>> to <<Dao>> : the <<Dao>> object must be injected in service object.
  • From <<Dao>> to <<Entity>> : the <<Dao>> must be responsible for managing the dependent <<Entity>>.

demo-3

Some examples of generated files:
  • The file src/org/acceleo/sample/demo/spring/services/I_ProductsServices.java is the Java interface of service:

demo-4

  • The file src/org/acceleo/sample/demo/spring/services/I_ProductsServicesWebService.java is the Java interface of Web service and publishes only operations stereotypes with the <<Remote>> stereotype;

demo-5

  • The file src/org/acceleo/sample/demo/spring/services/impl/ProductsServicesImpl.java is the Java class of service which implements both interfaces of service:

demo-6

  • The file resources/META-INF/spring/component.xml is the main Spring configuration file. It includes configuration files used by all application layers:

demo-7.png

  • The file resources/META-INF/spring/org.acceleo.sample.demo.spring/layer-services.xml is the Spring configuration file used to describe beans of business services layer:

demo-8.png


It remains to be done & Contribute! :