Skip to content

Commit 040b8f9

Browse files
author
eugenp
committed
- major cleanup and testing work
1 parent 080bf07 commit 040b8f9

117 files changed

Lines changed: 3813 additions & 1663 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#Sat Oct 29 15:33:06 EEST 2011
1+
#Sun Jan 08 22:52:25 EET 2012
22
eclipse.preferences.version=1
33
encoding//src/main/resources/rebel.xml=UTF-8

‎.settings/org.eclipse.jdt.core.prefs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Sat Nov 12 22:05:37 EET 2011
1+
#Sat Jan 21 23:04:26 EET 2012
22
eclipse.preferences.version=1
33
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
44
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
@@ -63,7 +63,7 @@ org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=error
6363
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=error
6464
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=error
6565
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
66-
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=error
66+
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
6767
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
6868
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled
6969
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled

‎.settings/org.eclipse.jdt.ui.prefs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Tue Oct 18 23:55:33 EEST 2011
1+
#Sat Jan 21 23:04:06 EET 2012
22
eclipse.preferences.version=1
33
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
44
sp_cleanup.add_default_serial_version_id=true
@@ -12,8 +12,8 @@ sp_cleanup.add_missing_override_annotations_interface_methods=true
1212
sp_cleanup.add_serial_version_id=false
1313
sp_cleanup.always_use_blocks=true
1414
sp_cleanup.always_use_parentheses_in_expressions=true
15-
sp_cleanup.always_use_this_for_non_static_field_access=true
16-
sp_cleanup.always_use_this_for_non_static_method_access=true
15+
sp_cleanup.always_use_this_for_non_static_field_access=false
16+
sp_cleanup.always_use_this_for_non_static_method_access=false
1717
sp_cleanup.convert_to_enhanced_for_loop=true
1818
sp_cleanup.correct_indentation=true
1919
sp_cleanup.format_source_code=true
@@ -50,6 +50,6 @@ sp_cleanup.use_blocks=false
5050
sp_cleanup.use_blocks_only_for_return_and_throw=false
5151
sp_cleanup.use_parentheses_in_expressions=false
5252
sp_cleanup.use_this_for_non_static_field_access=true
53-
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false
53+
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
5454
sp_cleanup.use_this_for_non_static_method_access=true
55-
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false
55+
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
#Tue Oct 18 21:27:36 EEST 2011
1+
#Tue Dec 20 23:36:09 EET 2011
22
DELEGATES_PREFERENCE=delegateValidatorList
33
USER_BUILD_PREFERENCE=enabledBuildValidatorList
44
USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator;
55
USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.302.v201107140600
66
eclipse.preferences.version=1
77
override=true
88
suspend=false
9+
vals/org.eclipse.wst.xml.core.xml/global=TF03
910
vf.version=3

‎.springBeans‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beansProjectDescription>
33
<version>1</version>
4-
<pluginVersion><![CDATA[2.8.0.201110170010-RELEASE]]></pluginVersion>
4+
<pluginVersion><![CDATA[2.8.1.201111220115-RELEASE]]></pluginVersion>
55
<configSuffixes>
66
<configSuffix><![CDATA[xml]]></configSuffix>
77
</configSuffixes>
88
<enableImports><![CDATA[false]]></enableImports>
99
<configs>
10-
<config>src/main/resources/spring-security-context.xml</config>
10+
<config>src/main/resources/springSecurityConfig.xml</config>
1111
</configs>
1212
<configSets>
1313
</configSets>

‎README.md‎

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,52 @@
1-
## Overview
1+
# Overview
22

3-
This is a **learning project**, and can be used as a starting point for a **RESTful web service** implemented with **Spring 3.1** and Java configuration. <br/> <br/>
3+
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 <br/>
44

5+
# Technology Stack
6+
The project uses the following technologies: <br/>
7+
- **web/REST**: Spring 3.1 <br/>
8+
- **marshalling**: Jackson (for JSON) and XStream (for XML) <br/>
9+
- **persistence**: JPA, Spring Data JPA and Hibernate <br/>
10+
- **testing**: Junit, Hamcrest, Mockito, rest-assured <br/>
11+
12+
13+
# THE PERSISTENCE LAYER (technical notes)
14+
### The DAO layer
15+
- to create a new DAO, only the interface needs to be created; **Spring Data JPA** will generates the DAO implementation automatically
16+
- the DAO interface MUST extend the Spring Data managed interface: _JpaRepository_ (with the correct parametrization)
17+
- 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_
18+
19+
20+
### The Service layer
21+
- all Service interfaces MUST extend the _IService_ interface (with the proper parametrization)
22+
- all Service implementations MUST extend the _AbstractService_ abstract class (with the proper parametrization)
23+
- extending _AbstractService_ and _IService_ enables a base of consistent and common functionality across services
24+
- the Service artifacts MUST be annotated with the _@Service_ annotation
25+
26+
- 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
27+
28+
29+
30+
# THE WEB LAYER (technical notes)
31+
### The Controller layer
32+
- the Controller layer MUST only use the Service layer directly (never the DAO layer)
33+
- the Controller layer SHOULD not implement any interface
34+
- the Controller layer MUST extend _AbstractController_ (with the proper parametrization)
35+
- the Controller artifacts MUST be annotated with the _@Controller_ annotation
36+
37+
38+
## Transaction Management and Configuration (technical notes)
39+
- the Service layer is the transaction owner (and is annotated with _@Transactional_)
40+
- the default transaction semantics are: propagation REQUIRED, default isolation, rollback on runtime exceptions
41+
- **NOTE**: the transactional semantics MAY be subject to change
42+
43+
44+
# Eclipse
45+
- see the [Eclipse wiki page](https://github.com/eugenp/REST/wiki/Eclipse:-Setup-and-Configuration) of this project
46+
47+
48+
49+
# A Learning Project
550
Because it's a learning project, most of it's implementation is explained carefully and in great detail, in a series of posts:
651
### Spring and Maven basics <br/>
752
- [Java based Spring Configuration](http://www.baeldung.com/2011/10/20/bootstraping-a-web-application-with-spring-3-1-and-java-based-configuration-part-1/) <br/>
@@ -26,19 +71,3 @@ Because it's a learning project, most of it's implementation is explained carefu
2671
### Testing <br/>
2772
- [**Integration testing** of the REST service](http://www.baeldung.com/2011/10/13/integration-testing-a-rest-api/) <br/>
2873
- [Comprehensive unit testing of the web tier, focusing on relevant behaviors to avoid brittleness](http://www.baeldung.com/2011/10/02/testing-the-service-layer/) <br/>
29-
30-
31-
## TECHNOLOGY STACK
32-
33-
- Spring 3.1 with Jackson, JAXB <br/>
34-
- Hibernate 3.6 (to be moved to Hibernate 4.0 soon) <br/>
35-
- Junit, Mockito, Hamcrest, rest-assured <br/>
36-
37-
38-
39-
## FURTHER DEVELOPMENT
40-
======================
41-
42-
* improvements in validation and HTTP response codes
43-
* improving the marshaling of the server stack trace
44-
* expand on the design document, covering: details of the transaction strategy

‎pom.xml‎

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
<groupId>org.springframework</groupId>
5050
<artifactId>spring-oxm</artifactId>
5151
<version>${spring.version}</version>
52-
<scope>runtime</scope>
5352
</dependency>
5453

5554
<!-- security -->
@@ -93,13 +92,28 @@
9392
<version>1.0</version>
9493
<scope>runtime</scope>
9594
</dependency>
95+
<dependency>
96+
<groupId>com.thoughtworks.xstream</groupId>
97+
<artifactId>xstream</artifactId>
98+
<version>1.4.2</version>
99+
</dependency>
96100

97101
<!-- persistence -->
102+
<dependency>
103+
<groupId>org.springframework</groupId>
104+
<artifactId>spring-jdbc</artifactId>
105+
<version>${spring.version}</version>
106+
</dependency>
98107
<dependency>
99108
<groupId>org.springframework</groupId>
100109
<artifactId>spring-orm</artifactId>
101110
<version>${spring.version}</version>
102111
</dependency>
112+
<dependency>
113+
<groupId>org.springframework.data</groupId>
114+
<artifactId>spring-data-jpa</artifactId>
115+
<version>1.0.2.RELEASE</version>
116+
</dependency>
103117
<dependency>
104118
<groupId>cglib</groupId>
105119
<artifactId>cglib-nodep</artifactId>
@@ -113,13 +127,8 @@
113127
<version>${mysql-connector-java.version}</version>
114128
<scope>runtime</scope>
115129
</dependency>
116-
<!-- <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>${commons-dbcp.version}</version> </dependency> -->
117-
118-
<dependency>
119-
<groupId>org.hibernate</groupId>
120-
<artifactId>hibernate-core</artifactId>
121-
<version>${hibernate.version}</version>
122-
</dependency>
130+
<!-- <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId>
131+
<version>${commons-dbcp.version}</version> </dependency> -->
123132

124133
<dependency>
125134
<groupId>org.hibernate</groupId>
@@ -184,7 +193,7 @@
184193
<dependency>
185194
<groupId>org.apache.httpcomponents</groupId>
186195
<artifactId>httpclient</artifactId>
187-
<version>${http.version}</version>
196+
<version>${httpclient.version}</version>
188197
<scope>test</scope>
189198
<exclusions>
190199
<exclusion>
@@ -204,7 +213,7 @@
204213
<dependency>
205214
<groupId>com.jayway.restassured</groupId>
206215
<artifactId>rest-assured</artifactId>
207-
<version>1.4.5</version>
216+
<version>1.5</version>
208217
<scope>test</scope>
209218
<exclusions>
210219
<exclusion>
@@ -233,7 +242,7 @@
233242
<plugin>
234243
<groupId>org.apache.maven.plugins</groupId>
235244
<artifactId>maven-surefire-plugin</artifactId>
236-
<version>2.10</version>
245+
<version>2.11</version>
237246
<configuration>
238247
<excludes>
239248
<exclude>**/*IntegrationTest.java</exclude>
@@ -253,7 +262,7 @@
253262
<plugin>
254263
<groupId>org.codehaus.cargo</groupId>
255264
<artifactId>cargo-maven2-plugin</artifactId>
256-
<version>1.1.3</version>
265+
<version>1.1.4</version>
257266
<configuration>
258267
<wait>true</wait>
259268
<container>
@@ -271,7 +280,7 @@
271280
<plugin>
272281
<groupId>org.zeroturnaround</groupId>
273282
<artifactId>jrebel-maven-plugin</artifactId>
274-
<version>1.1.0</version>
283+
<version>1.1.3</version>
275284
<executions>
276285
<execution>
277286
<id>generate-rebel-xml</id>
@@ -288,7 +297,8 @@
288297
<!-- generated by m2e -->
289298
<pluginManagement>
290299
<plugins>
291-
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
300+
<!--This plugin's configuration is used to store Eclipse m2e settings
301+
only. It has no influence on the Maven build itself. -->
292302
<plugin>
293303
<groupId>org.eclipse.m2e</groupId>
294304
<artifactId>lifecycle-mapping</artifactId>
@@ -419,16 +429,14 @@
419429
<cglib.version>2.2.2</cglib.version>
420430

421431
<commons-lang3.version>3.1</commons-lang3.version>
422-
<guava.version>10.0.1</guava.version>
432+
<guava.version>11.0</guava.version>
423433

424-
<jackson-mapper-asl.version>1.9.2</jackson-mapper-asl.version>
425-
<xstream.version>1.2.2</xstream.version>
426-
<jaxb-api.version>2.2.4</jaxb-api.version>
434+
<jackson-mapper-asl.version>1.9.3</jackson-mapper-asl.version>
435+
<jaxb-api.version>2.2.6</jaxb-api.version>
427436

428437
<!-- VERSIONS - persistence -->
429438
<mysql-connector-java.version>5.1.18</mysql-connector-java.version> <!-- latest version on: 02.10.2011 - http://dev.mysql.com/downloads/connector/j/ -->
430-
<hibernate.version>3.6.8.Final</hibernate.version>
431-
<hibernate-commons-annotations.version>3.2.0.Final</hibernate-commons-annotations.version>
439+
<hibernate.version>4.0.0.Final</hibernate.version> <!-- 3.6.9.Final -->
432440
<commons-dbcp.version>1.4</commons-dbcp.version>
433441

434442
<!-- VERSIONS - logging -->
@@ -437,9 +445,10 @@
437445
<!-- VERSIONS - testing -->
438446
<org.hamcrest.version>1.3.RC2</org.hamcrest.version>
439447
<junit.version>4.10</junit.version>
440-
<mockito.version>1.9.0-rc1</mockito.version>
448+
<mockito.version>1.9.0</mockito.version>
441449

442-
<http.version>4.1.2</http.version>
450+
<http.version>4.1.4</http.version>
451+
<httpclient.version>4.1.2</httpclient.version>
443452

444453
</properties>
445454

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.rest.common;
2+
3+
import java.io.Serializable;
4+
5+
public interface IEntity extends Serializable{
6+
7+
Long getId();
8+
void setId( final Long id );
9+
10+
}

‎src/main/java/org/rest/common/dao/ICommonOperations.java‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎src/main/java/org/rest/common/dao/IGenericDAO.java‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)