Parcourir la source

Added dates to TransitEdge, fixed RMI exposure of Pathfinder service

peter_backlund il y a 17 ans
Parent
révision
78c481fbc8

+ 4
- 2
dddsample/src/main/java/com/partner/pathfinder/api/GraphTraversalService.java Voir le fichier

@@ -1,5 +1,7 @@
1 1
 package com.partner.pathfinder.api;
2 2
 
3
+import java.rmi.Remote;
4
+import java.rmi.RemoteException;
3 5
 import java.util.List;
4 6
 import java.util.Properties;
5 7
 
@@ -8,8 +10,8 @@ import java.util.Properties;
8 10
  * and used by us (booking and tracking team).
9 11
  * 
10 12
  */
11
-public interface GraphTraversalService {
13
+public interface GraphTraversalService extends Remote {
12 14
 
13
-  List<TransitPath> findShortestPath(String originUnLocode, String destinationUnLocode, Properties limitations);
15
+  List<TransitPath> findShortestPath(String originUnLocode, String destinationUnLocode, Properties limitations) throws RemoteException;
14 16
 
15 17
 }

+ 27
- 7
dddsample/src/main/java/com/partner/pathfinder/api/TransitEdge.java Voir le fichier

@@ -1,31 +1,44 @@
1 1
 package com.partner.pathfinder.api;
2 2
 
3 3
 import java.io.Serializable;
4
+import java.util.Date;
4 5
 
5 6
 /**
6
- * DTO for a leg in an itinerary.
7
+ * Represents an edge in a path through a graph,
8
+ * describing the route of a cargo.
9
+ *  
7 10
  */
8 11
 public final class TransitEdge implements Serializable {
9 12
 
10
-  private final String carrierMovementId;
13
+  private final String voyageNumber;
11 14
   private final String fromUnLocode;
12 15
   private final String toUnLocode;
16
+  private final Date fromDate;
17
+  private final Date toDate;
13 18
 
14 19
   /**
15 20
    * Constructor.
16 21
    *
17
-   * @param carrierMovementId
22
+   * @param voyageNumber
18 23
    * @param fromUnLocode
19 24
    * @param toUnLocode
25
+   * @param fromDate
26
+   * @param toDate
20 27
    */
21
-  public TransitEdge(final String carrierMovementId, final String fromUnLocode, final String toUnLocode) {
22
-    this.carrierMovementId = carrierMovementId;
28
+  public TransitEdge(final String voyageNumber,
29
+                     final String fromUnLocode,
30
+                     final String toUnLocode,
31
+                     final Date fromDate,
32
+                     final Date toDate) {
33
+    this.voyageNumber = voyageNumber;
23 34
     this.fromUnLocode = fromUnLocode;
24 35
     this.toUnLocode = toUnLocode;
36
+    this.fromDate = fromDate;
37
+    this.toDate = toDate;
25 38
   }
26 39
 
27
-  public String getCarrierMovementId() {
28
-    return carrierMovementId;
40
+  public String getVoyageNumber() {
41
+    return voyageNumber;
29 42
   }
30 43
 
31 44
   public String getFromUnLocode() {
@@ -36,4 +49,11 @@ public final class TransitEdge implements Serializable {
36 49
     return toUnLocode;
37 50
   }
38 51
 
52
+  public Date getFromDate() {
53
+    return fromDate;
54
+  }
55
+
56
+  public Date getToDate() {
57
+    return toDate;
58
+  }
39 59
 }

+ 3
- 3
dddsample/src/main/java/com/partner/pathfinder/internal/GraphTraversalServiceImpl.java Voir le fichier

@@ -33,18 +33,18 @@ public class GraphTraversalServiceImpl implements GraphTraversalService {
33 33
 
34 34
       transitEdges.add(new TransitEdge(
35 35
         dao.getVoyageNumber(originUnLocode, firstLegTo),
36
-        originUnLocode, firstLegTo));
36
+        originUnLocode, firstLegTo, new Date(), new Date()));
37 37
 
38 38
       for (int j = 0; j < allVertices.size() - 1; j++) {
39 39
         final String curr = allVertices.get(j);
40 40
         final String next = allVertices.get(j + 1);
41
-        transitEdges.add(new TransitEdge(dao.getVoyageNumber(curr, next), curr, next));
41
+        transitEdges.add(new TransitEdge(dao.getVoyageNumber(curr, next), curr, next, new Date(), new Date()));
42 42
       }
43 43
 
44 44
       final String lastLegFrom = allVertices.get(allVertices.size() - 1);
45 45
       transitEdges.add(new TransitEdge(
46 46
         dao.getVoyageNumber(lastLegFrom, destinationUnLocode),
47
-        lastLegFrom, destinationUnLocode));
47
+        lastLegFrom, destinationUnLocode, new Date(), new Date()));
48 48
 
49 49
       candidates.add(new TransitPath(transitEdges));
50 50
     }

+ 2
- 2
dddsample/src/main/resources/com/partner/pathfinder/internal/applicationContext.xml Voir le fichier

@@ -4,7 +4,7 @@
4 4
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5 5
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
6 6
 
7
-  <bean id="graphTraversalService" class="com.partner.pathfinder.internal.GraphTraversalServiceImpl">
7
+  <bean id="internalGraphTraversalService" class="com.partner.pathfinder.internal.GraphTraversalServiceImpl">
8 8
     <constructor-arg ref="graphDAO"/>
9 9
   </bean>
10 10
 
@@ -12,7 +12,7 @@
12 12
 
13 13
   <bean id="rmiGraphTraversalService" class="org.springframework.remoting.rmi.RmiServiceExporter">
14 14
     <property name="serviceInterface" value="com.partner.pathfinder.api.GraphTraversalService"/>
15
-    <property name="service" ref="graphTraversalService"/>
15
+    <property name="service" ref="internalGraphTraversalService"/>
16 16
     <property name="serviceName" value="PathFinder"/>
17 17
   </bean>
18 18