Przeglądaj źródła

Minor cleanups, moving towards ctor-DI everywhere in core.

peter_backlund 17 lat temu
rodzic
commit
ee0c6941ea
13 zmienionych plików z 38 dodań i 55 usunięć
  1. 0
    4
      dddsample/tracking/booking-api/src/main/java/se/citerus/dddsample/tracking/booking/api/CargoRoutingDTO.java
  2. 10
    16
      dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/messaging/jms/JmsSystemEventsImpl.java
  3. 1
    1
      dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/hibernate/DatabaseTrackingIdGenerator.java
  4. 1
    1
      dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/inmemory/TrackingIdGeneratorInMem.java
  5. 13
    17
      dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/routing/ExternalRoutingService.java
  6. 3
    3
      dddsample/tracking/core/src/main/resources/context-infrastructure-messaging.xml
  7. 1
    1
      dddsample/tracking/core/src/main/resources/context-infrastructure-persistence.xml
  8. 3
    3
      dddsample/tracking/core/src/main/resources/context-infrastructure.xml
  9. 1
    1
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/model/cargo/CargoFactoryTest.java
  10. 1
    1
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/TrackingIdGeneratorTest.java
  11. 2
    5
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/routing/ExternalRoutingServiceTest.java
  12. 1
    1
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/scenario/CargoLifecycleScenarioTest.java
  13. 1
    1
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/scenario/VoyageRescheduledScenarioTest.java

+ 0
- 4
dddsample/tracking/booking-api/src/main/java/se/citerus/dddsample/tracking/booking/api/CargoRoutingDTO.java Wyświetl plik

@@ -60,10 +60,6 @@ public final class CargoRoutingDTO implements Serializable {
60 60
     return misrouted;
61 61
   }
62 62
 
63
-  public boolean isRouted() {
64
-    return !legs.isEmpty();
65
-  }
66
-
67 63
   public Date getArrivalDeadline() {
68 64
     return arrivalDeadline;
69 65
   }

+ 10
- 16
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/messaging/jms/JmsSystemEventsImpl.java Wyświetl plik

@@ -16,9 +16,15 @@ import javax.jms.Session;
16 16
  */
17 17
 public final class JmsSystemEventsImpl implements SystemEvents {
18 18
 
19
-  private JmsOperations jmsOperations;
20
-  private Destination cargoHandledDestination;
21
-  private Destination cargoUpdateDestination;
19
+  private final JmsOperations jmsOperations;
20
+  private final Destination cargoHandledDestination;
21
+  private final Destination cargoUpdateDestination;
22
+
23
+  public JmsSystemEventsImpl(final JmsOperations jmsOperations, final Destination cargoHandledDestination, final Destination cargoUpdateDestination) {
24
+    this.jmsOperations = jmsOperations;
25
+    this.cargoHandledDestination = cargoHandledDestination;
26
+    this.cargoUpdateDestination = cargoUpdateDestination;
27
+  }
22 28
 
23 29
   @Override
24 30
   public void notifyOfHandlingEvent(final HandlingEvent event) {
@@ -33,22 +39,10 @@ public final class JmsSystemEventsImpl implements SystemEvents {
33 39
   @Override
34 40
   public void notifyOfCargoUpdate(final Cargo cargo) {
35 41
     jmsOperations.send(cargoUpdateDestination, new MessageCreator() {
36
-      public Message createMessage(Session session) throws JMSException {
42
+      public Message createMessage(final Session session) throws JMSException {
37 43
         return session.createObjectMessage(cargo.trackingId());
38 44
       }
39 45
     });
40 46
   }
41 47
 
42
-  public void setJmsOperations(JmsOperations jmsOperations) {
43
-    this.jmsOperations = jmsOperations;
44
-  }
45
-
46
-  public void setCargoHandledDestination(Destination cargoHandledDestination) {
47
-    this.cargoHandledDestination = cargoHandledDestination;
48
-  }
49
-
50
-  public void setCargoUpdateDestination(Destination cargoUpdateDestination) {
51
-    this.cargoUpdateDestination = cargoUpdateDestination;
52
-  }
53
-
54 48
 }

dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/DatabaseTrackingIdGenerator.java → dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/hibernate/DatabaseTrackingIdGenerator.java Wyświetl plik

@@ -4,7 +4,7 @@
4 4
  * @created 2009-sep-17
5 5
  * $Id$
6 6
  */
7
-package se.citerus.dddsample.tracking.core.infrastructure.persistence;
7
+package se.citerus.dddsample.tracking.core.infrastructure.persistence.hibernate;
8 8
 
9 9
 import org.hibernate.SessionFactory;
10 10
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;

dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/TrackingIdGeneratorInMem.java → dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/inmemory/TrackingIdGeneratorInMem.java Wyświetl plik

@@ -4,7 +4,7 @@
4 4
  * @created 2009-sep-07
5 5
  * $Id$
6 6
  */
7
-package se.citerus.dddsample.tracking.core.infrastructure.persistence;
7
+package se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory;
8 8
 
9 9
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
10 10
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingIdGenerator;

+ 13
- 17
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/routing/ExternalRoutingService.java Wyświetl plik

@@ -28,12 +28,20 @@ import java.util.Properties;
28 28
  */
29 29
 public class ExternalRoutingService implements RoutingService {
30 30
 
31
-  private GraphTraversalService graphTraversalService;
32
-  private LocationRepository locationRepository;
33
-  private VoyageRepository voyageRepository;
31
+  private final GraphTraversalService graphTraversalService;
32
+  private final LocationRepository locationRepository;
33
+  private final VoyageRepository voyageRepository;
34 34
   private static final Log log = LogFactory.getLog(ExternalRoutingService.class);
35 35
 
36
-  public List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification) {
36
+  public ExternalRoutingService(final GraphTraversalService graphTraversalService,
37
+                                final LocationRepository locationRepository,
38
+                                final VoyageRepository voyageRepository) {
39
+    this.graphTraversalService = graphTraversalService;
40
+    this.locationRepository = locationRepository;
41
+    this.voyageRepository = voyageRepository;
42
+  }
43
+
44
+  public List<Itinerary> fetchRoutesForSpecification(final RouteSpecification routeSpecification) {
37 45
     /*
38 46
       The RouteSpecification is picked apart and adapted to the external API.
39 47
      */
@@ -81,7 +89,7 @@ public class ExternalRoutingService implements RoutingService {
81 89
     return new Itinerary(legs);
82 90
   }
83 91
 
84
-  private Leg toLeg(TransitEdge edge) {
92
+  private Leg toLeg(final TransitEdge edge) {
85 93
     return new Leg(
86 94
       voyageRepository.find(new VoyageNumber(edge.getVoyageNumber())),
87 95
       locationRepository.find(new UnLocode(edge.getFromUnLocode())),
@@ -90,16 +98,4 @@ public class ExternalRoutingService implements RoutingService {
90 98
     );
91 99
   }
92 100
 
93
-  public void setGraphTraversalService(GraphTraversalService graphTraversalService) {
94
-    this.graphTraversalService = graphTraversalService;
95
-  }
96
-
97
-  public void setLocationRepository(LocationRepository locationRepository) {
98
-    this.locationRepository = locationRepository;
99
-  }
100
-
101
-  public void setVoyageRepository(VoyageRepository voyageRepository) {
102
-    this.voyageRepository = voyageRepository;
103
-  }
104
-
105 101
 }

+ 3
- 3
dddsample/tracking/core/src/main/resources/context-infrastructure-messaging.xml Wyświetl plik

@@ -27,9 +27,9 @@
27 27
   </bean>
28 28
 
29 29
   <bean id="applicationEvents" class="se.citerus.dddsample.tracking.core.infrastructure.messaging.jms.JmsSystemEventsImpl">
30
-    <property name="jmsOperations" ref="jmsOperations"/>
31
-    <property name="cargoHandledDestination" ref="cargoHandledQueue"/>
32
-    <property name="cargoUpdateDestination" ref="cargoUpdateTopic"/>
30
+    <constructor-arg ref="jmsOperations"/>
31
+    <constructor-arg ref="cargoHandledQueue"/>
32
+    <constructor-arg ref="cargoUpdateTopic"/>
33 33
   </bean>
34 34
 
35 35
   <bean id="listener1" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">

+ 1
- 1
dddsample/tracking/core/src/main/resources/context-infrastructure-persistence.xml Wyświetl plik

@@ -52,6 +52,6 @@
52 52
     <property name="sessionFactory" ref="sessionFactory"/>
53 53
   </bean>
54 54
 
55
-  <bean id="trackingIdGenerator" class="se.citerus.dddsample.tracking.core.infrastructure.persistence.TrackingIdGeneratorInMem"/>
55
+  <bean id="trackingIdGenerator" class="se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.TrackingIdGeneratorInMem"/>
56 56
   
57 57
 </beans>

+ 3
- 3
dddsample/tracking/core/src/main/resources/context-infrastructure.xml Wyświetl plik

@@ -10,9 +10,9 @@
10 10
   <!-- External graph traversal routing service  -->
11 11
 
12 12
   <bean id="routingService" class="se.citerus.dddsample.tracking.core.infrastructure.routing.ExternalRoutingService">
13
-    <property name="graphTraversalService" ref="internalGraphTraversalService"/>
14
-    <property name="locationRepository" ref="locationRepository"/>
15
-    <property name="voyageRepository" ref="voyageRepository"/>
13
+    <constructor-arg ref="graphTraversalService"/>
14
+    <constructor-arg ref="locationRepository"/>
15
+    <constructor-arg ref="voyageRepository"/>
16 16
   </bean>
17 17
 
18 18
   <bean id="graphTraversalService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">

+ 1
- 1
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/model/cargo/CargoFactoryTest.java Wyświetl plik

@@ -12,7 +12,7 @@ import org.junit.Test;
12 12
 import static se.citerus.dddsample.tracking.core.application.util.DateTestUtil.toDate;
13 13
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.HONGKONG;
14 14
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.ROTTERDAM;
15
-import se.citerus.dddsample.tracking.core.infrastructure.persistence.TrackingIdGeneratorInMem;
15
+import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.TrackingIdGeneratorInMem;
16 16
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.LocationRepositoryInMem;
17 17
 
18 18
 public class CargoFactoryTest {

+ 1
- 1
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/TrackingIdGeneratorTest.java Wyświetl plik

@@ -4,7 +4,7 @@ import junit.framework.Assert;
4 4
 import junit.framework.TestCase;
5 5
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
6 6
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingIdGenerator;
7
-import se.citerus.dddsample.tracking.core.infrastructure.persistence.TrackingIdGeneratorInMem;
7
+import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.TrackingIdGeneratorInMem;
8 8
 
9 9
 public class TrackingIdGeneratorTest extends TestCase {
10 10
 

+ 2
- 5
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/routing/ExternalRoutingServiceTest.java Wyświetl plik

@@ -26,12 +26,8 @@ public class ExternalRoutingServiceTest extends TestCase {
26 26
   private VoyageRepository voyageRepository;
27 27
 
28 28
   protected void setUp() throws Exception {
29
-    externalRoutingService = new ExternalRoutingService();
30 29
     LocationRepository locationRepository = new LocationRepositoryInMem();
31
-    externalRoutingService.setLocationRepository(locationRepository);
32
-
33 30
     voyageRepository = createMock(VoyageRepository.class);
34
-    externalRoutingService.setVoyageRepository(voyageRepository);
35 31
 
36 32
     GraphTraversalService graphTraversalService = EasyMock.createMock(GraphTraversalService.class);
37 33
     expect(
@@ -40,7 +36,8 @@ public class ExternalRoutingServiceTest extends TestCase {
40 36
     
41 37
     EasyMock.replay(graphTraversalService);
42 38
     // TODO expectations on GTS
43
-    externalRoutingService.setGraphTraversalService(graphTraversalService);
39
+    externalRoutingService = new ExternalRoutingService(graphTraversalService, locationRepository, voyageRepository);
40
+
44 41
       /*new GraphTraversalServiceImpl(new GraphDAO() {
45 42
       public List<String> listLocations() {
46 43
         return Arrays.asList(TOKYO.unLocode().stringValue(), STOCKHOLM.unLocode().stringValue(), GOTHENBURG.unLocode().stringValue());

+ 1
- 1
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/scenario/CargoLifecycleScenarioTest.java Wyświetl plik

@@ -23,7 +23,7 @@ import static se.citerus.dddsample.tracking.core.domain.model.voyage.Voyage.NONE
23 23
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
24 24
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
25 25
 import se.citerus.dddsample.tracking.core.domain.service.RoutingService;
26
-import se.citerus.dddsample.tracking.core.infrastructure.persistence.TrackingIdGeneratorInMem;
26
+import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.TrackingIdGeneratorInMem;
27 27
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.CargoRepositoryInMem;
28 28
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.HandlingEventRepositoryInMem;
29 29
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.LocationRepositoryInMem;

+ 1
- 1
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/scenario/VoyageRescheduledScenarioTest.java Wyświetl plik

@@ -21,7 +21,7 @@ import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLoc
21 21
 import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.*;
22 22
 import se.citerus.dddsample.tracking.core.domain.model.voyage.Voyage;
23 23
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
24
-import se.citerus.dddsample.tracking.core.infrastructure.persistence.TrackingIdGeneratorInMem;
24
+import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.TrackingIdGeneratorInMem;
25 25
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.LocationRepositoryInMem;
26 26
 
27 27
 import java.util.Date;