Skip to content

Commit 3775b76

Browse files
author
Dan Eidmark
committed
Merge branch 'bump-java-and-spring'
2 parents fbb495e + 035a36b commit 3775b76

File tree

17 files changed

+625
-670
lines changed

17 files changed

+625
-670
lines changed

pom.xml

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<artifactId>dddsample</artifactId>
55
<packaging>war</packaging>
66
<name>DDDSample</name>
7-
<version>1.1.1-SNAPSHOT</version>
7+
<version>2.0-SNAPSHOT</version>
88
<description>This application shows a few key concepts of
99
Domain Driven Design implemented in Enterprise Java.
1010
</description>
@@ -65,17 +65,17 @@
6565
<url>https://github.com/citerus/dddsample-core</url>
6666
</scm>
6767
<properties>
68-
<spring.version>2.5.6</spring.version>
69-
<cxf.version>2.1.3</cxf.version>
68+
<spring.version>4.1.4.RELEASE</spring.version>
69+
<cxf.version>3.0.3</cxf.version>
7070
</properties>
7171
<build>
7272
<plugins>
7373
<!-- Compiler -->
7474
<plugin>
7575
<artifactId>maven-compiler-plugin</artifactId>
7676
<configuration>
77-
<source>1.6</source>
78-
<target>1.6</target>
77+
<source>1.8</source>
78+
<target>1.8</target>
7979
<encoding>UTF-8</encoding>
8080
</configuration>
8181
</plugin>
@@ -127,7 +127,7 @@
127127
<dependency>
128128
<groupId>junit</groupId>
129129
<artifactId>junit</artifactId>
130-
<version>4.4</version>
130+
<version>4.12</version>
131131
<scope>test</scope>
132132
</dependency>
133133
<dependency>
@@ -137,19 +137,28 @@
137137
</dependency>
138138
<dependency>
139139
<groupId>org.springframework</groupId>
140-
<artifactId>spring-web</artifactId>
140+
<artifactId>spring-tx</artifactId>
141141
<version>${spring.version}</version>
142142
</dependency>
143143
<dependency>
144144
<groupId>org.springframework</groupId>
145-
<artifactId>spring</artifactId>
145+
<artifactId>spring-jdbc</artifactId>
146+
<version>${spring.version}</version>
147+
</dependency>
148+
<dependency>
149+
<groupId>org.springframework</groupId>
150+
<artifactId>spring-jms</artifactId>
151+
<version>${spring.version}</version>
152+
</dependency>
153+
<dependency>
154+
<groupId>org.springframework</groupId>
155+
<artifactId>spring-orm</artifactId>
156+
<version>${spring.version}</version>
157+
</dependency>
158+
<dependency>
159+
<groupId>org.springframework</groupId>
160+
<artifactId>spring-web</artifactId>
146161
<version>${spring.version}</version>
147-
<exclusions>
148-
<exclusion>
149-
<groupId>commons-logging</groupId>
150-
<artifactId>commons-logging</artifactId>
151-
</exclusion>
152-
</exclusions>
153162
</dependency>
154163
<dependency>
155164
<groupId>org.springframework</groupId>
@@ -214,13 +223,13 @@
214223
<artifactId>hsqldb</artifactId>
215224
<version>1.8.0.7</version>
216225
</dependency>
217-
<dependency>
218-
<groupId>javax.servlet</groupId>
219-
<artifactId>servlet-api</artifactId>
220-
<version>2.5</version>
221-
<scope>provided</scope>
222-
</dependency>
223-
<dependency>
226+
<dependency>
227+
<groupId>javax.servlet</groupId>
228+
<artifactId>javax.servlet-api</artifactId>
229+
<version>3.1.0</version>
230+
<scope>provided</scope>
231+
</dependency>
232+
<dependency>
224233
<groupId>taglibs</groupId>
225234
<artifactId>standard</artifactId>
226235
<version>1.1.2</version>

src/main/java/se/citerus/dddsample/domain/shared/experimental/EntitySupport.java

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

src/main/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingController.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package se.citerus.dddsample.interfaces.tracking;
22

33
import org.springframework.context.MessageSource;
4+
import org.springframework.stereotype.Controller;
45
import org.springframework.validation.BindException;
5-
import org.springframework.web.servlet.ModelAndView;
6-
import org.springframework.web.servlet.mvc.SimpleFormController;
6+
import org.springframework.validation.BindingResult;
7+
import org.springframework.validation.Errors;
8+
import org.springframework.web.bind.WebDataBinder;
9+
import org.springframework.web.bind.annotation.*;
710
import org.springframework.web.servlet.support.RequestContextUtils;
811
import se.citerus.dddsample.domain.model.cargo.Cargo;
912
import se.citerus.dddsample.domain.model.cargo.CargoRepository;
@@ -12,7 +15,6 @@
1215
import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
1316

1417
import javax.servlet.http.HttpServletRequest;
15-
import javax.servlet.http.HttpServletResponse;
1618
import java.util.HashMap;
1719
import java.util.List;
1820
import java.util.Locale;
@@ -33,35 +35,36 @@
3335
* @see se.citerus.dddsample.interfaces.booking.web.CargoAdminController
3436
*
3537
*/
36-
public final class CargoTrackingController extends SimpleFormController {
38+
@Controller
39+
public final class CargoTrackingController {
3740

3841
private CargoRepository cargoRepository;
3942
private HandlingEventRepository handlingEventRepository;
43+
private MessageSource messageSource;
4044

41-
public CargoTrackingController() {
42-
setCommandClass(TrackCommand.class);
45+
@RequestMapping(method = RequestMethod.GET)
46+
public Map<String, CargoTrackingViewAdapter> get(final TrackCommand trackCommand) {
47+
return new HashMap<>();
4348
}
4449

45-
@Override
46-
protected ModelAndView onSubmit(final HttpServletRequest request, final HttpServletResponse response,
47-
final Object command, final BindException errors) throws Exception {
50+
@RequestMapping(method = RequestMethod.POST)
51+
protected Map<String, CargoTrackingViewAdapter> onSubmit(final HttpServletRequest request,
52+
final TrackCommand command,
53+
final BindingResult bindingResult) {
54+
new TrackCommandValidator().validate(command, bindingResult);
4855

49-
final TrackCommand trackCommand = (TrackCommand) command;
50-
final String trackingIdString = trackCommand.getTrackingId();
51-
52-
final TrackingId trackingId = new TrackingId(trackingIdString);
56+
final TrackingId trackingId = new TrackingId(command.getTrackingId());
5357
final Cargo cargo = cargoRepository.find(trackingId);
5458

5559
final Map<String, CargoTrackingViewAdapter> model = new HashMap<String, CargoTrackingViewAdapter>();
5660
if (cargo != null) {
57-
final MessageSource messageSource = getApplicationContext();
5861
final Locale locale = RequestContextUtils.getLocale(request);
5962
final List<HandlingEvent> handlingEvents = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId).distinctEventsByCompletionTime();
6063
model.put("cargo", new CargoTrackingViewAdapter(cargo, messageSource, locale, handlingEvents));
6164
} else {
62-
errors.rejectValue("trackingId", "cargo.unknown_id", new Object[]{trackCommand.getTrackingId()}, "Unknown tracking id");
65+
bindingResult.rejectValue("trackingId", "cargo.unknown_id", new Object[]{command.getTrackingId()}, "Unknown tracking id");
6366
}
64-
return showForm(request, response, errors, model);
67+
return model;
6568
}
6669

6770
public void setCargoRepository(CargoRepository cargoRepository) {
@@ -72,4 +75,8 @@ public void setHandlingEventRepository(HandlingEventRepository handlingEventRepo
7275
this.handlingEventRepository = handlingEventRepository;
7376
}
7477

78+
public void setMessageSource(MessageSource messageSource) {
79+
this.messageSource = messageSource;
80+
}
81+
7582
}

src/main/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingViewAdapter.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public final class CargoTrackingViewAdapter {
2121
private final Locale locale;
2222
private final List<HandlingEventViewAdapter> events;
2323
private final String FORMAT = "yyyy-MM-dd hh:mm";
24+
private final TimeZone timeZone;
2425

25-
/**
26+
/**
2627
* Constructor.
2728
*
2829
* @param cargo
@@ -31,15 +32,28 @@ public final class CargoTrackingViewAdapter {
3132
* @param handlingEvents
3233
*/
3334
public CargoTrackingViewAdapter(Cargo cargo, MessageSource messageSource, Locale locale, List<HandlingEvent> handlingEvents) {
34-
this.messageSource = messageSource;
35-
this.locale = locale;
36-
this.cargo = cargo;
35+
this(cargo, messageSource, locale, handlingEvents, TimeZone.getDefault());
36+
}
3737

38-
this.events = new ArrayList<HandlingEventViewAdapter>(handlingEvents.size());
39-
for (HandlingEvent handlingEvent : handlingEvents) {
40-
events.add(new HandlingEventViewAdapter(handlingEvent));
38+
/**
39+
* Constructor.
40+
*
41+
* @param cargo
42+
* @param messageSource
43+
* @param locale
44+
* @param handlingEvents
45+
*/
46+
public CargoTrackingViewAdapter(Cargo cargo, MessageSource messageSource, Locale locale, List<HandlingEvent> handlingEvents, TimeZone tz) {
47+
this.messageSource = messageSource;
48+
this.locale = locale;
49+
this.cargo = cargo;
50+
this.timeZone = tz;
51+
52+
this.events = new ArrayList<HandlingEventViewAdapter>(handlingEvents.size());
53+
for (HandlingEvent handlingEvent : handlingEvents) {
54+
events.add(new HandlingEventViewAdapter(handlingEvent));
55+
}
4156
}
42-
}
4357

4458
/**
4559
* @param location a location
@@ -165,7 +179,9 @@ public String getLocation() {
165179
* @return Time when the event was completed.
166180
*/
167181
public String getTime() {
168-
return new SimpleDateFormat(FORMAT).format(handlingEvent.completionTime());
182+
final SimpleDateFormat sdf = new SimpleDateFormat(FORMAT);
183+
sdf.setTimeZone(timeZone);
184+
return sdf.format(handlingEvent.completionTime());
169185
}
170186

171187
/**

0 commit comments

Comments
 (0)