Просмотр исходного кода

Renamed ApplicationEvents to SystemEvents, a term used in DDD litterature.

peter_backlund 17 лет назад
Родитель
Сommit
69f474ea61

+ 4
- 4
dddsample/src/main/java/se/citerus/dddsample/application/event/CargoUpdater.java Просмотреть файл

@@ -12,15 +12,15 @@ import se.citerus.dddsample.domain.model.shared.HandlingActivity;
12 12
 
13 13
 public class CargoUpdater {
14 14
 
15
-  private ApplicationEvents applicationEvents;
15
+  private SystemEvents systemEvents;
16 16
   private CargoRepository cargoRepository;
17 17
   private HandlingEventRepository handlingEventRepository;
18 18
   private final Log logger = LogFactory.getLog(getClass());
19 19
 
20
-  public CargoUpdater(final ApplicationEvents applicationEvents,
20
+  public CargoUpdater(final SystemEvents systemEvents,
21 21
                       final CargoRepository cargoRepository,
22 22
                       final HandlingEventRepository handlingEventRepository) {
23
-    this.applicationEvents = applicationEvents;
23
+    this.systemEvents = systemEvents;
24 24
     this.cargoRepository = cargoRepository;
25 25
     this.handlingEventRepository = handlingEventRepository;
26 26
   }
@@ -49,7 +49,7 @@ public class CargoUpdater {
49 49
     */
50 50
 
51 51
     cargoRepository.store(cargo);
52
-    applicationEvents.notifyOfCargoUpdate(cargo);
52
+    systemEvents.notifyOfCargoUpdate(cargo);
53 53
     logger.info("Updated delivery of cargo " + cargo);
54 54
   }
55 55
 

dddsample/src/main/java/se/citerus/dddsample/application/event/ApplicationEvents.java → dddsample/src/main/java/se/citerus/dddsample/application/event/SystemEvents.java Просмотреть файл

@@ -10,7 +10,7 @@ import se.citerus.dddsample.domain.model.handling.HandlingEvent;
10 10
  * It may be implemented synchronously or asynchronously, using
11 11
  * for example JMS.
12 12
  */
13
-public interface ApplicationEvents {
13
+public interface SystemEvents {
14 14
 
15 15
   /**
16 16
    * A cargo has been handled.

+ 5
- 5
dddsample/src/main/java/se/citerus/dddsample/application/impl/HandlingEventServiceImpl.java Просмотреть файл

@@ -4,7 +4,7 @@ import org.apache.commons.logging.Log;
4 4
 import org.apache.commons.logging.LogFactory;
5 5
 import org.springframework.transaction.annotation.Transactional;
6 6
 import se.citerus.dddsample.application.HandlingEventService;
7
-import se.citerus.dddsample.application.event.ApplicationEvents;
7
+import se.citerus.dddsample.application.event.SystemEvents;
8 8
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
9 9
 import se.citerus.dddsample.domain.model.handling.CannotCreateHandlingEventException;
10 10
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
@@ -17,16 +17,16 @@ import java.util.Date;
17 17
 
18 18
 public final class HandlingEventServiceImpl implements HandlingEventService {
19 19
 
20
-  private final ApplicationEvents applicationEvents;
20
+  private final SystemEvents systemEvents;
21 21
   private final HandlingEventRepository handlingEventRepository;
22 22
   private final HandlingEventFactory handlingEventFactory;
23 23
   private final Log logger = LogFactory.getLog(HandlingEventServiceImpl.class);
24 24
 
25 25
   public HandlingEventServiceImpl(final HandlingEventRepository handlingEventRepository,
26
-                                  final ApplicationEvents applicationEvents,
26
+                                  final SystemEvents systemEvents,
27 27
                                   final HandlingEventFactory handlingEventFactory) {
28 28
     this.handlingEventRepository = handlingEventRepository;
29
-    this.applicationEvents = applicationEvents;
29
+    this.systemEvents = systemEvents;
30 30
     this.handlingEventFactory = handlingEventFactory;
31 31
   }
32 32
 
@@ -53,7 +53,7 @@ public final class HandlingEventServiceImpl implements HandlingEventService {
53 53
     handlingEventRepository.store(event);
54 54
 
55 55
     /* Publish an event stating that a cargo has been handled. */
56
-    applicationEvents.notifyOfHandlingEvent(event);
56
+    systemEvents.notifyOfHandlingEvent(event);
57 57
 
58 58
     logger.info("Registered handling event");
59 59
   }

dddsample/src/main/java/se/citerus/dddsample/infrastructure/messaging/jms/JmsApplicationEventsImpl.java → dddsample/src/main/java/se/citerus/dddsample/infrastructure/messaging/jms/JmsSystemEventsImpl.java Просмотреть файл

@@ -2,7 +2,7 @@ package se.citerus.dddsample.infrastructure.messaging.jms;
2 2
 
3 3
 import org.springframework.jms.core.JmsOperations;
4 4
 import org.springframework.jms.core.MessageCreator;
5
-import se.citerus.dddsample.application.event.ApplicationEvents;
5
+import se.citerus.dddsample.application.event.SystemEvents;
6 6
 import se.citerus.dddsample.domain.model.cargo.Cargo;
7 7
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
8 8
 
@@ -14,7 +14,7 @@ import javax.jms.Session;
14 14
 /**
15 15
  * JMS based implementation.
16 16
  */
17
-public final class JmsApplicationEventsImpl implements ApplicationEvents {
17
+public final class JmsSystemEventsImpl implements SystemEvents {
18 18
 
19 19
   private JmsOperations jmsOperations;
20 20
   private Destination cargoHandledDestination;

+ 1
- 1
dddsample/src/main/resources/context-infrastructure-messaging.xml Просмотреть файл

@@ -26,7 +26,7 @@
26 26
     <property name="connectionFactory" ref="jmsConnectionFactory"/>
27 27
   </bean>
28 28
 
29
-  <bean id="applicationEvents" class="se.citerus.dddsample.infrastructure.messaging.jms.JmsApplicationEventsImpl">
29
+  <bean id="applicationEvents" class="se.citerus.dddsample.infrastructure.messaging.jms.JmsSystemEventsImpl">
30 30
     <property name="jmsOperations" ref="jmsOperations"/>
31 31
     <property name="cargoHandledDestination" ref="cargoHandledQueue"/>
32 32
     <property name="cargoUpdateDestination" ref="cargoUpdateTopic"/>

+ 7
- 7
dddsample/src/test/java/se/citerus/dddsample/application/HandlingEventServiceTest.java Просмотреть файл

@@ -2,7 +2,7 @@ package se.citerus.dddsample.application;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 import static org.easymock.EasyMock.*;
5
-import se.citerus.dddsample.application.event.ApplicationEvents;
5
+import se.citerus.dddsample.application.event.SystemEvents;
6 6
 import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
7 7
 import se.citerus.dddsample.domain.model.cargo.Cargo;
8 8
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
@@ -20,7 +20,7 @@ import java.util.Date;
20 20
 
21 21
 public class HandlingEventServiceTest extends TestCase {
22 22
   private HandlingEventServiceImpl service;
23
-  private ApplicationEvents applicationEvents;
23
+  private SystemEvents systemEvents;
24 24
   private CargoRepository cargoRepository;
25 25
   private VoyageRepository voyageRepository;
26 26
   private HandlingEventRepository handlingEventRepository;
@@ -33,14 +33,14 @@ public class HandlingEventServiceTest extends TestCase {
33 33
     voyageRepository = createMock(VoyageRepository.class);
34 34
     handlingEventRepository = createMock(HandlingEventRepository.class);
35 35
     locationRepository = createMock(LocationRepository.class);
36
-    applicationEvents = createMock(ApplicationEvents.class);
36
+    systemEvents = createMock(SystemEvents.class);
37 37
 
38 38
     HandlingEventFactory handlingEventFactory = new HandlingEventFactory(cargoRepository, voyageRepository, locationRepository);
39
-    service = new HandlingEventServiceImpl(handlingEventRepository, applicationEvents, handlingEventFactory);
39
+    service = new HandlingEventServiceImpl(handlingEventRepository, systemEvents, handlingEventFactory);
40 40
   }
41 41
 
42 42
   protected void tearDown() throws Exception {
43
-    verify(cargoRepository, voyageRepository, handlingEventRepository, applicationEvents);
43
+    verify(cargoRepository, voyageRepository, handlingEventRepository, systemEvents);
44 44
   }
45 45
 
46 46
   public void testRegisterEvent() throws Exception {
@@ -48,9 +48,9 @@ public class HandlingEventServiceTest extends TestCase {
48 48
     expect(voyageRepository.find(CM001.voyageNumber())).andReturn(CM001);
49 49
     expect(locationRepository.find(STOCKHOLM.unLocode())).andReturn(STOCKHOLM);
50 50
     handlingEventRepository.store(isA(HandlingEvent.class));
51
-    applicationEvents.notifyOfHandlingEvent(isA(HandlingEvent.class));
51
+    systemEvents.notifyOfHandlingEvent(isA(HandlingEvent.class));
52 52
 
53
-    replay(cargoRepository, voyageRepository, handlingEventRepository, locationRepository, applicationEvents);
53
+    replay(cargoRepository, voyageRepository, handlingEventRepository, locationRepository, systemEvents);
54 54
 
55 55
     service.registerHandlingEvent(new Date(), cargo.trackingId(), CM001.voyageNumber(), STOCKHOLM.unLocode(), HandlingEvent.Type.LOAD);
56 56
   }