registration project cleanup

This commit is contained in:
eugenp 2015-01-04 12:44:17 +02:00
parent 82148bf6a6
commit 2b86a7869d
8 changed files with 32 additions and 37 deletions

View File

@ -1,10 +1,10 @@
package org.baeldung.event.listener;
package org.baeldung.registration.listener;
import java.util.UUID;
import org.baeldung.event.OnRegistrationCompleteEvent;
import org.baeldung.persistence.model.User;
import org.baeldung.persistence.service.IUserService;
import org.baeldung.registration.OnRegistrationCompleteEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.MessageSource;

View File

@ -6,20 +6,21 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.Environment;
import org.springframework.mail.javamail.JavaMailSenderImpl;
@Configuration
@ComponentScan(basePackages = { "org.baeldung.event.service", "org.baeldung.event", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" })
@Import({ MvcConfig.class, PersistenceJPAConfig.class, SecSecurityConfig.class })
@PropertySource("classpath:application.properties")
@ComponentScan(basePackages = { "org.baeldung.registration" })
@PropertySource("classpath:email.properties")
public class AppConfig {
@Autowired
private Environment env;
// beans
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();

View File

@ -23,7 +23,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
@Configuration
@ComponentScan(basePackages = { "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" })
@ComponentScan(basePackages = { "org.baeldung.web" })
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
@ -31,7 +31,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
super();
}
// API
//
@Override
public void addViewControllers(final ViewControllerRegistry registry) {
@ -51,15 +51,6 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
registry.addViewController("/successRegister.html");
}
@Bean
public ViewResolver viewResolver() {
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
bean.setViewClass(JstlView.class);
bean.setPrefix("/WEB-INF/view/");
bean.setSuffix(".jsp");
return bean;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/");
@ -72,6 +63,17 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
registry.addInterceptor(localeChangeInterceptor);
}
// beans
@Bean
public ViewResolver viewResolver() {
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
bean.setViewClass(JstlView.class);
bean.setPrefix("/WEB-INF/view/");
bean.setSuffix(".jsp");
return bean;
}
@Bean
public LocaleResolver localeResolver() {
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
@ -91,21 +93,17 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
@Bean
public EmailValidator usernameValidator() {
EmailValidator userNameValidator = new EmailValidator();
return userNameValidator;
return new EmailValidator();
}
@Bean
public PasswordMatchesValidator passwordMatchesValidator() {
PasswordMatchesValidator passwordMatchesValidator = new PasswordMatchesValidator();
return passwordMatchesValidator;
return new PasswordMatchesValidator();
}
// DIC 7
@Bean
public HashGenerator hashGenerator() {
HashGenerator hashGenerator = new HashGenerator();
return hashGenerator;
return new HashGenerator();
}
}

View File

@ -18,8 +18,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:application.properties" })
@ComponentScan({ "org.baeldung.persistence.model" })
@PropertySource({ "classpath:persistence.properties" })
@ComponentScan({ "org.baeldung.persistence" })
@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao")
public class PersistenceJPAConfig {

View File

@ -9,7 +9,7 @@ import org.baeldung.persistence.model.User;
import org.baeldung.persistence.model.VerificationToken;
import org.baeldung.persistence.service.UserDto;
import org.baeldung.persistence.service.IUserService;
import org.baeldung.event.OnRegistrationCompleteEvent;
import org.baeldung.registration.OnRegistrationCompleteEvent;
import org.baeldung.validation.service.EmailExistsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -8,10 +8,3 @@ init-db=false
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop
################### JavaMail Configuration ##########################
smtp.host=smtp.gmail.com
smtp.port=465
smtp.protocol=smtps
smtp.username=xxx777@gmail.com
smtp.password=
support.email=xxx777@gmail.com

View File

@ -5,6 +5,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<http use-expressions="true">
<intercept-url pattern="/login*" access="permitAll" />
<intercept-url pattern="/logout*" access="permitAll" />
@ -29,7 +30,9 @@
<logout invalidate-session="false" logout-success-url="/logout.html?logSucc=true"
logout-url="/j_spring_security_logout" delete-cookies="JSESSIONID" />
</http>
<authentication-manager>
<authentication-provider ref="authProvider"/>
<authentication-provider ref="authProvider" />
</authentication-manager>
</beans:beans>