This is a learning project; it's purpose be used as a starting point for a RESTful web service implemented with Spring 3.1 and Java configuration and to provide solutions to the common requirements necessary to properly implement REST
The project uses the following technologies:
- web/REST: Spring 3.1
- marshalling: Jackson (for JSON) and XStream (for XML)
- persistence: JPA, Spring Data JPA and Hibernate
- testing: Junit, Hamcrest, Mockito, rest-assured
- to create a new DAO, only the interface needs to be created; Spring Data JPA will generates the DAO implementation automatically
- the DAO interface MUST extend the Spring Data managed interface: JpaRepository (with the correct parametrization)
- the DAO layer is aware of the persistence engine it uses; this information MUST be encoded in the name; for example: IPrincipalJpaDAO for JPA instead of just IPrincipalDAO
-
all Service interfaces MUST extend the IService interface (with the proper parametrization)
-
all Service implementations MUST extend the AbstractService abstract class (with the proper parametrization)
-
extending AbstractService and IService enables a base of consistent and common functionality across services
-
the Service artifacts MUST be annotated with the @Service annotation
-
the Service layer is not aware of the persistence engine it uses (indirectly); if the persistence engine will change, the DAO artifacts will change, and the service will not
- the Controller layer MUST only use the Service layer directly (never the DAO layer)
- the Controller layer SHOULD not implement any interface
- the Controller layer MUST extend AbstractController (with the proper parametrization)
- the Controller artifacts MUST be annotated with the @Controller annotation
- the Service layer is the transaction owner (and is annotated with @Transactional)
- the default transaction semantics are: propagation REQUIRED, default isolation, rollback on runtime exceptions
- NOTE: the transactional semantics MAY be subject to change
- see the Eclipse wiki page of this project
Because it's a learning project, most of it's implementation is explained carefully and in great detail, in a series of posts:
- Java based Spring Configuration
- Usage of new concepts introduced with Spring 3.1
- How to set up Integration Testing with the Maven Cargo plugin
- Spring MVC for the REST web service
- Driving API discoverability with integration test
- Implementation of Discoverability with Spring
- REST advanced content type negotiation
- Security of the REST web service with Spring Security 3.1
- Basic and Digest authentication for the same URI mapping of the RESTful service