Bläddra i källkod

Restructured the context files to be organized per layer, and moved the external graph traversal application to its own, separate context. Communication is now through RMI.

peter_backlund 17 år sedan
förälder
incheckning
ed4bd9569e

+ 24
- 0
dddsample/src/main/resources/context-application.xml Visa fil

@@ -0,0 +1,24 @@
1
+<?xml version="1.0"?>
2
+
3
+<beans xmlns="http://www.springframework.org/schema/beans"
4
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
6
+
7
+  <bean id="bookingService" class="se.citerus.dddsample.application.impl.BookingServiceImpl">
8
+    <constructor-arg ref="cargoRepository"/>
9
+    <constructor-arg ref="locationRepository"/>
10
+    <constructor-arg ref="routingService"/>
11
+  </bean>
12
+
13
+  <bean id="trackingService" class="se.citerus.dddsample.application.impl.TrackingServiceImpl">
14
+    <constructor-arg ref="cargoRepository"/>
15
+    <constructor-arg ref="applicationEvents"/>
16
+  </bean>
17
+
18
+  <bean id="handlingEventService" class="se.citerus.dddsample.application.impl.HandlingEventServiceImpl">
19
+    <constructor-arg ref="handlingEventRepository"/>
20
+    <constructor-arg ref="handlingEventFactory"/>
21
+    <constructor-arg ref="applicationEvents"/>
22
+  </bean>
23
+
24
+</beans>

+ 13
- 0
dddsample/src/main/resources/context-domain.xml Visa fil

@@ -0,0 +1,13 @@
1
+<?xml version="1.0"?>
2
+
3
+<beans xmlns="http://www.springframework.org/schema/beans"
4
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
6
+
7
+  <bean id="handlingEventFactory" class="se.citerus.dddsample.domain.model.handling.HandlingEventFactory">
8
+    <constructor-arg ref="cargoRepository"/>
9
+    <constructor-arg ref="voyageRepository"/>
10
+    <constructor-arg ref="locationRepository"/>
11
+  </bean>
12
+
13
+</beans>

+ 115
- 0
dddsample/src/main/resources/context-infrastructure.xml Visa fil

@@ -0,0 +1,115 @@
1
+<?xml version="1.0"?>
2
+
3
+<beans xmlns="http://www.springframework.org/schema/beans"
4
+       xmlns:jms="http://www.springframework.org/schema/jms"
5
+       xmlns:amq="http://activemq.apache.org/schema/core"
6
+       xmlns:tx="http://www.springframework.org/schema/tx"
7
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8
+       xsi:schemaLocation="
9
+        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
10
+        http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.xsd
11
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
12
+        http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
13
+
14
+  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
15
+    <property name="location" value="classpath:jdbc.properties"/>
16
+  </bean>
17
+
18
+
19
+  <!-- JMS messaging -->
20
+
21
+  <amq:connectionFactory id="jmsConnectionFactory" brokerURL="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
22
+
23
+  <amq:topic id="cargoHandledTopic" name="CargoHandledTopic" physicalName="CargoHandledTopic"/>
24
+  <amq:topic id="misdirectedCargoTopic" name="MisdirectedCargoTopic" physicalName="MisdirectedCargoTopic"/>
25
+  <amq:topic id="deliveredCargoTopic" name="DeliveredCargoTopic" physicalName="DeliveredCargoTopic"/>
26
+  <amq:queue id="handlingEventRegistrationAttemptQueue" name="HandlingEventRegistrationAttemptQueue" physicalName="HandlingEventRegistrationAttemptQueue"/>
27
+  <amq:queue id="rejectedRegistrationAttemptsQueue" name="RejectedRegistrationAttemptsQueue" physicalName="RejectedRegistrationAttemptsQueue"/>
28
+
29
+  <jms:listener-container connection-factory="jmsConnectionFactory">
30
+    <jms:listener destination="CargoHandledTopic" ref="cargoHandledConsumer" />
31
+    <jms:listener destination="HandlingEventRegistrationAttemptQueue" ref="handlingEventRegistrationAttemptConsumer" />
32
+    <jms:listener destination="MisdirectedCargoTopic" ref="simpleLoggingConsumer"/>
33
+    <jms:listener destination="DeliveredCargoTopic" ref="simpleLoggingConsumer"/>
34
+    <jms:listener destination="RejectedRegistrationAttemptsQueue" ref="simpleLoggingConsumer"/>
35
+  </jms:listener-container>
36
+
37
+  <bean id="jmsOperations" class="org.springframework.jms.core.JmsTemplate">
38
+    <property name="connectionFactory" ref="jmsConnectionFactory"/>
39
+  </bean>
40
+
41
+  <bean id="applicationEvents" class="se.citerus.dddsample.infrastructure.messaging.jms.JmsApplicationEventsImpl">
42
+    <property name="jmsOperations" ref="jmsOperations"/>
43
+    <property name="cargoHandledTopic" ref="cargoHandledTopic"/>
44
+    <property name="misdirectedCargoTopic" ref="misdirectedCargoTopic"/>
45
+    <property name="deliveredCargoTopic" ref="deliveredCargoTopic"/>
46
+    <property name="rejectedRegistrationAttemptsQueue" ref="rejectedRegistrationAttemptsQueue"/>
47
+    <property name="handlingEventQueue" ref="handlingEventRegistrationAttemptQueue"/>
48
+  </bean>
49
+
50
+  <bean id="cargoHandledConsumer" class="se.citerus.dddsample.infrastructure.messaging.jms.CargoHandledConsumer">
51
+    <property name="trackingService" ref="trackingService"/>
52
+  </bean>
53
+
54
+  <bean id="handlingEventRegistrationAttemptConsumer" class="se.citerus.dddsample.infrastructure.messaging.jms.HandlingEventRegistrationAttemptConsumer">
55
+    <property name="handlingEventService" ref="handlingEventService"/>
56
+  </bean>
57
+
58
+  <bean id="simpleLoggingConsumer" class="se.citerus.dddsample.infrastructure.messaging.jms.SimpleLoggingConsumer"/>
59
+
60
+  
61
+  <!-- Persistence - database, Hibernate, repository implementations -->
62
+
63
+  
64
+  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
65
+    <property name="url" value="${hibernate.connection.url}"/>
66
+    <property name="driverClassName" value="${hibernate.connection.driver_class}"/>
67
+    <property name="username" value="${hibernate.connection.username}"/>
68
+    <property name="password" value="${hibernate.connection.password}"/>
69
+    <property name="initialSize" value="4"/>
70
+    <property name="defaultAutoCommit" value="false"/>
71
+  </bean>
72
+
73
+  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
74
+    <property name="dataSource" ref="dataSource"/>
75
+    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
76
+  </bean>
77
+
78
+  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
79
+    <property name="sessionFactory" ref="sessionFactory"/>
80
+  </bean>
81
+
82
+  <bean id="cargoRepository" class="se.citerus.dddsample.infrastructure.persistence.hibernate.CargoRepositoryHibernate">
83
+    <property name="sessionFactory" ref="sessionFactory"/>
84
+  </bean>
85
+
86
+  <bean id="handlingEventRepository" class="se.citerus.dddsample.infrastructure.persistence.hibernate.HandlingEventRepositoryHibernate">
87
+    <property name="sessionFactory" ref="sessionFactory"/>
88
+  </bean>
89
+
90
+  <bean id="voyageRepository" class="se.citerus.dddsample.infrastructure.persistence.hibernate.VoyageRepositoryHibernate">
91
+    <property name="sessionFactory" ref="sessionFactory"/>
92
+  </bean>
93
+
94
+  <bean id="locationRepository" class="se.citerus.dddsample.infrastructure.persistence.hibernate.LocationRepositoryHibernate">
95
+    <property name="sessionFactory" ref="sessionFactory"/>
96
+  </bean>
97
+
98
+  <tx:annotation-driven transaction-manager="transactionManager"/>
99
+
100
+
101
+  <!-- External graph traversal routing service  -->
102
+
103
+  <bean id="routingService" class="se.citerus.dddsample.infrastructure.routing.ExternalRoutingService">
104
+    <property name="graphTraversalService" ref="graphTraversalService"/>
105
+    <property name="locationRepository" ref="locationRepository"/>
106
+    <property name="voyageRepository" ref="voyageRepository"/>
107
+  </bean>
108
+
109
+  <bean id="graphTraversalService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
110
+    <property name="serviceUrl" value="rmi://localhost:1099/PathFinder"/>
111
+    <property name="serviceInterface" value="com.partner.pathfinder.api.GraphTraversalService"/>
112
+    <property name="lookupStubOnStartup" value="false"/>
113
+  </bean>
114
+
115
+</beans>

+ 103
- 0
dddsample/src/main/resources/context-interfaces.xml Visa fil

@@ -0,0 +1,103 @@
1
+<?xml version="1.0"?>
2
+
3
+<beans xmlns="http://www.springframework.org/schema/beans"
4
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+	     xmlns:jaxws="http://cxf.apache.org/jaxws"
6
+       xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
7
+                           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
8
+
9
+  <import resource="classpath:META-INF/cxf/cxf.xml"/>
10
+  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
11
+  <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
12
+
13
+
14
+  <!-- Handling report web service -->
15
+
16
+
17
+  <jaxws:endpoint id="jax-ws.http" implementor="#handlingReportService" address="/ws/RegisterEvent"/>
18
+
19
+  <bean id="handlingReportService" class="se.citerus.dddsample.interfaces.handling.ws.impl.HandlingReportServiceImpl">
20
+    <property name="applicationEvents" ref="applicationEvents"/>
21
+  </bean>
22
+
23
+
24
+  <!-- File upload directory scanner -->
25
+
26
+
27
+  <bean id="scheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
28
+    <property name="period" value="5000"/>
29
+    <property name="delay" value="5000"/>
30
+    <property name="timerTask" ref="uploadDirectoryScanner"/>
31
+  </bean>
32
+
33
+  <bean id="uploadDirectoryScanner" class="se.citerus.dddsample.interfaces.handling.file.UploadDirectoryScanner">
34
+    <property name="uploadDirectory" value="/tmp/upload"/>
35
+    <property name="parseFailureDirectory" value="/tmp/failed"/>
36
+    <property name="applicationEvents" ref="applicationEvents"/>
37
+  </bean>
38
+
39
+  <bean id="handlingReportConsumptionSupport" class="se.citerus.dddsample.interfaces.handling.HandlingReportParser"/>
40
+
41
+  <bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
42
+    <property name="scheduledTimerTasks">
43
+      <list>
44
+        <ref bean="scheduledTask"/>
45
+      </list>
46
+    </property>
47
+  </bean>
48
+
49
+
50
+  <!-- RMI exposed booking service facade, which operates in an open Hibernate session -->
51
+
52
+
53
+  <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
54
+    <property name="sessionFactory" ref="sessionFactory"/>
55
+  </bean>
56
+
57
+  <bean id="bookingServiceFacade" class="org.springframework.aop.framework.ProxyFactoryBean">
58
+    <property name="target" ref="bookingServiceFacadeTarget"/>
59
+    <property name="interceptorNames">
60
+      <list>
61
+        <value>hibernateInterceptor</value>
62
+      </list>
63
+    </property>
64
+  </bean>
65
+
66
+  <bean id="bookingServiceFacadeTarget" class="se.citerus.dddsample.interfaces.booking.facade.internal.BookingServiceFacadeImpl">
67
+    <property name="bookingService" ref="bookingService"/>
68
+    <property name="cargoRepository" ref="cargoRepository"/>
69
+    <property name="locationRepository" ref="locationRepository"/>
70
+    <property name="voyageRepository" ref="voyageRepository"/>
71
+  </bean>
72
+  
73
+  <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
74
+    <property name="serviceInterface" value="se.citerus.dddsample.interfaces.booking.facade.BookingServiceFacade"/>
75
+    <property name="service" ref="bookingServiceFacade"/>
76
+    <property name="serviceName" value="BookingService"/>
77
+  </bean>
78
+
79
+
80
+  <!-- Tracking web application support -->
81
+
82
+
83
+  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
84
+    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
85
+    <property name="prefix" value="/WEB-INF/jsp/pub/"/>
86
+    <property name="suffix" value=".jsp"/>
87
+    <property name="requestContextAttribute" value="rc"/>
88
+    <property name="cache" value="false"/>
89
+  </bean>
90
+
91
+  <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
92
+    <property name="basename" value="messages"/>
93
+  </bean>
94
+
95
+  <bean id="localeResolver" class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
96
+    <property name="defaultLocale" value="en"/>
97
+  </bean>
98
+
99
+  <bean id="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
100
+    <property name="sessionFactory" ref="sessionFactory"/>
101
+  </bean>
102
+
103
+</beans>

+ 0
- 44
dddsample/src/main/resources/context-persistence-hibernate.xml Visa fil

@@ -1,44 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-
3
-<beans xmlns="http://www.springframework.org/schema/beans"
4
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
6
-
7
-  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
8
-    <property name="location" value="classpath:jdbc.properties"/>
9
-  </bean>
10
-
11
-  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
12
-    <property name="url" value="${hibernate.connection.url}"/>
13
-    <property name="driverClassName" value="${hibernate.connection.driver_class}"/>
14
-    <property name="username" value="${hibernate.connection.username}"/>
15
-    <property name="password" value="${hibernate.connection.password}"/>
16
-    <property name="initialSize" value="4"/>
17
-    <property name="defaultAutoCommit" value="false"/>
18
-  </bean>
19
-
20
-  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
21
-    <property name="dataSource" ref="dataSource"/>
22
-    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
23
-  </bean>
24
-
25
-  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
26
-    <property name="sessionFactory" ref="sessionFactory"/>
27
-  </bean>
28
-  
29
-  <bean id="cargoRepository" class="se.citerus.dddsample.infrastructure.persistence.hibernate.CargoRepositoryHibernate">
30
-    <property name="sessionFactory" ref="sessionFactory"/>
31
-  </bean>
32
-
33
-  <bean id="handlingEventRepository" class="se.citerus.dddsample.infrastructure.persistence.hibernate.HandlingEventRepositoryHibernate">
34
-    <property name="sessionFactory" ref="sessionFactory"/>
35
-  </bean>
36
-
37
-  <bean id="voyageRepository" class="se.citerus.dddsample.infrastructure.persistence.hibernate.VoyageRepositoryHibernate">
38
-    <property name="sessionFactory" ref="sessionFactory"/>
39
-  </bean>
40
-
41
-  <bean id="locationRepository" class="se.citerus.dddsample.infrastructure.persistence.hibernate.LocationRepositoryHibernate">
42
-    <property name="sessionFactory" ref="sessionFactory"/>
43
-  </bean>
44
-</beans>

+ 0
- 41
dddsample/src/main/resources/context-service.xml Visa fil

@@ -1,41 +0,0 @@
1
-<?xml version="1.0"?>
2
-
3
-<beans xmlns="http://www.springframework.org/schema/beans"
4
-       xmlns:tx="http://www.springframework.org/schema/tx"
5
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
-       xsi:schemaLocation="
7
-        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
8
-        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
9
-
10
-  <bean id="bookingService" class="se.citerus.dddsample.application.impl.BookingServiceImpl">
11
-    <constructor-arg ref="cargoRepository"/>
12
-    <constructor-arg ref="locationRepository"/>
13
-    <constructor-arg ref="routingService"/>
14
-  </bean>
15
-
16
-  <bean id="trackingService" class="se.citerus.dddsample.application.impl.TrackingServiceImpl">
17
-    <constructor-arg ref="cargoRepository"/>
18
-    <constructor-arg ref="applicationEvents"/>
19
-  </bean>
20
-
21
-  <bean id="handlingEventService" class="se.citerus.dddsample.application.impl.HandlingEventServiceImpl">
22
-    <constructor-arg ref="handlingEventRepository"/>
23
-    <constructor-arg ref="handlingEventFactory"/>
24
-    <constructor-arg ref="applicationEvents"/>
25
-  </bean>
26
-
27
-  <bean id="handlingEventFactory" class="se.citerus.dddsample.domain.model.handling.HandlingEventFactory">
28
-    <constructor-arg ref="cargoRepository"/>
29
-    <constructor-arg ref="voyageRepository"/>
30
-    <constructor-arg ref="locationRepository"/>
31
-  </bean>
32
-
33
-  <tx:annotation-driven transaction-manager="transactionManager"/>
34
-
35
-  <bean id="routingService" class="se.citerus.dddsample.infrastructure.routing.ExternalRoutingService">
36
-    <property name="locationRepository" ref="locationRepository"/>
37
-    <property name="voyageRepository" ref="voyageRepository"/>
38
-    <property name="graphTraversalService" ref="graphTraversalService"/>
39
-  </bean>
40
-
41
-</beans>

+ 0
- 41
dddsample/src/main/resources/context-web.xml Visa fil

@@ -1,41 +0,0 @@
1
-<?xml version="1.0"?>
2
-
3
-<beans xmlns="http://www.springframework.org/schema/beans"
4
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
6
-
7
-  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
8
-    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
9
-    <property name="prefix" value="/WEB-INF/jsp/"/>
10
-    <property name="suffix" value=".jsp"/>
11
-    <property name="requestContextAttribute" value="rc"/>
12
-    <property name="cache" value="false"/>
13
-  </bean>
14
-
15
-  <!--
16
-    - This bean resolves specific types of exceptions to corresponding logical
17
-    - view names for error views. The default behaviour of DispatcherServlet
18
-    - is to propagate all exceptions to the servlet container: this will happen
19
-    - here with all other types of exceptions.
20
-  -->
21
-  <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
22
-    <property name="exceptionMappings">
23
-      <props>
24
-        <prop key="org.springframework.dao.DataAccessException">error/dataAccessFailure</prop>
25
-      </props>
26
-    </property>
27
-  </bean>
28
-
29
-  <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
30
-    <property name="basename" value="messages"/>
31
-  </bean>
32
-
33
-  <bean id="localeResolver" class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
34
-    <property name="defaultLocale" value="en"/>
35
-  </bean>
36
-
37
-  <bean id="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
38
-    <property name="sessionFactory" ref="sessionFactory"/>  
39
-  </bean>
40
-
41
-</beans>