|
|
@@ -3,18 +3,13 @@ package se.citerus.dddsample.application.ws;
|
|
3
|
3
|
import org.apache.commons.lang.StringUtils;
|
|
4
|
4
|
import org.apache.commons.logging.Log;
|
|
5
|
5
|
import org.apache.commons.logging.LogFactory;
|
|
6
|
|
-import org.springframework.jms.core.JmsOperations;
|
|
7
|
|
-import org.springframework.jms.core.MessageCreator;
|
|
8
|
6
|
import se.citerus.dddsample.application.HandlingEventRegistrationAttempt;
|
|
|
7
|
+import se.citerus.dddsample.application.SystemEvents;
|
|
9
|
8
|
import se.citerus.dddsample.domain.model.cargo.TrackingId;
|
|
10
|
9
|
import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
|
|
11
|
10
|
import se.citerus.dddsample.domain.model.handling.HandlingEvent;
|
|
12
|
11
|
import se.citerus.dddsample.domain.model.location.UnLocode;
|
|
13
|
12
|
|
|
14
|
|
-import javax.jms.JMSException;
|
|
15
|
|
-import javax.jms.Message;
|
|
16
|
|
-import javax.jms.Queue;
|
|
17
|
|
-import javax.jms.Session;
|
|
18
|
13
|
import javax.jws.WebService;
|
|
19
|
14
|
import java.text.ParseException;
|
|
20
|
15
|
import java.text.SimpleDateFormat;
|
|
|
@@ -32,8 +27,7 @@ import java.util.List;
|
|
32
|
27
|
@WebService(endpointInterface = "se.citerus.dddsample.application.ws.HandlingEventServiceEndpoint")
|
|
33
|
28
|
public class HandlingEventServiceEndpointImpl implements HandlingEventServiceEndpoint {
|
|
34
|
29
|
|
|
35
|
|
- private JmsOperations jmsOperations;
|
|
36
|
|
- private Queue handlingEventQueue;
|
|
|
30
|
+ private SystemEvents systemEvents;
|
|
37
|
31
|
private static final Log logger = LogFactory.getLog(HandlingEventServiceEndpointImpl.class);
|
|
38
|
32
|
|
|
39
|
33
|
public static final String ISO_8601_FORMAT = "yyyy-mm-dd HH:MM:SS.SSS";
|
|
|
@@ -49,25 +43,14 @@ public class HandlingEventServiceEndpointImpl implements HandlingEventServiceEnd
|
|
49
|
43
|
final UnLocode ul = parseUnLocode(unlocode, errors);
|
|
50
|
44
|
|
|
51
|
45
|
if (errors.isEmpty()) {
|
|
52
|
|
- sendRegistrationAttemptMessage(date, tid, voyageNumber, type, ul);
|
|
|
46
|
+ final HandlingEventRegistrationAttempt attempt = new HandlingEventRegistrationAttempt(new Date(), date, tid, voyageNumber, type, ul);
|
|
|
47
|
+ systemEvents.receivedHandlingEventRegistrationAttempt(attempt);
|
|
53
|
48
|
} else {
|
|
54
|
|
- logger.info("Handling event registration attempt failed: " + errors);
|
|
|
49
|
+ logger.warn("Handling event registration attempt failed: " + errors);
|
|
55
|
50
|
throw new RegistrationFailure(errors);
|
|
56
|
51
|
}
|
|
57
|
52
|
}
|
|
58
|
53
|
|
|
59
|
|
- private void sendRegistrationAttemptMessage(final Date completionDate, final TrackingId tid, final VoyageNumber voyageNumber, final HandlingEvent.Type type, final UnLocode ul) {
|
|
60
|
|
- jmsOperations.send(handlingEventQueue, new MessageCreator() {
|
|
61
|
|
- public Message createMessage(Session session) throws JMSException {
|
|
62
|
|
- final HandlingEventRegistrationAttempt attempt = new HandlingEventRegistrationAttempt(new Date(), completionDate, tid, voyageNumber, type, ul);
|
|
63
|
|
- return session.createObjectMessage(attempt);
|
|
64
|
|
- }
|
|
65
|
|
- });
|
|
66
|
|
- if (logger.isDebugEnabled()) {
|
|
67
|
|
- logger.debug("Incoming handling event registration attempt added to queue");
|
|
68
|
|
- }
|
|
69
|
|
- }
|
|
70
|
|
-
|
|
71
|
54
|
private UnLocode parseUnLocode(final String unlocode, final List<String> errors) {
|
|
72
|
55
|
try {
|
|
73
|
56
|
return new UnLocode(unlocode);
|
|
|
@@ -119,11 +102,7 @@ public class HandlingEventServiceEndpointImpl implements HandlingEventServiceEnd
|
|
119
|
102
|
}
|
|
120
|
103
|
}
|
|
121
|
104
|
|
|
122
|
|
- public void setJmsOperations(final JmsOperations jmsOperations) {
|
|
123
|
|
- this.jmsOperations = jmsOperations;
|
|
124
|
|
- }
|
|
125
|
|
-
|
|
126
|
|
- public void setHandlingEventQueue(final Queue handlingEventQueue) {
|
|
127
|
|
- this.handlingEventQueue = handlingEventQueue;
|
|
|
105
|
+ public void setSystemEvents(SystemEvents systemEvents) {
|
|
|
106
|
+ this.systemEvents = systemEvents;
|
|
128
|
107
|
}
|
|
129
|
108
|
}
|