Skip to content

Commit cb97926

Browse files
committed
migrate spring-boot
1 parent 0f54e7f commit cb97926

File tree

7 files changed

+208
-206
lines changed

7 files changed

+208
-206
lines changed

src/main/java/org/woehlke/simpleworklist/SimpleworklistApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
66
import org.springframework.boot.context.properties.EnableConfigurationProperties;
7-
import org.woehlke.simpleworklist.config.ApplicationConfig;
7+
import org.woehlke.simpleworklist.config.di.ApplicationConfig;
88
import org.woehlke.simpleworklist.config.ApplicationProperties;
9-
import org.woehlke.simpleworklist.config.WebMvcConfig;
10-
import org.woehlke.simpleworklist.config.WebSecurityConfig;
9+
import org.woehlke.simpleworklist.config.di.WebMvcConfig;
10+
import org.woehlke.simpleworklist.config.di.WebSecurityConfig;
1111

1212

1313
@ImportAutoConfiguration({

src/main/java/org/woehlke/simpleworklist/config/ApplicationConfig.java renamed to src/main/java/org/woehlke/simpleworklist/config/di/ApplicationConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.simpleworklist.config;
1+
package org.woehlke.simpleworklist.config.di;
22

33
import org.springframework.beans.factory.annotation.Autowired;
44
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -10,6 +10,7 @@
1010
import org.springframework.mail.javamail.JavaMailSenderImpl;
1111
import org.springframework.scheduling.annotation.EnableAsync;
1212
import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession;
13+
import org.woehlke.simpleworklist.config.ApplicationProperties;
1314

1415
import java.util.Properties;
1516

Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
package org.woehlke.simpleworklist.config;
2-
3-
import org.springframework.context.MessageSource;
4-
import org.springframework.context.annotation.Bean;
5-
import org.springframework.context.annotation.Configuration;
6-
import org.springframework.context.support.ResourceBundleMessageSource;
7-
import org.springframework.data.web.config.EnableSpringDataWebSupport;
8-
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
9-
import org.springframework.web.servlet.LocaleResolver;
10-
import org.springframework.web.servlet.config.annotation.*;
11-
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
12-
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
13-
import org.thymeleaf.dialect.springdata.SpringDataDialect;
14-
15-
import java.util.Locale;
16-
17-
18-
@Configuration
19-
@EnableWebMvc
20-
@EnableSpringDataWebSupport
21-
public class WebMvcConfig extends WebMvcConfigurerAdapter implements WebMvcConfigurer {
22-
23-
@Bean
24-
public LocaleResolver localeResolver() {
25-
SessionLocaleResolver slr = new SessionLocaleResolver();
26-
slr.setDefaultLocale(Locale.GERMANY);
27-
return slr;
28-
}
29-
30-
@Bean
31-
public LocaleChangeInterceptor localeChangeInterceptor() {
32-
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
33-
lci.setParamName("lang");
34-
return lci;
35-
}
36-
37-
@Bean
38-
public MessageSource messageSource(){
39-
ResourceBundleMessageSource x = new ResourceBundleMessageSource();
40-
x.setBasename("messages");
41-
return x;
42-
}
43-
44-
@Bean
45-
public SpringDataDialect springDataDialect() {
46-
return new SpringDataDialect();
47-
}
48-
49-
@Bean
50-
public MethodValidationPostProcessor methodValidationPostProcessor() {
51-
return new MethodValidationPostProcessor();
52-
}
53-
54-
public void addInterceptors(InterceptorRegistry registry) {
55-
registry.addInterceptor(localeChangeInterceptor());
56-
}
57-
58-
public void addViewControllers(ViewControllerRegistry registry) {
59-
registry.addViewController("/").setViewName("redirect:/taskstate/inbox");
60-
registry.addViewController("/home").setViewName("redirect:/taskstate/inbox");
61-
}
62-
63-
public void addResourceHandlers(ResourceHandlerRegistry registry) {
64-
registry.addResourceHandler("/css/*").addResourceLocations("classpath:/static/css/");
65-
registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
66-
registry.addResourceHandler("/img/*").addResourceLocations("classpath:/static/img/");
67-
registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/");
68-
registry.addResourceHandler("/js/*").addResourceLocations("classpath:/static/js/");
69-
registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
70-
registry.addResourceHandler("/webjars/*").addResourceLocations("/webjars/");
71-
registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/");
72-
}
73-
}
1+
package org.woehlke.simpleworklist.config.di;
2+
3+
import org.springframework.context.MessageSource;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.context.support.ResourceBundleMessageSource;
7+
import org.springframework.data.web.config.EnableSpringDataWebSupport;
8+
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
9+
import org.springframework.web.servlet.LocaleResolver;
10+
import org.springframework.web.servlet.config.annotation.*;
11+
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
12+
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
13+
import org.thymeleaf.dialect.springdata.SpringDataDialect;
14+
15+
import java.util.Locale;
16+
17+
18+
@Configuration
19+
@EnableWebMvc
20+
@EnableSpringDataWebSupport
21+
public class WebMvcConfig extends WebMvcConfigurerAdapter implements WebMvcConfigurer {
22+
23+
@Bean
24+
public LocaleResolver localeResolver() {
25+
SessionLocaleResolver slr = new SessionLocaleResolver();
26+
slr.setDefaultLocale(Locale.GERMANY);
27+
return slr;
28+
}
29+
30+
@Bean
31+
public LocaleChangeInterceptor localeChangeInterceptor() {
32+
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
33+
lci.setParamName("lang");
34+
return lci;
35+
}
36+
37+
@Bean
38+
public MessageSource messageSource(){
39+
ResourceBundleMessageSource x = new ResourceBundleMessageSource();
40+
x.setBasename("messages");
41+
return x;
42+
}
43+
44+
@Bean
45+
public SpringDataDialect springDataDialect() {
46+
return new SpringDataDialect();
47+
}
48+
49+
@Bean
50+
public MethodValidationPostProcessor methodValidationPostProcessor() {
51+
return new MethodValidationPostProcessor();
52+
}
53+
54+
public void addInterceptors(InterceptorRegistry registry) {
55+
registry.addInterceptor(localeChangeInterceptor());
56+
}
57+
58+
public void addViewControllers(ViewControllerRegistry registry) {
59+
registry.addViewController("/").setViewName("redirect:/taskstate/inbox");
60+
registry.addViewController("/home").setViewName("redirect:/taskstate/inbox");
61+
}
62+
63+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
64+
registry.addResourceHandler("/css/*").addResourceLocations("classpath:/static/css/");
65+
registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
66+
registry.addResourceHandler("/img/*").addResourceLocations("classpath:/static/img/");
67+
registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/");
68+
registry.addResourceHandler("/js/*").addResourceLocations("classpath:/static/js/");
69+
registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
70+
registry.addResourceHandler("/webjars/*").addResourceLocations("/webjars/");
71+
registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/");
72+
}
73+
}

src/main/java/org/woehlke/simpleworklist/config/WebSecurityConfig.java renamed to src/main/java/org/woehlke/simpleworklist/config/di/WebSecurityConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.simpleworklist.config;
1+
package org.woehlke.simpleworklist.config.di;
22

33
import org.springframework.beans.factory.annotation.Autowired;
44
import org.springframework.context.annotation.Bean;
@@ -14,6 +14,7 @@
1414
import org.springframework.security.crypto.password.PasswordEncoder;
1515
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
1616
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
17+
import org.woehlke.simpleworklist.user.login.LoginSuccessHandler;
1718
import org.woehlke.simpleworklist.model.services.UserAccountSecurityService;
1819

1920
@Configuration
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
package org.woehlke.simpleworklist.application;
2-
3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
5-
import org.springframework.beans.factory.annotation.Autowired;
6-
import org.springframework.context.ApplicationListener;
7-
import org.springframework.context.event.ContextRefreshedEvent;
8-
import org.springframework.stereotype.Component;
9-
import org.woehlke.simpleworklist.model.services.SearchService;
10-
11-
12-
/**
13-
* Created by tw on 14.02.16.
14-
*/
15-
@Component
16-
public class ContextRefreshedListener implements ApplicationListener<ContextRefreshedEvent> {
17-
18-
private static final Logger LOGGER = LoggerFactory.getLogger(ContextRefreshedListener.class);
19-
20-
private final SearchService searchService;
21-
22-
@Autowired
23-
public ContextRefreshedListener(SearchService searchService) {
24-
this.searchService = searchService;
25-
}
26-
27-
@Override
28-
public void onApplicationEvent(ContextRefreshedEvent event) {
29-
LOGGER.info("----------------------------------------------------");
30-
LOGGER.info("onApplicationEvent: "+event.toString());
31-
LOGGER.info("----------------------------------------------------");
32-
searchService.resetSearchIndex();
33-
LOGGER.info("----------------------------------------------------");
34-
}
35-
}
1+
package org.woehlke.simpleworklist.config.listener;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.context.ApplicationListener;
7+
import org.springframework.context.event.ContextRefreshedEvent;
8+
import org.springframework.stereotype.Component;
9+
import org.woehlke.simpleworklist.model.services.SearchService;
10+
11+
12+
/**
13+
* Created by tw on 14.02.16.
14+
*/
15+
@Component
16+
public class ContextRefreshedListener implements ApplicationListener<ContextRefreshedEvent> {
17+
18+
private static final Logger LOGGER = LoggerFactory.getLogger(ContextRefreshedListener.class);
19+
20+
private final SearchService searchService;
21+
22+
@Autowired
23+
public ContextRefreshedListener(SearchService searchService) {
24+
this.searchService = searchService;
25+
}
26+
27+
@Override
28+
public void onApplicationEvent(ContextRefreshedEvent event) {
29+
LOGGER.info("----------------------------------------------------");
30+
LOGGER.info("onApplicationEvent: "+event.toString());
31+
LOGGER.info("----------------------------------------------------");
32+
searchService.resetSearchIndex();
33+
LOGGER.info("----------------------------------------------------");
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
package org.woehlke.simpleworklist.application;
2-
3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
5-
import org.springframework.context.ApplicationListener;
6-
import org.springframework.context.event.ContextStartedEvent;
7-
import org.springframework.stereotype.Component;
8-
import org.woehlke.simpleworklist.model.services.SearchService;
9-
10-
import org.springframework.beans.factory.annotation.Autowired;
11-
12-
/**
13-
* Created by tw on 14.02.16.
14-
*/
15-
@Component
16-
public class ContextStartedListener implements ApplicationListener<ContextStartedEvent> {
17-
18-
private static final Logger LOGGER = LoggerFactory.getLogger(ContextStartedListener.class);
19-
20-
private final SearchService searchService;
21-
22-
@Autowired
23-
public ContextStartedListener(SearchService searchService) {
24-
this.searchService = searchService;
25-
}
26-
27-
@Override
28-
public void onApplicationEvent(ContextStartedEvent event) {
29-
LOGGER.info("----------------------------------------------------");
30-
LOGGER.info("onApplicationEvent and resetSearchIndex "+event.toString());
31-
LOGGER.info("----------------------------------------------------");
32-
searchService.resetSearchIndex();
33-
LOGGER.info("----------------------------------------------------");
34-
}
35-
36-
}
1+
package org.woehlke.simpleworklist.config.listener;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.context.ApplicationListener;
6+
import org.springframework.context.event.ContextStartedEvent;
7+
import org.springframework.stereotype.Component;
8+
import org.woehlke.simpleworklist.model.services.SearchService;
9+
10+
import org.springframework.beans.factory.annotation.Autowired;
11+
12+
/**
13+
* Created by tw on 14.02.16.
14+
*/
15+
@Component
16+
public class ContextStartedListener implements ApplicationListener<ContextStartedEvent> {
17+
18+
private static final Logger LOGGER = LoggerFactory.getLogger(ContextStartedListener.class);
19+
20+
private final SearchService searchService;
21+
22+
@Autowired
23+
public ContextStartedListener(SearchService searchService) {
24+
this.searchService = searchService;
25+
}
26+
27+
@Override
28+
public void onApplicationEvent(ContextStartedEvent event) {
29+
LOGGER.info("----------------------------------------------------");
30+
LOGGER.info("onApplicationEvent and resetSearchIndex "+event.toString());
31+
LOGGER.info("----------------------------------------------------");
32+
searchService.resetSearchIndex();
33+
LOGGER.info("----------------------------------------------------");
34+
}
35+
36+
}

0 commit comments

Comments
 (0)