瀏覽代碼

Generated Java classes from WSDL for the handling report web service, under com.aggregator. Eliminated related handwritten Java code.

peter_backlund 17 年之前
父節點
當前提交
5da56ab2e9

+ 3
- 2
dddsample/pom.xml 查看文件

@@ -116,7 +116,7 @@
116 116
         </configuration>
117 117
       </plugin>
118 118
 
119
-      <!-- Generates WSDL from Java -->
119
+      <!-- Generates WSDL from Java
120 120
       <plugin>
121 121
         <groupId>org.apache.cxf</groupId>
122 122
         <artifactId>cxf-java2ws-plugin</artifactId>
@@ -142,6 +142,7 @@
142 142
           </execution>
143 143
         </executions>
144 144
       </plugin>
145
+      -->
145 146
 
146 147
       <plugin>
147 148
         <artifactId>maven-jar-plugin</artifactId>
@@ -156,7 +157,7 @@
156 157
             <configuration>
157 158
               <classifier>ws-client</classifier>
158 159
               <includes>
159
-                <include>**/se/citerus/dddsample/interfaces/handling/ws/*.class</include>
160
+                <include>**/com/aggregator/*.class</include>
160 161
               </includes>
161 162
               <archive>
162 163
                 <addMavenDescriptor>false</addMavenDescriptor>

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/interfaces/handling/HandlingReportParser.java 查看文件

@@ -1,11 +1,11 @@
1 1
 package se.citerus.dddsample.interfaces.handling;
2 2
 
3
+import com.aggregator.HandlingReport;
3 4
 import org.apache.commons.lang.StringUtils;
4 5
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
5 6
 import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
6 7
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
7 8
 import se.citerus.dddsample.domain.model.location.UnLocode;
8
-import se.citerus.dddsample.interfaces.handling.ws.HandlingReport;
9 9
 
10 10
 import javax.xml.datatype.XMLGregorianCalendar;
11 11
 import java.text.ParseException;

+ 3
- 4
dddsample/src/main/java/se/citerus/dddsample/interfaces/handling/file/UploadDirectoryScanner.java 查看文件

@@ -11,7 +11,6 @@ import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
11 11
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
12 12
 import se.citerus.dddsample.domain.model.location.UnLocode;
13 13
 import static se.citerus.dddsample.interfaces.handling.HandlingReportParser.*;
14
-import se.citerus.dddsample.interfaces.handling.ws.HandlingReportErrors;
15 14
 
16 15
 import java.io.File;
17 16
 import java.io.IOException;
@@ -75,7 +74,7 @@ public class UploadDirectoryScanner extends TimerTask implements InitializingBea
75 74
     );
76 75
   }
77 76
 
78
-  private void parseLine(final String line) throws HandlingReportErrors {
77
+  private void parseLine(final String line) throws Exception {
79 78
     final String[] columns = line.split("\t");
80 79
     if (columns.length == 5) {
81 80
       queueAttempt(columns[0], columns[1], columns[2], columns[3], columns[4]);
@@ -86,7 +85,7 @@ public class UploadDirectoryScanner extends TimerTask implements InitializingBea
86 85
     }
87 86
   }
88 87
 
89
-  private void queueAttempt(String completionTimeStr, String trackingIdStr, String voyageNumberStr, String unLocodeStr, String eventTypeStr) throws HandlingReportErrors {
88
+  private void queueAttempt(String completionTimeStr, String trackingIdStr, String voyageNumberStr, String unLocodeStr, String eventTypeStr) throws Exception {
90 89
     final List<String> errors = new ArrayList<String>();
91 90
 
92 91
     final Date date = parseDate(completionTimeStr, errors);
@@ -99,7 +98,7 @@ public class UploadDirectoryScanner extends TimerTask implements InitializingBea
99 98
       final HandlingEventRegistrationAttempt attempt = new HandlingEventRegistrationAttempt(new Date(), date, trackingId, voyageNumber, eventType, unLocode);
100 99
       applicationEvents.receivedHandlingEventRegistrationAttempt(attempt);
101 100
     } else {
102
-      throw new HandlingReportErrors(errors);
101
+      throw new Exception(errors.toString());
103 102
     }
104 103
   }
105 104
 

+ 0
- 90
dddsample/src/main/java/se/citerus/dddsample/interfaces/handling/ws/HandlingReport.java 查看文件

@@ -1,90 +0,0 @@
1
-package se.citerus.dddsample.interfaces.handling.ws;
2
-
3
-import javax.xml.bind.annotation.XmlElement;
4
-import javax.xml.bind.annotation.XmlSchemaType;
5
-import javax.xml.datatype.XMLGregorianCalendar;
6
-
7
-/**
8
- * Data type for registering handling events
9
- * using the web service api. Focus here is interoperability
10
- * and maintaining a stable api, and possibly things like
11
- * backwards compatibility with a system that's being replaced,
12
- * or adhering to an industry standard.
13
- *
14
- * We do not want this to constrain our modeling in any way.
15
- * 
16
- */
17
-public class HandlingReport {
18
-
19
-  private String[] trackingIds;
20
-  private String unLocode;
21
-  private String voyageNumber;
22
-  private XMLGregorianCalendar completionTime;
23
-  private String type;
24
-
25
-  /**
26
-   * @return tracking ids of cargos that have been handled (the same way)
27
-   */
28
-  @XmlElement(required = true)
29
-  public String[] getTrackingIds() {
30
-    return trackingIds;
31
-  }
32
-
33
-  public void setTrackingIds(String[] trackingIds) {
34
-    this.trackingIds = trackingIds;
35
-  }
36
-
37
-  /**
38
-   * @return United Nations Location Code for the location where the event occured
39
-   */
40
-  @XmlElement(required = true)
41
-  public String getUnLocode() {
42
-    return unLocode;
43
-  }
44
-
45
-  public void setUnLocode(String unLocode) {
46
-    this.unLocode = unLocode;
47
-  }
48
-
49
-  /**
50
-   * Not all events are associated with a voyage (customs handling etc).
51
-   * 
52
-   * @return voyage number, if applicable
53
-   */
54
-
55
-  @XmlElement(required = false)
56
-  public String getVoyageNumber() {
57
-    return voyageNumber;
58
-  }
59
-
60
-  public void setVoyageNumber(String voyageNumber) {
61
-    this.voyageNumber = voyageNumber;
62
-  }
63
-
64
-  /**
65
-   * @return time when event occured, for example a the loading of cargo was completed
66
-   */
67
-
68
-  @XmlSchemaType(name="dateTime")
69
-  @XmlElement(required = true)
70
-  public XMLGregorianCalendar getCompletionTime() {
71
-    return completionTime;
72
-  }
73
-
74
-  public void setCompletionTime(XMLGregorianCalendar completionTime) {
75
-    this.completionTime = completionTime;
76
-  }
77
-
78
-  /**
79
-   * @return type of event
80
-   */
81
-
82
-  @XmlElement(required = true)
83
-  public String getType() {
84
-    return type;
85
-  }
86
-
87
-  public void setType(String type) {
88
-    this.type = type;
89
-  }
90
-}

+ 0
- 38
dddsample/src/main/java/se/citerus/dddsample/interfaces/handling/ws/HandlingReportErrors.java 查看文件

@@ -1,38 +0,0 @@
1
-package se.citerus.dddsample.interfaces.handling.ws;
2
-
3
-import javax.xml.bind.annotation.XmlElement;
4
-import javax.xml.bind.annotation.XmlRootElement;
5
-import java.util.ArrayList;
6
-import java.util.List;
7
-
8
-@XmlRootElement
9
-public class HandlingReportErrors extends Exception {
10
-
11
-  @XmlElement
12
-  List<String> errors;
13
-
14
-  public HandlingReportErrors() {
15
-  }
16
-
17
-  public HandlingReportErrors(List<String> errors) {
18
-    setErrors(errors);
19
-  }
20
-
21
-  public List<String> getErrors() {
22
-    return errors;
23
-  }
24
-
25
-  public void setErrors(List<String> errors) {
26
-    if (errors == null) {
27
-      errors = new ArrayList<String>();
28
-    }
29
-    this.errors = errors;
30
-  }
31
-
32
-  @Override
33
-  @XmlElement(required = true)
34
-  public String getMessage() {
35
-    return "Report errors: " + errors;
36
-  }
37
-  
38
-}

+ 0
- 21
dddsample/src/main/java/se/citerus/dddsample/interfaces/handling/ws/HandlingReportService.java 查看文件

@@ -1,21 +0,0 @@
1
-package se.citerus.dddsample.interfaces.handling.ws;
2
-
3
-import javax.jws.WebParam;
4
-import javax.jws.WebService;
5
-
6
-/**
7
- * Web service endpoint for handling report submissions.
8
- *
9
- */
10
-@WebService
11
-public interface HandlingReportService {
12
-
13
-  /**
14
-   * Submits a report of handled cargos.
15
-   *
16
-   * @param handlingReport handling report
17
-   * @throws HandlingReportErrors if there are formatting errors in the handling report
18
-   */
19
-  void submitReport(@WebParam HandlingReport handlingReport) throws HandlingReportErrors;
20
-
21
-}

dddsample/src/main/java/se/citerus/dddsample/interfaces/handling/ws/impl/HandlingReportServiceImpl.java → dddsample/src/main/java/se/citerus/dddsample/interfaces/handling/ws/HandlingReportServiceImpl.java 查看文件

@@ -1,5 +1,9 @@
1
-package se.citerus.dddsample.interfaces.handling.ws.impl;
1
+package se.citerus.dddsample.interfaces.handling.ws;
2 2
 
3
+import com.aggregator.HandlingReport;
4
+import com.aggregator.HandlingReportErrors;
5
+import com.aggregator.HandlingReportErrors_Exception;
6
+import com.aggregator.HandlingReportService;
3 7
 import org.apache.commons.logging.Log;
4 8
 import org.apache.commons.logging.LogFactory;
5 9
 import se.citerus.dddsample.application.ApplicationEvents;
@@ -9,10 +13,8 @@ import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
9 13
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
10 14
 import se.citerus.dddsample.domain.model.location.UnLocode;
11 15
 import static se.citerus.dddsample.interfaces.handling.HandlingReportParser.*;
12
-import se.citerus.dddsample.interfaces.handling.ws.HandlingReport;
13
-import se.citerus.dddsample.interfaces.handling.ws.HandlingReportErrors;
14
-import se.citerus.dddsample.interfaces.handling.ws.HandlingReportService;
15 16
 
17
+import javax.jws.WebParam;
16 18
 import javax.jws.WebService;
17 19
 import java.util.ArrayList;
18 20
 import java.util.Date;
@@ -24,14 +26,14 @@ import java.util.List;
24 26
  * with the informtion to the handling event registration system for proper registration.
25 27
  *  
26 28
  */
27
-@WebService(endpointInterface = "se.citerus.dddsample.interfaces.handling.ws.HandlingReportService")
29
+@WebService(endpointInterface = "com.aggregator.HandlingReportService")
28 30
 public class HandlingReportServiceImpl implements HandlingReportService {
29 31
 
30 32
   private ApplicationEvents applicationEvents;
31 33
   private final static Log logger = LogFactory.getLog(HandlingReportServiceImpl.class);
32 34
 
33 35
   @Override
34
-  public void submitReport(HandlingReport handlingReport) throws HandlingReportErrors {
36
+  public void submitReport(@WebParam(name = "arg0", targetNamespace = "") HandlingReport handlingReport) throws HandlingReportErrors_Exception {
35 37
     final List<String> errors = new ArrayList<String>();
36 38
 
37 39
     final Date completionTime = parseCompletionTime(handlingReport, errors);
@@ -51,9 +53,11 @@ public class HandlingReportServiceImpl implements HandlingReportService {
51 53
         applicationEvents.receivedHandlingEventRegistrationAttempt(attempt);
52 54
       } else {
53 55
         logger.error("Parse error in handling report: " + errors);
54
-        throw new HandlingReportErrors(errors);
56
+        final HandlingReportErrors faultInfo = new HandlingReportErrors();
57
+        throw new HandlingReportErrors_Exception(errors.toString(), faultInfo);
55 58
       }
56 59
     }
60
+
57 61
   }
58 62
 
59 63
   public void setApplicationEvents(ApplicationEvents applicationEvents) {

dddsample/src/main/java/com/pathfinder/internal/applicationContext.xml → dddsample/src/main/resources/com/pathfinder/internal/applicationContext.xml 查看文件


+ 1
- 1
dddsample/src/main/resources/context-interfaces.xml 查看文件

@@ -17,7 +17,7 @@
17 17
 
18 18
   <jaxws:endpoint id="jax-ws.http" implementor="#handlingReportService" address="/RegisterEvent"/>
19 19
 
20
-  <bean id="handlingReportService" class="se.citerus.dddsample.interfaces.handling.ws.impl.HandlingReportServiceImpl">
20
+  <bean id="handlingReportService" class="se.citerus.dddsample.interfaces.handling.ws.HandlingReportServiceImpl">
21 21
     <property name="applicationEvents" ref="applicationEvents"/>
22 22
   </bean>
23 23
 

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/infrastructure/messaging/stub/SynchronousApplicationEventsStub.java 查看文件

@@ -11,7 +11,7 @@ public class SynchronousApplicationEventsStub implements ApplicationEvents {
11 11
 
12 12
   CargoInspectionService cargoInspectionService;
13 13
 
14
-  public SynchronousApplicationEventsStub(CargoInspectionService cargoInspectionService) {
14
+  public void setCargoInspectionService(CargoInspectionService cargoInspectionService) {
15 15
     this.cargoInspectionService = cargoInspectionService;
16 16
   }
17 17
 

+ 4
- 1
dddsample/src/test/java/se/citerus/dddsample/scenario/CargoLifecycleScenarioTest.java 查看文件

@@ -297,7 +297,7 @@ public class CargoLifecycleScenarioTest extends TestCase {
297 297
     };
298 298
 
299 299
 
300
-    applicationEvents = new SynchronousApplicationEventsStub(cargoInspectionService);
300
+    applicationEvents = new SynchronousApplicationEventsStub();
301 301
 
302 302
     // Stub
303 303
     // TODO move functionality to in-mem impl
@@ -329,6 +329,9 @@ public class CargoLifecycleScenarioTest extends TestCase {
329 329
     handlingEventFactory = new HandlingEventFactory(cargoRepository, voyageRepository, locationRepository);
330 330
     handlingEventService = new HandlingEventServiceImpl(handlingEventRepository, applicationEvents, handlingEventFactory);
331 331
     bookingService = new BookingServiceImpl(cargoRepository, locationRepository, routingService);
332
+
333
+    // Stub
334
+    ((SynchronousApplicationEventsStub) applicationEvents).setCargoInspectionService(cargoInspectionService);
332 335
   }
333 336
 
334 337
 }