Sfoglia il codice sorgente

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

peter_backlund 17 anni fa
parent
commit
69f474ea61

+ 4
- 4
dddsample/src/main/java/se/citerus/dddsample/application/event/CargoUpdater.java Vedi File

12
 
12
 
13
 public class CargoUpdater {
13
 public class CargoUpdater {
14
 
14
 
15
-  private ApplicationEvents applicationEvents;
15
+  private SystemEvents systemEvents;
16
   private CargoRepository cargoRepository;
16
   private CargoRepository cargoRepository;
17
   private HandlingEventRepository handlingEventRepository;
17
   private HandlingEventRepository handlingEventRepository;
18
   private final Log logger = LogFactory.getLog(getClass());
18
   private final Log logger = LogFactory.getLog(getClass());
19
 
19
 
20
-  public CargoUpdater(final ApplicationEvents applicationEvents,
20
+  public CargoUpdater(final SystemEvents systemEvents,
21
                       final CargoRepository cargoRepository,
21
                       final CargoRepository cargoRepository,
22
                       final HandlingEventRepository handlingEventRepository) {
22
                       final HandlingEventRepository handlingEventRepository) {
23
-    this.applicationEvents = applicationEvents;
23
+    this.systemEvents = systemEvents;
24
     this.cargoRepository = cargoRepository;
24
     this.cargoRepository = cargoRepository;
25
     this.handlingEventRepository = handlingEventRepository;
25
     this.handlingEventRepository = handlingEventRepository;
26
   }
26
   }
49
     */
49
     */
50
 
50
 
51
     cargoRepository.store(cargo);
51
     cargoRepository.store(cargo);
52
-    applicationEvents.notifyOfCargoUpdate(cargo);
52
+    systemEvents.notifyOfCargoUpdate(cargo);
53
     logger.info("Updated delivery of cargo " + cargo);
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 Vedi File

10
  * It may be implemented synchronously or asynchronously, using
10
  * It may be implemented synchronously or asynchronously, using
11
  * for example JMS.
11
  * for example JMS.
12
  */
12
  */
13
-public interface ApplicationEvents {
13
+public interface SystemEvents {
14
 
14
 
15
   /**
15
   /**
16
    * A cargo has been handled.
16
    * A cargo has been handled.

+ 5
- 5
dddsample/src/main/java/se/citerus/dddsample/application/impl/HandlingEventServiceImpl.java Vedi File

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

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

+ 1
- 1
dddsample/src/main/resources/context-infrastructure-messaging.xml Vedi File

26
     <property name="connectionFactory" ref="jmsConnectionFactory"/>
26
     <property name="connectionFactory" ref="jmsConnectionFactory"/>
27
   </bean>
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
     <property name="jmsOperations" ref="jmsOperations"/>
30
     <property name="jmsOperations" ref="jmsOperations"/>
31
     <property name="cargoHandledDestination" ref="cargoHandledQueue"/>
31
     <property name="cargoHandledDestination" ref="cargoHandledQueue"/>
32
     <property name="cargoUpdateDestination" ref="cargoUpdateTopic"/>
32
     <property name="cargoUpdateDestination" ref="cargoUpdateTopic"/>

+ 7
- 7
dddsample/src/test/java/se/citerus/dddsample/application/HandlingEventServiceTest.java Vedi File

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