|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+package se.citerus.dddsample.config;
|
|
|
2
|
+
|
|
|
3
|
+import com.pathfinder.api.GraphTraversalService;
|
|
|
4
|
+import org.hibernate.SessionFactory;
|
|
|
5
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
6
|
+import org.springframework.context.annotation.Bean;
|
|
|
7
|
+import org.springframework.context.annotation.Configuration;
|
|
|
8
|
+import org.springframework.context.annotation.ImportResource;
|
|
|
9
|
+import org.springframework.transaction.PlatformTransactionManager;
|
|
|
10
|
+import se.citerus.dddsample.application.ApplicationEvents;
|
|
|
11
|
+import se.citerus.dddsample.application.BookingService;
|
|
|
12
|
+import se.citerus.dddsample.application.CargoInspectionService;
|
|
|
13
|
+import se.citerus.dddsample.application.HandlingEventService;
|
|
|
14
|
+import se.citerus.dddsample.application.impl.BookingServiceImpl;
|
|
|
15
|
+import se.citerus.dddsample.application.impl.CargoInspectionServiceImpl;
|
|
|
16
|
+import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
|
|
|
17
|
+import se.citerus.dddsample.application.util.SampleDataGenerator;
|
|
|
18
|
+import se.citerus.dddsample.domain.model.cargo.CargoRepository;
|
|
|
19
|
+import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
|
|
|
20
|
+import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
|
|
|
21
|
+import se.citerus.dddsample.domain.model.location.LocationRepository;
|
|
|
22
|
+import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
|
|
|
23
|
+import se.citerus.dddsample.domain.service.RoutingService;
|
|
|
24
|
+import se.citerus.dddsample.infrastructure.routing.ExternalRoutingService;
|
|
|
25
|
+
|
|
|
26
|
+@Configuration
|
|
|
27
|
+@ImportResource({
|
|
|
28
|
+ "classpath:context-interfaces.xml",
|
|
|
29
|
+ "classpath:context-infrastructure-messaging.xml",
|
|
|
30
|
+ "classpath:context-infrastructure-persistence.xml"})
|
|
|
31
|
+public class DDDSampleApplicationContext {
|
|
|
32
|
+
|
|
|
33
|
+ @Autowired
|
|
|
34
|
+ CargoRepository cargoRepository;
|
|
|
35
|
+
|
|
|
36
|
+ @Autowired
|
|
|
37
|
+ LocationRepository locationRepository;
|
|
|
38
|
+
|
|
|
39
|
+ @Autowired
|
|
|
40
|
+ VoyageRepository voyageRepository;
|
|
|
41
|
+
|
|
|
42
|
+ @Autowired
|
|
|
43
|
+ RoutingService routingService;
|
|
|
44
|
+
|
|
|
45
|
+ @Autowired
|
|
|
46
|
+ HandlingEventRepository handlingEventRepository;
|
|
|
47
|
+
|
|
|
48
|
+ @Autowired
|
|
|
49
|
+ HandlingEventFactory handlingEventFactory;
|
|
|
50
|
+
|
|
|
51
|
+ @Autowired
|
|
|
52
|
+ ApplicationEvents applicationEvents;
|
|
|
53
|
+
|
|
|
54
|
+ @Autowired
|
|
|
55
|
+ GraphTraversalService graphTraversalService;
|
|
|
56
|
+
|
|
|
57
|
+ @Autowired
|
|
|
58
|
+ PlatformTransactionManager platformTransactionManager;
|
|
|
59
|
+
|
|
|
60
|
+ @Autowired
|
|
|
61
|
+ SessionFactory sessionFactory;
|
|
|
62
|
+
|
|
|
63
|
+ @Bean
|
|
|
64
|
+ public BookingService bookingService() {
|
|
|
65
|
+ return new BookingServiceImpl(cargoRepository, locationRepository, routingService);
|
|
|
66
|
+ }
|
|
|
67
|
+
|
|
|
68
|
+ @Bean
|
|
|
69
|
+ public CargoInspectionService cargoInspectionService() {
|
|
|
70
|
+ return new CargoInspectionServiceImpl(applicationEvents, cargoRepository, handlingEventRepository);
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ @Bean
|
|
|
74
|
+ public HandlingEventService handlingEventService() {
|
|
|
75
|
+ return new HandlingEventServiceImpl(handlingEventRepository, applicationEvents, handlingEventFactory);
|
|
|
76
|
+ }
|
|
|
77
|
+
|
|
|
78
|
+ @Bean
|
|
|
79
|
+ public HandlingEventFactory handlingEventFactory() {
|
|
|
80
|
+ return new HandlingEventFactory(cargoRepository, voyageRepository, locationRepository);
|
|
|
81
|
+ }
|
|
|
82
|
+
|
|
|
83
|
+ @Bean
|
|
|
84
|
+ public RoutingService routingService() {
|
|
|
85
|
+ ExternalRoutingService routingService = new ExternalRoutingService();
|
|
|
86
|
+ routingService.setGraphTraversalService(graphTraversalService);
|
|
|
87
|
+ routingService.setLocationRepository(locationRepository);
|
|
|
88
|
+ routingService.setVoyageRepository(voyageRepository);
|
|
|
89
|
+ return routingService;
|
|
|
90
|
+ }
|
|
|
91
|
+
|
|
|
92
|
+ @Bean
|
|
|
93
|
+ public SampleDataGenerator sampleDataGenerator() {
|
|
|
94
|
+ return new SampleDataGenerator(platformTransactionManager, sessionFactory, cargoRepository, voyageRepository, locationRepository, handlingEventRepository);
|
|
|
95
|
+ }
|
|
|
96
|
+}
|