Skip to content

Commit f508ecc

Browse files
BAEL - 318 - resolving conflicts
2 parents 64f0428 + 300b9ab commit f508ecc

File tree

14 files changed

+437
-3
lines changed

14 files changed

+437
-3
lines changed

guava/src/test/java/org/baeldung/guava/GuavaEventBusTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ public void givenCustomEvent_whenEventHandled_thenSuccess() {
4444
}
4545

4646
@Test
47-
public void givenUnSubscribedEvent_whenEventHandledByDeadEvent_thenSuccess() throws InterruptedException {
47+
public void givenUnSubscribedEvent_whenEventHandledByDeadEvent_thenSuccess() {
4848
listener.resetEventsHandled();
4949

5050
eventBus.post(12345);
51-
5251
assertEquals(1, listener.getEventsHandled());
5352
}
5453

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
<module>spring-mvc-tiles</module>
157157
<module>spring-mvc-velocity</module>
158158
<module>spring-mvc-web-vs-initializer</module>
159+
<module>spring-mvc-webflow</module>
159160
<module>spring-mvc-xml</module>
160161
<module>spring-mvc-simple</module>
161162
<module>spring-security-openid</module>
@@ -253,4 +254,4 @@
253254
</extension>-->
254255
</extensions>
255256
</build>
256-
</project>
257+
</project>

spring-mvc-webflow/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=========
2+
3+
## Spring MVC with Spring Web Flow
4+
5+
###The Course
6+
7+
### Relevant Articles:
8+
-

spring-mvc-webflow/pom.xml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.baeldung</groupId>
4+
<version>0.1-SNAPSHOT</version>
5+
<artifactId>spring-mvc-webflow</artifactId>
6+
7+
<name>spring-mvc-webflow</name>
8+
<packaging>war</packaging>
9+
10+
<dependencies>
11+
12+
<!-- Spring -->
13+
<dependency>
14+
<groupId>org.springframework</groupId>
15+
<artifactId>spring-web</artifactId>
16+
<version>${org.springframework.version}</version>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.springframework</groupId>
20+
<artifactId>spring-webmvc</artifactId>
21+
<version>${org.springframework.version}</version>
22+
</dependency>
23+
24+
<!-- Spring Web Flow-->
25+
<dependency>
26+
<groupId>org.springframework.webflow</groupId>
27+
<artifactId>spring-webflow</artifactId>
28+
<version>${spring.webflow}</version>
29+
</dependency>
30+
31+
<!-- web -->
32+
33+
<dependency>
34+
<groupId>javax.servlet</groupId>
35+
<artifactId>javax.servlet-api</artifactId>
36+
<version>${javax.servlet-api.version}</version>
37+
<scope>provided</scope>
38+
</dependency>
39+
40+
<dependency>
41+
<groupId>javax.servlet</groupId>
42+
<artifactId>jstl</artifactId>
43+
<version>${jstl.version}</version>
44+
<scope>runtime</scope>
45+
</dependency>
46+
47+
<!-- logging -->
48+
49+
<dependency>
50+
<groupId>org.slf4j</groupId>
51+
<artifactId>slf4j-api</artifactId>
52+
<version>${org.slf4j.version}</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>ch.qos.logback</groupId>
56+
<artifactId>logback-classic</artifactId>
57+
<version>${logback.version}</version>
58+
<!-- <scope>runtime</scope> -->
59+
</dependency>
60+
<dependency>
61+
<groupId>org.slf4j</groupId>
62+
<artifactId>jcl-over-slf4j</artifactId>
63+
<version>${org.slf4j.version}</version>
64+
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
65+
</dependency>
66+
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
67+
<groupId>org.slf4j</groupId>
68+
<artifactId>log4j-over-slf4j</artifactId>
69+
<version>${org.slf4j.version}</version>
70+
</dependency>
71+
72+
<!-- test scoped -->
73+
74+
<dependency>
75+
<groupId>junit</groupId>
76+
<artifactId>junit</artifactId>
77+
<version>${junit.version}</version>
78+
<scope>test</scope>
79+
</dependency>
80+
81+
<dependency>
82+
<groupId>org.hamcrest</groupId>
83+
<artifactId>hamcrest-core</artifactId>
84+
<version>${org.hamcrest.version}</version>
85+
<scope>test</scope>
86+
</dependency>
87+
<dependency>
88+
<groupId>org.hamcrest</groupId>
89+
<artifactId>hamcrest-library</artifactId>
90+
<version>${org.hamcrest.version}</version>
91+
<scope>test</scope>
92+
</dependency>
93+
94+
<dependency>
95+
<groupId>org.mockito</groupId>
96+
<artifactId>mockito-core</artifactId>
97+
<version>${mockito.version}</version>
98+
<scope>test</scope>
99+
</dependency>
100+
101+
</dependencies>
102+
103+
<build>
104+
<finalName>spring-mvc-webflow</finalName>
105+
<resources>
106+
<resource>
107+
<directory>src/main/resources</directory>
108+
<filtering>true</filtering>
109+
</resource>
110+
</resources>
111+
112+
<plugins>
113+
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-compiler-plugin</artifactId>
117+
<version>${maven-compiler-plugin.version}</version>
118+
<configuration>
119+
<source>1.8</source>
120+
<target>1.8</target>
121+
</configuration>
122+
</plugin>
123+
124+
<plugin>
125+
<groupId>org.apache.maven.plugins</groupId>
126+
<artifactId>maven-war-plugin</artifactId>
127+
<version>${maven-war-plugin.version}</version>
128+
<configuration>
129+
<failOnMissingWebXml>false</failOnMissingWebXml>
130+
</configuration>
131+
</plugin>
132+
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-surefire-plugin</artifactId>
136+
<version>${maven-surefire-plugin.version}</version>
137+
<configuration>
138+
<excludes>
139+
<!-- <exclude>**/*ProductionTest.java</exclude> -->
140+
</excludes>
141+
<systemPropertyVariables>
142+
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
143+
</systemPropertyVariables>
144+
</configuration>
145+
</plugin>
146+
147+
</plugins>
148+
149+
</build>
150+
151+
<properties>
152+
<!-- Spring -->
153+
<org.springframework.version>4.3.4.RELEASE</org.springframework.version>
154+
155+
<!-- Spring Web Flow-->
156+
<spring.webflow>2.4.4.RELEASE</spring.webflow>
157+
158+
<!-- logging -->
159+
<org.slf4j.version>1.7.21</org.slf4j.version>
160+
<logback.version>1.1.7</logback.version>
161+
162+
<!-- testing -->
163+
<org.hamcrest.version>1.3</org.hamcrest.version>
164+
<junit.version>4.12</junit.version>
165+
<mockito.version>1.10.19</mockito.version>
166+
167+
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
168+
<jstl.version>1.2</jstl.version>
169+
170+
<httpcore.version>4.4.5</httpcore.version>
171+
<httpclient.version>4.5.2</httpclient.version>
172+
173+
<rest-assured.version>2.9.0</rest-assured.version>
174+
175+
<!-- Maven plugins -->
176+
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
177+
<maven-war-plugin.version>2.6</maven-war-plugin.version>
178+
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
179+
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
180+
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
181+
182+
</properties>
183+
184+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.baeldung.servlet;
2+
3+
import javax.servlet.ServletRegistration.Dynamic;
4+
5+
import org.baeldung.spring.WebFlowConfig;
6+
import org.baeldung.spring.WebMvcConfig;
7+
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
8+
9+
public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
10+
11+
public WebInitializer() {
12+
super();
13+
}
14+
15+
// API
16+
protected Class<?>[] getRootConfigClasses() {
17+
return new Class<?>[] { WebMvcConfig.class, WebFlowConfig.class };
18+
}
19+
20+
@Override
21+
protected Class<?>[] getServletConfigClasses() {
22+
return null;
23+
}
24+
25+
@Override
26+
protected String[] getServletMappings() {
27+
return new String[] { "/" };
28+
}
29+
30+
@Override
31+
protected void customizeRegistration(final Dynamic registration) {
32+
super.customizeRegistration(registration);
33+
}
34+
35+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.baeldung.spring;
2+
3+
import java.util.Collections;
4+
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.webflow.config.AbstractFlowConfiguration;
9+
import org.springframework.webflow.definition.registry.FlowDefinitionRegistry;
10+
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
11+
import org.springframework.webflow.executor.FlowExecutor;
12+
import org.springframework.webflow.mvc.builder.MvcViewFactoryCreator;
13+
14+
@Configuration
15+
public class WebFlowConfig extends AbstractFlowConfiguration {
16+
17+
@Autowired
18+
private WebMvcConfig webMvcConfig;
19+
20+
@Bean
21+
public FlowDefinitionRegistry flowRegistry() {
22+
return getFlowDefinitionRegistryBuilder(flowBuilderServices()).addFlowLocation("/WEB-INF/flows/activation-flow.xml", "activationFlow").build();
23+
}
24+
25+
@Bean
26+
public FlowExecutor flowExecutor() {
27+
return getFlowExecutorBuilder(flowRegistry()).build();
28+
}
29+
30+
@Bean
31+
public FlowBuilderServices flowBuilderServices() {
32+
return getFlowBuilderServicesBuilder().setViewFactoryCreator(mvcViewFactoryCreator()).setDevelopmentMode(true).build();
33+
}
34+
35+
@Bean
36+
public MvcViewFactoryCreator mvcViewFactoryCreator() {
37+
MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
38+
factoryCreator.setViewResolvers(Collections.singletonList(this.webMvcConfig.viewResolver()));
39+
factoryCreator.setUseSpringBeanBinding(true);
40+
return factoryCreator;
41+
}
42+
43+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package org.baeldung.spring;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.ComponentScan;
6+
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.context.annotation.ImportResource;
8+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
9+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
10+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
11+
import org.springframework.web.servlet.view.InternalResourceViewResolver;
12+
import org.springframework.web.servlet.view.JstlView;
13+
import org.springframework.webflow.mvc.servlet.FlowHandlerAdapter;
14+
import org.springframework.webflow.mvc.servlet.FlowHandlerMapping;
15+
16+
@EnableWebMvc // <mvc:annotation-driven />
17+
@Configuration
18+
// @ImportResource("classpath:/flow-definition.xml")
19+
public class WebMvcConfig extends WebMvcConfigurerAdapter {
20+
21+
@Autowired
22+
private WebFlowConfig webFlowConfig;
23+
24+
@Override
25+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
26+
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
27+
}
28+
29+
@Bean
30+
public InternalResourceViewResolver viewResolver() {
31+
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
32+
viewResolver.setViewClass(JstlView.class);
33+
viewResolver.setPrefix("/WEB-INF/view/");
34+
viewResolver.setSuffix(".jsp");
35+
return viewResolver;
36+
}
37+
38+
@Bean
39+
public FlowHandlerMapping flowHandlerMapping() {
40+
FlowHandlerMapping handlerMapping = new FlowHandlerMapping();
41+
handlerMapping.setOrder(-1);
42+
handlerMapping.setFlowRegistry(this.webFlowConfig.flowRegistry());
43+
return handlerMapping;
44+
}
45+
46+
@Bean
47+
public FlowHandlerAdapter flowHandlerAdapter() {
48+
FlowHandlerAdapter handlerAdapter = new FlowHandlerAdapter();
49+
handlerAdapter.setFlowExecutor(this.webFlowConfig.flowExecutor());
50+
handlerAdapter.setSaveOutputToFlashScopeOnRedirect(true);
51+
return handlerAdapter;
52+
}
53+
54+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:flow="http://www.springframework.org/schema/webflow-config"
5+
xsi:schemaLocation="http://www.springframework.org/schema/webflow-config
6+
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.4.xsd
7+
http://www.springframework.org/schema/beans
8+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
9+
10+
11+
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
12+
<property name="flowRegistry" ref="activationFlowRegistry"/>
13+
</bean>
14+
15+
<flow:flow-builder-services id="flowBuilderServices"
16+
view-factory-creator="mvcViewFactoryCreator"/>
17+
18+
<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
19+
<property name="viewResolvers" ref="jspViewResolver"/>
20+
</bean>
21+
22+
<flow:flow-registry id="activationFlowRegistry" flow-builder-services="flowBuilderServices">
23+
<flow:flow-location id="activationFlow" path="/WEB-INF/flows/activation-flow.xml"/>
24+
</flow:flow-registry>
25+
26+
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
27+
<property name="flowExecutor" ref="activationFlowExecutor"/>
28+
</bean>
29+
<flow:flow-executor id="activationFlowExecutor" flow-registry="activationFlowRegistry"/>
30+
31+
32+
</beans>
33+

0 commit comments

Comments
 (0)